Merge "Catch a rare NPE in TilesConnectionBinder that could cause test flakiness" into androidx-main
diff --git a/appsearch/appsearch-local-storage/src/androidTest/java/androidx/appsearch/localstorage/AppSearchImplTest.java b/appsearch/appsearch-local-storage/src/androidTest/java/androidx/appsearch/localstorage/AppSearchImplTest.java
index 3967751..c8ac003 100644
--- a/appsearch/appsearch-local-storage/src/androidTest/java/androidx/appsearch/localstorage/AppSearchImplTest.java
+++ b/appsearch/appsearch-local-storage/src/androidTest/java/androidx/appsearch/localstorage/AppSearchImplTest.java
@@ -53,6 +53,7 @@
import androidx.appsearch.app.SetSchemaResponse;
import androidx.appsearch.app.StorageInfo;
import androidx.appsearch.exceptions.AppSearchException;
+import androidx.appsearch.flags.Flags;
import androidx.appsearch.localstorage.stats.InitializeStats;
import androidx.appsearch.localstorage.stats.OptimizeStats;
import androidx.appsearch.localstorage.util.PrefixUtil;
@@ -64,6 +65,9 @@
import androidx.appsearch.observer.ObserverSpec;
import androidx.appsearch.observer.SchemaChangeInfo;
import androidx.appsearch.testutil.TestObserverCallback;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import androidx.collection.ArrayMap;
import androidx.collection.ArraySet;
import androidx.test.core.app.ApplicationProvider;
@@ -115,6 +119,10 @@
* Always trigger optimize in this class. OptimizeStrategy will be tested in its own test class.
*/
private static final OptimizeStrategy ALWAYS_OPTIMIZE = optimizeInfo -> true;
+
+ @Rule
+ public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
+
@Rule
public TemporaryFolder mTemporaryFolder = new TemporaryFolder();
private File mAppSearchDir;
@@ -2253,6 +2261,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_BLOB_STORE)
public void testWriteAndReadBlob() throws Exception {
mAppSearchImpl = AppSearchImpl.create(
mAppSearchDir,
@@ -2284,6 +2293,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_BLOB_STORE)
public void testOpenReadForWrite_notAllowed() throws Exception {
mAppSearchImpl = AppSearchImpl.create(
mAppSearchDir,
@@ -2319,6 +2329,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_BLOB_STORE)
public void testOpenWriteForRead_allowed() throws Exception {
mAppSearchImpl = AppSearchImpl.create(
mAppSearchDir,
@@ -2341,6 +2352,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_BLOB_STORE)
public void testOptimizeBlob() throws Exception {
// Create a new AppSearchImpl with lower orphan blob time to live.
mAppSearchImpl.close();
@@ -2384,6 +2396,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_BLOB_STORE)
public void testOptimizeBlobWithDocument() throws Exception {
// Create a new AppSearchImpl with lower orphan blob time to live.
mAppSearchImpl.close();
@@ -2463,6 +2476,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_BLOB_STORE)
public void testRevokeFileDescriptor() throws Exception {
mAppSearchImpl = AppSearchImpl.create(
mAppSearchDir,
@@ -2507,6 +2521,8 @@
}
}
+ // Verify the blob handle won't sent request to Icing. So no need to enable
+ // FLAG_ENABLE_BLOB_STORE.
@Test
public void testInvalidBlobHandle() throws Exception {
mAppSearchImpl = AppSearchImpl.create(
diff --git a/appsearch/appsearch-local-storage/src/androidTest/java/androidx/appsearch/localstorage/converter/SchemaToProtoConverterTest.java b/appsearch/appsearch-local-storage/src/androidTest/java/androidx/appsearch/localstorage/converter/SchemaToProtoConverterTest.java
index a1af529..41bd101 100644
--- a/appsearch/appsearch-local-storage/src/androidTest/java/androidx/appsearch/localstorage/converter/SchemaToProtoConverterTest.java
+++ b/appsearch/appsearch-local-storage/src/androidTest/java/androidx/appsearch/localstorage/converter/SchemaToProtoConverterTest.java
@@ -286,11 +286,14 @@
.setCardinality(AppSearchSchema.PropertyConfig.CARDINALITY_OPTIONAL)
.setJoinableValueType(AppSearchSchema.StringPropertyConfig
.JOINABLE_VALUE_TYPE_QUALIFIED_ID)
+ .setDeletePropagationType(AppSearchSchema.StringPropertyConfig
+ .DELETE_PROPAGATION_TYPE_PROPAGATE_FROM)
.build()
).build();
JoinableConfig joinableConfig = JoinableConfig.newBuilder()
.setValueType(JoinableConfig.ValueType.Code.QUALIFIED_ID)
+ .setDeletePropagationType(JoinableConfig.DeletePropagationType.Code.PROPAGATE_FROM)
.build();
SchemaTypeConfigProto expectedAlbumProto = SchemaTypeConfigProto.newBuilder()
@@ -551,6 +554,7 @@
.isEqualTo(emailSchema);
}
+ @Test
public void testGetProto_withScorablePropertyEnabled() {
AppSearchSchema emailSchema = new AppSearchSchema.Builder("Email")
.addProperty(new AppSearchSchema.LongPropertyConfig.Builder("viewTimes")
diff --git a/appsearch/appsearch-local-storage/src/androidTest/java/androidx/appsearch/localstorage/converter/SearchResultToProtoConverterTest.java b/appsearch/appsearch-local-storage/src/androidTest/java/androidx/appsearch/localstorage/converter/SearchResultToProtoConverterTest.java
index 2560643..1576821 100644
--- a/appsearch/appsearch-local-storage/src/androidTest/java/androidx/appsearch/localstorage/converter/SearchResultToProtoConverterTest.java
+++ b/appsearch/appsearch-local-storage/src/androidTest/java/androidx/appsearch/localstorage/converter/SearchResultToProtoConverterTest.java
@@ -120,10 +120,18 @@
if (Flags.enableSearchResultParentTypes()) {
assertThat(result.getParentTypeMap()).isEqualTo(
ImmutableMap.of(schemaType, ImmutableList.of(parentSchemaType)));
+// @exportToFramework:startStrip()
+ // TODO(b/371610934): Remove this once GenericDocument#getParentTypes is fully
+ // deprecated.
+ // GenericDocument#getParentTypes is annotated with @hide in platform and will be
+ // removed after deprecation.
assertThat(result.getGenericDocument().getParentTypes()).isNull();
+// @exportToFramework:endStrip()
} else {
assertThat(result.getParentTypeMap()).isEmpty();
+// @exportToFramework:startStrip()
assertThat(result.getGenericDocument().getParentTypes()).contains(parentSchemaType);
+// @exportToFramework:endStrip()
}
}
diff --git a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/AlwaysSupportedFeatures.java b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/AlwaysSupportedFeatures.java
index 444eccd..23e42cc 100644
--- a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/AlwaysSupportedFeatures.java
+++ b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/AlwaysSupportedFeatures.java
@@ -98,6 +98,8 @@
case Features.SCHEMA_SCORABLE_PROPERTY_CONFIG:
// fall through
case Features.SEARCH_RESULT_PARENT_TYPES:
+ // fall through
+ case Features.SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM:
return true;
default:
return false;
diff --git a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/AppSearchConfigImpl.java b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/AppSearchConfigImpl.java
index b8f5e22..40447a1 100644
--- a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/AppSearchConfigImpl.java
+++ b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/AppSearchConfigImpl.java
@@ -124,11 +124,6 @@
}
@Override
- public boolean getEnableBlobStore() {
- return mIcingOptionsConfig.getEnableBlobStore();
- }
-
- @Override
public int getMaxDocumentSizeBytes() {
return mLimitConfig.getMaxDocumentSizeBytes();
}
diff --git a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/AppSearchImpl.java b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/AppSearchImpl.java
index 416d882..9c58fac 100644
--- a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/AppSearchImpl.java
+++ b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/AppSearchImpl.java
@@ -247,7 +247,7 @@
private int mOptimizeIntervalCountLocked = 0;
@Nullable
- private AppSearchRevocableFileDescriptorStore mRevocableFileDescriptorStore;
+ private RevocableFileDescriptorStore mRevocableFileDescriptorStore;
/** Whether this instance has been closed, and therefore unusable. */
@GuardedBy("mReadWriteLock")
@@ -275,7 +275,7 @@
@NonNull AppSearchConfig config,
@Nullable InitializeStats.Builder initStatsBuilder,
@Nullable VisibilityChecker visibilityChecker,
- @Nullable AppSearchRevocableFileDescriptorStore revocableFileDescriptorStore,
+ @Nullable RevocableFileDescriptorStore revocableFileDescriptorStore,
@NonNull OptimizeStrategy optimizeStrategy)
throws AppSearchException {
return new AppSearchImpl(icingDir, config, initStatsBuilder, visibilityChecker,
@@ -290,7 +290,7 @@
@NonNull AppSearchConfig config,
@Nullable InitializeStats.Builder initStatsBuilder,
@Nullable VisibilityChecker visibilityChecker,
- @Nullable AppSearchRevocableFileDescriptorStore revocableFileDescriptorStore,
+ @Nullable RevocableFileDescriptorStore revocableFileDescriptorStore,
@NonNull OptimizeStrategy optimizeStrategy)
throws AppSearchException {
Preconditions.checkNotNull(icingDir);
@@ -323,11 +323,13 @@
.setUseNewQualifiedIdJoinIndex(mConfig.getUseNewQualifiedIdJoinIndex())
.setBuildPropertyExistenceMetadataHits(
mConfig.getBuildPropertyExistenceMetadataHits())
- .setEnableBlobStore(mConfig.getEnableBlobStore())
+ .setEnableBlobStore(Flags.enableBlobStore())
.setOrphanBlobTimeToLiveMs(mConfig.getOrphanBlobTimeToLiveMs())
.setEnableEmbeddingIndex(Flags.enableSchemaEmbeddingPropertyConfig())
.setEnableEmbeddingQuantization(Flags.enableSchemaEmbeddingQuantization())
.setEnableScorableProperties(Flags.enableScorableProperty())
+ .setEnableQualifiedIdJoinIndexV3AndDeletePropagateFrom(
+ Flags.enableDeletePropagationType())
.build();
LogUtil.piiTrace(TAG, "Constructing IcingSearchEngine, request", options);
mIcingSearchEngineLocked = new IcingSearchEngine(options);
diff --git a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/IcingOptionsConfig.java b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/IcingOptionsConfig.java
index bdc2da2..2f1c5711 100644
--- a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/IcingOptionsConfig.java
+++ b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/IcingOptionsConfig.java
@@ -229,14 +229,6 @@
boolean getBuildPropertyExistenceMetadataHits();
/**
- * Flag for {@link com.google.android.icing.proto.IcingSearchEngineOptions}.
- *
- * <p>Whether to enable the blob store. If set to true, the BlobStore will be created to store
- * and retrieve blobs.
- */
- boolean getEnableBlobStore();
-
- /**
* Config for {@link com.google.android.icing.proto.IcingSearchEngineOptions}.
*
* <p>The maximum time in millisecond for a orphan blob to get recycled and deleted if there is
diff --git a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/JetpackRevocableFileDescriptorStore.java b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/JetpackRevocableFileDescriptorStore.java
index 7fccab8..0edee8b 100644
--- a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/JetpackRevocableFileDescriptorStore.java
+++ b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/JetpackRevocableFileDescriptorStore.java
@@ -33,7 +33,7 @@
import java.util.Map;
/**
- * The local storage implementation of {@link AppSearchRevocableFileDescriptorStore}.
+ * The local storage implementation of {@link RevocableFileDescriptorStore}.
*
* <p> The {@link ParcelFileDescriptor} sent to the client side from the local storage won't cross
* the binder, we could revoke the {@link ParcelFileDescriptor} in the client side by directly close
@@ -46,7 +46,7 @@
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public class JetpackRevocableFileDescriptorStore implements
- AppSearchRevocableFileDescriptorStore {
+ RevocableFileDescriptorStore {
private final Object mLock = new Object();
private final AppSearchConfig mConfig;
diff --git a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/LocalStorage.java b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/LocalStorage.java
index 4263ec1..b5fe923 100644
--- a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/LocalStorage.java
+++ b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/LocalStorage.java
@@ -360,7 +360,7 @@
/* storeParentInfoAsSyntheticProperty= */ false,
/* shouldRetrieveParentInfo= */ true
);
- AppSearchRevocableFileDescriptorStore revocableFileDescriptorStore = null;
+ RevocableFileDescriptorStore revocableFileDescriptorStore = null;
if (Flags.enableBlobStore()) {
revocableFileDescriptorStore = new JetpackRevocableFileDescriptorStore(config);
}
diff --git a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/LocalStorageIcingOptionsConfig.java b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/LocalStorageIcingOptionsConfig.java
index 51e1125..d0837fd 100644
--- a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/LocalStorageIcingOptionsConfig.java
+++ b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/LocalStorageIcingOptionsConfig.java
@@ -100,11 +100,6 @@
}
@Override
- public boolean getEnableBlobStore() {
- return true;
- }
-
- @Override
public long getOrphanBlobTimeToLiveMs() {
return DEFAULT_ORPHAN_BLOB_TIME_TO_LIVE_MS;
}
diff --git a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/AppSearchRevocableFileDescriptorStore.java b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/RevocableFileDescriptorStore.java
similarity index 98%
rename from appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/AppSearchRevocableFileDescriptorStore.java
rename to appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/RevocableFileDescriptorStore.java
index 86bcc64..fa8cfc1 100644
--- a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/AppSearchRevocableFileDescriptorStore.java
+++ b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/RevocableFileDescriptorStore.java
@@ -38,7 +38,7 @@
* @exportToFramework:hide
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
-public interface AppSearchRevocableFileDescriptorStore {
+public interface RevocableFileDescriptorStore {
/**
* Wraps the provided ParcelFileDescriptor into a revocable file descriptor.
diff --git a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/converter/SchemaToProtoConverter.java b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/converter/SchemaToProtoConverter.java
index 74efda8..21b2570 100644
--- a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/converter/SchemaToProtoConverter.java
+++ b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/converter/SchemaToProtoConverter.java
@@ -100,6 +100,9 @@
if (property instanceof AppSearchSchema.StringPropertyConfig) {
AppSearchSchema.StringPropertyConfig stringProperty =
(AppSearchSchema.StringPropertyConfig) property;
+ // No need to check against delete propagation type vs joinable value type here, because
+ // the builder has already enforced the restriction.
+
// Set JoinableConfig only if it is joinable (i.e. joinableValueType is not NONE).
if (stringProperty.getJoinableValueType()
!= AppSearchSchema.StringPropertyConfig.JOINABLE_VALUE_TYPE_NONE) {
@@ -107,6 +110,9 @@
.setValueType(
convertJoinableValueTypeToProto(
stringProperty.getJoinableValueType()))
+ .setDeletePropagationType(
+ convertDeletePropagationTypeToProto(
+ stringProperty.getDeletePropagationType()))
.build();
builder.setJoinableConfig(joinableConfig);
}
@@ -252,6 +258,9 @@
.setJoinableValueType(
convertJoinableValueTypeFromProto(
proto.getJoinableConfig().getValueType()))
+ .setDeletePropagationType(
+ convertDeletePropagationTypeFromProto(
+ proto.getJoinableConfig().getDeletePropagationType()))
.setTokenizerType(
proto.getStringIndexingConfig().getTokenizerType().getNumber());
@@ -352,6 +361,37 @@
}
@NonNull
+ @OptIn(markerClass = ExperimentalAppSearchApi.class)
+ private static JoinableConfig.DeletePropagationType.Code convertDeletePropagationTypeToProto(
+ @AppSearchSchema.StringPropertyConfig.DeletePropagationType int deletePropagationType) {
+ switch (deletePropagationType) {
+ case AppSearchSchema.StringPropertyConfig.DELETE_PROPAGATION_TYPE_NONE:
+ return JoinableConfig.DeletePropagationType.Code.NONE;
+ case AppSearchSchema.StringPropertyConfig.DELETE_PROPAGATION_TYPE_PROPAGATE_FROM:
+ return JoinableConfig.DeletePropagationType.Code.PROPAGATE_FROM;
+ default:
+ throw new IllegalArgumentException(
+ "Invalid deletePropagationType: " + deletePropagationType);
+ }
+ }
+
+ @AppSearchSchema.StringPropertyConfig.DeletePropagationType
+ @OptIn(markerClass = ExperimentalAppSearchApi.class)
+ private static int convertDeletePropagationTypeFromProto(
+ @NonNull JoinableConfig.DeletePropagationType.Code deletePropagationType) {
+ switch (deletePropagationType) {
+ case NONE:
+ return AppSearchSchema.StringPropertyConfig.DELETE_PROPAGATION_TYPE_NONE;
+ case PROPAGATE_FROM:
+ return AppSearchSchema.StringPropertyConfig.DELETE_PROPAGATION_TYPE_PROPAGATE_FROM;
+ }
+ // Avoid crashing in the 'read' path; we should try to interpret the schema to the
+ // extent possible.
+ Log.w(TAG, "Invalid deletePropagationType: " + deletePropagationType.getNumber());
+ return AppSearchSchema.StringPropertyConfig.DELETE_PROPAGATION_TYPE_NONE;
+ }
+
+ @NonNull
private static TermMatchType.Code convertTermMatchTypeToProto(
@AppSearchSchema.StringPropertyConfig.IndexingType int indexingType) {
switch (indexingType) {
diff --git a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/converter/SearchSpecToProtoConverter.java b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/converter/SearchSpecToProtoConverter.java
index 4f80e5a..2c81868 100644
--- a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/converter/SearchSpecToProtoConverter.java
+++ b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/converter/SearchSpecToProtoConverter.java
@@ -541,6 +541,8 @@
protoBuilder.addAllAdditionalAdvancedScoringExpressions(
mSearchSpec.getInformationalRankingExpressions());
+ // TODO(b/380924970): create extractEnabledScoringFeatures() for populating scorable
+ // features
if (mSearchSpec.isScorablePropertyRankingEnabled()) {
protoBuilder.addScoringFeatureTypesEnabled(
ScoringFeatureType.SCORABLE_PROPERTY_RANKING);
@@ -1110,8 +1112,17 @@
List<String> extractEnabledSearchFeatures(List<String> allEnabledFeatures) {
List<String> searchFeatures = new ArrayList<>();
- for (String feature : allEnabledFeatures) {
+ for (int i = 0; i < allEnabledFeatures.size(); ++i) {
+ String feature = allEnabledFeatures.get(i);
if (FeatureConstants.SCORABLE_FEATURE_SET.contains(feature)) {
+ // The `allEnabledFeatures` set contains both scorable features and search features.
+ // Here, we extract the search related features and populate them to
+ // `SearchSpecProto`. The scoring related features are later populated to the
+ // `ScoringSpecProto` individually in `toScoringSpecProto()`.
+ // - This is because in Icing, the search expression and scoring expression are
+ // parsed separately, and the enforcement of these enabled features are separate.
+ // Icing needs the two different proto messages to distinguish between
+ // features in the search expression and features in the scoring expression.
continue;
}
searchFeatures.add(feature);
diff --git a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/stats/CallStats.java b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/stats/CallStats.java
index 5f28ea0..e8c3199 100644
--- a/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/stats/CallStats.java
+++ b/appsearch/appsearch-local-storage/src/main/java/androidx/appsearch/localstorage/stats/CallStats.java
@@ -78,7 +78,10 @@
CALL_TYPE_REGISTER_OBSERVER_CALLBACK,
CALL_TYPE_UNREGISTER_OBSERVER_CALLBACK,
CALL_TYPE_GLOBAL_GET_NEXT_PAGE,
- CALL_TYPE_EXECUTE_APP_FUNCTION
+ CALL_TYPE_EXECUTE_APP_FUNCTION,
+ CALL_TYPE_OPEN_WRITE_BLOB,
+ CALL_TYPE_COMMIT_BLOB,
+ CALL_TYPE_OPEN_READ_BLOB
})
@Retention(RetentionPolicy.SOURCE)
public @interface CallType {
@@ -116,6 +119,9 @@
public static final int CALL_TYPE_UNREGISTER_OBSERVER_CALLBACK = 29;
public static final int CALL_TYPE_GLOBAL_GET_NEXT_PAGE = 30;
public static final int CALL_TYPE_EXECUTE_APP_FUNCTION = 31;
+ public static final int CALL_TYPE_OPEN_WRITE_BLOB = 32;
+ public static final int CALL_TYPE_COMMIT_BLOB = 33;
+ public static final int CALL_TYPE_OPEN_READ_BLOB = 34;
// These strings are for the subset of call types that correspond to an AppSearchManager API
private static final String CALL_TYPE_STRING_INITIALIZE = "initialize";
@@ -148,6 +154,9 @@
"globalUnregisterObserverCallback";
private static final String CALL_TYPE_STRING_GLOBAL_GET_NEXT_PAGE = "globalGetNextPage";
private static final String CALL_TYPE_STRING_EXECUTE_APP_FUNCTION = "executeAppFunction";
+ private static final String CALL_TYPE_STRING_OPEN_WRITE_BLOB = "openWriteBlob";
+ private static final String CALL_TYPE_STRING_COMMIT_BLOB = "commitBlob";
+ private static final String CALL_TYPE_STRING_OPEN_READ_BLOB = "openReadBlob";
@Nullable
private final String mPackageName;
@@ -416,6 +425,12 @@
return CALL_TYPE_GLOBAL_GET_NEXT_PAGE;
case CALL_TYPE_STRING_EXECUTE_APP_FUNCTION:
return CALL_TYPE_EXECUTE_APP_FUNCTION;
+ case CALL_TYPE_STRING_OPEN_WRITE_BLOB:
+ return CALL_TYPE_OPEN_WRITE_BLOB;
+ case CALL_TYPE_STRING_COMMIT_BLOB:
+ return CALL_TYPE_COMMIT_BLOB;
+ case CALL_TYPE_STRING_OPEN_READ_BLOB:
+ return CALL_TYPE_OPEN_READ_BLOB;
default:
return CALL_TYPE_UNKNOWN;
}
@@ -452,6 +467,9 @@
CALL_TYPE_REGISTER_OBSERVER_CALLBACK,
CALL_TYPE_UNREGISTER_OBSERVER_CALLBACK,
CALL_TYPE_GLOBAL_GET_NEXT_PAGE,
- CALL_TYPE_EXECUTE_APP_FUNCTION));
+ CALL_TYPE_EXECUTE_APP_FUNCTION,
+ CALL_TYPE_OPEN_WRITE_BLOB,
+ CALL_TYPE_COMMIT_BLOB,
+ CALL_TYPE_OPEN_READ_BLOB));
}
}
diff --git a/appsearch/appsearch-platform-storage/src/main/java/androidx/appsearch/platformstorage/FeaturesImpl.java b/appsearch/appsearch-platform-storage/src/main/java/androidx/appsearch/platformstorage/FeaturesImpl.java
index 8623198..a549054 100644
--- a/appsearch/appsearch-platform-storage/src/main/java/androidx/appsearch/platformstorage/FeaturesImpl.java
+++ b/appsearch/appsearch-platform-storage/src/main/java/androidx/appsearch/platformstorage/FeaturesImpl.java
@@ -145,6 +145,9 @@
case Features.SEARCH_RESULT_PARENT_TYPES:
// TODO(b/371610934) : Update when feature is ready in service-appsearch.
// fall through
+ case Features.SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM:
+ // TODO(b/376913014) : Update when feature is ready in service-appsearch.
+ // fall through
default:
return false;
}
diff --git a/appsearch/appsearch-platform-storage/src/main/java/androidx/appsearch/platformstorage/converter/SchemaToPlatformConverter.java b/appsearch/appsearch-platform-storage/src/main/java/androidx/appsearch/platformstorage/converter/SchemaToPlatformConverter.java
index 7bbde59..fa3b54c 100644
--- a/appsearch/appsearch-platform-storage/src/main/java/androidx/appsearch/platformstorage/converter/SchemaToPlatformConverter.java
+++ b/appsearch/appsearch-platform-storage/src/main/java/androidx/appsearch/platformstorage/converter/SchemaToPlatformConverter.java
@@ -136,6 +136,7 @@
TOKENIZER_TYPE_NONE, TOKENIZER_TYPE_PLAIN, "tokenizerType");
}
+ // Check joinable value type.
if (stringProperty.getJoinableValueType()
== AppSearchSchema.StringPropertyConfig.JOINABLE_VALUE_TYPE_QUALIFIED_ID) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
@@ -146,6 +147,16 @@
ApiHelperForU.setJoinableValueType(platformBuilder,
stringProperty.getJoinableValueType());
}
+
+ // Check delete propagation type.
+ if (stringProperty.getDeletePropagationType()
+ != AppSearchSchema.StringPropertyConfig.DELETE_PROPAGATION_TYPE_NONE) {
+ // TODO(b/376913014): add isAtLeastW check to allow
+ // DELETE_PROPAGATION_TYPE_PROPAGATE_FROM after Android W.
+ throw new UnsupportedOperationException(
+ "StringPropertyConfig.DELETE_PROPAGATION_TYPE_PROPAGATE_FROM is not"
+ + " supported on this AppSearch implementation.");
+ }
return platformBuilder.build();
} else if (jetpackProperty instanceof AppSearchSchema.LongPropertyConfig) {
AppSearchSchema.LongPropertyConfig longProperty =
diff --git a/appsearch/appsearch-play-services-storage/src/main/java/androidx/appsearch/playservicesstorage/FeaturesImpl.java b/appsearch/appsearch-play-services-storage/src/main/java/androidx/appsearch/playservicesstorage/FeaturesImpl.java
index 512b995..e136c62 100644
--- a/appsearch/appsearch-play-services-storage/src/main/java/androidx/appsearch/playservicesstorage/FeaturesImpl.java
+++ b/appsearch/appsearch-play-services-storage/src/main/java/androidx/appsearch/playservicesstorage/FeaturesImpl.java
@@ -95,6 +95,8 @@
// fall through
case Features.SEARCH_RESULT_PARENT_TYPES:
// fall through
+ case Features.SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM:
+ // fall through
default:
return false; // AppSearch features absent in GMSCore AppSearch.
}
diff --git a/appsearch/appsearch-play-services-storage/src/main/java/androidx/appsearch/playservicesstorage/converter/SchemaToGmsConverter.java b/appsearch/appsearch-play-services-storage/src/main/java/androidx/appsearch/playservicesstorage/converter/SchemaToGmsConverter.java
index 155bb43..724d46f 100644
--- a/appsearch/appsearch-play-services-storage/src/main/java/androidx/appsearch/playservicesstorage/converter/SchemaToGmsConverter.java
+++ b/appsearch/appsearch-play-services-storage/src/main/java/androidx/appsearch/playservicesstorage/converter/SchemaToGmsConverter.java
@@ -118,6 +118,14 @@
== AppSearchSchema.StringPropertyConfig.JOINABLE_VALUE_TYPE_QUALIFIED_ID) {
gmsBuilder.setJoinableValueType(stringProperty.getJoinableValueType());
}
+ if (stringProperty.getDeletePropagationType()
+ == AppSearchSchema.StringPropertyConfig
+ .DELETE_PROPAGATION_TYPE_PROPAGATE_FROM) {
+ // TODO(b/376913014): remove this once delete propagation API is available.
+ throw new UnsupportedOperationException(
+ "StringPropertyConfig.DELETE_PROPAGATION_TYPE_PROPAGATE_FROM is not"
+ + " supported on this AppSearch implementation.");
+ }
return gmsBuilder.build();
} else if (jetpackProperty instanceof AppSearchSchema.LongPropertyConfig) {
AppSearchSchema.LongPropertyConfig longProperty =
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/flags/CheckFlagsRule.java b/appsearch/appsearch-test-util/src/main/java/androidx/appsearch/testutil/flags/CheckFlagsRule.java
similarity index 81%
rename from appsearch/appsearch/src/androidTest/java/androidx/appsearch/flags/CheckFlagsRule.java
rename to appsearch/appsearch-test-util/src/main/java/androidx/appsearch/testutil/flags/CheckFlagsRule.java
index 3ec5386..fd57f25 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/flags/CheckFlagsRule.java
+++ b/appsearch/appsearch-test-util/src/main/java/androidx/appsearch/testutil/flags/CheckFlagsRule.java
@@ -14,7 +14,10 @@
* limitations under the License.
*/
// @exportToFramework:skipFile()
-package androidx.appsearch.flags;
+package androidx.appsearch.testutil.flags;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
@@ -27,7 +30,8 @@
*/
public final class CheckFlagsRule implements TestRule {
@Override
- public Statement apply(Statement base, Description description) {
+ @NonNull
+ public Statement apply(@NonNull Statement base, @Nullable Description description) {
return base;
}
}
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/flags/DeviceFlagsValueProvider.java b/appsearch/appsearch-test-util/src/main/java/androidx/appsearch/testutil/flags/DeviceFlagsValueProvider.java
similarity index 91%
rename from appsearch/appsearch/src/androidTest/java/androidx/appsearch/flags/DeviceFlagsValueProvider.java
rename to appsearch/appsearch-test-util/src/main/java/androidx/appsearch/testutil/flags/DeviceFlagsValueProvider.java
index 1a2858a..0b3dc81 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/flags/DeviceFlagsValueProvider.java
+++ b/appsearch/appsearch-test-util/src/main/java/androidx/appsearch/testutil/flags/DeviceFlagsValueProvider.java
@@ -14,7 +14,9 @@
* limitations under the License.
*/
// @exportToFramework:skipFile()
-package androidx.appsearch.flags;
+package androidx.appsearch.testutil.flags;
+
+import androidx.annotation.NonNull;
/**
* Shim for real DeviceFlagsValueProvider defined in Framework.
@@ -25,6 +27,7 @@
private DeviceFlagsValueProvider() {}
/** Provides a shim rule that can be used to check the status of flags on device */
+ @NonNull
public static CheckFlagsRule createCheckFlagsRule() {
return new CheckFlagsRule();
}
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/flags/RequiresFlagsEnabled.java b/appsearch/appsearch-test-util/src/main/java/androidx/appsearch/testutil/flags/RequiresFlagsEnabled.java
similarity index 97%
rename from appsearch/appsearch/src/androidTest/java/androidx/appsearch/flags/RequiresFlagsEnabled.java
rename to appsearch/appsearch-test-util/src/main/java/androidx/appsearch/testutil/flags/RequiresFlagsEnabled.java
index d4f3bf0..47b3ae1 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/flags/RequiresFlagsEnabled.java
+++ b/appsearch/appsearch-test-util/src/main/java/androidx/appsearch/testutil/flags/RequiresFlagsEnabled.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
// @exportToFramework:skipFile()
-package androidx.appsearch.flags;
+package androidx.appsearch.testutil.flags;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
diff --git a/appsearch/appsearch/api/current.txt b/appsearch/appsearch/api/current.txt
index 4f0745e..bc6ded2 100644
--- a/appsearch/appsearch/api/current.txt
+++ b/appsearch/appsearch/api/current.txt
@@ -262,9 +262,12 @@
}
public static final class AppSearchSchema.StringPropertyConfig extends androidx.appsearch.app.AppSearchSchema.PropertyConfig {
+ method @SuppressCompatibility @androidx.appsearch.app.ExperimentalAppSearchApi public int getDeletePropagationType();
method public int getIndexingType();
method public int getJoinableValueType();
method public int getTokenizerType();
+ field @SuppressCompatibility @androidx.appsearch.app.ExperimentalAppSearchApi public static final int DELETE_PROPAGATION_TYPE_NONE = 0; // 0x0
+ field @SuppressCompatibility @RequiresFeature(enforcement="androidx.appsearch.app.Features#isFeatureSupported", name=androidx.appsearch.app.Features.SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM) @androidx.appsearch.app.ExperimentalAppSearchApi public static final int DELETE_PROPAGATION_TYPE_PROPAGATE_FROM = 1; // 0x1
field public static final int INDEXING_TYPE_EXACT_TERMS = 1; // 0x1
field public static final int INDEXING_TYPE_NONE = 0; // 0x0
field public static final int INDEXING_TYPE_PREFIXES = 2; // 0x2
@@ -280,6 +283,7 @@
ctor public AppSearchSchema.StringPropertyConfig.Builder(String);
method public androidx.appsearch.app.AppSearchSchema.StringPropertyConfig build();
method public androidx.appsearch.app.AppSearchSchema.StringPropertyConfig.Builder setCardinality(int);
+ method @SuppressCompatibility @RequiresFeature(enforcement="androidx.appsearch.app.Features#isFeatureSupported", name=androidx.appsearch.app.Features.SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM) @androidx.appsearch.app.ExperimentalAppSearchApi public androidx.appsearch.app.AppSearchSchema.StringPropertyConfig.Builder setDeletePropagationType(@SuppressCompatibility int);
method @SuppressCompatibility @RequiresFeature(enforcement="androidx.appsearch.app.Features#isFeatureSupported", name=androidx.appsearch.app.Features.SCHEMA_SET_DESCRIPTION) @androidx.appsearch.app.ExperimentalAppSearchApi public androidx.appsearch.app.AppSearchSchema.StringPropertyConfig.Builder setDescription(String);
method public androidx.appsearch.app.AppSearchSchema.StringPropertyConfig.Builder setIndexingType(int);
method public androidx.appsearch.app.AppSearchSchema.StringPropertyConfig.Builder setJoinableValueType(int);
@@ -353,7 +357,7 @@
field public static final String GLOBAL_SEARCH_SESSION_REGISTER_OBSERVER_CALLBACK = "GLOBAL_SEARCH_SESSION_REGISTER_OBSERVER_CALLBACK";
field public static final String JOIN_SPEC_AND_QUALIFIED_ID = "JOIN_SPEC_AND_QUALIFIED_ID";
field public static final String LIST_FILTER_HAS_PROPERTY_FUNCTION = "LIST_FILTER_HAS_PROPERTY_FUNCTION";
- field public static final String LIST_FILTER_MATCH_SCORE_EXPRESSION_FUNCTION = "LIST_FILTER_MATCH_SCORE_EXPRESSION_FUNCTION";
+ field @SuppressCompatibility @androidx.appsearch.app.ExperimentalAppSearchApi public static final String LIST_FILTER_MATCH_SCORE_EXPRESSION_FUNCTION = "LIST_FILTER_MATCH_SCORE_EXPRESSION_FUNCTION";
field public static final String LIST_FILTER_QUERY_LANGUAGE = "LIST_FILTER_QUERY_LANGUAGE";
field public static final String NUMERIC_SEARCH = "NUMERIC_SEARCH";
field public static final String SCHEMA_ADD_INDEXABLE_NESTED_PROPERTIES = "SCHEMA_ADD_INDEXABLE_NESTED_PROPERTIES";
@@ -362,6 +366,7 @@
field @SuppressCompatibility @androidx.appsearch.app.ExperimentalAppSearchApi public static final String SCHEMA_EMBEDDING_QUANTIZATION = "SCHEMA_EMBEDDING_QUANTIZATION";
field @SuppressCompatibility @androidx.appsearch.app.ExperimentalAppSearchApi public static final String SCHEMA_SCORABLE_PROPERTY_CONFIG = "SCHEMA_SCORABLE_PROPERTY_CONFIG";
field @SuppressCompatibility @androidx.appsearch.app.ExperimentalAppSearchApi public static final String SCHEMA_SET_DESCRIPTION = "SCHEMA_SET_DESCRIPTION";
+ field @SuppressCompatibility @androidx.appsearch.app.ExperimentalAppSearchApi public static final String SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM = "SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM";
field public static final String SEARCH_RESULT_MATCH_INFO_SUBMATCH = "SEARCH_RESULT_MATCH_INFO_SUBMATCH";
field @SuppressCompatibility @androidx.appsearch.app.ExperimentalAppSearchApi public static final String SEARCH_RESULT_PARENT_TYPES = "SEARCH_RESULT_PARENT_TYPES";
field @SuppressCompatibility @androidx.appsearch.app.ExperimentalAppSearchApi public static final String SEARCH_SPEC_ADD_FILTER_DOCUMENT_IDS = "SEARCH_SPEC_ADD_FILTER_DOCUMENT_IDS";
diff --git a/appsearch/appsearch/api/restricted_current.txt b/appsearch/appsearch/api/restricted_current.txt
index 4f0745e..bc6ded2 100644
--- a/appsearch/appsearch/api/restricted_current.txt
+++ b/appsearch/appsearch/api/restricted_current.txt
@@ -262,9 +262,12 @@
}
public static final class AppSearchSchema.StringPropertyConfig extends androidx.appsearch.app.AppSearchSchema.PropertyConfig {
+ method @SuppressCompatibility @androidx.appsearch.app.ExperimentalAppSearchApi public int getDeletePropagationType();
method public int getIndexingType();
method public int getJoinableValueType();
method public int getTokenizerType();
+ field @SuppressCompatibility @androidx.appsearch.app.ExperimentalAppSearchApi public static final int DELETE_PROPAGATION_TYPE_NONE = 0; // 0x0
+ field @SuppressCompatibility @RequiresFeature(enforcement="androidx.appsearch.app.Features#isFeatureSupported", name=androidx.appsearch.app.Features.SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM) @androidx.appsearch.app.ExperimentalAppSearchApi public static final int DELETE_PROPAGATION_TYPE_PROPAGATE_FROM = 1; // 0x1
field public static final int INDEXING_TYPE_EXACT_TERMS = 1; // 0x1
field public static final int INDEXING_TYPE_NONE = 0; // 0x0
field public static final int INDEXING_TYPE_PREFIXES = 2; // 0x2
@@ -280,6 +283,7 @@
ctor public AppSearchSchema.StringPropertyConfig.Builder(String);
method public androidx.appsearch.app.AppSearchSchema.StringPropertyConfig build();
method public androidx.appsearch.app.AppSearchSchema.StringPropertyConfig.Builder setCardinality(int);
+ method @SuppressCompatibility @RequiresFeature(enforcement="androidx.appsearch.app.Features#isFeatureSupported", name=androidx.appsearch.app.Features.SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM) @androidx.appsearch.app.ExperimentalAppSearchApi public androidx.appsearch.app.AppSearchSchema.StringPropertyConfig.Builder setDeletePropagationType(@SuppressCompatibility int);
method @SuppressCompatibility @RequiresFeature(enforcement="androidx.appsearch.app.Features#isFeatureSupported", name=androidx.appsearch.app.Features.SCHEMA_SET_DESCRIPTION) @androidx.appsearch.app.ExperimentalAppSearchApi public androidx.appsearch.app.AppSearchSchema.StringPropertyConfig.Builder setDescription(String);
method public androidx.appsearch.app.AppSearchSchema.StringPropertyConfig.Builder setIndexingType(int);
method public androidx.appsearch.app.AppSearchSchema.StringPropertyConfig.Builder setJoinableValueType(int);
@@ -353,7 +357,7 @@
field public static final String GLOBAL_SEARCH_SESSION_REGISTER_OBSERVER_CALLBACK = "GLOBAL_SEARCH_SESSION_REGISTER_OBSERVER_CALLBACK";
field public static final String JOIN_SPEC_AND_QUALIFIED_ID = "JOIN_SPEC_AND_QUALIFIED_ID";
field public static final String LIST_FILTER_HAS_PROPERTY_FUNCTION = "LIST_FILTER_HAS_PROPERTY_FUNCTION";
- field public static final String LIST_FILTER_MATCH_SCORE_EXPRESSION_FUNCTION = "LIST_FILTER_MATCH_SCORE_EXPRESSION_FUNCTION";
+ field @SuppressCompatibility @androidx.appsearch.app.ExperimentalAppSearchApi public static final String LIST_FILTER_MATCH_SCORE_EXPRESSION_FUNCTION = "LIST_FILTER_MATCH_SCORE_EXPRESSION_FUNCTION";
field public static final String LIST_FILTER_QUERY_LANGUAGE = "LIST_FILTER_QUERY_LANGUAGE";
field public static final String NUMERIC_SEARCH = "NUMERIC_SEARCH";
field public static final String SCHEMA_ADD_INDEXABLE_NESTED_PROPERTIES = "SCHEMA_ADD_INDEXABLE_NESTED_PROPERTIES";
@@ -362,6 +366,7 @@
field @SuppressCompatibility @androidx.appsearch.app.ExperimentalAppSearchApi public static final String SCHEMA_EMBEDDING_QUANTIZATION = "SCHEMA_EMBEDDING_QUANTIZATION";
field @SuppressCompatibility @androidx.appsearch.app.ExperimentalAppSearchApi public static final String SCHEMA_SCORABLE_PROPERTY_CONFIG = "SCHEMA_SCORABLE_PROPERTY_CONFIG";
field @SuppressCompatibility @androidx.appsearch.app.ExperimentalAppSearchApi public static final String SCHEMA_SET_DESCRIPTION = "SCHEMA_SET_DESCRIPTION";
+ field @SuppressCompatibility @androidx.appsearch.app.ExperimentalAppSearchApi public static final String SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM = "SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM";
field public static final String SEARCH_RESULT_MATCH_INFO_SUBMATCH = "SEARCH_RESULT_MATCH_INFO_SUBMATCH";
field @SuppressCompatibility @androidx.appsearch.app.ExperimentalAppSearchApi public static final String SEARCH_RESULT_PARENT_TYPES = "SEARCH_RESULT_PARENT_TYPES";
field @SuppressCompatibility @androidx.appsearch.app.ExperimentalAppSearchApi public static final String SEARCH_SPEC_ADD_FILTER_DOCUMENT_IDS = "SEARCH_SPEC_ADD_FILTER_DOCUMENT_IDS";
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/app/SearchSpecInternalTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/app/SearchSpecInternalTest.java
index 0fce1ed..e983429 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/app/SearchSpecInternalTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/app/SearchSpecInternalTest.java
@@ -19,7 +19,7 @@
import static com.google.common.truth.Truth.assertThat;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import com.google.common.collect.ImmutableMap;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/app/aidl/AppSearchBatchResultGeneralKeyParcelTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/app/aidl/AppSearchBatchResultParcelV2Test.java
similarity index 90%
rename from appsearch/appsearch/src/androidTest/java/androidx/appsearch/app/aidl/AppSearchBatchResultGeneralKeyParcelTest.java
rename to appsearch/appsearch/src/androidTest/java/androidx/appsearch/app/aidl/AppSearchBatchResultParcelV2Test.java
index d2dd377..1d10dc8 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/app/aidl/AppSearchBatchResultGeneralKeyParcelTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/app/aidl/AppSearchBatchResultParcelV2Test.java
@@ -33,7 +33,7 @@
import java.io.File;
-public class AppSearchBatchResultGeneralKeyParcelTest {
+public class AppSearchBatchResultParcelV2Test {
@Test
public void testFromBlobHandleToPfd() throws Exception {
@@ -56,8 +56,8 @@
.setResult(blobHandle1, successResult)
.setResult(blobHandle2, failureResult)
.build();
- AppSearchBatchResultGeneralKeyParcel<AppSearchBlobHandle, ParcelFileDescriptor>
- resultParcel = AppSearchBatchResultGeneralKeyParcel.fromBlobHandleToPfd(result);
+ AppSearchBatchResultParcelV2<AppSearchBlobHandle, ParcelFileDescriptor>
+ resultParcel = AppSearchBatchResultParcelV2.fromBlobHandleToPfd(result);
AppSearchBatchResult<AppSearchBlobHandle, ParcelFileDescriptor> outResult =
resultParcel.getResult();
@@ -84,8 +84,8 @@
.setResult(blobHandle1, successResult)
.setResult(blobHandle2, failureResult)
.build();
- AppSearchBatchResultGeneralKeyParcel<AppSearchBlobHandle, Void>
- resultParcel = AppSearchBatchResultGeneralKeyParcel.fromBlobHandleToVoid(result);
+ AppSearchBatchResultParcelV2<AppSearchBlobHandle, Void> resultParcel =
+ AppSearchBatchResultParcelV2.fromBlobHandleToVoid(result);
AppSearchBatchResult<AppSearchBlobHandle, Void> outResult = resultParcel.getResult();
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchBatchResultCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchBatchResultCtsTest.java
index 0852d6f..83b04c8 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchBatchResultCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchBatchResultCtsTest.java
@@ -20,10 +20,10 @@
import androidx.appsearch.app.AppSearchBatchResult;
import androidx.appsearch.app.AppSearchResult;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Rule;
import org.junit.Test;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchBlobHandleCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchBlobHandleCtsTest.java
index b294eac..9e14154 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchBlobHandleCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchBlobHandleCtsTest.java
@@ -24,10 +24,10 @@
import static org.junit.Assert.assertThrows;
import androidx.appsearch.app.AppSearchBlobHandle;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Rule;
import org.junit.Test;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSchemaCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSchemaCtsTest.java
index 24e89c1..8401565 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSchemaCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSchemaCtsTest.java
@@ -28,11 +28,11 @@
import androidx.appsearch.app.AppSearchSchema.PropertyConfig;
import androidx.appsearch.app.AppSearchSchema.StringPropertyConfig;
import androidx.appsearch.app.PropertyPath;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
import androidx.appsearch.testutil.AppSearchEmail;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Rule;
import org.junit.Test;
@@ -61,10 +61,31 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_DELETE_PROPAGATION_TYPE)
+ public void testStringPropertyConfigDefaultValues_withDeletePropagationType() {
+ StringPropertyConfig builder = new StringPropertyConfig.Builder("test").build();
+ assertThat(builder.getIndexingType()).isEqualTo(StringPropertyConfig.INDEXING_TYPE_NONE);
+ assertThat(builder.getTokenizerType()).isEqualTo(StringPropertyConfig.TOKENIZER_TYPE_NONE);
+ assertThat(builder.getCardinality()).isEqualTo(PropertyConfig.CARDINALITY_OPTIONAL);
+ assertThat(builder.getJoinableValueType())
+ .isEqualTo(StringPropertyConfig.JOINABLE_VALUE_TYPE_NONE);
+ assertThat(builder.getDeletePropagationType())
+ .isEqualTo(StringPropertyConfig.DELETE_PROPAGATION_TYPE_NONE);
+ }
+
+ @Test
public void testLongPropertyConfigDefaultValues() {
LongPropertyConfig builder = new LongPropertyConfig.Builder("test").build();
assertThat(builder.getIndexingType()).isEqualTo(LongPropertyConfig.INDEXING_TYPE_NONE);
assertThat(builder.getCardinality()).isEqualTo(PropertyConfig.CARDINALITY_OPTIONAL);
+ }
+
+ @Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_SCORABLE_PROPERTY)
+ public void testLongPropertyConfigDefaultValuesWithScorableConfig() {
+ LongPropertyConfig builder = new LongPropertyConfig.Builder("test").build();
+ assertThat(builder.getIndexingType()).isEqualTo(LongPropertyConfig.INDEXING_TYPE_NONE);
+ assertThat(builder.getCardinality()).isEqualTo(PropertyConfig.CARDINALITY_OPTIONAL);
assertThat(builder.isScoringEnabled()).isEqualTo(false);
}
@@ -193,6 +214,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_SCORABLE_PROPERTY)
public void testEquals_failWithDifferentScorableTypes() {
AppSearchSchema schema1 = new AppSearchSchema.Builder("Email")
.addProperty(new LongPropertyConfig.Builder("id")
@@ -481,6 +503,68 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_DELETE_PROPAGATION_TYPE)
+ public void testPropertyConfig_withDeletePropagationType() {
+ AppSearchSchema schema =
+ new AppSearchSchema.Builder("Test")
+ .addProperty(
+ new AppSearchSchema.StringPropertyConfig.Builder("qualifiedId1")
+ .setCardinality(
+ AppSearchSchema.PropertyConfig.CARDINALITY_OPTIONAL)
+ .setJoinableValueType(
+ AppSearchSchema.StringPropertyConfig
+ .JOINABLE_VALUE_TYPE_QUALIFIED_ID)
+ .setDeletePropagationType(
+ AppSearchSchema.StringPropertyConfig
+ .DELETE_PROPAGATION_TYPE_PROPAGATE_FROM)
+ .build())
+ .addProperty(
+ new AppSearchSchema.StringPropertyConfig.Builder("qualifiedId2")
+ .setCardinality(
+ AppSearchSchema.PropertyConfig.CARDINALITY_REQUIRED)
+ .setJoinableValueType(
+ AppSearchSchema.StringPropertyConfig
+ .JOINABLE_VALUE_TYPE_QUALIFIED_ID)
+ .setDeletePropagationType(
+ StringPropertyConfig.DELETE_PROPAGATION_TYPE_NONE)
+ .build())
+ .build();
+
+ assertThat(schema.getSchemaType()).isEqualTo("Test");
+ List<PropertyConfig> properties = schema.getProperties();
+ assertThat(properties).hasSize(2);
+
+ assertThat(properties.get(0).getName()).isEqualTo("qualifiedId1");
+ assertThat(properties.get(0).getCardinality())
+ .isEqualTo(AppSearchSchema.PropertyConfig.CARDINALITY_OPTIONAL);
+ assertThat(
+ ((AppSearchSchema.StringPropertyConfig) properties.get(0))
+ .getJoinableValueType())
+ .isEqualTo(
+ AppSearchSchema.StringPropertyConfig.JOINABLE_VALUE_TYPE_QUALIFIED_ID);
+ assertThat(
+ ((AppSearchSchema.StringPropertyConfig) properties.get(0))
+ .getDeletePropagationType())
+ .isEqualTo(
+ AppSearchSchema.StringPropertyConfig
+ .DELETE_PROPAGATION_TYPE_PROPAGATE_FROM);
+
+ assertThat(properties.get(1).getName()).isEqualTo("qualifiedId2");
+ assertThat(properties.get(1).getCardinality())
+ .isEqualTo(AppSearchSchema.PropertyConfig.CARDINALITY_REQUIRED);
+ assertThat(
+ ((AppSearchSchema.StringPropertyConfig) properties.get(1))
+ .getJoinableValueType())
+ .isEqualTo(
+ AppSearchSchema.StringPropertyConfig.JOINABLE_VALUE_TYPE_QUALIFIED_ID);
+ assertThat(
+ ((AppSearchSchema.StringPropertyConfig) properties.get(1))
+ .getDeletePropagationType())
+ .isEqualTo(
+ AppSearchSchema.StringPropertyConfig.DELETE_PROPAGATION_TYPE_NONE);
+ }
+
+ @Test
public void testInvalidStringPropertyConfigsTokenizerNone() {
// Everything should work fine with the defaults.
final StringPropertyConfig.Builder builder =
@@ -617,6 +701,22 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_DELETE_PROPAGATION_TYPE)
+ public void testSetDeletePropagationTypeWithoutJoinableValueTypeQualifiedId_throwsException() {
+ // Setting delete propagation type PROPAGATE_FROM with joinable value type other than
+ // QUALIFIED_ID should fail.
+ final StringPropertyConfig.Builder builder =
+ new StringPropertyConfig.Builder("qualifiedId")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setDeletePropagationType(
+ StringPropertyConfig.DELETE_PROPAGATION_TYPE_PROPAGATE_FROM);
+ IllegalStateException e =
+ assertThrows(IllegalStateException.class, () -> builder.build());
+ assertThat(e).hasMessageThat().contains(
+ "Cannot set delete propagation without setting JOINABLE_VALUE_TYPE_QUALIFIED_ID.");
+ }
+
+ @Test
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_APP_FUNCTIONS) // setDescription
public void testAppSearchSchema_toString() {
AppSearchSchema schema =
@@ -835,6 +935,69 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_DELETE_PROPAGATION_TYPE)
+ public void testAppSearchSchema_toString_withDeletePropagationType() {
+ AppSearchSchema schema =
+ new AppSearchSchema.Builder("testSchema")
+ .addProperty(
+ new StringPropertyConfig.Builder("qualifiedId1")
+ .setDescription("first qualifiedId")
+ .setCardinality(PropertyConfig.CARDINALITY_REQUIRED)
+ .setJoinableValueType(
+ StringPropertyConfig
+ .JOINABLE_VALUE_TYPE_QUALIFIED_ID)
+ .setDeletePropagationType(
+ StringPropertyConfig
+ .DELETE_PROPAGATION_TYPE_PROPAGATE_FROM)
+ .build())
+ .addProperty(
+ new StringPropertyConfig.Builder("qualifiedId2")
+ .setDescription("second qualifiedId")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setJoinableValueType(
+ StringPropertyConfig
+ .JOINABLE_VALUE_TYPE_QUALIFIED_ID)
+ .setDeletePropagationType(
+ StringPropertyConfig.DELETE_PROPAGATION_TYPE_NONE)
+ .build())
+ .build();
+
+ String schemaString = schema.toString();
+
+ String expectedString =
+ "{\n"
+ + " schemaType: \"testSchema\",\n"
+ + " properties: [\n"
+ + " {\n"
+ + " name: \"qualifiedId1\",\n"
+ + " description: \"first qualifiedId\",\n"
+ + " indexingType: INDEXING_TYPE_NONE,\n"
+ + " tokenizerType: TOKENIZER_TYPE_NONE,\n"
+ + " joinableValueType: JOINABLE_VALUE_TYPE_QUALIFIED_ID,\n"
+ + " deletePropagationType: DELETE_PROPAGATION_TYPE_PROPAGATE_FROM,\n"
+ + " cardinality: CARDINALITY_REQUIRED,\n"
+ + " dataType: DATA_TYPE_STRING,\n"
+ + " },\n"
+ + " {\n"
+ + " name: \"qualifiedId2\",\n"
+ + " description: \"second qualifiedId\",\n"
+ + " indexingType: INDEXING_TYPE_NONE,\n"
+ + " tokenizerType: TOKENIZER_TYPE_NONE,\n"
+ + " joinableValueType: JOINABLE_VALUE_TYPE_QUALIFIED_ID,\n"
+ + " deletePropagationType: DELETE_PROPAGATION_TYPE_NONE,\n"
+ + " cardinality: CARDINALITY_OPTIONAL,\n"
+ + " dataType: DATA_TYPE_STRING,\n"
+ + " }\n"
+ + " ]\n"
+ + "}";
+
+ String[] lines = expectedString.split("\n");
+ for (String line : lines) {
+ assertThat(schemaString).contains(line);
+ }
+ }
+
+ @Test
public void testAppSearchSchema_toStringNoDescriptionSet() {
AppSearchSchema schema =
new AppSearchSchema.Builder("testSchema")
@@ -859,6 +1022,7 @@
+ " indexingType: INDEXING_TYPE_NONE,\n"
+ " tokenizerType: TOKENIZER_TYPE_NONE,\n"
+ " joinableValueType: JOINABLE_VALUE_TYPE_NONE,\n"
+ + " deletePropagationType: DELETE_PROPAGATION_TYPE_NONE,\n"
+ " cardinality: CARDINALITY_REQUIRED,\n"
+ " dataType: DATA_TYPE_STRING,\n"
+ " }\n"
@@ -892,6 +1056,20 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_DELETE_PROPAGATION_TYPE)
+ public void testStringPropertyConfig_setDeletePropagationType() {
+ assertThrows(IllegalArgumentException.class, () ->
+ new StringPropertyConfig.Builder("qualifiedId").setDeletePropagationType(5)
+ .build());
+ assertThrows(IllegalArgumentException.class, () ->
+ new StringPropertyConfig.Builder("qualifiedId").setDeletePropagationType(2)
+ .build());
+ assertThrows(IllegalArgumentException.class, () ->
+ new StringPropertyConfig.Builder("qualifiedId").setDeletePropagationType(-1)
+ .build());
+ }
+
+ @Test
public void testLongPropertyConfig_setIndexingType() {
assertThrows(IllegalArgumentException.class, () ->
new LongPropertyConfig.Builder("timestamp").setIndexingType(5).build());
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSessionBlobCtsTestBase.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSessionBlobCtsTestBase.java
index f271597..91ab2d4 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSessionBlobCtsTestBase.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSessionBlobCtsTestBase.java
@@ -45,10 +45,10 @@
import androidx.appsearch.app.OpenBlobForWriteResponse;
import androidx.appsearch.app.PutDocumentsRequest;
import androidx.appsearch.app.SetSchemaRequest;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import androidx.test.core.app.ApplicationProvider;
import com.google.common.collect.ImmutableSet;
@@ -63,7 +63,6 @@
import java.io.InputStream;
import java.io.OutputStream;
-@RequiresFlagsEnabled(Flags.FLAG_ENABLE_BLOB_STORE)
public abstract class AppSearchSessionBlobCtsTestBase {
static final String DB_NAME_1 = "";
@@ -97,6 +96,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_BLOB_STORE)
public void testWriteAndReadBlob() throws Exception {
assumeTrue(mDb1.getFeatures().isFeatureSupported(Features.BLOB_STORAGE));
mDb1.setSchemaAsync(new SetSchemaRequest.Builder().setForceOverride(true).build()).get();
@@ -159,6 +159,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_BLOB_STORE)
public void testWriteAndReadBlob_withoutCommit() throws Exception {
assumeTrue(mDb1.getFeatures().isFeatureSupported(Features.BLOB_STORAGE));
mDb1.setSchemaAsync(new SetSchemaRequest.Builder().setForceOverride(true).build()).get();
@@ -197,6 +198,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_BLOB_STORE)
public void testRewrite_notAllowed() throws Exception {
assumeTrue(mDb1.getFeatures().isFeatureSupported(Features.BLOB_STORAGE));
mDb1.setSchemaAsync(new SetSchemaRequest.Builder().setForceOverride(true).build()).get();
@@ -249,6 +251,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_BLOB_STORE)
public void testOpenWriteForRead_allowed() throws Exception {
assumeTrue(mDb1.getFeatures().isFeatureSupported(Features.BLOB_STORAGE));
mDb1.setSchemaAsync(new SetSchemaRequest.Builder().setForceOverride(true).build()).get();
@@ -274,6 +277,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_BLOB_STORE)
public void testOpenReadForWrite_notAllowed() throws Exception {
assumeTrue(mDb1.getFeatures().isFeatureSupported(Features.BLOB_STORAGE));
mDb1.setSchemaAsync(new SetSchemaRequest.Builder().setForceOverride(true).build()).get();
@@ -316,6 +320,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_BLOB_STORE)
public void testCommitBlobWithWrongDigest() throws Exception {
assumeTrue(mDb1.getFeatures().isFeatureSupported(Features.BLOB_STORAGE));
mDb1.setSchemaAsync(new SetSchemaRequest.Builder().setForceOverride(true).build()).get();
@@ -353,6 +358,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_BLOB_STORE)
public void testCloseWriteResponse() throws Exception {
assumeTrue(mDb1.getFeatures().isFeatureSupported(Features.BLOB_STORAGE));
mDb1.setSchemaAsync(new SetSchemaRequest.Builder().setForceOverride(true).build()).get();
@@ -389,6 +395,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_BLOB_STORE)
public void testCloseReadResponse() throws Exception {
assumeTrue(mDb1.getFeatures().isFeatureSupported(Features.BLOB_STORAGE));
mDb1.setSchemaAsync(new SetSchemaRequest.Builder().setForceOverride(true).build()).get();
@@ -452,6 +459,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_BLOB_STORE)
public void testSetBlobSchema() throws Exception {
assumeTrue(mDb1.getFeatures().isFeatureSupported(Features.BLOB_STORAGE));
AppSearchSchema schema = new AppSearchSchema.Builder("Type")
@@ -467,6 +475,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_BLOB_STORE)
public void testPutDocumentWithBlobProperty() throws Exception {
assumeTrue(mDb1.getFeatures().isFeatureSupported(Features.BLOB_STORAGE));
AppSearchSchema schema = new AppSearchSchema.Builder("Type")
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSessionBlobGmsCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSessionBlobGmsCtsTest.java
index 05428ce..672137a 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSessionBlobGmsCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSessionBlobGmsCtsTest.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+// @exportToFramework:skipFile()
package androidx.appsearch.cts.app;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSessionBlobPlatformCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSessionBlobPlatformCtsTest.java
index d8a8f0c..4e0a746 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSessionBlobPlatformCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSessionBlobPlatformCtsTest.java
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+// @exportToFramework:skipFile()
package androidx.appsearch.cts.app;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSessionCtsTestBase.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSessionCtsTestBase.java
index 0b9308d..edea125 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSessionCtsTestBase.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/AppSearchSessionCtsTestBase.java
@@ -64,11 +64,11 @@
import androidx.appsearch.app.StorageInfo;
import androidx.appsearch.cts.app.customer.EmailDocument;
import androidx.appsearch.exceptions.AppSearchException;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
import androidx.appsearch.testutil.AppSearchEmail;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import androidx.appsearch.usagereporting.ClickAction;
import androidx.appsearch.usagereporting.DismissAction;
import androidx.appsearch.usagereporting.ImpressionAction;
@@ -1334,6 +1334,120 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_DELETE_PROPAGATION_TYPE)
+ public void testGetSchema_deletePropagationTypePropagateFrom() throws Exception {
+ assumeTrue(mDb1.getFeatures().isFeatureSupported(Features.JOIN_SPEC_AND_QUALIFIED_ID));
+ assumeTrue(mDb1.getFeatures().isFeatureSupported(
+ Features.SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM));
+
+ AppSearchSchema inSchema = new AppSearchSchema.Builder("Test")
+ .addProperty(new StringPropertyConfig.Builder("normalStr")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .build()
+ ).addProperty(new StringPropertyConfig.Builder("qualifiedId")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setJoinableValueType(StringPropertyConfig.JOINABLE_VALUE_TYPE_QUALIFIED_ID)
+ .setDeletePropagationType(
+ StringPropertyConfig.DELETE_PROPAGATION_TYPE_PROPAGATE_FROM)
+ .build()
+ ).build();
+
+ SetSchemaRequest request = new SetSchemaRequest.Builder()
+ .addSchemas(inSchema).build();
+
+ mDb1.setSchemaAsync(request).get();
+
+ Set<AppSearchSchema> actual = mDb1.getSchemaAsync().get().getSchemas();
+ assertThat(actual).hasSize(1);
+ assertThat(actual).containsExactlyElementsIn(request.getSchemas());
+ }
+
+ @Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_DELETE_PROPAGATION_TYPE)
+ public void testGetSchema_deletePropagationTypeNoneWithNonJoinable_succeeds() throws Exception {
+ AppSearchSchema inSchema = new AppSearchSchema.Builder("Test")
+ .addProperty(new StringPropertyConfig.Builder("optionalString")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setJoinableValueType(StringPropertyConfig.JOINABLE_VALUE_TYPE_NONE)
+ .setDeletePropagationType(StringPropertyConfig.DELETE_PROPAGATION_TYPE_NONE)
+ .build()
+ ).addProperty(new StringPropertyConfig.Builder("requiredString")
+ .setCardinality(PropertyConfig.CARDINALITY_REQUIRED)
+ .setJoinableValueType(StringPropertyConfig.JOINABLE_VALUE_TYPE_NONE)
+ .setDeletePropagationType(StringPropertyConfig.DELETE_PROPAGATION_TYPE_NONE)
+ .build()
+ ).addProperty(new StringPropertyConfig.Builder("repeatedString")
+ .setCardinality(PropertyConfig.CARDINALITY_REPEATED)
+ .setJoinableValueType(StringPropertyConfig.JOINABLE_VALUE_TYPE_NONE)
+ .setDeletePropagationType(StringPropertyConfig.DELETE_PROPAGATION_TYPE_NONE)
+ .build()
+ ).build();
+
+ SetSchemaRequest request = new SetSchemaRequest.Builder()
+ .addSchemas(inSchema).build();
+
+ mDb1.setSchemaAsync(request).get();
+
+ Set<AppSearchSchema> actual = mDb1.getSchemaAsync().get().getSchemas();
+ assertThat(actual).hasSize(1);
+ assertThat(actual).containsExactlyElementsIn(request.getSchemas());
+ }
+
+ @Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_DELETE_PROPAGATION_TYPE)
+ public void testGetSchema_deletePropagationTypeNoneWithJoinable_succeeds() throws Exception {
+ assumeTrue(mDb1.getFeatures().isFeatureSupported(Features.JOIN_SPEC_AND_QUALIFIED_ID));
+
+ AppSearchSchema inSchema = new AppSearchSchema.Builder("Test")
+ .addProperty(new StringPropertyConfig.Builder("optionalString")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setJoinableValueType(StringPropertyConfig.JOINABLE_VALUE_TYPE_QUALIFIED_ID)
+ .setDeletePropagationType(StringPropertyConfig.DELETE_PROPAGATION_TYPE_NONE)
+ .build()
+ ).addProperty(new StringPropertyConfig.Builder("requiredString")
+ .setCardinality(PropertyConfig.CARDINALITY_REQUIRED)
+ .setJoinableValueType(StringPropertyConfig.JOINABLE_VALUE_TYPE_QUALIFIED_ID)
+ .setDeletePropagationType(StringPropertyConfig.DELETE_PROPAGATION_TYPE_NONE)
+ .build()
+ ).build();
+
+ SetSchemaRequest request = new SetSchemaRequest.Builder()
+ .addSchemas(inSchema).build();
+
+ mDb1.setSchemaAsync(request).get();
+
+ Set<AppSearchSchema> actual = mDb1.getSchemaAsync().get().getSchemas();
+ assertThat(actual).hasSize(1);
+ assertThat(actual).containsExactlyElementsIn(request.getSchemas());
+ }
+
+ @Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_DELETE_PROPAGATION_TYPE)
+ public void testGetSchema_deletePropagationTypePropagateFrom_notSupported() throws Exception {
+ assumeTrue(mDb1.getFeatures().isFeatureSupported(Features.JOIN_SPEC_AND_QUALIFIED_ID));
+ assumeFalse(mDb1.getFeatures().isFeatureSupported(
+ Features.SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM));
+
+ AppSearchSchema inSchema = new AppSearchSchema.Builder("Test")
+ .addProperty(new StringPropertyConfig.Builder("qualifiedId")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setJoinableValueType(StringPropertyConfig.JOINABLE_VALUE_TYPE_QUALIFIED_ID)
+ .setDeletePropagationType(
+ StringPropertyConfig.DELETE_PROPAGATION_TYPE_PROPAGATE_FROM)
+ .build()
+ ).build();
+
+ SetSchemaRequest request = new SetSchemaRequest.Builder()
+ .addSchemas(inSchema).build();
+
+ UnsupportedOperationException e = assertThrows(UnsupportedOperationException.class, () ->
+ mDb1.setSchemaAsync(request).get());
+ assertThat(e.getMessage()).isEqualTo(
+ "StringPropertyConfig.DELETE_PROPAGATION_TYPE_PROPAGATE_FROM is not supported on "
+ + "this AppSearch implementation.");
+ }
+
+ @Test
public void testGetNamespaces() throws Exception {
// Schema registration
mDb1.setSchemaAsync(
@@ -5302,6 +5416,387 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_DELETE_PROPAGATION_TYPE)
+ public void testRemove_withDeletePropagationFromParentToChildren() throws Exception {
+ assumeTrue(mDb1.getFeatures().isFeatureSupported(Features.JOIN_SPEC_AND_QUALIFIED_ID));
+ assumeTrue(mDb1.getFeatures().isFeatureSupported(
+ Features.SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM));
+
+ // Person (parent) schema.
+ AppSearchSchema personSchema = new AppSearchSchema.Builder("Person")
+ .addProperty(
+ new StringPropertyConfig.Builder("name")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setIndexingType(
+ StringPropertyConfig.INDEXING_TYPE_PREFIXES)
+ .setTokenizerType(StringPropertyConfig.TOKENIZER_TYPE_PLAIN)
+ .build())
+ .build();
+ // Email (child) schema: "sender" has delete propagation type PROPAGATE_FROM, and "receiver"
+ // doesn't have delete propagation.
+ AppSearchSchema emailSchema = new AppSearchSchema.Builder("Email")
+ .addProperty(
+ new StringPropertyConfig.Builder("subject")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setIndexingType(
+ StringPropertyConfig.INDEXING_TYPE_PREFIXES)
+ .setTokenizerType(StringPropertyConfig.TOKENIZER_TYPE_PLAIN)
+ .build())
+ .addProperty(
+ new StringPropertyConfig.Builder("sender")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setJoinableValueType(
+ StringPropertyConfig.JOINABLE_VALUE_TYPE_QUALIFIED_ID)
+ .setDeletePropagationType(
+ StringPropertyConfig.DELETE_PROPAGATION_TYPE_PROPAGATE_FROM)
+ .build())
+ .addProperty(
+ new StringPropertyConfig.Builder("receiver")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setJoinableValueType(
+ StringPropertyConfig.JOINABLE_VALUE_TYPE_QUALIFIED_ID)
+ .build())
+ .build();
+
+ // Schema registration
+ mDb1.setSchemaAsync(
+ new SetSchemaRequest.Builder().addSchemas(personSchema, emailSchema)
+ .build()).get();
+
+ // Put 1 person and 2 email documents.
+ GenericDocument person =
+ new GenericDocument.Builder<>("namespace", "person", "Person")
+ .setPropertyString("name", "test person")
+ .build();
+ String personQualifiedId = DocumentIdUtil.createQualifiedId(
+ mContext.getPackageName(), DB_NAME_1, "namespace", "person");
+ GenericDocument email1 =
+ new GenericDocument.Builder<>("namespace", "email1", "Email")
+ .setPropertyString("subject", "test email subject")
+ .setPropertyString("sender", personQualifiedId)
+ .build();
+ GenericDocument email2 =
+ new GenericDocument.Builder<>("namespace", "email2", "Email")
+ .setPropertyString("subject", "test email subject")
+ .setPropertyString("receiver", personQualifiedId)
+ .build();
+ checkIsBatchResultSuccess(mDb1.putAsync(
+ new PutDocumentsRequest.Builder().addGenericDocuments(person, email1, email2)
+ .build()));
+
+ // Check the presence of the documents
+ assertThat(doGet(mDb1, "namespace", "person")).hasSize(1);
+ assertThat(doGet(mDb1, "namespace", "email1")).hasSize(1);
+ assertThat(doGet(mDb1, "namespace", "email2")).hasSize(1);
+
+ // Delete the person (parent) document
+ checkIsBatchResultSuccess(mDb1.removeAsync(
+ new RemoveByDocumentIdRequest.Builder("namespace").addIds("person").build()));
+
+ // Verify that:
+ // - Person document is deleted.
+ // - Email1 document is also deleted due to the delete propagation via "sender".
+ // - Email2 document is still present since "receiver" does not have delete propagation.
+ AppSearchBatchResult<String, GenericDocument> getResult1 =
+ mDb1.getByDocumentIdAsync(
+ new GetByDocumentIdRequest.Builder("namespace").addIds(
+ "person", "email1").build())
+ .get();
+ assertThat(getResult1.isSuccess()).isFalse();
+ assertThat(getResult1.getFailures()).hasSize(2);
+ assertThat(getResult1.getFailures().get("person").getResultCode())
+ .isEqualTo(AppSearchResult.RESULT_NOT_FOUND);
+ assertThat(getResult1.getFailures().get("email1").getResultCode())
+ .isEqualTo(AppSearchResult.RESULT_NOT_FOUND);
+
+ AppSearchBatchResult<String, GenericDocument> getResult2 =
+ mDb1.getByDocumentIdAsync(
+ new GetByDocumentIdRequest.Builder("namespace").addIds(
+ "email2").build())
+ .get();
+ assertThat(getResult2.isSuccess()).isTrue();
+ assertThat(getResult2.getSuccesses()).hasSize(1);
+ assertThat(getResult2.getSuccesses().get("email2")).isEqualTo(email2);
+ }
+
+ @Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_DELETE_PROPAGATION_TYPE)
+ public void testRemove_withDeletePropagationFromParentToGrandchildren() throws Exception {
+ assumeTrue(mDb1.getFeatures().isFeatureSupported(Features.JOIN_SPEC_AND_QUALIFIED_ID));
+ assumeTrue(mDb1.getFeatures().isFeatureSupported(
+ Features.SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM));
+
+ // Person (parent) schema.
+ AppSearchSchema personSchema = new AppSearchSchema.Builder("Person")
+ .addProperty(
+ new StringPropertyConfig.Builder("name")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setIndexingType(
+ StringPropertyConfig.INDEXING_TYPE_PREFIXES)
+ .setTokenizerType(StringPropertyConfig.TOKENIZER_TYPE_PLAIN)
+ .build())
+ .build();
+ // Email (child) schema: "sender" has delete propagation type PROPAGATE_FROM, and "receiver"
+ // doesn't have delete propagation.
+ AppSearchSchema emailSchema = new AppSearchSchema.Builder("Email")
+ .addProperty(
+ new StringPropertyConfig.Builder("subject")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setIndexingType(
+ StringPropertyConfig.INDEXING_TYPE_PREFIXES)
+ .setTokenizerType(StringPropertyConfig.TOKENIZER_TYPE_PLAIN)
+ .build())
+ .addProperty(
+ new StringPropertyConfig.Builder("sender")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setJoinableValueType(
+ StringPropertyConfig.JOINABLE_VALUE_TYPE_QUALIFIED_ID)
+ .setDeletePropagationType(
+ StringPropertyConfig.DELETE_PROPAGATION_TYPE_PROPAGATE_FROM)
+ .build())
+ .addProperty(
+ new StringPropertyConfig.Builder("receiver")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setJoinableValueType(
+ StringPropertyConfig.JOINABLE_VALUE_TYPE_QUALIFIED_ID)
+ .build())
+ .build();
+
+ // Label (grandchild) schema: "object" has delete propagation type PROPAGATE_FROM, and
+ // "softLink" doesn't have delete propagation.
+ AppSearchSchema labelSchema = new AppSearchSchema.Builder("Label")
+ .addProperty(
+ new StringPropertyConfig.Builder("text")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setIndexingType(
+ StringPropertyConfig.INDEXING_TYPE_PREFIXES)
+ .setTokenizerType(StringPropertyConfig.TOKENIZER_TYPE_PLAIN)
+ .build())
+ .addProperty(
+ new StringPropertyConfig.Builder("object")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setJoinableValueType(
+ StringPropertyConfig.JOINABLE_VALUE_TYPE_QUALIFIED_ID)
+ .setDeletePropagationType(
+ StringPropertyConfig.DELETE_PROPAGATION_TYPE_PROPAGATE_FROM)
+ .build())
+ .addProperty(
+ new StringPropertyConfig.Builder("softLink")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setJoinableValueType(
+ StringPropertyConfig.JOINABLE_VALUE_TYPE_QUALIFIED_ID)
+ .build())
+ .build();
+
+ // Schema registration
+ mDb1.setSchemaAsync(
+ new SetSchemaRequest.Builder().addSchemas(personSchema, emailSchema, labelSchema)
+ .build()).get();
+
+ // Put 1 person, 2 email, and 4 label documents with the following relations:
+ //
+ // ("object") - label1
+ // /
+ // email1 <-
+ // / \
+ // ("sender") ("softLink") - label2
+ // /
+ // person <-
+ // \
+ // ("receiver") ("object") - label3
+ // \ /
+ // email2 <-
+ // \
+ // ("softLink") - label4
+ GenericDocument person =
+ new GenericDocument.Builder<>("namespace", "person", "Person")
+ .setPropertyString("name", "test person")
+ .build();
+ String personQualifiedId = DocumentIdUtil.createQualifiedId(
+ mContext.getPackageName(), DB_NAME_1, "namespace", "person");
+
+ GenericDocument email1 =
+ new GenericDocument.Builder<>("namespace", "email1", "Email")
+ .setPropertyString("subject", "test email subject")
+ .setPropertyString("sender", personQualifiedId)
+ .build();
+ GenericDocument email2 =
+ new GenericDocument.Builder<>("namespace", "email2", "Email")
+ .setPropertyString("subject", "test email subject")
+ .setPropertyString("receiver", personQualifiedId)
+ .build();
+ String emailQualifiedId1 = DocumentIdUtil.createQualifiedId(
+ mContext.getPackageName(), DB_NAME_1, "namespace", "email1");
+ String emailQualifiedId2 = DocumentIdUtil.createQualifiedId(
+ mContext.getPackageName(), DB_NAME_1, "namespace", "email2");
+
+ GenericDocument label1 =
+ new GenericDocument.Builder<>("namespace", "label1", "Label")
+ .setPropertyString("text", "label1")
+ .setPropertyString("object", emailQualifiedId1)
+ .build();
+ GenericDocument label2 =
+ new GenericDocument.Builder<>("namespace", "label2", "Label")
+ .setPropertyString("text", "label2")
+ .setPropertyString("softLink", emailQualifiedId1)
+ .build();
+ GenericDocument label3 =
+ new GenericDocument.Builder<>("namespace", "label3", "Label")
+ .setPropertyString("text", "label3")
+ .setPropertyString("object", emailQualifiedId2)
+ .build();
+ GenericDocument label4 =
+ new GenericDocument.Builder<>("namespace", "label4", "Label")
+ .setPropertyString("text", "label4")
+ .setPropertyString("softLink", emailQualifiedId2)
+ .build();
+
+ checkIsBatchResultSuccess(mDb1.putAsync(
+ new PutDocumentsRequest.Builder().addGenericDocuments(
+ person, email1, email2, label1, label2, label3, label4)
+ .build()));
+
+ // Check the presence of the documents
+ assertThat(doGet(mDb1, "namespace", "person")).hasSize(1);
+ assertThat(doGet(mDb1, "namespace", "email1")).hasSize(1);
+ assertThat(doGet(mDb1, "namespace", "email2")).hasSize(1);
+ assertThat(doGet(mDb1, "namespace", "label1")).hasSize(1);
+ assertThat(doGet(mDb1, "namespace", "label2")).hasSize(1);
+ assertThat(doGet(mDb1, "namespace", "label3")).hasSize(1);
+ assertThat(doGet(mDb1, "namespace", "label4")).hasSize(1);
+
+ // Delete the person (parent) document
+ checkIsBatchResultSuccess(mDb1.removeAsync(
+ new RemoveByDocumentIdRequest.Builder("namespace").addIds("person").build()));
+
+ // Verify that:
+ // - Person document is deleted.
+ // - Email1 document is also deleted due to the delete propagation via "sender".
+ // - Label1 document is also deleted due to the delete propagation via "object".
+ // - Label2 document is still present since "softLink" does not have delete propagation.
+ // - Email2 document is still present since "receiver" does not have delete propagation.
+ // - Label3 document is still present since Email2 is not deleted.
+ // - Label4 document is still present since Email2 is not deleted.
+ AppSearchBatchResult<String, GenericDocument> getResult1 =
+ mDb1.getByDocumentIdAsync(
+ new GetByDocumentIdRequest.Builder("namespace").addIds(
+ "person", "email1", "label1").build())
+ .get();
+ assertThat(getResult1.isSuccess()).isFalse();
+ assertThat(getResult1.getFailures()).hasSize(3);
+ assertThat(getResult1.getFailures().get("person").getResultCode())
+ .isEqualTo(AppSearchResult.RESULT_NOT_FOUND);
+ assertThat(getResult1.getFailures().get("email1").getResultCode())
+ .isEqualTo(AppSearchResult.RESULT_NOT_FOUND);
+ assertThat(getResult1.getFailures().get("label1").getResultCode())
+ .isEqualTo(AppSearchResult.RESULT_NOT_FOUND);
+
+ AppSearchBatchResult<String, GenericDocument> getResult2 =
+ mDb1.getByDocumentIdAsync(
+ new GetByDocumentIdRequest.Builder("namespace").addIds(
+ "email2", "label2", "label3", "label4").build())
+ .get();
+ assertThat(getResult2.isSuccess()).isTrue();
+ assertThat(getResult2.getSuccesses()).hasSize(4);
+ assertThat(getResult2.getSuccesses().get("email2")).isEqualTo(email2);
+ assertThat(getResult2.getSuccesses().get("label2")).isEqualTo(label2);
+ assertThat(getResult2.getSuccesses().get("label3")).isEqualTo(label3);
+ assertThat(getResult2.getSuccesses().get("label4")).isEqualTo(label4);
+ }
+
+ @Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_DELETE_PROPAGATION_TYPE)
+ public void testRemove_withDeletePropagationFromParentToChildren_fromMultipleProperties()
+ throws Exception {
+ assumeTrue(mDb1.getFeatures().isFeatureSupported(Features.JOIN_SPEC_AND_QUALIFIED_ID));
+ assumeTrue(mDb1.getFeatures().isFeatureSupported(
+ Features.SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM));
+
+ // Person (parent) schema.
+ AppSearchSchema personSchema = new AppSearchSchema.Builder("Person")
+ .addProperty(
+ new StringPropertyConfig.Builder("name")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setIndexingType(
+ StringPropertyConfig.INDEXING_TYPE_PREFIXES)
+ .setTokenizerType(StringPropertyConfig.TOKENIZER_TYPE_PLAIN)
+ .build())
+ .build();
+ // Email (child) schema: "sender" has delete propagation type PROPAGATE_FROM, and "receiver"
+ // doesn't have delete propagation.
+ AppSearchSchema emailSchema = new AppSearchSchema.Builder("Email")
+ .addProperty(
+ new StringPropertyConfig.Builder("subject")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setIndexingType(
+ StringPropertyConfig.INDEXING_TYPE_PREFIXES)
+ .setTokenizerType(StringPropertyConfig.TOKENIZER_TYPE_PLAIN)
+ .build())
+ .addProperty(
+ new StringPropertyConfig.Builder("sender")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setJoinableValueType(
+ StringPropertyConfig.JOINABLE_VALUE_TYPE_QUALIFIED_ID)
+ .setDeletePropagationType(
+ StringPropertyConfig.DELETE_PROPAGATION_TYPE_PROPAGATE_FROM)
+ .build())
+ .addProperty(
+ new StringPropertyConfig.Builder("receiver")
+ .setCardinality(PropertyConfig.CARDINALITY_OPTIONAL)
+ .setJoinableValueType(
+ StringPropertyConfig.JOINABLE_VALUE_TYPE_QUALIFIED_ID)
+ .build())
+ .build();
+
+ // Schema registration
+ mDb1.setSchemaAsync(
+ new SetSchemaRequest.Builder().addSchemas(personSchema, emailSchema)
+ .build()).get();
+
+ // Put 1 person and 1 email document.
+ // Email document has both "sender" and "receiver" referring to the person document.
+ GenericDocument person =
+ new GenericDocument.Builder<>("namespace", "person", "Person")
+ .setPropertyString("name", "test person")
+ .build();
+ String personQualifiedId = DocumentIdUtil.createQualifiedId(
+ mContext.getPackageName(), DB_NAME_1, "namespace", "person");
+ GenericDocument email =
+ new GenericDocument.Builder<>("namespace", "email", "Email")
+ .setPropertyString("subject", "test email subject")
+ .setPropertyString("sender", personQualifiedId)
+ .setPropertyString("receiver", personQualifiedId)
+ .build();
+ checkIsBatchResultSuccess(mDb1.putAsync(
+ new PutDocumentsRequest.Builder().addGenericDocuments(person, email)
+ .build()));
+
+ // Check the presence of the documents
+ assertThat(doGet(mDb1, "namespace", "person")).hasSize(1);
+ assertThat(doGet(mDb1, "namespace", "email")).hasSize(1);
+
+ // Delete the person (parent) document
+ checkIsBatchResultSuccess(mDb1.removeAsync(
+ new RemoveByDocumentIdRequest.Builder("namespace").addIds("person").build()));
+
+ // Verify that:
+ // - Person document is deleted.
+ // - Email document is also deleted since there is at least one property ("sender") with
+ // DELETE_PROPAGATION_TYPE_PROPAGATE_FROM.
+ AppSearchBatchResult<String, GenericDocument> getResult1 =
+ mDb1.getByDocumentIdAsync(
+ new GetByDocumentIdRequest.Builder("namespace").addIds(
+ "person", "email").build())
+ .get();
+ assertThat(getResult1.isSuccess()).isFalse();
+ assertThat(getResult1.getFailures()).hasSize(2);
+ assertThat(getResult1.getFailures().get("person").getResultCode())
+ .isEqualTo(AppSearchResult.RESULT_NOT_FOUND);
+ assertThat(getResult1.getFailures().get("email").getResultCode())
+ .isEqualTo(AppSearchResult.RESULT_NOT_FOUND);
+ }
+
+ @Test
public void testRemoveByQuery() throws Exception {
// Schema registration
mDb1.setSchemaAsync(
@@ -11049,22 +11544,6 @@
mDb1.setSchemaAsync(new SetSchemaRequest.Builder()
.addSchemas(schemaWithPropertyNotScorable).build()).get();
- // Ranking with the property will return an error, and the scorable cache will also be
- // erased.
- ExecutionException exception = assertThrows(ExecutionException.class,
- () -> {
- SearchSpec invalidSearchSpec = new SearchSpec.Builder()
- .setScorablePropertyRankingEnabled(true)
- .setRankingStrategy(
- "sum(getScorableProperty(\"Gmail\", \"important\"))")
- .build();
- SearchResults invalidSearchResults =
- mDb1.search("", invalidSearchSpec);
- retrieveAllSearchResults(invalidSearchResults);
- });
- assertThat(exception.getMessage()).matches(
- ".*\'important\' is not defined as a scorable property under schema type.*");
-
// Update the schema by updating the property to scorable again.
mDb1.setSchemaAsync(new SetSchemaRequest.Builder()
.addSchemas(schemaWithPropertyScorable).build()).get();
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/CommitBlobResponseTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/CommitBlobResponseTest.java
index fe851aa..366f189 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/CommitBlobResponseTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/CommitBlobResponseTest.java
@@ -25,10 +25,10 @@
import androidx.appsearch.app.AppSearchBlobHandle;
import androidx.appsearch.app.AppSearchResult;
import androidx.appsearch.app.CommitBlobResponse;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Rule;
import org.junit.Test;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/EnterpriseGlobalSearchSessionCtsTestBase.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/EnterpriseGlobalSearchSessionCtsTestBase.java
index 2c9bf17..1b2c9be 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/EnterpriseGlobalSearchSessionCtsTestBase.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/EnterpriseGlobalSearchSessionCtsTestBase.java
@@ -25,10 +25,10 @@
import androidx.appsearch.app.EnterpriseGlobalSearchSession;
import androidx.appsearch.app.GenericDocument;
import androidx.appsearch.app.GetByDocumentIdRequest;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import com.google.common.util.concurrent.ListenableFuture;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/GenericDocumentCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/GenericDocumentCtsTest.java
index 475d33d..6bfea59 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/GenericDocumentCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/GenericDocumentCtsTest.java
@@ -28,10 +28,10 @@
import androidx.appsearch.app.AppSearchBlobHandle;
import androidx.appsearch.app.EmbeddingVector;
import androidx.appsearch.app.GenericDocument;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Rule;
import org.junit.Test;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/GetSchemaResponseCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/GetSchemaResponseCtsTest.java
index c4a7722..98573bb 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/GetSchemaResponseCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/GetSchemaResponseCtsTest.java
@@ -25,10 +25,10 @@
import androidx.appsearch.app.PackageIdentifier;
import androidx.appsearch.app.SchemaVisibilityConfig;
import androidx.appsearch.app.SetSchemaRequest;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import com.google.common.collect.ImmutableSet;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/GlobalSearchSessionCtsTestBase.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/GlobalSearchSessionCtsTestBase.java
index 3a35de1..9d5fe3d 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/GlobalSearchSessionCtsTestBase.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/GlobalSearchSessionCtsTestBase.java
@@ -49,12 +49,14 @@
import androidx.appsearch.app.SetSchemaRequest;
import androidx.appsearch.exceptions.AppSearchException;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
import androidx.appsearch.observer.DocumentChangeInfo;
import androidx.appsearch.observer.ObserverSpec;
import androidx.appsearch.observer.SchemaChangeInfo;
import androidx.appsearch.testutil.AppSearchEmail;
import androidx.appsearch.testutil.TestObserverCallback;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import androidx.test.core.app.ApplicationProvider;
import com.google.common.collect.ImmutableList;
@@ -64,6 +66,7 @@
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import java.util.ArrayList;
@@ -85,6 +88,9 @@
protected GlobalSearchSession mGlobalSearchSession;
+ @Rule
+ public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule();
+
protected abstract ListenableFuture<AppSearchSession> createSearchSessionAsync(
@NonNull String dbName) throws Exception;
@@ -2028,6 +2034,7 @@
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_SCORABLE_PROPERTY)
public void testRankWithScorableProperty_searchFromMultipleDbs() throws Exception {
assumeTrue(mGlobalSearchSession.getFeatures()
.isFeatureSupported(Features.SCHEMA_SCORABLE_PROPERTY_CONFIG));
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/JoinSpecCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/JoinSpecCtsTest.java
index a307a22..8bb5e1b 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/JoinSpecCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/JoinSpecCtsTest.java
@@ -20,10 +20,10 @@
import androidx.appsearch.app.JoinSpec;
import androidx.appsearch.app.SearchSpec;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Rule;
import org.junit.Test;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/OpenBlobForReadResponseTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/OpenBlobForReadResponseTest.java
index 1378e7c..24d85cb 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/OpenBlobForReadResponseTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/OpenBlobForReadResponseTest.java
@@ -31,10 +31,10 @@
import androidx.appsearch.app.AppSearchBlobHandle;
import androidx.appsearch.app.AppSearchResult;
import androidx.appsearch.app.OpenBlobForReadResponse;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.After;
import org.junit.Before;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/OpenBlobForWriteResponseTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/OpenBlobForWriteResponseTest.java
index a9f4bfc..8481aab 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/OpenBlobForWriteResponseTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/OpenBlobForWriteResponseTest.java
@@ -31,10 +31,10 @@
import androidx.appsearch.app.AppSearchBlobHandle;
import androidx.appsearch.app.AppSearchResult;
import androidx.appsearch.app.OpenBlobForWriteResponse;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.After;
import org.junit.Before;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/SearchResultCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/SearchResultCtsTest.java
index 3761d6f..322b898 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/SearchResultCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/SearchResultCtsTest.java
@@ -22,11 +22,11 @@
import androidx.appsearch.app.PropertyPath;
import androidx.appsearch.app.SearchResult;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
import androidx.appsearch.testutil.AppSearchEmail;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Rule;
import org.junit.Test;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/SearchSpecCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/SearchSpecCtsTest.java
index 9b13d2c..444d67a 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/SearchSpecCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/SearchSpecCtsTest.java
@@ -28,10 +28,10 @@
import androidx.appsearch.app.JoinSpec;
import androidx.appsearch.app.PropertyPath;
import androidx.appsearch.app.SearchSpec;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@@ -88,6 +88,78 @@
.setNumericSearchEnabled(true)
.setVerbatimSearchEnabled(true)
.setListFilterQueryLanguageEnabled(true)
+ .build();
+
+ assertThat(searchSpec.getTermMatch()).isEqualTo(SearchSpec.TERM_MATCH_PREFIX);
+ assertThat(searchSpec.getFilterNamespaces())
+ .containsExactly("namespace1", "namespace2", "namespace3").inOrder();
+ assertThat(searchSpec.getFilterSchemas())
+ .containsExactly("schemaTypes1", "schemaTypes2", "schemaTypes3").inOrder();
+ assertThat(searchSpec.getFilterPackageNames())
+ .containsExactly("package1", "package2", "package3").inOrder();
+ assertThat(searchSpec.getSnippetCount()).isEqualTo(5);
+ assertThat(searchSpec.getSnippetCountPerProperty()).isEqualTo(10);
+ assertThat(searchSpec.getMaxSnippetSize()).isEqualTo(15);
+ assertThat(searchSpec.getResultCountPerPage()).isEqualTo(42);
+ assertThat(searchSpec.getOrder()).isEqualTo(SearchSpec.ORDER_ASCENDING);
+ assertThat(searchSpec.getRankingStrategy())
+ .isEqualTo(SearchSpec.RANKING_STRATEGY_RELEVANCE_SCORE);
+ assertThat(searchSpec.getResultGroupingTypeFlags())
+ .isEqualTo(SearchSpec.GROUPING_TYPE_PER_NAMESPACE
+ | SearchSpec.GROUPING_TYPE_PER_PACKAGE);
+ assertThat(searchSpec.getProjections())
+ .containsExactly("schemaTypes1", expectedPropertyPaths1, "schemaTypes2",
+ expectedPropertyPaths2);
+ assertThat(searchSpec.getResultGroupingLimit()).isEqualTo(37);
+ assertThat(searchSpec.getPropertyWeights().keySet()).containsExactly("schemaTypes1",
+ "schemaTypes2");
+ assertThat(searchSpec.getPropertyWeights().get("schemaTypes1"))
+ .containsExactly("property1", 1.0, "property2", 2.0);
+ assertThat(searchSpec.getPropertyWeights().get("schemaTypes2"))
+ .containsExactly("property1.nested", 1.0);
+ assertThat(searchSpec.getPropertyWeightPaths().get("schemaTypes1"))
+ .containsExactly(new PropertyPath("property1"), 1.0,
+ new PropertyPath("property2"), 2.0);
+ assertThat(searchSpec.getPropertyWeightPaths().get("schemaTypes2"))
+ .containsExactly(new PropertyPath("property1.nested"), 1.0);
+ assertThat(searchSpec.isNumericSearchEnabled()).isTrue();
+ assertThat(searchSpec.isVerbatimSearchEnabled()).isTrue();
+ assertThat(searchSpec.isListFilterQueryLanguageEnabled()).isTrue();
+ }
+
+ @Test
+ @RequiresFlagsEnabled(Flags.FLAG_ENABLE_SCORABLE_PROPERTY)
+ public void testBuildSearchSpec_scorablePropertyRanking() {
+ List<String> expectedPropertyPaths1 = ImmutableList.of("path1", "path2");
+ List<String> expectedPropertyPaths2 = ImmutableList.of("path3", "path4");
+ Map<String, Double> expectedPropertyWeights = ImmutableMap.of("property1", 1.0,
+ "property2", 2.0);
+ Map<PropertyPath, Double> expectedPropertyWeightPaths =
+ ImmutableMap.of(new PropertyPath("property1.nested"), 1.0);
+
+ SearchSpec searchSpec = new SearchSpec.Builder()
+ .setTermMatch(SearchSpec.TERM_MATCH_PREFIX)
+ .addFilterNamespaces("namespace1", "namespace2")
+ .addFilterNamespaces(ImmutableList.of("namespace3"))
+ .addFilterSchemas("schemaTypes1", "schemaTypes2")
+ .addFilterSchemas(ImmutableList.of("schemaTypes3"))
+ .addFilterPackageNames("package1", "package2")
+ .addFilterPackageNames(ImmutableList.of("package3"))
+ .setSnippetCount(5)
+ .setSnippetCountPerProperty(10)
+ .setMaxSnippetSize(15)
+ .setResultCountPerPage(42)
+ .setOrder(SearchSpec.ORDER_ASCENDING)
+ .setRankingStrategy(SearchSpec.RANKING_STRATEGY_RELEVANCE_SCORE)
+ .setResultGrouping(SearchSpec.GROUPING_TYPE_PER_NAMESPACE
+ | SearchSpec.GROUPING_TYPE_PER_PACKAGE, /*limit=*/ 37)
+ .addProjection("schemaTypes1", expectedPropertyPaths1)
+ .addProjection("schemaTypes2", expectedPropertyPaths2)
+ .setPropertyWeights("schemaTypes1", expectedPropertyWeights)
+ .setPropertyWeightPaths("schemaTypes2", expectedPropertyWeightPaths)
+ .setNumericSearchEnabled(true)
+ .setVerbatimSearchEnabled(true)
+ .setListFilterQueryLanguageEnabled(true)
.setScorablePropertyRankingEnabled(true)
.build();
@@ -940,6 +1012,74 @@
.setNumericSearchEnabled(true)
.setVerbatimSearchEnabled(true)
.setListFilterQueryLanguageEnabled(true)
+ .build();
+ SearchSpec searchSpecCopy = new SearchSpec.Builder(searchSpec).build();
+ assertThat(searchSpecCopy.getTermMatch()).isEqualTo(searchSpec.getTermMatch());
+ assertThat(searchSpecCopy.getFilterNamespaces()).isEqualTo(
+ searchSpec.getFilterNamespaces());
+ assertThat(searchSpecCopy.getFilterSchemas()).isEqualTo(searchSpec.getFilterSchemas());
+ assertThat(searchSpecCopy.getFilterPackageNames()).isEqualTo(
+ searchSpec.getFilterPackageNames());
+ assertThat(searchSpecCopy.getSnippetCount()).isEqualTo(searchSpec.getSnippetCount());
+ assertThat(searchSpecCopy.getSnippetCountPerProperty()).isEqualTo(
+ searchSpec.getSnippetCountPerProperty());
+ assertThat(searchSpecCopy.getMaxSnippetSize()).isEqualTo(searchSpec.getMaxSnippetSize());
+ assertThat(searchSpecCopy.getResultCountPerPage()).isEqualTo(
+ searchSpec.getResultCountPerPage());
+ assertThat(searchSpecCopy.getOrder()).isEqualTo(searchSpec.getOrder());
+ assertThat(searchSpecCopy.getRankingStrategy()).isEqualTo(searchSpec.getRankingStrategy());
+ assertThat(searchSpecCopy.getResultGroupingTypeFlags()).isEqualTo(
+ searchSpec.getResultGroupingTypeFlags());
+ assertThat(searchSpecCopy.getProjections()).isEqualTo(searchSpec.getProjections());
+ assertThat(searchSpecCopy.getResultGroupingLimit()).isEqualTo(
+ searchSpec.getResultGroupingLimit());
+ assertThat(searchSpecCopy.getPropertyWeights()).isEqualTo(searchSpec.getPropertyWeights());
+ assertThat(searchSpecCopy.getPropertyWeightPaths()).isEqualTo(
+ searchSpec.getPropertyWeightPaths());
+ assertThat(searchSpecCopy.isNumericSearchEnabled()).isEqualTo(
+ searchSpec.isNumericSearchEnabled());
+ assertThat(searchSpecCopy.isVerbatimSearchEnabled()).isEqualTo(
+ searchSpec.isVerbatimSearchEnabled());
+ assertThat(searchSpecCopy.isListFilterQueryLanguageEnabled()).isEqualTo(
+ searchSpec.isListFilterQueryLanguageEnabled());
+ }
+
+ @Test
+ @RequiresFlagsEnabled({
+ Flags.FLAG_ENABLE_ADDITIONAL_BUILDER_COPY_CONSTRUCTORS,
+ Flags.FLAG_ENABLE_SCORABLE_PROPERTY
+ })
+ public void testSearchSpecBuilder_copyConstructorWithScorableProperty() {
+ List<String> expectedPropertyPaths1 = ImmutableList.of("path1", "path2");
+ List<String> expectedPropertyPaths2 = ImmutableList.of("path3", "path4");
+ Map<String, Double> expectedPropertyWeights = ImmutableMap.of("property1", 1.0,
+ "property2", 2.0);
+ Map<PropertyPath, Double> expectedPropertyWeightPaths =
+ ImmutableMap.of(new PropertyPath("property1.nested"), 1.0);
+
+ SearchSpec searchSpec = new SearchSpec.Builder()
+ .setTermMatch(SearchSpec.TERM_MATCH_PREFIX)
+ .addFilterNamespaces("namespace1", "namespace2")
+ .addFilterNamespaces(ImmutableList.of("namespace3"))
+ .addFilterSchemas("schemaTypes1", "schemaTypes2")
+ .addFilterSchemas(ImmutableList.of("schemaTypes3"))
+ .addFilterPackageNames("package1", "package2")
+ .addFilterPackageNames(ImmutableList.of("package3"))
+ .setSnippetCount(5)
+ .setSnippetCountPerProperty(10)
+ .setMaxSnippetSize(15)
+ .setResultCountPerPage(42)
+ .setOrder(SearchSpec.ORDER_ASCENDING)
+ .setRankingStrategy(SearchSpec.RANKING_STRATEGY_RELEVANCE_SCORE)
+ .setResultGrouping(SearchSpec.GROUPING_TYPE_PER_NAMESPACE
+ | SearchSpec.GROUPING_TYPE_PER_PACKAGE, /*limit=*/ 37)
+ .addProjection("schemaTypes1", expectedPropertyPaths1)
+ .addProjection("schemaTypes2", expectedPropertyPaths2)
+ .setPropertyWeights("schemaTypes1", expectedPropertyWeights)
+ .setPropertyWeightPaths("schemaTypes2", expectedPropertyWeightPaths)
+ .setNumericSearchEnabled(true)
+ .setVerbatimSearchEnabled(true)
+ .setListFilterQueryLanguageEnabled(true)
.setScorablePropertyRankingEnabled(true)
.build();
SearchSpec searchSpecCopy = new SearchSpec.Builder(searchSpec).build();
@@ -1121,6 +1261,7 @@
assertThat(searchSpec.getFilterDocumentIds()).isEmpty();
}
+ @Test
@RequiresFlagsEnabled(Flags.FLAG_ENABLE_SCORABLE_PROPERTY)
public void testSetAndGetEnableScorablePropertyRanking() {
SearchSpec defaultSearchSpec = new SearchSpec.Builder().build();
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/SetSchemaRequestCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/SetSchemaRequestCtsTest.java
index 315b037..2151dd7 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/SetSchemaRequestCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/SetSchemaRequestCtsTest.java
@@ -33,11 +33,11 @@
import androidx.appsearch.app.SchemaVisibilityConfig;
import androidx.appsearch.app.SetSchemaRequest;
import androidx.appsearch.exceptions.AppSearchException;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
import androidx.appsearch.testutil.AppSearchEmail;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import androidx.collection.ArrayMap;
import com.google.common.collect.ImmutableSet;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/NegationNodeCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/NegationNodeCtsTest.java
index 0ed9372..40c4d19 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/NegationNodeCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/NegationNodeCtsTest.java
@@ -23,10 +23,10 @@
import androidx.appsearch.ast.NegationNode;
import androidx.appsearch.ast.Node;
import androidx.appsearch.ast.TextNode;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Rule;
import org.junit.Test;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/TextNodeCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/TextNodeCtsTest.java
index 574a49f..d7335e4 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/TextNodeCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/TextNodeCtsTest.java
@@ -21,10 +21,10 @@
import static org.junit.Assert.assertThrows;
import androidx.appsearch.ast.TextNode;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Rule;
import org.junit.Test;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/operators/AndNodeCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/operators/AndNodeCtsTest.java
index c61a6fe..122ecb2 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/operators/AndNodeCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/operators/AndNodeCtsTest.java
@@ -25,10 +25,10 @@
import androidx.appsearch.ast.TextNode;
import androidx.appsearch.ast.operators.AndNode;
import androidx.appsearch.ast.operators.OrNode;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Rule;
import org.junit.Test;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/operators/ComparatorNodeCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/operators/ComparatorNodeCtsTest.java
index 5c2d32c..f4a8480 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/operators/ComparatorNodeCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/operators/ComparatorNodeCtsTest.java
@@ -22,10 +22,10 @@
import androidx.appsearch.app.PropertyPath;
import androidx.appsearch.ast.operators.ComparatorNode;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Rule;
import org.junit.Test;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/operators/OrNodeCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/operators/OrNodeCtsTest.java
index 574134e..0cfbc0b 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/operators/OrNodeCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/operators/OrNodeCtsTest.java
@@ -25,10 +25,10 @@
import androidx.appsearch.ast.TextNode;
import androidx.appsearch.ast.operators.AndNode;
import androidx.appsearch.ast.operators.OrNode;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Rule;
import org.junit.Test;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/operators/PropertyRestrictNodeTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/operators/PropertyRestrictNodeTest.java
index 806e317..1e3fc4e 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/operators/PropertyRestrictNodeTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/operators/PropertyRestrictNodeTest.java
@@ -24,10 +24,10 @@
import androidx.appsearch.ast.Node;
import androidx.appsearch.ast.TextNode;
import androidx.appsearch.ast.operators.PropertyRestrictNode;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Rule;
import org.junit.Test;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/GetSearchStringParameterNodeCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/GetSearchStringParameterNodeCtsTest.java
index 3628fe2..b564377 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/GetSearchStringParameterNodeCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/GetSearchStringParameterNodeCtsTest.java
@@ -21,10 +21,10 @@
import static org.junit.Assert.assertThrows;
import androidx.appsearch.ast.query.GetSearchStringParameterNode;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Rule;
import org.junit.Test;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/HasPropertyNodeCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/HasPropertyNodeCtsTest.java
index 345081f..4d77b00 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/HasPropertyNodeCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/HasPropertyNodeCtsTest.java
@@ -22,10 +22,10 @@
import androidx.appsearch.app.PropertyPath;
import androidx.appsearch.ast.query.HasPropertyNode;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Rule;
import org.junit.Test;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/PropertyDefinedNodeCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/PropertyDefinedNodeCtsTest.java
index a4cd6ba..1b7901f 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/PropertyDefinedNodeCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/PropertyDefinedNodeCtsTest.java
@@ -22,10 +22,10 @@
import androidx.appsearch.app.PropertyPath;
import androidx.appsearch.ast.query.PropertyDefinedNode;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Rule;
import org.junit.Test;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/SearchNodeCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/SearchNodeCtsTest.java
index 041af4e..14559e6 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/SearchNodeCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/SearchNodeCtsTest.java
@@ -24,10 +24,10 @@
import androidx.appsearch.ast.Node;
import androidx.appsearch.ast.TextNode;
import androidx.appsearch.ast.query.SearchNode;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Rule;
import org.junit.Test;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/SemanticSearchNodeCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/SemanticSearchNodeCtsTest.java
index b76f036..c532d57 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/SemanticSearchNodeCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/query/SemanticSearchNodeCtsTest.java
@@ -22,10 +22,10 @@
import androidx.appsearch.app.SearchSpec;
import androidx.appsearch.ast.query.SemanticSearchNode;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Rule;
import org.junit.Test;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/searchtest/AbstractSyntaxTreeSearchCtsTestBase.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/searchtest/AbstractSyntaxTreeSearchCtsTestBase.java
index 8fb2cd9..1eead7f 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/searchtest/AbstractSyntaxTreeSearchCtsTestBase.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/searchtest/AbstractSyntaxTreeSearchCtsTestBase.java
@@ -48,11 +48,11 @@
import androidx.appsearch.ast.query.PropertyDefinedNode;
import androidx.appsearch.ast.query.SearchNode;
import androidx.appsearch.ast.query.SemanticSearchNode;
-import androidx.appsearch.flags.CheckFlagsRule;
-import androidx.appsearch.flags.DeviceFlagsValueProvider;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
import androidx.appsearch.testutil.AppSearchEmail;
+import androidx.appsearch.testutil.flags.CheckFlagsRule;
+import androidx.appsearch.testutil.flags.DeviceFlagsValueProvider;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import com.google.common.util.concurrent.ListenableFuture;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/searchtest/AbstractSyntaxTreeSearchLocalCtsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/searchtest/AbstractSyntaxTreeSearchLocalCtsTest.java
index d7620a2..88775a7 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/searchtest/AbstractSyntaxTreeSearchLocalCtsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/ast/searchtest/AbstractSyntaxTreeSearchLocalCtsTest.java
@@ -22,8 +22,8 @@
import androidx.annotation.NonNull;
import androidx.appsearch.app.AppSearchSession;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
import androidx.appsearch.localstorage.LocalStorage;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import androidx.test.core.app.ApplicationProvider;
import com.google.common.util.concurrent.ListenableFuture;
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/flags/FlagsTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/flags/FlagsTest.java
index 6c7023a..bd8d8ac 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/flags/FlagsTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/flags/FlagsTest.java
@@ -35,8 +35,10 @@
@Test
public void testFlagValue_enableListFilterMatchScoreExpressionFunction() {
- assertThat(Flags.FLAG_ENABLE_LIST_FILTER_MATCH_SCORE_EXPRESSION_FUNCTION).isEqualTo(
- "com.android.appsearch.flags.enable_list_filter_match_score_expression_function");
+ assertThat(Flags.FLAG_ENABLE_LIST_FILTER_MATCH_SCORE_EXPRESSION_FUNCTION)
+ .isEqualTo(
+ "com.android.appsearch"
+ + ".flags.enable_list_filter_match_score_expression_function");
}
@Test
diff --git a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/safeparcel/GenericDocumentParcelTest.java b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/safeparcel/GenericDocumentParcelTest.java
index 0a463e9..c6e1304 100644
--- a/appsearch/appsearch/src/androidTest/java/androidx/appsearch/safeparcel/GenericDocumentParcelTest.java
+++ b/appsearch/appsearch/src/androidTest/java/androidx/appsearch/safeparcel/GenericDocumentParcelTest.java
@@ -28,7 +28,7 @@
import androidx.appsearch.app.AppSearchBlobHandle;
import androidx.appsearch.app.EmbeddingVector;
import androidx.appsearch.flags.Flags;
-import androidx.appsearch.flags.RequiresFlagsEnabled;
+import androidx.appsearch.testutil.flags.RequiresFlagsEnabled;
import org.junit.Test;
diff --git a/appsearch/appsearch/src/main/java/androidx/appsearch/app/AppSearchSchema.java b/appsearch/appsearch/src/main/java/androidx/appsearch/app/AppSearchSchema.java
index faa351d..e5860c7 100644
--- a/appsearch/appsearch/src/main/java/androidx/appsearch/app/AppSearchSchema.java
+++ b/appsearch/appsearch/src/main/java/androidx/appsearch/app/AppSearchSchema.java
@@ -872,6 +872,51 @@
name = Features.JOIN_SPEC_AND_QUALIFIED_ID)
public static final int JOINABLE_VALUE_TYPE_QUALIFIED_ID = 1;
+ /**
+ * The delete propagation type of the property. By setting the delete propagation type for a
+ * property, the client can propagate deletion between the document and the referenced
+ * document. The propagation direction is determined by the delete propagation type.
+ *
+ * @exportToFramework:hide
+ */
+ // NOTE: The integer values of these constants must match the proto enum constants in
+ // com.google.android.icing.proto.JoinableConfig.DeletePropagationType.Code.
+ @IntDef(value = {
+ DELETE_PROPAGATION_TYPE_NONE,
+ DELETE_PROPAGATION_TYPE_PROPAGATE_FROM,
+ })
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ @Retention(RetentionPolicy.SOURCE)
+ @ExperimentalAppSearchApi
+ public @interface DeletePropagationType {
+ }
+
+ /** Does not propagate deletion. */
+ @ExperimentalAppSearchApi
+ public static final int DELETE_PROPAGATION_TYPE_NONE = 0;
+
+ /**
+ * Content in this string property will be used as a qualified id referring to another
+ * (parent) document, and the deletion of the referenced document will propagate to this
+ * (child) document.
+ *
+ * <p>Please note that this propagates further. If the child document has any children that
+ * also set delete propagation type PROPAGATE_FROM for their joinable properties, then those
+ * (grandchild) documents will be deleted.
+ *
+ * <p>Since delete propagation works between the document and the referenced document, if
+ * setting this type for delete propagation, the string property should also be qualified id
+ * joinable (i.e. having {@link StringPropertyConfig#JOINABLE_VALUE_TYPE_QUALIFIED_ID} for
+ * the joinable value type). Otherwise, throw {@link IllegalStateException} when building
+ * (see {@link StringPropertyConfig.Builder#build}).
+ */
+ @RequiresFeature(
+ enforcement = "androidx.appsearch.app.Features#isFeatureSupported",
+ name = Features
+ .SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM)
+ @ExperimentalAppSearchApi
+ public static final int DELETE_PROPAGATION_TYPE_PROPAGATE_FROM = 1;
+
StringPropertyConfig(@NonNull PropertyConfigParcel propertyConfigParcel) {
super(propertyConfigParcel);
}
@@ -914,7 +959,25 @@
return joinableConfigParcel.getJoinableValueType();
}
+ /**
+ * Returns how the deletion will be propagated between this document and the referenced
+ * document whose qualified id is held by this property.
+ */
+ @FlaggedApi(Flags.FLAG_ENABLE_DELETE_PROPAGATION_TYPE)
+ @ExperimentalAppSearchApi
+ @DeletePropagationType
+ public int getDeletePropagationType() {
+ JoinableConfigParcel joinableConfigParcel = mPropertyConfigParcel
+ .getJoinableConfigParcel();
+ if (joinableConfigParcel == null) {
+ return DELETE_PROPAGATION_TYPE_NONE;
+ }
+
+ return joinableConfigParcel.getDeletePropagationType();
+ }
+
/** Builder for {@link StringPropertyConfig}. */
+ @OptIn(markerClass = ExperimentalAppSearchApi.class)
public static final class Builder {
private final String mPropertyName;
private String mDescription = "";
@@ -926,7 +989,8 @@
private int mTokenizerType = TOKENIZER_TYPE_NONE;
@JoinableValueType
private int mJoinableValueType = JOINABLE_VALUE_TYPE_NONE;
- private boolean mDeletionPropagation = false;
+ @DeletePropagationType
+ private int mDeletePropagationType = DELETE_PROPAGATION_TYPE_NONE;
/** Creates a new {@link StringPropertyConfig.Builder}. */
public Builder(@NonNull String propertyName) {
@@ -1027,7 +1091,53 @@
}
/**
+ * Configures how the deletion will be propagated between this document and the
+ * referenced document whose qualified id is held by this property.
+ *
+ * <p>If this method is not called, the default delete propagation type is
+ * {@link StringPropertyConfig#DELETE_PROPAGATION_TYPE_NONE}, indicating that deletion
+ * will not propagate between this document and the referenced document.
+ *
+ * <p>If the delete propagation type is not
+ * {@link StringPropertyConfig#DELETE_PROPAGATION_TYPE_NONE}, then
+ * {@link StringPropertyConfig#JOINABLE_VALUE_TYPE_QUALIFIED_ID} must also be set since
+ * the delete propagation has to use the qualified id. Otherwise, throw
+ * {@link IllegalStateException} when building.
+ */
+ @CanIgnoreReturnValue
+ @RequiresFeature(
+ enforcement = "androidx.appsearch.app.Features#isFeatureSupported",
+ name = Features
+ .SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM)
+ @FlaggedApi(Flags.FLAG_ENABLE_DELETE_PROPAGATION_TYPE)
+ @ExperimentalAppSearchApi
+ @NonNull
+ public StringPropertyConfig.Builder setDeletePropagationType(
+ @DeletePropagationType int deletePropagationType) {
+ Preconditions.checkArgumentInRange(
+ deletePropagationType,
+ DELETE_PROPAGATION_TYPE_NONE,
+ DELETE_PROPAGATION_TYPE_PROPAGATE_FROM,
+ "deletePropagationType");
+ mDeletePropagationType = deletePropagationType;
+ return this;
+ }
+
+ /**
* Constructs a new {@link StringPropertyConfig} from the contents of this builder.
+ *
+ * @throws IllegalStateException if any following condition:
+ * <ul>
+ * <li>Tokenizer type is not {@link StringPropertyConfig#TOKENIZER_TYPE_NONE} with
+ * indexing type {@link StringPropertyConfig#INDEXING_TYPE_NONE}.
+ * <li>Indexing type is not {@link StringPropertyConfig#INDEXING_TYPE_NONE} with
+ * tokenizer type {@link StringPropertyConfig#TOKENIZER_TYPE_NONE}.
+ * <li>{@link StringPropertyConfig#JOINABLE_VALUE_TYPE_QUALIFIED_ID} is set to a
+ * {@link PropertyConfig#CARDINALITY_REPEATED} property.
+ * <li>Deletion type other than
+ * {@link StringPropertyConfig#DELETE_PROPAGATION_TYPE_NONE} is used without setting
+ * {@link StringPropertyConfig#JOINABLE_VALUE_TYPE_QUALIFIED_ID}.
+ * </ul>
*/
@NonNull
public StringPropertyConfig build() {
@@ -1042,14 +1152,16 @@
if (mJoinableValueType == JOINABLE_VALUE_TYPE_QUALIFIED_ID) {
Preconditions.checkState(mCardinality != CARDINALITY_REPEATED, "Cannot set "
+ "JOINABLE_VALUE_TYPE_QUALIFIED_ID with CARDINALITY_REPEATED.");
- } else {
- Preconditions.checkState(!mDeletionPropagation, "Cannot set deletion "
- + "propagation without setting a joinable value type");
+ }
+ if (mDeletePropagationType != DELETE_PROPAGATION_TYPE_NONE) {
+ Preconditions.checkState(mJoinableValueType == JOINABLE_VALUE_TYPE_QUALIFIED_ID,
+ "Cannot set delete propagation without setting "
+ + "JOINABLE_VALUE_TYPE_QUALIFIED_ID.");
}
PropertyConfigParcel.StringIndexingConfigParcel stringConfigParcel =
new StringIndexingConfigParcel(mIndexingType, mTokenizerType);
JoinableConfigParcel joinableConfigParcel =
- new JoinableConfigParcel(mJoinableValueType, mDeletionPropagation);
+ new JoinableConfigParcel(mJoinableValueType, mDeletePropagationType);
return new StringPropertyConfig(
PropertyConfigParcel.createForString(
mPropertyName,
@@ -1068,6 +1180,7 @@
*
* @param builder the builder to append to.
*/
+ @OptIn(markerClass = ExperimentalAppSearchApi.class)
void appendStringPropertyConfigFields(@NonNull IndentingStringBuilder builder) {
switch (getIndexingType()) {
case AppSearchSchema.StringPropertyConfig.INDEXING_TYPE_NONE:
@@ -1110,6 +1223,18 @@
default:
builder.append("joinableValueType: JOINABLE_VALUE_TYPE_UNKNOWN,\n");
}
+
+ switch (getDeletePropagationType()) {
+ case StringPropertyConfig.DELETE_PROPAGATION_TYPE_NONE:
+ builder.append("deletePropagationType: DELETE_PROPAGATION_TYPE_NONE,\n");
+ break;
+ case StringPropertyConfig.DELETE_PROPAGATION_TYPE_PROPAGATE_FROM:
+ builder.append(
+ "deletePropagationType: DELETE_PROPAGATION_TYPE_PROPAGATE_FROM,\n");
+ break;
+ default:
+ builder.append("deletePropagationType: DELETE_PROPAGATION_TYPE_UNKNOWN,\n");
+ }
}
}
@@ -1463,9 +1588,8 @@
@ExperimentalAppSearchApi
@FlaggedApi(Flags.FLAG_ENABLE_SCORABLE_PROPERTY)
@NonNull
- public BooleanPropertyConfig.Builder setScoringEnabled(
- boolean ScoringEnabled) {
- mScoringEnabled = ScoringEnabled;
+ public BooleanPropertyConfig.Builder setScoringEnabled(boolean scoringEnabled) {
+ mScoringEnabled = scoringEnabled;
return this;
}
diff --git a/appsearch/appsearch/src/main/java/androidx/appsearch/app/AppSearchSession.java b/appsearch/appsearch/src/main/java/androidx/appsearch/app/AppSearchSession.java
index b9fe4d4..a28a3a5 100644
--- a/appsearch/appsearch/src/main/java/androidx/appsearch/app/AppSearchSession.java
+++ b/appsearch/appsearch/src/main/java/androidx/appsearch/app/AppSearchSession.java
@@ -176,6 +176,11 @@
* {@link AppSearchResult} with error code {@link AppSearchResult#RESULT_ALREADY_EXISTS} will be
* associated with the {@link AppSearchBlobHandle}.
*
+ * <p>If the blob content doesn't match the digest in {@link AppSearchBlobHandle}, a failed
+ * {@link AppSearchResult} with error code {@link AppSearchResult#RESULT_INVALID_ARGUMENT} will
+ * be associated with the {@link AppSearchBlobHandle}. The pending Blob file will be removed
+ * from AppSearch.
+ *
* <p> Pending blobs won't be lost or auto-commit if {@link AppSearchSession} closed.
* Pending blobs will store in disk rather than memory. You can re-open {@link AppSearchSession}
* and re-write the pending blobs.
diff --git a/appsearch/appsearch/src/main/java/androidx/appsearch/app/CommitBlobResponse.java b/appsearch/appsearch/src/main/java/androidx/appsearch/app/CommitBlobResponse.java
index d363476..a95508f 100644
--- a/appsearch/appsearch/src/main/java/androidx/appsearch/app/CommitBlobResponse.java
+++ b/appsearch/appsearch/src/main/java/androidx/appsearch/app/CommitBlobResponse.java
@@ -20,7 +20,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
-import androidx.appsearch.app.aidl.AppSearchBatchResultGeneralKeyParcel;
+import androidx.appsearch.app.aidl.AppSearchBatchResultParcelV2;
import androidx.appsearch.flags.FlaggedApi;
import androidx.appsearch.flags.Flags;
import androidx.appsearch.safeparcel.AbstractSafeParcelable;
@@ -46,19 +46,19 @@
new CommitBlobResponseCreator();
@Field(id = 1, getter = "getResponseParcel")
- private final AppSearchBatchResultGeneralKeyParcel<AppSearchBlobHandle, Void> mResultParcel;
+ private final AppSearchBatchResultParcelV2<AppSearchBlobHandle, Void> mResultParcel;
/**
* Creates a {@link CommitBlobResponse} with given {@link AppSearchBatchResult}.
*/
public CommitBlobResponse(
@NonNull AppSearchBatchResult<AppSearchBlobHandle, Void> result) {
- this(AppSearchBatchResultGeneralKeyParcel.fromBlobHandleToVoid(result));
+ this(AppSearchBatchResultParcelV2.fromBlobHandleToVoid(result));
}
@Constructor
CommitBlobResponse(
- @Param(id = 1) @NonNull AppSearchBatchResultGeneralKeyParcel<AppSearchBlobHandle, Void>
+ @Param(id = 1) @NonNull AppSearchBatchResultParcelV2<AppSearchBlobHandle, Void>
resultParcel) {
mResultParcel = Preconditions.checkNotNull(resultParcel);
}
@@ -83,7 +83,7 @@
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@NonNull
- public AppSearchBatchResultGeneralKeyParcel<AppSearchBlobHandle, Void> getResponseParcel() {
+ public AppSearchBatchResultParcelV2<AppSearchBlobHandle, Void> getResponseParcel() {
return mResultParcel;
}
diff --git a/appsearch/appsearch/src/main/java/androidx/appsearch/app/Features.java b/appsearch/appsearch/src/main/java/androidx/appsearch/app/Features.java
index 0777ac6..7f6c575 100644
--- a/appsearch/appsearch/src/main/java/androidx/appsearch/app/Features.java
+++ b/appsearch/appsearch/src/main/java/androidx/appsearch/app/Features.java
@@ -127,6 +127,7 @@
* <p>For details on the "matchScoreExpression" function in the query language, see
* {@link AppSearchSession#search}.
*/
+ @ExperimentalAppSearchApi
String LIST_FILTER_MATCH_SCORE_EXPRESSION_FUNCTION =
FeatureConstants.LIST_FILTER_MATCH_SCORE_EXPRESSION_FUNCTION;
@@ -289,6 +290,15 @@
String SEARCH_RESULT_PARENT_TYPES = "SEARCH_RESULT_PARENT_TYPES";
/**
+ * Feature for {@link #isFeatureSupported(String)}. This feature covers
+ * {@link AppSearchSchema.StringPropertyConfig#DELETE_PROPAGATION_TYPE_PROPAGATE_FROM} and
+ * {@link AppSearchSchema.StringPropertyConfig.Builder#setDeletePropagationType}.
+ */
+ @ExperimentalAppSearchApi
+ String SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM =
+ "SCHEMA_STRING_PROPERTY_CONFIG_DELETE_PROPAGATION_TYPE_PROPAGATE_FROM";
+
+ /**
* Returns whether a feature is supported at run-time. Feature support depends on the
* feature in question, the AppSearch backend being used and the Android version of the
* device.
diff --git a/appsearch/appsearch/src/main/java/androidx/appsearch/app/OpenBlobForReadResponse.java b/appsearch/appsearch/src/main/java/androidx/appsearch/app/OpenBlobForReadResponse.java
index 95bbdad..3bf2cd9 100644
--- a/appsearch/appsearch/src/main/java/androidx/appsearch/app/OpenBlobForReadResponse.java
+++ b/appsearch/appsearch/src/main/java/androidx/appsearch/app/OpenBlobForReadResponse.java
@@ -20,7 +20,7 @@
import android.os.Parcelable;
import androidx.annotation.NonNull;
-import androidx.appsearch.app.aidl.AppSearchBatchResultGeneralKeyParcel;
+import androidx.appsearch.app.aidl.AppSearchBatchResultParcelV2;
import androidx.appsearch.flags.FlaggedApi;
import androidx.appsearch.flags.Flags;
import androidx.appsearch.safeparcel.AbstractSafeParcelable;
@@ -56,7 +56,7 @@
new OpenBlobForReadResponseCreator();
@Field(id = 1)
- final AppSearchBatchResultGeneralKeyParcel<AppSearchBlobHandle, ParcelFileDescriptor>
+ final AppSearchBatchResultParcelV2<AppSearchBlobHandle, ParcelFileDescriptor>
mResultParcel;
/**
@@ -64,13 +64,13 @@
*/
public OpenBlobForReadResponse(
@NonNull AppSearchBatchResult<AppSearchBlobHandle, ParcelFileDescriptor> result) {
- this(AppSearchBatchResultGeneralKeyParcel.fromBlobHandleToPfd(result));
+ this(AppSearchBatchResultParcelV2.fromBlobHandleToPfd(result));
}
@Constructor
OpenBlobForReadResponse(
@AbstractSafeParcelable.Param(id = 1)
- @NonNull AppSearchBatchResultGeneralKeyParcel<AppSearchBlobHandle, ParcelFileDescriptor>
+ @NonNull AppSearchBatchResultParcelV2<AppSearchBlobHandle, ParcelFileDescriptor>
resultParcel) {
mResultParcel = Preconditions.checkNotNull(resultParcel);
}
diff --git a/appsearch/appsearch/src/main/java/androidx/appsearch/app/OpenBlobForWriteResponse.java b/appsearch/appsearch/src/main/java/androidx/appsearch/app/OpenBlobForWriteResponse.java
index 1ee1b0a..935e473 100644
--- a/appsearch/appsearch/src/main/java/androidx/appsearch/app/OpenBlobForWriteResponse.java
+++ b/appsearch/appsearch/src/main/java/androidx/appsearch/app/OpenBlobForWriteResponse.java
@@ -20,7 +20,7 @@
import android.os.Parcelable;
import androidx.annotation.NonNull;
-import androidx.appsearch.app.aidl.AppSearchBatchResultGeneralKeyParcel;
+import androidx.appsearch.app.aidl.AppSearchBatchResultParcelV2;
import androidx.appsearch.flags.FlaggedApi;
import androidx.appsearch.flags.Flags;
import androidx.appsearch.safeparcel.AbstractSafeParcelable;
@@ -56,7 +56,7 @@
new OpenBlobForWriteResponseCreator();
@Field(id = 1)
- final AppSearchBatchResultGeneralKeyParcel<AppSearchBlobHandle, ParcelFileDescriptor>
+ final AppSearchBatchResultParcelV2<AppSearchBlobHandle, ParcelFileDescriptor>
mResultParcel;
/**
@@ -64,13 +64,13 @@
*/
public OpenBlobForWriteResponse(
@NonNull AppSearchBatchResult<AppSearchBlobHandle, ParcelFileDescriptor> result) {
- this(AppSearchBatchResultGeneralKeyParcel.fromBlobHandleToPfd(result));
+ this(AppSearchBatchResultParcelV2.fromBlobHandleToPfd(result));
}
@Constructor
OpenBlobForWriteResponse(
@AbstractSafeParcelable.Param(id = 1)
- @NonNull AppSearchBatchResultGeneralKeyParcel<AppSearchBlobHandle, ParcelFileDescriptor>
+ @NonNull AppSearchBatchResultParcelV2<AppSearchBlobHandle, ParcelFileDescriptor>
resultParcel) {
mResultParcel = Preconditions.checkNotNull(resultParcel);
}
diff --git a/appsearch/appsearch/src/main/java/androidx/appsearch/app/SearchResult.java b/appsearch/appsearch/src/main/java/androidx/appsearch/app/SearchResult.java
index 736b84e..c2f447f5 100644
--- a/appsearch/appsearch/src/main/java/androidx/appsearch/app/SearchResult.java
+++ b/appsearch/appsearch/src/main/java/androidx/appsearch/app/SearchResult.java
@@ -95,8 +95,8 @@
* <p>All schema names in this map are un-prefixed, for both keys and values.
*/
@NonNull
- @Field(id = 8, getter = "getParentTypeMap")
- private final Bundle mParentTypeMap;
+ @Field(id = 8)
+ final Bundle mParentTypeMap;
/** Cache of the {@link GenericDocument}. Comes from mDocument at first use. */
@@ -454,14 +454,18 @@
* <p>The map should include entries for the {@link GenericDocument}'s own type and all
* of the nested documents' types.
*
- * <p>Child types must appear before parent types in each list. Otherwise, the
* <!--@exportToFramework:ifJetpack()-->
- * {@link GenericDocument#toDocumentClass(java.lang.Class, DocumentClassMappingContext)}
- * <!--@exportToFramework:else()
- * GenericDocument's toDocumentClass
- * -->
+ * <p>Child types must appear before parent types in each list. Otherwise, the
+ * {@link GenericDocument#toDocumentClass(java.lang.Class, DocumentClassMappingContext)}
* method may not correctly identify the most concrete type. This could lead to unintended
* deserialization into a more general type instead of a more specific type.
+ * <!--@exportToFramework:else()
+ * <p>Child types must appear before parent types in each list. Otherwise, the
+ * GenericDocument's toDocumentClass method (an AndroidX-only API) may not correctly
+ * identify the most concrete type. This could lead to unintended deserialization into a
+ * more general type instead of a
+ * more specific type.
+ * -->
*
* <p>Parent types should include transitive parents.
*/
diff --git a/appsearch/appsearch/src/main/java/androidx/appsearch/app/aidl/AppSearchBatchResultGeneralKeyParcel.java b/appsearch/appsearch/src/main/java/androidx/appsearch/app/aidl/AppSearchBatchResultParcelV2.java
similarity index 74%
rename from appsearch/appsearch/src/main/java/androidx/appsearch/app/aidl/AppSearchBatchResultGeneralKeyParcel.java
rename to appsearch/appsearch/src/main/java/androidx/appsearch/app/aidl/AppSearchBatchResultParcelV2.java
index 238f9c7..980aae7 100644
--- a/appsearch/appsearch/src/main/java/androidx/appsearch/app/aidl/AppSearchBatchResultGeneralKeyParcel.java
+++ b/appsearch/appsearch/src/main/java/androidx/appsearch/app/aidl/AppSearchBatchResultParcelV2.java
@@ -26,40 +26,40 @@
import androidx.core.util.Preconditions;
/**
- * A dummy version of AppSearchBatchResultGeneralKeyParcel in jetpack.
+ * A dummy version of AppSearchBatchResultParcelV2 in jetpack.
* @param <KeyType> The type of keys in the batch result, such as {@link AppSearchBlobHandle}.
* @param <ValueType> The type of values in the batch result, such as {@link ParcelFileDescriptor}
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@ExperimentalAppSearchApi
-public final class AppSearchBatchResultGeneralKeyParcel<KeyType, ValueType> {
+public final class AppSearchBatchResultParcelV2<KeyType, ValueType> {
private final AppSearchBatchResult<KeyType, ValueType> mResult;
- private AppSearchBatchResultGeneralKeyParcel(
+ private AppSearchBatchResultParcelV2(
@NonNull AppSearchBatchResult<KeyType, ValueType> result) {
mResult = Preconditions.checkNotNull(result);
}
/**
- * Creates an instance of {@link AppSearchBatchResultGeneralKeyParcel} with key type
+ * Creates an instance of {@link AppSearchBatchResultParcelV2} with key type
* {@link AppSearchBlobHandle} and value type {@link ParcelFileDescriptor}.
*/
@NonNull
- public static AppSearchBatchResultGeneralKeyParcel<AppSearchBlobHandle, ParcelFileDescriptor>
+ public static AppSearchBatchResultParcelV2<AppSearchBlobHandle, ParcelFileDescriptor>
fromBlobHandleToPfd(
@NonNull AppSearchBatchResult<AppSearchBlobHandle, ParcelFileDescriptor> result) {
- return new AppSearchBatchResultGeneralKeyParcel<>(result);
+ return new AppSearchBatchResultParcelV2<>(result);
}
/**
- * Creates an instance of {@link AppSearchBatchResultGeneralKeyParcel} with key type
+ * Creates an instance of {@link AppSearchBatchResultParcelV2} with key type
* {@link AppSearchBlobHandle} and value type {@link Void}.
*/
@NonNull
- public static AppSearchBatchResultGeneralKeyParcel<AppSearchBlobHandle, Void>
+ public static AppSearchBatchResultParcelV2<AppSearchBlobHandle, Void>
fromBlobHandleToVoid(
@NonNull AppSearchBatchResult<AppSearchBlobHandle, Void> result) {
- return new AppSearchBatchResultGeneralKeyParcel<>(result);
+ return new AppSearchBatchResultParcelV2<>(result);
}
/** Returns the wrapped batch result. */
diff --git a/appsearch/appsearch/src/main/java/androidx/appsearch/flags/Flags.java b/appsearch/appsearch/src/main/java/androidx/appsearch/flags/Flags.java
index 8df00e8..57aabaf 100644
--- a/appsearch/appsearch/src/main/java/androidx/appsearch/flags/Flags.java
+++ b/appsearch/appsearch/src/main/java/androidx/appsearch/flags/Flags.java
@@ -190,6 +190,10 @@
public static final String FLAG_ENABLE_SEARCH_RESULT_PARENT_TYPES =
FLAG_PREFIX + "enable_search_result_parent_types";
+ /** Enables delete propagation type related APIs. */
+ public static final String FLAG_ENABLE_DELETE_PROPAGATION_TYPE =
+ FLAG_PREFIX + "enable_delete_propagation_type";
+
// Whether the features should be enabled.
//
// In Jetpack, those should always return true.
@@ -374,4 +378,9 @@
public static boolean enableSearchResultParentTypes() {
return true;
}
+
+ /** Whether delete propagation related APIs should be enabled. */
+ public static boolean enableDeletePropagationType() {
+ return true;
+ }
}
diff --git a/appsearch/appsearch/src/main/java/androidx/appsearch/safeparcel/PropertyConfigParcel.java b/appsearch/appsearch/src/main/java/androidx/appsearch/safeparcel/PropertyConfigParcel.java
index 3ed8d04..4ee703f 100644
--- a/appsearch/appsearch/src/main/java/androidx/appsearch/safeparcel/PropertyConfigParcel.java
+++ b/appsearch/appsearch/src/main/java/androidx/appsearch/safeparcel/PropertyConfigParcel.java
@@ -26,6 +26,7 @@
import androidx.appsearch.app.AppSearchSchema;
import androidx.appsearch.app.AppSearchSchema.PropertyConfig.Cardinality;
import androidx.appsearch.app.AppSearchSchema.PropertyConfig.DataType;
+import androidx.appsearch.app.AppSearchSchema.StringPropertyConfig.DeletePropagationType;
import androidx.appsearch.app.AppSearchSchema.StringPropertyConfig.JoinableValueType;
import androidx.appsearch.app.AppSearchSchema.StringPropertyConfig.TokenizerType;
import androidx.appsearch.app.ExperimentalAppSearchApi;
@@ -387,7 +388,7 @@
mJoinableConfigParcel, otherProperty.mJoinableConfigParcel)
&& ObjectsCompat.equals(
mEmbeddingIndexingConfigParcel, otherProperty.mEmbeddingIndexingConfigParcel)
- && ObjectsCompat.equals(mScoringEnabled, otherProperty.mScoringEnabled);
+ && mScoringEnabled == otherProperty.mScoringEnabled;
}
@Override
@@ -438,16 +439,16 @@
@Field(id = 1, getter = "getJoinableValueType")
private final int mJoinableValueType;
- @Field(id = 2, getter = "getDeletionPropagation")
- private final boolean mDeletionPropagation;
+ @Field(id = 3, getter = "getDeletePropagationType")
+ private final int mDeletePropagationType;
/** Constructor for {@link JoinableConfigParcel}. */
@Constructor
public JoinableConfigParcel(
@Param(id = 1) @JoinableValueType int joinableValueType,
- @Param(id = 2) boolean deletionPropagation) {
+ @Param(id = 3) @DeletePropagationType int deletePropagationType) {
mJoinableValueType = joinableValueType;
- mDeletionPropagation = deletionPropagation;
+ mDeletePropagationType = deletePropagationType;
}
/** Gets {@link JoinableValueType} of the join. */
@@ -456,9 +457,10 @@
return mJoinableValueType;
}
- /** Gets whether delete will be propagated. */
- public boolean getDeletionPropagation() {
- return mDeletionPropagation;
+ /** Gets {@link DeletePropagationType} of the join. */
+ @DeletePropagationType
+ public int getDeletePropagationType() {
+ return mDeletePropagationType;
}
@Override
@@ -468,7 +470,7 @@
@Override
public int hashCode() {
- return ObjectsCompat.hash(mJoinableValueType, mDeletionPropagation);
+ return ObjectsCompat.hash(mJoinableValueType, mDeletePropagationType);
}
@Override
@@ -481,14 +483,14 @@
}
JoinableConfigParcel otherObject = (JoinableConfigParcel) other;
return ObjectsCompat.equals(mJoinableValueType, otherObject.mJoinableValueType)
- && ObjectsCompat.equals(mDeletionPropagation, otherObject.mDeletionPropagation);
+ && mDeletePropagationType == otherObject.mDeletePropagationType;
}
@Override
@NonNull
public String toString() {
return "{joinableValueType: " + mJoinableValueType
- + ", deletePropagation " + mDeletionPropagation + "}";
+ + ", deletePropagationType: " + mDeletePropagationType + "}";
}
}
@@ -547,7 +549,7 @@
return false;
}
StringIndexingConfigParcel otherObject = (StringIndexingConfigParcel) other;
- return ObjectsCompat.equals(mIndexingType, otherObject.mIndexingType)
+ return mIndexingType == otherObject.mIndexingType
&& ObjectsCompat.equals(mTokenizerType, otherObject.mTokenizerType);
}
@@ -555,7 +557,7 @@
@NonNull
public String toString() {
return "{indexingType: " + mIndexingType
- + ", tokenizerType " + mTokenizerType + "}";
+ + ", tokenizerType: " + mTokenizerType + "}";
}
}
@@ -602,7 +604,7 @@
return false;
}
IntegerIndexingConfigParcel otherObject = (IntegerIndexingConfigParcel) other;
- return ObjectsCompat.equals(mIndexingType, otherObject.mIndexingType);
+ return mIndexingType == otherObject.mIndexingType;
}
@Override
@@ -736,8 +738,8 @@
return false;
}
EmbeddingIndexingConfigParcel otherObject = (EmbeddingIndexingConfigParcel) other;
- return ObjectsCompat.equals(mIndexingType, otherObject.mIndexingType)
- && ObjectsCompat.equals(mQuantizationType, otherObject.mQuantizationType);
+ return mIndexingType == otherObject.mIndexingType
+ && mQuantizationType == otherObject.mQuantizationType;
}
@Override
diff --git a/appsearch/exportToFramework.py b/appsearch/exportToFramework.py
index c23398a..eb6423d 100755
--- a/appsearch/exportToFramework.py
+++ b/appsearch/exportToFramework.py
@@ -209,13 +209,13 @@
def _TransformTestCode(self, contents):
contents = (contents
.replace(
- 'androidx.appsearch.flags.CheckFlagsRule',
+ 'androidx.appsearch.testutil.CheckFlagsRule',
'android.platform.test.flag.junit.CheckFlagsRule')
.replace(
- 'androidx.appsearch.flags.DeviceFlagsValueProvider',
+ 'androidx.appsearch.testutil.DeviceFlagsValueProvider',
'android.platform.test.flag.junit.DeviceFlagsValueProvider')
.replace(
- 'androidx.appsearch.flags.RequiresFlagsEnabled',
+ 'androidx.appsearch.testutil.RequiresFlagsEnabled',
'android.platform.test.annotations.RequiresFlagsEnabled')
.replace('androidx.appsearch.testutil.', 'android.app.appsearch.testutil.')
.replace(
diff --git a/benchmark/benchmark-common/lint-baseline.xml b/benchmark/benchmark-common/lint-baseline.xml
deleted file mode 100644
index bed8eb1..0000000
--- a/benchmark/benchmark-common/lint-baseline.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<issues format="6" by="lint 8.8.0-alpha06" type="baseline" client="gradle" dependencies="false" name="AGP (8.8.0-alpha06)" variant="all" version="8.8.0-alpha06">
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; `SDK_INT` is always >= 21"
- errorLine1="@file:RequiresApi(21)"
- errorLine2="~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/benchmark/Api21.kt"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; `SDK_INT` is always >= 21"
- errorLine1="@RequiresApi(21) // needed for shell access"
- errorLine2="~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/benchmark/perfetto/PerfettoConfig.kt"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; `SDK_INT` is always >= 21"
- errorLine1=" if (sampled && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/benchmark/Profiler.kt"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; `SDK_INT` is always >= 21"
- errorLine1="@RequiresApi(21)"
- errorLine2="~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/benchmark/PropOverride.kt"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; `SDK_INT` is always >= 21"
- errorLine1=" if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/benchmark/Shell.kt"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; `SDK_INT` is always >= 21"
- errorLine1=" return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/benchmark/Shell.kt"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; `SDK_INT` is always >= 21"
- errorLine1=" if (Build.VERSION.SDK_INT >= 21) {"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/benchmark/SideEffects.kt"/>
- </issue>
-
- <issue
- id="ObsoleteSdkInt"
- message="Unnecessary; `SDK_INT` is always >= 21"
- errorLine1=" if (Build.VERSION.SDK_INT >= 21) {"
- errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
- <location
- file="src/main/java/androidx/benchmark/SideEffects.kt"/>
- </issue>
-
-</issues>
diff --git a/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/ShellTest.kt b/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/ShellTest.kt
index 15abdf6..1ea94ba 100644
--- a/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/ShellTest.kt
+++ b/benchmark/benchmark-common/src/androidTest/java/androidx/benchmark/ShellTest.kt
@@ -48,31 +48,6 @@
}
}
- @Test
- fun optionalCommand_ls() {
- // command isn't important, it's just something that's not `echo`, and guaranteed to print
- val output = Shell.optionalCommand("ls /sys/devices/system/cpu")
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- assertNotNull(output)
- } else {
- assertNull(output)
- }
- }
-
- @Test
- fun optionalCommand_echo() {
- val output = Shell.optionalCommand("echo foo")
-
- val expected =
- when {
- Build.VERSION.SDK_INT >= 21 -> "foo\n"
- else -> null
- }
-
- assertEquals(expected, output)
- }
-
private fun CpuInfo.CoreDir.scalingMinFreqPath() = "$path/cpufreq/scaling_min_freq"
@Test
@@ -92,11 +67,7 @@
val output = Shell.catProcFileLong(it.scalingMinFreqPath())
// if the path exists, it should be readable by shell for every online core
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- assertNotNull(output)
- } else {
- assertNull(output)
- }
+ assertNotNull(output)
}
}
@@ -502,7 +473,6 @@
)
}
- @RequiresApi(21)
private fun pidof(packageName: String): Int? {
return Shell.getPidsForProcess(packageName).firstOrNull()
}
diff --git a/benchmark/benchmark-common/src/main/java/androidx/benchmark/Api21.kt b/benchmark/benchmark-common/src/main/java/androidx/benchmark/Api21.kt
deleted file mode 100644
index 745a4a9..0000000
--- a/benchmark/benchmark-common/src/main/java/androidx/benchmark/Api21.kt
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-@file:RequiresApi(21)
-
-package androidx.benchmark
-
-import android.content.Context
-import android.os.Debug
-import android.os.Environment
-import androidx.annotation.RequiresApi
-import androidx.annotation.RestrictTo
-import java.io.File
-
-internal fun startMethodTracingSampling(tracePath: String, bufferSize: Int, intervalUs: Int) {
- Debug.startMethodTracingSampling(tracePath, bufferSize, intervalUs)
-}
-
-@RestrictTo(RestrictTo.Scope.LIBRARY)
-fun Context.getFirstMountedMediaDir(): File? {
- @Suppress("DEPRECATION")
- return externalMediaDirs.firstOrNull {
- Environment.getExternalStorageState(it) == Environment.MEDIA_MOUNTED
- }
-}
diff --git a/benchmark/benchmark-common/src/main/java/androidx/benchmark/Arguments.kt b/benchmark/benchmark-common/src/main/java/androidx/benchmark/Arguments.kt
index fae211b..be459d07 100644
--- a/benchmark/benchmark-common/src/main/java/androidx/benchmark/Arguments.kt
+++ b/benchmark/benchmark-common/src/main/java/androidx/benchmark/Arguments.kt
@@ -82,7 +82,7 @@
internal val iterations: Int?
internal val profiler: Profiler?
internal val profilerDefault: Boolean
- internal val profilerSampleFrequency: Int
+ internal val profilerSampleFrequencyHz: Int
internal val profilerSampleDurationSeconds: Long
internal val profilerSkipWhenDurationRisksAnr: Boolean
internal val profilerPerfCompareEnable: Boolean
@@ -246,7 +246,7 @@
val profilerState = arguments.getProfiler(outputEnable)
profiler = profilerState.first
profilerDefault = profilerState.second
- profilerSampleFrequency =
+ profilerSampleFrequencyHz =
arguments.getBenchmarkArgument("profiling.sampleFrequency")?.ifBlank { null }?.toInt()
?: 1000
profilerSampleDurationSeconds =
@@ -263,7 +263,7 @@
Log.d(
BenchmarkState.TAG,
"Profiler ${profiler.javaClass.simpleName}, freq " +
- "$profilerSampleFrequency, duration $profilerSampleDurationSeconds"
+ "$profilerSampleFrequencyHz, duration $profilerSampleDurationSeconds"
)
}
diff --git a/benchmark/benchmark-common/src/main/java/androidx/benchmark/Outputs.kt b/benchmark/benchmark-common/src/main/java/androidx/benchmark/Outputs.kt
index d5c233c..0fd399d 100644
--- a/benchmark/benchmark-common/src/main/java/androidx/benchmark/Outputs.kt
+++ b/benchmark/benchmark-common/src/main/java/androidx/benchmark/Outputs.kt
@@ -18,6 +18,7 @@
import android.annotation.SuppressLint
import android.os.Build
+import android.os.Environment
import android.util.Log
import androidx.annotation.RestrictTo
import androidx.benchmark.FileMover.moveTo
@@ -73,7 +74,10 @@
// Additionally, Benchmarks append user space traces to the ones produced
// by the Macro Benchmark run; and that is a lot simpler to do if we use the
// Media directory. (b/216588251)
- context.getFirstMountedMediaDir()
+ @Suppress("DEPRECATION")
+ context.externalMediaDirs.firstOrNull {
+ Environment.getExternalStorageState(it) == Environment.MEDIA_MOUNTED
+ }
}
Build.VERSION.SDK_INT <= 22 -> {
// prior to API 23, shell didn't have access to externalCacheDir
diff --git a/benchmark/benchmark-common/src/main/java/androidx/benchmark/Profiler.kt b/benchmark/benchmark-common/src/main/java/androidx/benchmark/Profiler.kt
index afbf28d..950f6d7 100644
--- a/benchmark/benchmark-common/src/main/java/androidx/benchmark/Profiler.kt
+++ b/benchmark/benchmark-common/src/main/java/androidx/benchmark/Profiler.kt
@@ -170,8 +170,9 @@
InstrumentationResults.reportAdditionalFileToCopy("profiling_trace", path)
val bufferSize = 16 * 1024 * 1024
- if (sampled && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- startMethodTracingSampling(path, bufferSize, Arguments.profilerSampleFrequency)
+ if (sampled) {
+ val intervalUs = (1_000_000.0 / Arguments.profilerSampleFrequencyHz).toInt()
+ Debug.startMethodTracingSampling(path, bufferSize, intervalUs)
} else {
// NOTE: 0x10 flag enables low-overhead wall clock timing when ART module version supports
// it. Note that this doesn't affect trace parsing, since this doesn't affect wall clock,
@@ -317,7 +318,7 @@
Shell.executeScriptSilent(it.findSimpleperf() + " api-prepare")
it.startRecording(
RecordOptions()
- .setSampleFrequency(Arguments.profilerSampleFrequency)
+ .setSampleFrequency(Arguments.profilerSampleFrequencyHz)
.recordDwarfCallGraph() // enable Java/Kotlin callstacks
.setEvent("cpu-clock") // Required on API 33 to enable traceOffCpu
.traceOffCpu() // track time sleeping
@@ -351,7 +352,7 @@
override fun config(packageNames: List<String>) =
StackSamplingConfig(
packageNames = packageNames,
- frequency = Arguments.profilerSampleFrequency.toLong(),
+ frequency = Arguments.profilerSampleFrequencyHz.toLong(),
duration = Arguments.profilerSampleDurationSeconds,
)
diff --git a/benchmark/benchmark-common/src/main/java/androidx/benchmark/PropOverride.kt b/benchmark/benchmark-common/src/main/java/androidx/benchmark/PropOverride.kt
index b8430ef..4de378f 100644
--- a/benchmark/benchmark-common/src/main/java/androidx/benchmark/PropOverride.kt
+++ b/benchmark/benchmark-common/src/main/java/androidx/benchmark/PropOverride.kt
@@ -17,7 +17,6 @@
package androidx.benchmark
import android.util.Log
-import androidx.annotation.RequiresApi
import androidx.annotation.RestrictTo
/**
@@ -30,7 +29,6 @@
* missed.
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
-@RequiresApi(21)
public class PropOverride(private val propName: String, private val overrideValue: String) {
private var resetValue: String? = null
diff --git a/benchmark/benchmark-common/src/main/java/androidx/benchmark/Shell.kt b/benchmark/benchmark-common/src/main/java/androidx/benchmark/Shell.kt
index 70186dad..500f13f 100644
--- a/benchmark/benchmark-common/src/main/java/androidx/benchmark/Shell.kt
+++ b/benchmark/benchmark-common/src/main/java/androidx/benchmark/Shell.kt
@@ -75,22 +75,7 @@
}
fun connectUiAutomation() {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- ShellImpl // force initialization
- }
- }
-
- /**
- * Run a command, and capture stdout, dropping / ignoring stderr
- *
- * Below L, returns null
- */
- fun optionalCommand(command: String): String? {
- return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- executeScriptCaptureStdoutStderr(command).stdout
- } else {
- null
- }
+ ShellImpl // force initialization
}
/**
@@ -98,7 +83,7 @@
* directly by the app process.
*/
fun catProcFileLong(path: String): Long? {
- return optionalCommand("cat $path")?.trim()?.run {
+ return executeScriptCaptureStdoutStderr("cat $path").stdout.trim().run {
try {
toLong()
} catch (exception: NumberFormatException) {
diff --git a/benchmark/benchmark-common/src/main/java/androidx/benchmark/SideEffects.kt b/benchmark/benchmark-common/src/main/java/androidx/benchmark/SideEffects.kt
index a91bc5c..ceae337 100644
--- a/benchmark/benchmark-common/src/main/java/androidx/benchmark/SideEffects.kt
+++ b/benchmark/benchmark-common/src/main/java/androidx/benchmark/SideEffects.kt
@@ -31,17 +31,13 @@
}
override fun setup() {
- if (Build.VERSION.SDK_INT >= 21) {
- Log.d(BenchmarkState.TAG, "Disabling packages $packages")
- Shell.disablePackages(packages)
- }
+ Log.d(BenchmarkState.TAG, "Disabling packages $packages")
+ Shell.disablePackages(packages)
}
override fun tearDown() {
- if (Build.VERSION.SDK_INT >= 21) {
- Log.d(BenchmarkState.TAG, "Re-enabling packages $packages")
- Shell.enablePackages(packages)
- }
+ Log.d(BenchmarkState.TAG, "Re-enabling packages $packages")
+ Shell.enablePackages(packages)
}
companion object {
diff --git a/benchmark/gradle-plugin/lint-baseline.xml b/benchmark/gradle-plugin/lint-baseline.xml
deleted file mode 100644
index 8c91fdc..0000000
--- a/benchmark/gradle-plugin/lint-baseline.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<issues format="6" by="lint 8.7.0-alpha02" type="baseline" client="gradle" dependencies="false" name="AGP (8.7.0-alpha02)" variant="all" version="8.7.0-alpha02">
-
- <issue
- id="GradleProjectIsolation"
- message="Avoid using method getRootProject"
- errorLine1=" if (!project.rootProject.tasks.exists("lockClocks")) {"
- errorLine2=" ~~~~~~~~~~~">
- <location
- file="src/main/kotlin/androidx/benchmark/gradle/BenchmarkPlugin.kt"/>
- </issue>
-
- <issue
- id="GradleProjectIsolation"
- message="Avoid using method getRootProject"
- errorLine1=" project.rootProject.tasks.register("lockClocks", LockClocksTask::class.java).configure {"
- errorLine2=" ~~~~~~~~~~~">
- <location
- file="src/main/kotlin/androidx/benchmark/gradle/BenchmarkPlugin.kt"/>
- </issue>
-
- <issue
- id="GradleProjectIsolation"
- message="Avoid using method getRootProject"
- errorLine1=" if (!project.rootProject.tasks.exists("unlockClocks")) {"
- errorLine2=" ~~~~~~~~~~~">
- <location
- file="src/main/kotlin/androidx/benchmark/gradle/BenchmarkPlugin.kt"/>
- </issue>
-
- <issue
- id="GradleProjectIsolation"
- message="Avoid using method getRootProject"
- errorLine1=" project.rootProject.tasks"
- errorLine2=" ~~~~~~~~~~~">
- <location
- file="src/main/kotlin/androidx/benchmark/gradle/BenchmarkPlugin.kt"/>
- </issue>
-
-</issues>
diff --git a/buildSrc/private/src/main/kotlin/androidx/build/kythe/GenerateKotlinKzipTask.kt b/buildSrc/private/src/main/kotlin/androidx/build/kythe/GenerateKotlinKzipTask.kt
index 374a2f4..b014bc9 100644
--- a/buildSrc/private/src/main/kotlin/androidx/build/kythe/GenerateKotlinKzipTask.kt
+++ b/buildSrc/private/src/main/kotlin/androidx/build/kythe/GenerateKotlinKzipTask.kt
@@ -115,6 +115,8 @@
val args = buildList {
addAll(
listOf(
+ // Kythe drops arg[0] as it's unix convention that is the executable name
+ "kotlinc",
"-jvm-target",
jvmTarget.get().target,
"-no-reflect",
@@ -133,6 +135,9 @@
listOf("-Xmulti-platform")
} else emptyList()
+ val filteredKotlincFreeCompilerArgs =
+ kotlincFreeCompilerArgs.get().distinct().filter { !it.startsWith("-Xjdk-release") }
+
val command = buildList {
add(kotlincExtractorBin.get().asFile)
addAll(
@@ -146,8 +151,7 @@
"-vnames",
vnamesJson.get().asFile.relativeTo(checkoutRoot).path,
"-args",
- (args + multiplatformArg + kotlincFreeCompilerArgs.get().distinct())
- .joinToString(" ")
+ (args + multiplatformArg + filteredKotlincFreeCompilerArgs).joinToString(" ")
)
)
sourceFiles.forEach { addAll(listOf("-srcs", it.path)) }
diff --git a/buildSrc/private/src/main/kotlin/androidx/build/kythe/KzipTasks.kt b/buildSrc/private/src/main/kotlin/androidx/build/kythe/KzipTasks.kt
index e9a90d0..175953b 100644
--- a/buildSrc/private/src/main/kotlin/androidx/build/kythe/KzipTasks.kt
+++ b/buildSrc/private/src/main/kotlin/androidx/build/kythe/KzipTasks.kt
@@ -23,6 +23,7 @@
import androidx.build.getDefaultTargetJavaVersion
import org.gradle.api.Project
+/** Sets up tasks for generating kzip files that are used for generating xref support on website. */
fun Project.configureProjectForKzipTasks(config: ApiTaskConfig, extension: AndroidXExtension) =
// afterEvaluate required to read extension properties
afterEvaluate {
diff --git a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/Camera2CameraController.kt b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/Camera2CameraController.kt
index 9c2ec94..5fc57f2 100644
--- a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/Camera2CameraController.kt
+++ b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/Camera2CameraController.kt
@@ -253,7 +253,7 @@
controllerState = ControllerState.STOPPING
Log.debug { "Stopping Camera2CameraController" }
- disconnectSessionAndCamera(session, camera)
+ detachSessionAndCamera(session, camera)
}
private fun onCameraStatusChanged(cameraStatus: CameraStatus) {
@@ -295,7 +295,7 @@
cameraPrioritiesJob = null
cameraStatusMonitor.close()
- disconnectSessionAndCamera(session, camera)
+ detachSessionAndCamera(session, camera)
if (graphConfig.flags.closeCameraDeviceOnClose) {
Log.debug { "Quirk: Closing all camera devices" }
camera2DeviceManager.closeAll()
@@ -342,10 +342,10 @@
session.cameraDevice = cameraState.cameraDevice
}
is CameraStateClosing -> {
- session.disconnect()
+ session.shutdown()
}
is CameraStateClosed -> {
- session.disconnect()
+ session.shutdown()
onStateClosed(cameraState)
}
else -> {
@@ -383,10 +383,10 @@
}
}
- private fun disconnectSessionAndCamera(session: CaptureSessionState?, camera: VirtualCamera?) {
+ private fun detachSessionAndCamera(session: CaptureSessionState?, camera: VirtualCamera?) {
val deferred =
scope.async {
- session?.disconnect()
+ session?.shutdown()
camera?.disconnect()
}
if (
diff --git a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/Camera2CaptureSequenceProcessor.kt b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/Camera2CaptureSequenceProcessor.kt
index 1481c7a..f1a515b 100644
--- a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/Camera2CaptureSequenceProcessor.kt
+++ b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/Camera2CaptureSequenceProcessor.kt
@@ -37,6 +37,7 @@
import androidx.camera.camera2.pipe.core.Debug
import androidx.camera.camera2.pipe.core.Log
import androidx.camera.camera2.pipe.core.Log.MonitoredLogMessages.REPEATING_REQUEST_STARTED_TIMEOUT
+import androidx.camera.camera2.pipe.core.Threading
import androidx.camera.camera2.pipe.core.Threads
import androidx.camera.camera2.pipe.graph.StreamGraphImpl
import androidx.camera.camera2.pipe.media.AndroidImageWriter
@@ -45,8 +46,6 @@
import javax.inject.Inject
import kotlin.reflect.KClass
import kotlinx.atomicfu.atomic
-import kotlinx.coroutines.TimeoutCancellationException
-import kotlinx.coroutines.withTimeout
internal interface Camera2CaptureSequenceProcessorFactory {
fun create(
@@ -102,9 +101,6 @@
private val debugId = captureSequenceProcessorDebugIds.incrementAndGet()
private val lock = Any()
- @GuardedBy("lock") private var closed = false
-
- // TODO: Review if there's a better option than having a closed and disconnected state
@GuardedBy("lock") private var disconnected = false
@GuardedBy("lock")
@@ -165,10 +161,8 @@
}
val image = request.inputRequest.image
synchronized(lock) {
- if (closed || disconnected) {
- Log.warn {
- "$this closed or disconnected. $image can't be queued to $imageWriter"
- }
+ if (disconnected) {
+ Log.warn { "$this disconnected. $image can't be queued to $imageWriter" }
return null
}
}
@@ -300,8 +294,8 @@
override fun submit(captureSequence: Camera2CaptureSequence): Int? =
synchronized(lock) {
- if (closed) {
- Log.warn { "$this closed. $captureSequence won't be submitted" }
+ if (disconnected) {
+ Log.warn { "$this disconnected. $captureSequence won't be submitted" }
return null
}
val captureCallback = captureSequence as CameraCaptureSession.CaptureCallback
@@ -343,31 +337,26 @@
}
override suspend fun shutdown() {
- val captureSequence: Camera2CaptureSequence?
- synchronized(lock) {
- if (closed) {
- return
- }
- closed = true
- captureSequence = lastSingleRepeatingRequestSequence
- }
-
- if (awaitRepeatingRequestOnDisconnect && captureSequence != null) {
- awaitRepeatingRequestStarted(captureSequence)
- }
-
disconnect()
}
internal fun disconnect() {
// Shutdown is responsible for releasing resources that are no longer in use.
Debug.trace("$this#disconnect") {
- synchronized(lock) {
- if (!disconnected) {
- disconnected = true
- imageWriter?.close()
- session.inputSurface?.release()
+ val captureSequence: Camera2CaptureSequence? =
+ synchronized(lock) {
+ if (!disconnected) {
+ disconnected = true
+ imageWriter?.close()
+ session.inputSurface?.release()
+ lastSingleRepeatingRequestSequence
+ } else {
+ null
+ }
}
+ // Wait for the last submitted repeating request sequence to start, if one was set.
+ if (awaitRepeatingRequestOnDisconnect && captureSequence != null) {
+ awaitRepeatingRequestStarted(captureSequence)
}
}
}
@@ -376,7 +365,7 @@
return "Camera2CaptureSequenceProcessor-$debugId"
}
- private suspend fun awaitRepeatingRequestStarted(captureSequence: Camera2CaptureSequence) {
+ private fun awaitRepeatingRequestStarted(captureSequence: Camera2CaptureSequence) {
Log.debug { "Waiting for the last repeating request sequence: $captureSequence" }
// On certain devices, the submitted repeating request sequence may not give
// us onCaptureStarted() or onCaptureSequenceAborted() [1]. Hence we wrap
@@ -384,15 +373,16 @@
//
// [1] b/307588161 - [ANR] at
// androidx.camera.camera2.pipe.compat.Camera2CaptureSequenceProcessor.close
- try {
- withTimeout(WAIT_FOR_REPEATING_TIMEOUT_MS) { captureSequence.awaitStarted() }
- } catch (e: TimeoutCancellationException) {
- Log.error {
+ Threading.runBlockingCheckedOrNull(
+ threads.backgroundDispatcher,
+ WAIT_FOR_REPEATING_TIMEOUT_MS,
+ ) {
+ captureSequence.awaitStarted()
+ }
+ ?: Log.error {
"$this#close: $REPEATING_REQUEST_STARTED_TIMEOUT" +
", lastSingleRepeatingRequestSequence = $captureSequence"
}
- throw e
- }
}
/**
diff --git a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/Camera2DeviceCloser.kt b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/Camera2DeviceCloser.kt
index dd6eb6e..a352af6 100644
--- a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/Camera2DeviceCloser.kt
+++ b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/Camera2DeviceCloser.kt
@@ -157,6 +157,8 @@
override fun onCaptureQueueEmpty(session: CameraCaptureSessionWrapper) {}
+ override fun onSessionDisconnected() {}
+
override fun onSessionFinalized() {}
override fun onActive(session: CameraCaptureSessionWrapper) {}
diff --git a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CameraDeviceWrapper.kt b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CameraDeviceWrapper.kt
index f7709f6..76ed623 100644
--- a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CameraDeviceWrapper.kt
+++ b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CameraDeviceWrapper.kt
@@ -123,7 +123,7 @@
private val threads: Threads
) : CameraDeviceWrapper {
private val closed = atomic(false)
- private val _lastStateCallback = atomic<OnSessionFinalized?>(null)
+ private val _lastStateCallback = atomic<SessionStateCallback?>(null)
override fun createCaptureSession(
outputs: List<Surface>,
@@ -131,6 +131,7 @@
): Boolean {
val (success, previousStateCallback) = checkAndSetStateCallback(stateCallback)
if (!success) return false
+ previousStateCallback?.onSessionDisconnectedWithTrace()
val result =
instrumentAndCatch("createCaptureSession") {
// This function was deprecated in Android Q, but is required for some
@@ -172,6 +173,7 @@
}
val (success, previousStateCallback) = checkAndSetStateCallback(stateCallback)
if (!success) return false
+ previousStateCallback?.onSessionDisconnectedWithTrace()
val result =
instrumentAndCatch("createExtensionSession") {
val sessionConfig =
@@ -221,6 +223,7 @@
): Boolean {
val (success, previousStateCallback) = checkAndSetStateCallback(stateCallback)
if (!success) return false
+ previousStateCallback?.onSessionDisconnectedWithTrace()
val result =
instrumentAndCatch("createReprocessableCaptureSession") {
// This function was deprecated in Android Q, but is required for some
@@ -259,6 +262,7 @@
): Boolean {
val (success, previousStateCallback) = checkAndSetStateCallback(stateCallback)
if (!success) return false
+ previousStateCallback?.onSessionDisconnectedWithTrace()
val result =
instrumentAndCatch("createConstrainedHighSpeedCaptureSession") {
// This function was deprecated in Android Q, but is required for some
@@ -297,6 +301,7 @@
): Boolean {
val (success, previousStateCallback) = checkAndSetStateCallback(stateCallback)
if (!success) return false
+ previousStateCallback?.onSessionDisconnectedWithTrace()
val result =
instrumentAndCatch("createCaptureSessionByOutputConfigurations") {
// This function was deprecated in Android Q, but is required for some
@@ -336,6 +341,7 @@
): Boolean {
val (success, previousStateCallback) = checkAndSetStateCallback(stateCallback)
if (!success) return false
+ previousStateCallback?.onSessionDisconnectedWithTrace()
val result =
instrumentAndCatch("createReprocessableCaptureSessionByConfigurations") {
// This function was deprecated in Android Q, but is required for some
@@ -375,6 +381,7 @@
override fun createCaptureSession(config: SessionConfigData): Boolean {
val (success, previousStateCallback) = checkAndSetStateCallback(config.stateCallback)
if (!success) return false
+ previousStateCallback?.onSessionDisconnectedWithTrace()
val result =
instrumentAndCatch("createCaptureSession") {
val sessionConfig =
@@ -500,14 +507,18 @@
}
private fun checkAndSetStateCallback(
- stateCallback: OnSessionFinalized
- ): Pair<Boolean, OnSessionFinalized?> {
+ stateCallback: SessionStateCallback
+ ): Pair<Boolean, SessionStateCallback?> {
if (closed.value) {
stateCallback.onSessionFinalized()
return Pair(false, null)
}
return Pair(true, _lastStateCallback.getAndSet(stateCallback))
}
+
+ private fun SessionStateCallback.onSessionDisconnectedWithTrace() {
+ Debug.trace("${this@AndroidCameraDevice}#onSessionDisconnected") { onSessionDisconnected() }
+ }
}
/**
diff --git a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CaptureSessionFactory.kt b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CaptureSessionFactory.kt
index ba37301..028a1eb 100644
--- a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CaptureSessionFactory.kt
+++ b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CaptureSessionFactory.kt
@@ -137,7 +137,7 @@
"Failed to create reprocessable captures session from $cameraDevice for" +
" $captureSessionState!"
}
- captureSessionState.disconnect()
+ captureSessionState.shutdown()
}
} else {
if (
@@ -171,7 +171,7 @@
"Failed to create ConstrainedHighSpeedCaptureSession " +
"from $cameraDevice for $captureSessionState!"
}
- captureSessionState.disconnect()
+ captureSessionState.shutdown()
}
return emptyMap()
}
@@ -513,7 +513,7 @@
"Failed to create ExtensionCaptureSession from $cameraDevice " +
"for $captureSessionState!"
}
- captureSessionState.disconnect()
+ captureSessionState.shutdown()
}
return emptyMap()
diff --git a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CaptureSessionState.kt b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CaptureSessionState.kt
index 99a6f15..ed0a9d7 100644
--- a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CaptureSessionState.kt
+++ b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CaptureSessionState.kt
@@ -155,14 +155,14 @@
override fun onClosed(session: CameraCaptureSessionWrapper) {
Log.debug { "$this Closed" }
Debug.traceStart { "$this#onClosed" }
- disconnect()
+ shutdown()
Debug.traceStop()
}
override fun onConfigureFailed(session: CameraCaptureSessionWrapper) {
Log.warn { "$this Configuration Failed" }
Debug.traceStart { "$this#onConfigureFailed" }
- disconnect()
+ shutdown()
Debug.traceStop()
}
@@ -181,12 +181,19 @@
Log.debug { "$this CaptureQueueEmpty" }
}
+ override fun onSessionDisconnected() {
+ Log.debug { "$this session disconnecting" }
+ Debug.traceStart { "$this#onSessionDisconnected" }
+ disconnect()
+ Debug.traceStop()
+ }
+
override fun onSessionFinalized() {
// Only invoke finalizeSession once regardless of the number of times it is invoked.
if (finalized.compareAndSet(expect = false, update = true)) {
- Log.debug { "$this Finalizing Session" }
+ Log.debug { "$this session finalizing" }
Debug.traceStart { "$this#onSessionFinalized" }
- disconnect()
+ shutdown()
finalizeSession(0L)
Debug.traceStop()
}
@@ -256,17 +263,11 @@
/**
* This is used to disconnect the cached [CameraCaptureSessionWrapper] and put this object into
- * a closed state. This will not cancel repeating requests or abort captures.
+ * a closing state. This may stop the repeating request, abort captures, as well as release
+ * resources and perform any further actions to facilitate/enable the creation of the next
+ * capture session.
*/
fun disconnect() {
- shutdown(abortAndStopRepeating = cameraGraphFlags.abortCapturesOnStop)
- }
-
- /**
- * This is used to disconnect the cached [CameraCaptureSessionWrapper] and put this object into
- * a closed state. This may stop the repeating request and abort captures.
- */
- private fun shutdown(abortAndStopRepeating: Boolean) {
var configuredCaptureSession: ConfiguredCameraCaptureSession? = null
synchronized(lock) {
@@ -297,7 +298,7 @@
Debug.traceStart { "$graphListener#onGraphStopped" }
graphListener.onGraphStopped(graphProcessor)
Debug.traceStop()
- if (abortAndStopRepeating) {
+ if (cameraGraphFlags.abortCapturesOnStop) {
Debug.traceStart { "$this#stopRepeating" }
graphProcessor.stopRepeating()
Debug.traceStop()
@@ -336,6 +337,15 @@
graphListener.onGraphStopped(null)
Debug.traceStop()
}
+ }
+
+ /**
+ * This is used to disconnect, shutdown the cached [CameraCaptureSessionWrapper] and put this
+ * object into a closed state. This would finalize pending resources if any, such as surface
+ * usage tracking.
+ */
+ fun shutdown() {
+ disconnect()
var shouldFinalizeSession = false
var finalizeSessionDelayMs = 0L
diff --git a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CaptureSessionWrapper.kt b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CaptureSessionWrapper.kt
index 95c6641..b75cb23 100644
--- a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CaptureSessionWrapper.kt
+++ b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/CaptureSessionWrapper.kt
@@ -111,7 +111,7 @@
fun finalizeOutputConfigurations(outputConfigs: List<OutputConfigurationWrapper>): Boolean
/** @see CameraCaptureSession.StateCallback */
- interface StateCallback : OnSessionFinalized {
+ interface StateCallback : SessionStateCallback {
/** @see CameraCaptureSession.StateCallback.onActive */
fun onActive(session: CameraCaptureSessionWrapper)
@@ -145,7 +145,7 @@
internal class AndroidCaptureSessionStateCallback(
private val device: CameraDeviceWrapper,
private val stateCallback: CameraCaptureSessionWrapper.StateCallback,
- lastStateCallback: OnSessionFinalized?,
+ lastStateCallback: SessionStateCallback?,
private val cameraErrorListener: CameraErrorListener,
private val interopSessionStateCallback: CameraCaptureSession.StateCallback? = null,
private val callbackHandler: Handler
diff --git a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/ExtensionSessionState.kt b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/ExtensionSessionState.kt
index 6865b04..c314b97 100644
--- a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/ExtensionSessionState.kt
+++ b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/ExtensionSessionState.kt
@@ -39,6 +39,10 @@
captureSessionState.onConfigured(session as CameraCaptureSessionWrapper)
}
+ override fun onSessionDisconnected() {
+ captureSessionState.onSessionDisconnected()
+ }
+
override fun onSessionFinalized() {
captureSessionState.onSessionFinalized()
}
diff --git a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/ExtensionSessionWrapper.kt b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/ExtensionSessionWrapper.kt
index 608dc0f..bbd4519 100644
--- a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/ExtensionSessionWrapper.kt
+++ b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/ExtensionSessionWrapper.kt
@@ -53,7 +53,7 @@
override fun stopRepeating(): Boolean
/** @see CameraExtensionSession.StateCallback */
- interface StateCallback : OnSessionFinalized {
+ interface StateCallback : SessionStateCallback {
/** @see CameraExtensionSession.StateCallback.onClosed */
fun onClosed(session: CameraExtensionSessionWrapper)
@@ -71,7 +71,7 @@
internal class AndroidExtensionSessionStateCallback(
private val device: CameraDeviceWrapper,
private val stateCallback: CameraExtensionSessionWrapper.StateCallback,
- lastStateCallback: OnSessionFinalized?,
+ lastStateCallback: SessionStateCallback?,
private val cameraErrorListener: CameraErrorListener,
private val interopSessionStateCallback: CameraExtensionSession.StateCallback? = null,
private val callbackExecutor: Executor
diff --git a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/OnSessionFinalized.kt b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/SessionStateCallback.kt
similarity index 73%
rename from camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/OnSessionFinalized.kt
rename to camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/SessionStateCallback.kt
index 4ec420e..ea8c501 100644
--- a/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/OnSessionFinalized.kt
+++ b/camera/camera-camera2-pipe/src/main/java/androidx/camera/camera2/pipe/compat/SessionStateCallback.kt
@@ -17,7 +17,17 @@
package androidx.camera.camera2.pipe.compat
/** Base class for CameraCaptureSession.StateCallback() */
-public interface OnSessionFinalized {
+public interface SessionStateCallback {
+
+ /**
+ * Event indicating the session should be discard any necessary resources or complete certain
+ * actions in order for a new capture session to be created. This method should be invoked on
+ * the current session before we create a new session.
+ *
+ * See b/146773463, b/267557892, b/379347826 for more details.
+ */
+ public fun onSessionDisconnected()
+
/**
* Artificial event indicating the session is no longer in use and may be called several times.
* onClosed() and [onConfigureFailed() methods should call this method directly. This method
diff --git a/camera/camera-camera2-pipe/src/test/java/androidx/camera/camera2/pipe/compat/CameraDeviceWrapperTest.kt b/camera/camera-camera2-pipe/src/test/java/androidx/camera/camera2/pipe/compat/CameraDeviceWrapperTest.kt
new file mode 100644
index 0000000..8d72673
--- /dev/null
+++ b/camera/camera-camera2-pipe/src/test/java/androidx/camera/camera2/pipe/compat/CameraDeviceWrapperTest.kt
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.camera.camera2.pipe.compat
+
+import android.hardware.camera2.CameraCaptureSession
+import android.hardware.camera2.CameraDevice
+import android.os.Build
+import androidx.camera.camera2.pipe.CameraId
+import androidx.camera.camera2.pipe.internal.CameraErrorListener
+import androidx.camera.camera2.pipe.testing.FakeCameraMetadata
+import androidx.camera.camera2.pipe.testing.FakeThreads
+import androidx.camera.camera2.pipe.testing.RobolectricCameraPipeTestRunner
+import kotlin.test.Test
+import kotlin.test.assertFalse
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.test.TestScope
+import kotlinx.coroutines.test.advanceUntilIdle
+import kotlinx.coroutines.test.runTest
+import org.junit.runner.RunWith
+import org.mockito.kotlin.any
+import org.mockito.kotlin.mock
+import org.mockito.kotlin.times
+import org.mockito.kotlin.verify
+import org.mockito.kotlin.whenever
+import org.robolectric.annotation.Config
+
+@Suppress("deprecation")
+@OptIn(ExperimentalCoroutinesApi::class)
+@RunWith(RobolectricCameraPipeTestRunner::class)
+@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
+class CameraDeviceWrapperTest {
+ private val cameraId = CameraId("0")
+ private val cameraMetadata = FakeCameraMetadata(cameraId = cameraId)
+ private val cameraDevice: CameraDevice = mock()
+ private val cameraErrorListener: CameraErrorListener = mock()
+ private val testScope = TestScope()
+ private val fakeThreads = FakeThreads.fromTestScope(testScope)
+
+ private val androidCameraDevice =
+ AndroidCameraDevice(
+ cameraMetadata,
+ cameraDevice,
+ cameraId,
+ cameraErrorListener,
+ threads = fakeThreads,
+ )
+
+ private val sessionStateCallback1: CameraCaptureSessionWrapper.StateCallback = mock()
+ private val sessionStateCallback2: CameraCaptureSessionWrapper.StateCallback = mock()
+
+ @Test
+ fun testCreateCaptureSession() =
+ testScope.runTest {
+ androidCameraDevice.createCaptureSession(emptyList(), sessionStateCallback1)
+ advanceUntilIdle()
+
+ verify(cameraDevice, times(1)).createCaptureSession(any(), any(), any())
+ }
+
+ @Test
+ fun testCaptureSessionGetsFinalizedWhenDeviceClosed() =
+ testScope.runTest {
+ androidCameraDevice.onDeviceClosed()
+ advanceUntilIdle()
+
+ assertFalse(
+ androidCameraDevice.createCaptureSession(emptyList(), sessionStateCallback1)
+ )
+ verify(sessionStateCallback1, times(1)).onSessionFinalized()
+ }
+
+ @Test
+ fun testCreateSecondCaptureSessionDisconnectsAndFinalizesTheFirstOne() =
+ testScope.runTest {
+ androidCameraDevice.createCaptureSession(emptyList(), sessionStateCallback1)
+ advanceUntilIdle()
+
+ verify(cameraDevice, times(1)).createCaptureSession(any(), any(), any())
+
+ whenever(cameraDevice.createCaptureSession(any(), any(), any())).thenAnswer {
+ val callback = it.arguments[1] as CameraCaptureSession.StateCallback
+ val session: CameraCaptureSession = mock()
+ callback.onConfigured(session)
+ }
+ androidCameraDevice.createCaptureSession(emptyList(), sessionStateCallback2)
+ verify(sessionStateCallback1, times(1)).onSessionDisconnected()
+ advanceUntilIdle()
+ verify(sessionStateCallback1, times(1)).onSessionFinalized()
+ }
+}
diff --git a/camera/camera-camera2-pipe/src/test/java/androidx/camera/camera2/pipe/compat/CaptureSessionStateTest.kt b/camera/camera-camera2-pipe/src/test/java/androidx/camera/camera2/pipe/compat/CaptureSessionStateTest.kt
index 866bc7b..0dcf26e 100644
--- a/camera/camera-camera2-pipe/src/test/java/androidx/camera/camera2/pipe/compat/CaptureSessionStateTest.kt
+++ b/camera/camera-camera2-pipe/src/test/java/androidx/camera/camera2/pipe/compat/CaptureSessionStateTest.kt
@@ -90,7 +90,7 @@
}
@Test
- fun disconnectBeforeCameraDoesNotAcceptCamera() = runTest {
+ fun shutdownBeforeCameraDoesNotAcceptCamera() = runTest {
val state =
CaptureSessionState(
fakeGraphListener,
@@ -102,7 +102,7 @@
this
)
// When disconnect is called first
- state.disconnect()
+ state.shutdown()
// Setting a camera device has no effect
state.cameraDevice = fakeCameraDevice
@@ -113,7 +113,7 @@
}
@Test
- fun disconnectBeforeCameraCallsSurfaceListener() = runTest {
+ fun shutdownBeforeCameraCallsSurfaceListener() = runTest {
val state =
CaptureSessionState(
fakeGraphListener,
@@ -131,7 +131,7 @@
verify(fakeSurfaceListener, times(1)).onSurfaceActive(eq(surface2))
// And a device is never set
- state.disconnect()
+ state.shutdown()
// Then fakeSurfaceListener marks surfaces as inactive.
advanceUntilIdle()
@@ -141,7 +141,7 @@
}
@Test
- fun disconnectAfterCaptureSessionDoesNotCallOnSurfaceInactive() = runTest {
+ fun shutdownAfterCaptureSessionDoesNotCallOnSurfaceInactive() = runTest {
val state =
CaptureSessionState(
fakeGraphListener,
@@ -165,7 +165,7 @@
advanceUntilIdle()
// And the state is then disconnected
- state.disconnect()
+ state.shutdown()
// Then fakeSurfaceListener does not mark surfaces as inactive.
advanceUntilIdle()
@@ -276,7 +276,7 @@
state.onConfigured(fakeCaptureSession)
// And the state is then disconnected
- state.disconnect()
+ state.shutdown()
// Then make sure we do close the capture session.
advanceUntilIdle()
diff --git a/camera/media3/OWNERS b/camera/media3/OWNERS
new file mode 100644
index 0000000..15331e5
--- /dev/null
+++ b/camera/media3/OWNERS
@@ -0,0 +1 @@
+# [email protected]
diff --git a/camera/media3/media3-effect/api/current.txt b/camera/media3/media3-effect/api/current.txt
new file mode 100644
index 0000000..e6f50d0
--- /dev/null
+++ b/camera/media3/media3-effect/api/current.txt
@@ -0,0 +1 @@
+// Signature format: 4.0
diff --git a/camera/media3/media3-effect/api/res-current.txt b/camera/media3/media3-effect/api/res-current.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/camera/media3/media3-effect/api/res-current.txt
diff --git a/camera/media3/media3-effect/api/restricted_current.txt b/camera/media3/media3-effect/api/restricted_current.txt
new file mode 100644
index 0000000..e6f50d0
--- /dev/null
+++ b/camera/media3/media3-effect/api/restricted_current.txt
@@ -0,0 +1 @@
+// Signature format: 4.0
diff --git a/camera/media3/media3-effect/build.gradle b/camera/media3/media3-effect/build.gradle
new file mode 100644
index 0000000..630f430
--- /dev/null
+++ b/camera/media3/media3-effect/build.gradle
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This file was created using the `create_project.py` script located in the
+ * `<AndroidX root>/development/project-creator` directory.
+ *
+ * Please use that script when creating a new project, rather than copying an existing project and
+ * modifying its settings.
+ */
+import androidx.build.LibraryType
+
+plugins {
+ id("AndroidXPlugin")
+ id("com.android.library")
+ id("org.jetbrains.kotlin.android")
+}
+
+dependencies {
+ api(libs.kotlinStdlib)
+ // Add dependencies here
+}
+
+android {
+ namespace "androidx.camera.media3.effect"
+}
+
+androidx {
+ name = "androidx.camera.media3:media3-effect"
+ type = LibraryType.PUBLISHED_LIBRARY
+ inceptionYear = "2024"
+ description = "Media3 effect components for the Jetpack Camera Library, a library providing a seamless integration that enables media3 effect in CameraX."
+}
diff --git a/camera/media3/media3-effect/src/main/java/androidx/camera/media3/androidx-camera-media3-media3-effect-documentation.md b/camera/media3/media3-effect/src/main/java/androidx/camera/media3/androidx-camera-media3-media3-effect-documentation.md
new file mode 100644
index 0000000..165cc9f
--- /dev/null
+++ b/camera/media3/media3-effect/src/main/java/androidx/camera/media3/androidx-camera-media3-media3-effect-documentation.md
@@ -0,0 +1,7 @@
+# Module root
+
+androidx.camera.media3 media3-effect
+
+# Package androidx.camera.media3.effect
+
+Media3 effect components for the Jetpack Camera Library, a library providing a seamless integration that enables media3 effect in CameraX.
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-af/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-af/strings.xml
index 352c09a..f3ec77f 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-af/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-af/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Net die sekondêre handeling kan gekies word"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Versieringtoets"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Sekondêre handelinge en versiering"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Ry met sekondêre handelinge en versiering wat ’n baie lang titel het"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Die ry kan ook gekies word"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Sekondêre handeling is gekies"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Primêre handeling vir ry is gekies"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-am/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-am/strings.xml
index c177f54..2e43ab6 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-am/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-am/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"መመረጥ የሚችለው ሁለተኛው እርምጃ ብቻ ነው"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"የማስዋቢያ ሙከራ"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"ሁለተኛ እርምጃዎች እና ማስዋብ"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"ሁለተኛ እርምጃዎች ያሉት ረድፍ እና በጣም ረዥም ርዕስ ያለው ማስዋቢያ"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"እንዲሁም ረድፉ መመረጥ ይችላል"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"ሁለተኛ እርምጃ ተመርጧል"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"የረድፍ አንደኛ እርምጃ ተመርጧል"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-ar/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-ar/strings.xml
index 5bd36dd..f6fb1cc 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-ar/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-ar/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"يمكن اختيار الإجراء الثانوي فقط."</string>
<string name="decoration_test_title" msgid="8450127046762442244">"تصميم تجريبي"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"الإجراءات الثانوية والتصميم"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"صف يتضمن \"الإجراءات الثانوية\" و\"التصميم\" وله عنوان طويل جدًا"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"يمكن أيضًا اختيار الصف."</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"تم اختيار إجراء ثانوي للصف."</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"تم اختيار إجراء أساسي للصف."</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-as/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-as/strings.xml
index f4e9b53..548a2ee 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-as/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-as/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"কেৱল গৌণ কাৰ্যটোও বাছনি কৰিব পৰা যায়"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"সজোৱা কাৰ্য"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"গৌণ কাৰ্য আৰু সজোৱা কাৰ্য"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"এটা সঁচাকৈয়ে দীঘল শিৰোনামৰ সৈতে গৌণ কাৰ্য আৰু সজোৱা কাৰ্যসমূহ থকা শাৰী"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"শাৰীটোও বাছনি কৰিব পৰা যায়"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"গৌণ কাৰ্য বাছনি কৰা হৈছে"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"শাৰীৰ প্ৰাথমিক কাৰ্য বাছনি কৰা হৈছে"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-az/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-az/strings.xml
index a165ae5..757edef 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-az/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-az/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Yalnız ikinci dərəcəli əməliyyat seçilə bilər"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Dekorasiya Testi"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"İkinci Dərəcəli Əməliyyatlar və Dekorasiya"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Həqiqətən uzun başlığa sahib İkincil Fəaliyyətlər və Dekorasiya olan sətir"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Sıra da seçilə bilər"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"İkinci Dərəcəli Əməliyyat seçilib"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Sıra üzrə əsas əməliyyat seçilib"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-b+sr+Latn/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-b+sr+Latn/strings.xml
index 072729c..3e1a9ed 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-b+sr+Latn/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-b+sr+Latn/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Može da se izabere samo sekundarna radnja"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Test dekoracije"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Sekundarne radnje i dekoracija"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Red sa sekundarnim radnjama i dekoracijom sa veoma dugim naslovom"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Može da se izabere i red"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Sekundarna radnja je izabrana"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Primarna radnja reda je izabrana"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-be/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-be/strings.xml
index b070966..9d37bb1 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-be/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-be/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Можна выбраць толькі другаснае дзеянне"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Тэст элементаў аздаблення"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Другасныя дзеянні і аздабленне"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Радок з другаснымі дзеяннямі і аздабленнем з вельмі доўгай назвай"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Таксама можна выбраць радок"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Выбрана другаснае дзеянне"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Выбрана галоўнае дзеянне для радка"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-bg/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-bg/strings.xml
index e4604b0..9d1ac46 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-bg/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-bg/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Само алтернативното действие може да бъде избрано"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Тестване на декоративен елемент"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Алтернативни действия и декоративни елементи"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Ред с алтернативни действия и декоративни елементи с много дълго заглавие"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Редът може също да бъде избран"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Избрано е алтернативното действие"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Избрано е основното действие за реда"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-bn/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-bn/strings.xml
index 0e64f6b..a5a729b 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-bn/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-bn/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"শুধুমাত্র সেকেন্ডারি অ্যাকশন বেছে নেওয়া যেতে পারে"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"ডেকরেশন টেস্ট"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"সেকেন্ডারি অ্যাকশন ও ডেকরেশন"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"সেকেন্ডারি অ্যাকশন ও ডেকরেশনের দীর্ঘ টাইটেল আছে এমন সারি"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"সারিও বেছে নেওয়া যেতে পারে"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"সেকেন্ডারি অ্যাকশন বেছে নেওয়া হয়েছে"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"সারির প্রাইমারি অ্যাকশন বেছে নেওয়া হয়েছে"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-bs/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-bs/strings.xml
index fa47207..d1ac68f 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-bs/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-bs/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Moguće je odabrati samo sekundarnu radnju"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Test dekoracije"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Sekundarne radnje i dekoracija"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Red sa sekundarnim radnjama i dekoracijom s veoma dugim naslovom"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Moguće je odabrati i red"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Odabrana je sekundarna radnja"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Odabrana je primarna radnja reda"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-ca/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-ca/strings.xml
index 17ceb5b..e25a8de 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-ca/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-ca/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Només es pot seleccionar l\'acció secundària"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Prova de decoració"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Accions secundàries i decoració"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Fila amb accions secundàries i decoració amb un títol molt llarg"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"La fila també es pot seleccionar"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"S\'ha seleccionat l\'acció secundària"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"S\'ha seleccionat l\'acció principal de la fila"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-cs/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-cs/strings.xml
index 5657fa0..9618bca 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-cs/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-cs/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Lze vybrat pouze sekundární akci"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Zkouška dekorace"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Sekundární akce a dekorace"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Řádek se sekundárními akcemi a dekorace s opravdu dlouhým názvem"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Řádek lze také vybrat"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Je vybrána sekundární akce"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Je vybrána primární akce řádku"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-da/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-da/strings.xml
index 0c962df..721a67a 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-da/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-da/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Det er kun den sekundære handling, der kan vælges"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Dekorationstest"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Sekundære handlinger og dekoration"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Række med sekundære handlinger og dekoration med en meget lang titel"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Rækken kan også vælges"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Sekundær handling er valgt"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Primær handling for rækken er valgt"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-de/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-de/strings.xml
index 68c8836..2cb4991 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-de/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-de/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Nur die sekundäre Aktion kann ausgewählt werden"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Dekorationstest"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Sekundäre Aktionen und Dekoration"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Zeile mit sekundären Aktionen und Dekoration mit einem sehr langen Titel"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Auch diese Zeile kann ausgewählt werden"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Sekundäre Aktion ist ausgewählt"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Zeile mit der primären Aktion ist ausgewählt"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-el/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-el/strings.xml
index 0461d8d..053faa4 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-el/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-el/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Μόνο η δευτερεύουσα ενέργεια μπορεί να επιλεγεί"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Δοκιμή διακόσμησης"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Δευτερεύουσες ενέργειες και διακόσμηση"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Σειρά με δευτερεύουσες ενέργειες και διακόσμηση με πολύ μεγάλο τίτλο"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Η σειρά μπορεί επίσης να επιλεγεί"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Επιλέχθηκε η δευτερεύουσα ενέργεια σειράς"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Επιλέχθηκε η κύρια ενέργεια σειράς"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-en-rAU/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-en-rAU/strings.xml
index 39f6518..63d6e89 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-en-rAU/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-en-rAU/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Only the secondary action can be selected"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Decoration test"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Secondary actions and decoration"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Row with Secondary Actions and Decoration with a really long title"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"The row can also be selected"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Secondary action is selected"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Row primary action is selected"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-en-rGB/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-en-rGB/strings.xml
index 39f6518..63d6e89 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-en-rGB/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-en-rGB/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Only the secondary action can be selected"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Decoration test"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Secondary actions and decoration"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Row with Secondary Actions and Decoration with a really long title"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"The row can also be selected"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Secondary action is selected"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Row primary action is selected"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-en-rIN/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-en-rIN/strings.xml
index 39f6518..63d6e89 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-en-rIN/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-en-rIN/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Only the secondary action can be selected"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Decoration test"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Secondary actions and decoration"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Row with Secondary Actions and Decoration with a really long title"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"The row can also be selected"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Secondary action is selected"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Row primary action is selected"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-es-rUS/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-es-rUS/strings.xml
index 290e04a..cfeddbac 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-es-rUS/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-es-rUS/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Sólo puede seleccionarse la acción secundaria"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Prueba de decoración"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Acciones secundarias y decoraciones"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Fila con acciones secundarias y decoración con un título muy largo"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"También se puede seleccionar la fila"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Se seleccionó una acción secundaria"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Se seleccionó una acción de fila principal"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-es/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-es/strings.xml
index c21e4c6..2dffac1 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-es/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-es/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Solo se puede seleccionar la acción secundaria"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Prueba de decoración"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Acciones secundarias y decoración"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Fila con acciones secundarias y decoración con un título muy largo"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"También se puede seleccionar la fila"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Se ha seleccionado la acción secundaria"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Se ha seleccionado la acción principal de la fila"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-et/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-et/strings.xml
index fd8b184..8e69ee8 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-et/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-et/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Valida saab ainult teisese toimingu"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Dekoratsiooni test"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Teisesed toimingud ja dekoratsioon"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Rida tõeliselt pika pealkirjaga teiseste toimingute ja dekoratsiooniga"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Rea saab samuti valida"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Valitud on teisene toiming"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Valitud on rea peamine toiming"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-eu/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-eu/strings.xml
index e09a079..07c63dc 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-eu/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-eu/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Bigarren mailako ekintza soilik hauta daiteke"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Apainketaren proba"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Bigarren mailako ekintzak eta apainketa"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Bigarren mailako ekintzak eta apainketak dituen errenkada, oso izen luzearekin"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Errenkada ere hauta daiteke"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Bigarren mailako ekintza hautatuta dago"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Errenkadari dagokion ekintza nagusia hautatuta dago"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-fa/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-fa/strings.xml
index e839771..e15e53f 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-fa/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-fa/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"فقط کنش فرعی را میتوان انتخاب کرد"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"آزمایش آرایهگری"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"کنشهای فرعی و آرایهگری"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"ردیفی با «کنشهای فرعی» و «آرایهگری» با عنوان بسیار طولانی"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"ردیف را هم میتوان انتخاب کرد"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"کنش فرعی انتخاب شده است"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"کنش اصلی ردیف انتخاب شده است"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-fi/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-fi/strings.xml
index 8bde3c0..a2fe340 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-fi/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-fi/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Voit valita vain toissijaisen toiminnon"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Kuviotesti"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Toissijaiset toiminnot ja kuvio"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Rivi, jossa on toissijaiset toiminnot ja kuvio, jolla on todella pitkä nimi"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Voit valita myös rivin"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Toissijainen toiminto on valittu"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Rivin ensisijainen toiminto on valittu"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-fr-rCA/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-fr-rCA/strings.xml
index badf7e0..43192a4 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-fr-rCA/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-fr-rCA/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Seule l\'action secondaire peut être sélectionnée"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Test de décoration"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Actions secondaires et décoration"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Rangée avec Actions secondaires et Décoration avec un titre très long"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Cette ligne peut également être sélectionnée"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"L\'action secondaire est sélectionnée"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"L\'action primaire de la ligne est sélectionnée"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-fr/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-fr/strings.xml
index e4d2a31..f497c3f 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-fr/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-fr/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Seule l\'action secondaire peut être sélectionnée"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Test de la décoration"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Actions secondaires et décoration"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Ligne contenant des actions secondaires et une décoration comportant un titre très long"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"La ligne peut également être sélectionnée"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"L\'action secondaire est sélectionnée"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"L\'action principale de la ligne est sélectionnée"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-gl/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-gl/strings.xml
index f624e35..3b68f403 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-gl/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-gl/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Só se pode seleccionar a acción secundaria"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Proba de decoración"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Accións secundarias e decoración"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Fila con accións secundarias e decoración cun título moi longo"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Tamén se pode seleccionar a fila"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Seleccionouse a acción secundaria"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Seleccionouse a acción principal da fila"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-gu/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-gu/strings.xml
index a8fc6b4..9a42507 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-gu/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-gu/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"માત્ર ગૌણ ઍક્શન પસંદ કરી શકાય છે"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"ડેકોરેશન પરીક્ષણ"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"ગૌણ ઍક્શન અને ડેકોરેશન"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"સેકન્ડરી ઍક્શન અને ડેકોરેશનની ઘણા લાંબા શીર્ષકવાળી પંક્તિ"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"પંક્તિ પણ પસંદ કરી શકાય છે"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"ગૌણ ઍક્શન પસંદ કરી"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"પ્રાથમિક ઍક્શન પંક્તિ પસંદ કરી"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-hi/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-hi/strings.xml
index ebda291..bbee798 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-hi/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-hi/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"सिर्फ़ सेकंडरी ऐक्शन को चुना जा सकता है"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"डेकोरेशन टेस्ट"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"सेकंडरी ऐक्शन और डेकोरेशन"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"सेकंडरी ऐक्शन और डेकोरेशन के लंबे टाइटल वाली लाइन"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"पंक्ति को भी चुना जा सकता है"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"सेकंडरी ऐक्शन चुना गया"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"पंक्ति से जुड़ा प्राइमरी ऐक्शन चुना गया"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-hr/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-hr/strings.xml
index fd52cca..770e9db 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-hr/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-hr/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Može se odabrati samo sekundarna radnja"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Test dekoracije"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Sekundarne radnje i dekoracija"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Redak sa sekundarnim radnjama i dekoracijom s vrlo dugim naslovom"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Može se odabrati i redak"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Odabrana je sekundarna radnja"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Odabran je redak primarne radnje"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-hu/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-hu/strings.xml
index 46d3c07..f17a127 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-hu/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-hu/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Csak a másodlagos művelet választható ki"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Dekoráció tesztelése"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Másodlagos műveletek és dekorációk"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Másodlagos műveletekkel és dekorációval rendelkező sor nagyon hosszú címmel"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"A sor is kiválasztható"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Másodlagos művelet kiválasztva"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Sor elsődleges művelete kiválasztva"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-in/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-in/strings.xml
index bb53c17..f38edf5 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-in/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-in/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Hanya tindakan sekunder yang dapat dipilih"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Pengujian Dekorasi"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Tindakan Sekunder dan Dekorasi"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Baris dengan Tindakan Sekunder dan Dekorasi dengan judul yang sangat panjang"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Baris juga dapat dipilih"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Tindakan Sekunder dipilih"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Tindakan utama baris dipilih"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-is/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-is/strings.xml
index f2d4365..b0f3d7f 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-is/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-is/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Aðeins er hægt að velja aukaaðgerð"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Prufuskreyting"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Aukaaðgerðir og skreyting"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Lína með aukaaðgerðum, skreytingum og mjög löngum titli"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Einnig er hægt að velja línuna"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Aukaaðgerð er valin"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Aðalaðgerð línu er valin"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-it/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-it/strings.xml
index 8d06a75..4aa203d 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-it/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-it/strings.xml
@@ -38,7 +38,7 @@
<string name="settings_action_title" msgid="8616900063253887861">"Impostazioni"</string>
<string name="accept_action_title" msgid="4899660585470647578">"Accetta"</string>
<string name="reject_action_title" msgid="6730366705938402668">"Rifiuta"</string>
- <string name="ok_action_title" msgid="7128494973966098611">"OK"</string>
+ <string name="ok_action_title" msgid="7128494973966098611">"Ok"</string>
<string name="throw_action_title" msgid="7163710562670220163">"Genera"</string>
<string name="commute_action_title" msgid="2585755255290185096">"Tragitto giornaliero"</string>
<string name="sign_out_action_title" msgid="1653943000866713010">"Esci"</string>
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Solo l\'azione secondaria può essere selezionata"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Test decorazione"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Azioni secondarie e decorazione"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Riga con Azioni secondarie e decorazione con un titolo molto lungo"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Anche la riga può essere selezionata"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"È stata selezionata l\'azione secondaria"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"È stata selezionata l\'azione principale della riga"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-iw/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-iw/strings.xml
index 9bd0fbd..1a89e7e9 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-iw/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-iw/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"ניתן לבחור רק את הפעולה המשנית"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"בדיקת עיצוב"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"פעולות משניות ועיצוב"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"שורה עם פעולות משניות ועיצוב עם כותרת ארוכה מאוד"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"ניתן לבחור גם את השורה"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"נבחרה פעולה משנית"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"נבחרה פעולה ראשית בשורה"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-ka/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-ka/strings.xml
index be42714..9ff7c3e 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-ka/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-ka/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"შესაძლებელია მხოლოდ მეორადი მოქმედების არჩევა"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"დეკორაციის ტესტი"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"მეორადი მოქმედებები და დეკორაცია"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"დამატებითი აქტივობების მწკრივი და გაფორმება ძალიან გრძელი სათაურით"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"ასევე შეიძლება მწკრივის არჩევა"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"არჩეულია მეორადი მოქმედება"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"არჩეულია მწკრივის პირველადი მოქმედება"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-kk/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-kk/strings.xml
index 7be8e7c..95d6393 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-kk/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-kk/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Қосымша әрекет қана таңдалады."</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Безендіруді сынау"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Қосымша әрекеттер және безендіру"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Қосымша әрекеттерден және декорациядан тұратын, ұзын тақырыпты жол"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Жолды да таңдауға болады."</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Қосымша әрекет таңдалды."</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Жол үшін негізгі әрекет таңдалды."</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-km/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-km/strings.xml
index a41d2e7..0eb3cfc 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-km/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-km/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"អាចជ្រើសរើសបានតែសកម្មភាពបន្ទាប់បន្សំប៉ុណ្ណោះ"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"តេស្តនៃការតុបតែង"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"ការតុបតែង និងសកម្មភាពបន្ទាប់បន្សំ"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"ជួរដេកដែលមានសកម្មភាពបន្ទាប់បន្សំ និងការតុបតែងដែលមានចំណងជើងវែងខ្លាំង"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"ជួរដេកក៏អាចត្រូវបានជ្រើសរើសផងដែរ"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"សកម្មភាពបន្ទាប់បន្សំត្រូវបានជ្រើសរើស"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"សកម្មភាពចម្បងជួរដេកត្រូវបានជ្រើសរើស"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-ko/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-ko/strings.xml
index 1d27f9d..6da438e1 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-ko/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-ko/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"보조 작업만 선택할 수 있습니다."</string>
<string name="decoration_test_title" msgid="8450127046762442244">"장식 테스트"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"보조 작업 및 장식"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"제목이 매우 긴 보조 작업 및 장식이 있는 행"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"행도 선택할 수 있습니다."</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"보조 작업 선택됨"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"행 기본 작업 선택됨"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-ky/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-ky/strings.xml
index 3fbeef2..c54ddf8 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-ky/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-ky/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Кошумча аракетти гана тандоого болот"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Жасалгалоону сыноо"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Кошумча аракеттер жана Жасалгалоо"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Кошумча аракеттер жана Жасалгалоонун аталышы өтө узун болгон сап"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Сапты да тандоого болот"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Кошумча аракет тандалды"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Негизги аракет сабы тандалды"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-lo/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-lo/strings.xml
index cfc8724..76c1de3 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-lo/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-lo/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"ສາມາດເລືອກໄດ້ສະເພາະຄຳສັ່ງສຳຮອງເທົ່ານັ້ນ"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"ການທົດສອບການຕົກແຕ່ງ"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"ຄຳສັ່ງສຳຮອງ ແລະ ການຕົກແຕ່ງ"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"ແຖວທີ່ມີຄຳສັ່ງສຳຮອງ ແລະ ການຕົກແຕ່ງທີ່ມີຊື່ທີ່ຍາວຫຼາຍ"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"ນອກຈາກນັ້ນຍັງເລືອກແຖວໄດ້ນຳ"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"ເລືອກຄຳສັ່ງສຳຮອງຂອງແຖວແລ້ວ"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"ເລືອກຄຳສັ່ງຫຼັກຂອງແຖວແລ້ວ"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-lt/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-lt/strings.xml
index aa6e83c..b50c0f3 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-lt/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-lt/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Galima pasirinkti tik antrinį veiksmą"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Dekoracijų bandymas"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Antriniai veiksmai ir dekoracijos"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Eilutė su antriniais veiksmais ir dekoracijomis su tikrai ilgu pavadinimu"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Taip pat galima pasirinkti eilutę"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Pasirinktas antrinis veiksmas"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Pasirinktas pagrindinis eilutės veiksmas"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-lv/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-lv/strings.xml
index b7c3701..33a267e 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-lv/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-lv/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Atlasīt var tikai sekundāro darbību"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Noformējuma tests"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Sekundārās darbības un noformējums"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Rindiņa ar sekundārajām darbībām un noformējumu, kam ir ļoti garš nosaukums"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Arī rindu var atlasīt"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Atlasīta sekundārā darbība"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Atlasīta rindas primārā darbība"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-mk/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-mk/strings.xml
index a65e36e..9bbcfbf 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-mk/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-mk/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Само секундарното дејство може да се избере"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Проба за украсување"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Секундарни дејства и украсување"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Ред со секундарни дејства и украсување со навистина долг наслов"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Редот исто така може да се избере"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Избрано е секундарно дејство"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Избрано е примарно дејство на ред"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-ml/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-ml/strings.xml
index 2f1533f..4faf21d 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-ml/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-ml/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"സെക്കൻഡറി പ്രവർത്തനം മാത്രമേ തിരഞ്ഞെടുക്കാനാകൂ"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"ഡെക്കറേഷൻ ടെസ്റ്റ്"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"സെക്കൻഡറി പ്രവർത്തനങ്ങളും ഡെക്കറേഷനും"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"സെക്കൻഡറി നടപടികളുള്ള വരി, വളരെ നീളമുള്ള പേരുള്ള ഡെക്കറേഷൻ"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"വരിയും തിരഞ്ഞെടുക്കാവുന്നതാണ്"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"സെക്കൻഡറി പ്രവർത്തനം തിരഞ്ഞെടുത്തു"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"വരിയുടെ പ്രാഥമിക പ്രവർത്തനം തിരഞ്ഞെടുത്തു"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-mn/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-mn/strings.xml
index 8de303c..c5c466e 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-mn/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-mn/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Зөвхөн хоёрдогч үйлдлийг сонгох боломжтой"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Чимэглэлийн туршилт"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Хоёрдогч үйлдлүүд ба чимэглэл"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Хоёрдогч үйлдлүүд, маш урт нэртэй чимэглэлийн мөр"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Мөрийг мөн сонгож болно"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Хоёрдогч үйлдлийг сонгосон"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Мөрийн үндсэн үйлдлийг сонгосон"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-ms/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-ms/strings.xml
index 61380fa..fd7401d 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-ms/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-ms/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Hanya tindakan sekunder boleh dipilih"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Ujian Perhiasan"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Tindakan Sekunder dan Perhiasan"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Baris dengan Tindakan Kedua dan Hiasan dengan tajuk yang benar-benar panjang"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Baris ini juga boleh dipilih"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Tindakan Sekunder dipilih"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Tindakan utama baris dipilih"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-my/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-my/strings.xml
index 886009b..40f6d21 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-my/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-my/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"ဒုတိယဦးစားပေးလုပ်ဆောင်ချက်ကိုသာ ရွေးနိုင်သည်"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"တန်ဆာဆင်မှု စမ်းသပ်ခြင်း"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"ဒုတိယဦးစားပေးလုပ်ဆောင်ချက်များနှင့် တန်ဆာဆင်ခြင်း"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"ဒုတိယလုပ်ဆောင်ချက်များပါဝင်သည့် အတန်းနှင့် အမှန်တကယ်ရှည်သောခေါင်းစဉ်ဖြင့် အလှဆင်ခြင်း"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"အတန်းကိုလည်း ရွေးနိုင်သည်"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"ဒုတိယဦးစားပေး လုပ်ဆောင်ချက်ကို ရွေးထားသည်"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"အတန်း၏ ပထမဦးစားပေး လုပ်ဆောင်ချက်ကို ရွေးထားသည်"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-nb/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-nb/strings.xml
index 74d3248..2cc0a0a 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-nb/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-nb/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Bare sekundærhandlingen kan velges"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Dekorasjonstest"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Sekundærhandling og dekorasjon"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Rad med sekundærhandlinger og dekorasjon med en veldig lang tittel"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Raden kan også velges"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Sekundærhandlingen er valgt"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Hovedhandlingen til raden er valgt"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-ne/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-ne/strings.xml
index fa6b8bb..9ee2aac 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-ne/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-ne/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"सेकेन्डरी एक्सन मात्र चयन गर्न सकिन्छ"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"डेकोरेसन टेस्ट"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"सेकेन्डरी एक्सन तथा डेकोरेसन"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"गौण कार्य र सजावटसम्बन्धी वास्तवमै लामो शीर्षक भएको रो"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"रो पनि चयन गर्न सकिन्छ"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"सेकेन्डरी एक्सन चयन गरिएको छ"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"रोको प्राइमरी एक्सन चयन गरिएको छ"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-nl/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-nl/strings.xml
index f50a354..f56e84c 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-nl/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-nl/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Alleen de secundaire actie kan worden geselecteerd"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Test voor decoratie"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Secundaire acties en decoratie"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Rij met secundaire acties en decoratie met een heel lange titel"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"De rij kan ook worden geselecteerd"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Secundaire actie is geselecteerd"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Rij voor primaire actie is geselecteerd"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-or/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-or/strings.xml
index 8f69dde..f0413e9 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-or/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-or/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"କେବଳ ଦ୍ୱିତୀୟ କାର୍ଯ୍ୟକୁ ଚୟନ କରାଯାଇପାରିବ"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"ଡେକୋରେସନ ଟେଷ୍ଟ"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"ଦ୍ୱିତୀୟ କାର୍ଯ୍ୟ ଏବଂ ଡେକୋରେସନ"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"ପ୍ରକୃତରେ ଏକ ବଡ଼ ଟାଇଟେଲ ସହ ସେକେଣ୍ଡାରୀ ଆକ୍ସନ ଏବଂ ଡେକୋରେସନ ଥିବା ଧାଡ଼ି"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"ଏହି ଧାଡ଼ିଟିକୁ ମଧ୍ୟ ଚୟନ କରାଯାଇପାରିବ"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"ଦ୍ୱିତୀୟ କାର୍ଯ୍ୟ ଚୟନ କରାଯାଇଛି"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"ଧାଡ଼ିର ପ୍ରାଥମିକ କାର୍ଯ୍ୟ ଚୟନ କରାଯାଇଛି"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-pl/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-pl/strings.xml
index 9ad149a..2f48974 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-pl/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-pl/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Można wybrać tylko działanie alternatywne"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Test dekoracji"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Działania alternatywne i dekoracja"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Wiersz z działaniami alternatywnymi i dekoracją o bardzo długim tytule"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Można wybrać również wiersz"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Wybrano działanie alternatywne"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Wybrano wiersz z działaniem głównym"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-pt-rBR/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-pt-rBR/strings.xml
index fa55a9a..8f2bcc6 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-pt-rBR/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-pt-rBR/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Apenas a ação secundária pode ser selecionada"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Teste de decoração"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Ações secundárias e decoração"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Linha com ações secundárias e decoração com um título muito longo"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"A linha também pode ser selecionada"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"A ação secundária está selecionada"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"A ação principal da linha está selecionada"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-pt/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-pt/strings.xml
index fa55a9a..8f2bcc6 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-pt/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-pt/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Apenas a ação secundária pode ser selecionada"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Teste de decoração"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Ações secundárias e decoração"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Linha com ações secundárias e decoração com um título muito longo"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"A linha também pode ser selecionada"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"A ação secundária está selecionada"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"A ação principal da linha está selecionada"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-ro/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-ro/strings.xml
index 7233bfa..72b5c28 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-ro/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-ro/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Numai acțiunea secundară poate fi selectată"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Test pentru decorație"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Acțiuni secundare și decorație"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Rând cu acțiuni secundare și element decorativ cu un titlu foarte lung"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Și rândul poate fi selectat"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Acțiunea secundară a fost selectată"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Acțiunea principală de pe rând a fost selectată"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-ru/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-ru/strings.xml
index 157fa2a..9c88c83 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-ru/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-ru/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Можно выбрать только второстепенное действие"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Тест оформления"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Второстепенные действия и оформление"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Строка со второстепенными действиями и оформлением, у которых очень длинные названия"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Можно также выбрать строку"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Выбрано второстепенное действие."</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Выбрано главное действие для строки."</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-si/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-si/strings.xml
index fc5bbbb..9287572 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-si/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-si/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"ද්විතියික ක්රියාව පමණක් තෝරා ගත හැක"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"සැරසිලි පරීක්ෂණය"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"ද්විතියික ක්රියා සහ සැරසිලි"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"ද්විතීයික ක්රියා සහිත පේළිය සහ ඇත්තෙන්ම දිගු මාතෘකාවක් සහිත සැරසිලි"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"පේළිය ද තෝරා ගත හැක"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"ද්විතියික ක්රියාව තෝරා ඇත"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"පේළියේ මූලික ක්රියාව තෝරා ඇත"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-sk/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-sk/strings.xml
index a2d26f2..7722b84 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-sk/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-sk/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Vybrať sa dá iba sekundárna akcia"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Test dekorácie"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Sekundárne akcie a dekorácia"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Riadok so sekundárnymi akciami a dekoráciou s veľmi dlhým názvom"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Môžete vybrať aj daný riadok"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Bola vybraná sekundárna akcia"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Bola vybraná primárna akcia riadka"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-sq/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-sq/strings.xml
index 165afd2..3010d7d 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-sq/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-sq/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Mund të zgjidhet vetëm veprimi dytësor"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Testimi i dekorimit"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Veprimet dytësore dhe dekorimi"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Rreshti me veprimet dytësore dhe zbukurime me një titull vërtet të gjatë"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Rreshti mund të zgjidhet gjithashtu"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"U zgjodh veprimi dytësor"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"U zgjodh veprimi kryesor i rreshtit"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-sr/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-sr/strings.xml
index 4ef599d..c7443dd 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-sr/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-sr/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Може да се изабере само секундарна радња"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Тест декорације"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Секундарне радње и декорација"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Ред са секундарним радњама и декорацијом са веома дугим насловом"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Може да се изабере и ред"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Секундарна радња је изабрана"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Примарна радња реда је изабрана"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-sv/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-sv/strings.xml
index 8efbfec..5ca6aee 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-sv/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-sv/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Det går endast att välja den sekundära åtgärden"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Dekorationstest"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Sekundära åtgärder och dekoration"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Rad med sekundära åtgärder och dekoration med en väldigt lång titel"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Det går även att välja raden"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Den sekundära åtgärden har valts"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Radens primära åtgärd har valts"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-sw/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-sw/strings.xml
index 07b6998..d1b91b7 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-sw/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-sw/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Kitendo cha upili tu ndiyo kinaweza kuchaguliwa"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Jaribio la Usanifu"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Matendo ya Upili na Usanifu"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Safu Mlalo yenye Vitendo vya Ziada na Mapambo yenye jina refu zaidi"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Safu mlalo pia inaweza kuchaguliwa"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Kitendo cha Upili kimechaguliwa"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Kitendo cha msingi cha safu mlalo kimechaguliwa"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-th/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-th/strings.xml
index fdaf343..f3e29cd 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-th/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-th/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"เลือกได้เฉพาะการดำเนินการสำรอง"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"การทดสอบการตกแต่ง"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"การดำเนินการสำรองและการตกแต่ง"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"แถวที่มีการดำเนินการสำรองและการตกแต่งซึ่งมีชื่อที่ยาวมาก"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"เลือกแถวได้ด้วย"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"เลือกการดำเนินการสำรองแล้ว"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"เลือกการดำเนินการหลักของแถวแล้ว"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-tr/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-tr/strings.xml
index 06791fad..af20358 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-tr/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-tr/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Yalnızca ikincil işlem seçilebilir"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Süsleme Testi"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"İkincil İşlemler ve Süsleme"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Çok uzun bir başlığa sahip İkincil İşlemler ve Süsleme içeren satır"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Satır da seçilebilir"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"İkincil işlem seçildi"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Satırdaki birincil işlem seçildi"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-uk/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-uk/strings.xml
index 8db2abc..75ab546 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-uk/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-uk/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Можна вибрати лише додаткову дію"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Перевірка оформлення"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Додаткові дії й оформлення"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Рядок із додатковими діями й оформленням із дуже довгою назвою"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Рядок також можна вибрати"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Вибрано додаткову дію"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Вибрано основну дію рядка"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-vi/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-vi/strings.xml
index 9d3c9fa..45397e6 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-vi/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-vi/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Bạn chỉ có thể chọn hành động phụ"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Thử nghiệm phần trang trí"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Phần trang trí và hành động phụ"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Hàng có Phần trang trí và hành động phụ với tiêu đề rất dài"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Bạn cũng có thể chọn hàng"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Đã chọn hành động phụ"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Đã chọn hành động chính cho hàng"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-zh-rCN/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-zh-rCN/strings.xml
index 4e9fa74..4176a6f 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-zh-rCN/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-zh-rCN/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"只能选择次要操作"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"装饰测试"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"次要操作和装饰"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"包含次要操作和装饰以及长标题的行"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"也可以选择行"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"次要操作处于选中状态"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"行主要操作处于选中状态"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-zh-rHK/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-zh-rHK/strings.xml
index 96c5f99..d3bf08c 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-zh-rHK/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-zh-rHK/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"只可選取次要動作"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"裝飾測試"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"次要動作及裝飾"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"含有次要動作及修飾設定的列,且標題非常長"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"亦可選取列"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"已選取次要動作"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"已選取列的主要動作"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-zh-rTW/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-zh-rTW/strings.xml
index d6318e1..c6f9b78 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-zh-rTW/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-zh-rTW/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"只可以選取次要動作"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"裝飾測試"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"次要動作與裝飾"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"含有次要動作與修飾設定的列,且標題非常長"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"也可以選取列"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"已選取次要動作"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"已選取列的主要動作"</string>
diff --git a/car/app/app-samples/showcase/common/src/main/res/values-zu/strings.xml b/car/app/app-samples/showcase/common/src/main/res/values-zu/strings.xml
index c4b8273..cc8df31 100644
--- a/car/app/app-samples/showcase/common/src/main/res/values-zu/strings.xml
+++ b/car/app/app-samples/showcase/common/src/main/res/values-zu/strings.xml
@@ -321,8 +321,7 @@
<string name="secondary_actions_test_subtitle" msgid="6985282813402073703">"Isenzo sesibili kuphela esingakhethwa"</string>
<string name="decoration_test_title" msgid="8450127046762442244">"Ukuhlolwa Kokuhlobisa"</string>
<string name="secondary_actions_decoration_test_title" msgid="6282873404859209490">"Izenzo Zesibili Nokuhlobisa"</string>
- <!-- no translation found for secondary_actions_decoration_test_title_long (3700606949229899169) -->
- <skip />
+ <string name="secondary_actions_decoration_test_title_long" msgid="3700606949229899169">"Umugqa Unezenzo Zesibili Nokuhlotshiswa ngesihloko eside kakhulu"</string>
<string name="secondary_actions_decoration_test_subtitle" msgid="155884606592724532">"Umugqa ungabuye ukhethwe"</string>
<string name="secondary_action_toast" msgid="5076434693504006565">"Isenzo Sesibili Sikhethiwe"</string>
<string name="row_primary_action_toast" msgid="756516694751965204">"Isenzo esiyinhloko somugqa sikhethiwe"</string>
diff --git a/compose/foundation/foundation/api/current.txt b/compose/foundation/foundation/api/current.txt
index c166a14..6c0ed18 100644
--- a/compose/foundation/foundation/api/current.txt
+++ b/compose/foundation/foundation/api/current.txt
@@ -110,11 +110,9 @@
@SuppressCompatibility @androidx.compose.foundation.ExperimentalFoundationApi public final class ComposeFoundationFlags {
property public final boolean DragGesturePickUpEnabled;
property public final boolean NewNestedFlingPropagationEnabled;
- property public final boolean RemoveBasicTextGraphicsLayerEnabled;
field public static boolean DragGesturePickUpEnabled;
field public static final androidx.compose.foundation.ComposeFoundationFlags INSTANCE;
field public static boolean NewNestedFlingPropagationEnabled;
- field public static boolean RemoveBasicTextGraphicsLayerEnabled;
}
public final class DarkThemeKt {
diff --git a/compose/foundation/foundation/api/restricted_current.txt b/compose/foundation/foundation/api/restricted_current.txt
index 61f6ee4..4aaf099 100644
--- a/compose/foundation/foundation/api/restricted_current.txt
+++ b/compose/foundation/foundation/api/restricted_current.txt
@@ -110,11 +110,9 @@
@SuppressCompatibility @androidx.compose.foundation.ExperimentalFoundationApi public final class ComposeFoundationFlags {
property public final boolean DragGesturePickUpEnabled;
property public final boolean NewNestedFlingPropagationEnabled;
- property public final boolean RemoveBasicTextGraphicsLayerEnabled;
field public static boolean DragGesturePickUpEnabled;
field public static final androidx.compose.foundation.ComposeFoundationFlags INSTANCE;
field public static boolean NewNestedFlingPropagationEnabled;
- field public static boolean RemoveBasicTextGraphicsLayerEnabled;
}
public final class DarkThemeKt {
diff --git a/compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListFocusMoveCompositionCountTest.kt b/compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListFocusMoveCompositionCountTest.kt
index f714583..1292d4a 100644
--- a/compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListFocusMoveCompositionCountTest.kt
+++ b/compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListFocusMoveCompositionCountTest.kt
@@ -74,6 +74,93 @@
}
@Test
+ fun moveFocus_shouldCreateLimitedNumberOfItems() {
+ // Arrange.
+ val (rowSize, itemSize) = with(rule.density) { Pair(50.toDp(), 10.toDp()) }
+ lateinit var focusManager: FocusManager
+ rule.setContent {
+ focusManager = LocalFocusManager.current
+ LazyRow(Modifier.size(rowSize), state) {
+ items(100) { index ->
+ Box(
+ Modifier.size(itemSize)
+ .testTag("$index")
+ .then(if (index == 0 || index > 50) Modifier.focusable() else Modifier)
+ )
+ SideEffect { composedItems.add(index) }
+ }
+ }
+ }
+ rule.onNodeWithTag("0").requestFocus()
+ rule.runOnIdle { composedItems.clear() }
+
+ // Act.
+ rule.runOnIdle { focusManager.moveFocus(FocusDirection.Right) }
+
+ // Assert we composed only up to visible item count * BeyondBoundsViewportFactor
+ // (10 in this case).
+ rule.runOnIdle {
+ assertThat(composedItems).containsExactly(5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
+ }
+ }
+
+ @Test
+ fun moveFocus_shouldCreateLimitedNumberOfItems_largeItems() {
+ // Arrange.
+ val (rowSize, itemSize) = with(rule.density) { Pair(50.toDp(), 50.toDp()) }
+ lateinit var focusManager: FocusManager
+ rule.setContent {
+ focusManager = LocalFocusManager.current
+ LazyRow(Modifier.size(rowSize), state) {
+ items(100) { index ->
+ Box(
+ Modifier.size(itemSize)
+ .testTag("$index")
+ .then(if (index == 0 || index > 50) Modifier.focusable() else Modifier)
+ )
+ SideEffect { composedItems.add(index) }
+ }
+ }
+ }
+ rule.onNodeWithTag("0").requestFocus()
+ rule.runOnIdle { composedItems.clear() }
+
+ // Act.
+ rule.runOnIdle { focusManager.moveFocus(FocusDirection.Right) }
+
+ // Assert we only compose visibleCount * BeyondBoundsViewportFactor items. (2 in this case).
+ rule.runOnIdle { assertThat(composedItems).containsExactly(1, 2) }
+ }
+
+ @Test
+ fun moveFocus_shouldCreateLimitedNumberOfItems_differentSizedItems() {
+ // Arrange.
+ val rowSize = with(rule.density) { 50.toDp() }
+ lateinit var focusManager: FocusManager
+ rule.setContent {
+ focusManager = LocalFocusManager.current
+ LazyRow(Modifier.size(rowSize), state) {
+ items(100) { index ->
+ Box(
+ Modifier.size(with(rule.density) { ((index % 10) * 10 + 10).toDp() })
+ .testTag("$index")
+ .then(if (index == 0 || index > 50) Modifier.focusable() else Modifier)
+ )
+ SideEffect { composedItems.add(index) }
+ }
+ }
+ }
+ rule.onNodeWithTag("0").requestFocus()
+ rule.runOnIdle { composedItems.clear() }
+
+ // Act.
+ rule.runOnIdle { focusManager.moveFocus(FocusDirection.Right) }
+
+ // Assert we only compose visibleCount * BeyondBoundsViewportFactor items. (2 in this case).
+ rule.runOnIdle { assertThat(composedItems).containsExactly(3, 4, 5, 6) }
+ }
+
+ @Test
fun moveFocus_nestedFocusable() {
// Arrange.
val (rowSize, itemSize) = with(rule.density) { Pair(50.toDp(), 10.toDp()) }
diff --git a/compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListFocusMoveTest.kt b/compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListFocusMoveTest.kt
index 0302ffa..9daa391 100644
--- a/compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListFocusMoveTest.kt
+++ b/compose/foundation/foundation/integration-tests/lazy-tests/src/androidTest/kotlin/androidx/compose/foundation/lazy/list/LazyListFocusMoveTest.kt
@@ -343,74 +343,101 @@
}
@Test
- fun moveFocusToItemThatIsFarBeyondBounds() {
+ fun moveFocusToItemThatIsWithinOneViewport() {
// Arrange.
rule.setTestContent {
- lazyList(30.dp, it, lazyListState) {
- items(5) { FocusableBox(it) }
- items(100) { Box(Modifier.size(10.dp)) }
- item { FocusableBox(105) }
- item { FocusableBox(106, initiallyFocused) }
- item { FocusableBox(107) }
- items(100) { Box(Modifier.size(10.dp)) }
- items(5) { FocusableBox(it + 208) }
+ lazyList(100.dp, it, lazyListState) {
+ item { FocusableBox(0, initiallyFocused) }
+ items(6) { Box(Modifier.size(10.dp)) }
+ item { FocusableBox(7) }
}
}
with(rule) {
forEachParameter(ParamsToRun) { param ->
- runOnIdle {
- // Scroll so that the focused item is in the middle.
- runBlocking { lazyListState.scrollToItem(105) }
- initiallyFocused.requestFocus()
-
- // Move focus to the last visible item.
- when (focusDirection) {
- Left,
- Right,
- Up,
- Down,
- Previous,
- Next -> focusManager.moveFocus(focusDirection)
- Enter,
- Exit -> {
- // Do nothing
- }
- else -> unsupportedDirection()
- }
- }
+ runOnIdle { initiallyFocused.requestFocus() }
// Act.
- val success = runOnIdle { focusManager.moveFocus(focusDirection) }
+ runOnIdle { focusManager.moveFocus(focusDirection) }
// Assert.
runOnIdle {
- assertThat(success).apply {
- if (focusDirection == Enter) isFalse() else isTrue()
- }
when (focusDirection) {
Left ->
when (param.layoutDirection) {
Ltr ->
- assertThat(isFocused[if (param.reverseLayout) 208 else 4])
+ assertThat(isFocused[if (param.reverseLayout) 7 else 0])
.isTrue()
Rtl ->
- assertThat(isFocused[if (param.reverseLayout) 4 else 208])
+ assertThat(isFocused[if (param.reverseLayout) 0 else 7])
.isTrue()
}
Right ->
when (param.layoutDirection) {
Ltr ->
- assertThat(isFocused[if (param.reverseLayout) 4 else 208])
+ assertThat(isFocused[if (param.reverseLayout) 0 else 7])
.isTrue()
Rtl ->
- assertThat(isFocused[if (param.reverseLayout) 208 else 4])
+ assertThat(isFocused[if (param.reverseLayout) 7 else 0])
.isTrue()
}
- Up -> assertThat(isFocused[if (param.reverseLayout) 208 else 4]).isTrue()
- Down -> assertThat(isFocused[if (param.reverseLayout) 4 else 208]).isTrue()
- Previous -> assertThat(isFocused[4]).isTrue()
- Next -> assertThat(isFocused[208]).isTrue()
- Enter -> assertThat(isFocused[106]).isTrue()
+ Up -> assertThat(isFocused[if (param.reverseLayout) 7 else 0]).isTrue()
+ Down -> assertThat(isFocused[if (param.reverseLayout) 0 else 7]).isTrue()
+ Previous -> assertThat(isFocused[0]).isFalse()
+ Next -> assertThat(isFocused[7]).isTrue()
+ Enter -> assertThat(isFocused[0]).isTrue()
+ Exit -> assertThat(isLazyListFocused).isTrue()
+ else -> unsupportedDirection()
+ }
+ }
+ runOnIdle { runBlocking { lazyListState.scrollToItem(0) } }
+ resetTestCase()
+ }
+ }
+ }
+
+ @Test
+ fun moveFocusToItemThatIsBeyondOneViewport() {
+ // Arrange.
+ rule.setTestContent {
+ lazyList(100.dp, it, lazyListState) {
+ item { FocusableBox(0, initiallyFocused) }
+ items(6) { Box(Modifier.size(10.dp)) }
+ item { FocusableBox(7) }
+ }
+ }
+ with(rule) {
+ forEachParameter(ParamsToRun) { param ->
+ runOnIdle { initiallyFocused.requestFocus() }
+
+ // Act.
+ runOnIdle { focusManager.moveFocus(focusDirection) }
+
+ // Assert.
+ runOnIdle {
+ when (focusDirection) {
+ Left ->
+ when (param.layoutDirection) {
+ Ltr ->
+ assertThat(isFocused[if (param.reverseLayout) 7 else 0])
+ .isTrue()
+ Rtl ->
+ assertThat(isFocused[if (param.reverseLayout) 0 else 7])
+ .isTrue()
+ }
+ Right ->
+ when (param.layoutDirection) {
+ Rtl ->
+ assertThat(isFocused[if (param.reverseLayout) 7 else 0])
+ .isTrue()
+ Ltr ->
+ assertThat(isFocused[if (param.reverseLayout) 0 else 7])
+ .isTrue()
+ }
+ Up -> assertThat(isFocused[if (param.reverseLayout) 7 else 0]).isTrue()
+ Down -> assertThat(isFocused[if (param.reverseLayout) 0 else 7]).isTrue()
+ Previous -> assertThat(isFocused[0]).isFalse()
+ Next -> assertThat(isFocused[7]).isTrue()
+ Enter -> assertThat(isFocused[0]).isTrue()
Exit -> assertThat(isLazyListFocused).isTrue()
else -> unsupportedDirection()
}
diff --git a/compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/DraggableTest.kt b/compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/DraggableTest.kt
index f03fc1c2..5e5d0d2 100644
--- a/compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/DraggableTest.kt
+++ b/compose/foundation/foundation/src/androidInstrumentedTest/kotlin/androidx/compose/foundation/DraggableTest.kt
@@ -1161,6 +1161,29 @@
}
}
+ // On tests this wouldn't fail due to usage of a UnconfinedTestDispatcher. Using a
+ // standard test dispatcher will reveal this issue.
+ @Test
+ fun assertDraggableCallbackOrder() {
+ var onStartCalled = false
+ val draggableController = DraggableState { assertTrue { onStartCalled } }
+
+ rule.setContent {
+ Box(
+ Modifier.size(400.dp)
+ .draggable(
+ draggableController,
+ orientation = Orientation.Vertical,
+ onDragStarted = { onStartCalled = true },
+ onDragStopped = { assertTrue { onStartCalled } }
+ )
+ )
+ }
+
+ rule.onRoot().performTouchInput { swipeUp() }
+ rule.waitForIdle()
+ }
+
@Test
fun equalInputs_shouldResolveToEquals() {
val state = DraggableState {}
diff --git a/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/Magnifier.android.kt b/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/Magnifier.android.kt
index d8c9e95..45cee2f 100644
--- a/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/Magnifier.android.kt
+++ b/compose/foundation/foundation/src/androidMain/kotlin/androidx/compose/foundation/Magnifier.android.kt
@@ -50,6 +50,7 @@
import androidx.compose.ui.unit.DpSize
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.unit.toSize
+import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.launch
@@ -375,7 +376,8 @@
override fun onAttach() {
onObservedReadsChanged()
drawSignalChannel = Channel()
- coroutineScope.launch {
+ // Launch undispatched, otherwise we could miss the first draw signal
+ coroutineScope.launch(start = CoroutineStart.UNDISPATCHED) {
while (true) {
drawSignalChannel?.receive()
// don't update the magnifier immediately, actual frame draw happens right after
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/ComposeFoundationFlags.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/ComposeFoundationFlags.kt
index 7cae901..e541fe3 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/ComposeFoundationFlags.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/ComposeFoundationFlags.kt
@@ -16,8 +16,6 @@
package androidx.compose.foundation
-import androidx.compose.foundation.text.BasicText
-import androidx.compose.ui.graphics.graphicsLayer
import kotlin.jvm.JvmField
/**
@@ -66,16 +64,6 @@
@Suppress("MutableBareField") @JvmField var NewNestedFlingPropagationEnabled = true
/**
- * We have removed the implicit [graphicsLayer] from [BasicText]. This also affects the `Text`
- * composable in material modules.
- *
- * This change ideally improves the initial rendering performance of [BasicText] but it may have
- * negative effect on recomposition or redraw since [BasicText]s draw operations would not be
- * cached in a separate layer.
- */
- @JvmField @Suppress("MutableBareField") var RemoveBasicTextGraphicsLayerEnabled: Boolean = true
-
- /**
* Selecting flag to enable Drag Gesture "Pick-up" on drag gesture detectors. This also applies
* to Draggables and Scrollables which use gesture detectors as well. Any parent drag detector
* will continue to monitor the event stream until the gesture terminates (all pointers are
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Draggable.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Draggable.kt
index 885b489..23d2b4a 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Draggable.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/Draggable.kt
@@ -47,6 +47,7 @@
import androidx.compose.ui.unit.Velocity
import kotlin.coroutines.cancellation.CancellationException
import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.isActive
@@ -304,12 +305,14 @@
override fun onDragStarted(startedPosition: Offset) {
if (!isAttached || onDragStarted == NoOpOnDragStarted) return
- coroutineScope.launch { [email protected](this, startedPosition) }
+ coroutineScope.launch(start = CoroutineStart.UNDISPATCHED) {
+ [email protected](this, startedPosition)
+ }
}
override fun onDragStopped(velocity: Velocity) {
if (!isAttached || onDragStopped == NoOpOnDragStopped) return
- coroutineScope.launch {
+ coroutineScope.launch(start = CoroutineStart.UNDISPATCHED) {
[email protected](this, velocity.reverseIfNeeded().toFloat(orientation))
}
}
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListBeyondBoundsModifier.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListBeyondBoundsModifier.kt
index 11d3c6b..a21b4e3 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListBeyondBoundsModifier.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListBeyondBoundsModifier.kt
@@ -16,6 +16,7 @@
package androidx.compose.foundation.lazy
+import androidx.compose.foundation.gestures.snapping.singleAxisViewportSize
import androidx.compose.foundation.lazy.layout.LazyLayoutBeyondBoundsState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
@@ -48,4 +49,11 @@
itemCount - 1,
state.layoutInfo.visibleItemsInfo.last().index + beyondBoundsItemCount
)
+
+ override fun itemsPerViewport(): Int {
+ if (state.layoutInfo.visibleItemsInfo.isEmpty()) return 0
+ val viewportSize = state.layoutInfo.singleAxisViewportSize
+ val averageItemSize = state.layoutInfo.visibleItemsAverageSize()
+ return (viewportSize / averageItemSize).coerceAtLeast(1)
+ }
}
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListLayoutInfo.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListLayoutInfo.kt
index eb2bf7f..fe338be 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListLayoutInfo.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListLayoutInfo.kt
@@ -19,6 +19,7 @@
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.internal.JvmDefaultWithCompatibility
import androidx.compose.ui.unit.IntSize
+import androidx.compose.ui.util.fastSumBy
/**
* Contains useful information about the currently displayed layout state of lazy lists like
@@ -85,3 +86,9 @@
val mainAxisItemSpacing: Int
get() = 0
}
+
+internal fun LazyListLayoutInfo.visibleItemsAverageSize(): Int {
+ val visibleItems = visibleItemsInfo
+ val itemsSum = visibleItems.fastSumBy { it.size }
+ return itemsSum / visibleItems.size + mainAxisItemSpacing
+}
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListScrollScope.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListScrollScope.kt
index 812f04a..a945df0 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListScrollScope.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/LazyListScrollScope.kt
@@ -19,7 +19,6 @@
import androidx.compose.foundation.gestures.ScrollScope
import androidx.compose.foundation.lazy.layout.LazyLayoutScrollScope
import androidx.compose.ui.util.fastFirstOrNull
-import androidx.compose.ui.util.fastSumBy
/**
* An implementation of [LazyLayoutScrollScope] that can be used with LazyLists. Please refer to the
@@ -54,7 +53,7 @@
val layoutInfo = state.layoutInfo
if (layoutInfo.visibleItemsInfo.isEmpty()) return 0
return if (targetIndex !in firstVisibleItemIndex..lastVisibleItemIndex) {
- val averageSize = calculateVisibleItemsAverageSize(layoutInfo)
+ val averageSize = layoutInfo.visibleItemsAverageSize()
val indexesDiff = targetIndex - firstVisibleItemIndex
(averageSize * indexesDiff) - firstVisibleItemScrollOffset
} else {
@@ -63,11 +62,5 @@
visibleItem?.offset ?: 0
} + targetOffset
}
-
- private fun calculateVisibleItemsAverageSize(layoutInfo: LazyListLayoutInfo): Int {
- val visibleItems = layoutInfo.visibleItemsInfo
- val itemsSum = visibleItems.fastSumBy { it.size }
- return itemsSum / visibleItems.size + layoutInfo.mainAxisItemSpacing
- }
}
}
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridBeyondBoundsModifier.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridBeyondBoundsModifier.kt
index da43aa2..593597c 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridBeyondBoundsModifier.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridBeyondBoundsModifier.kt
@@ -16,6 +16,7 @@
package androidx.compose.foundation.lazy.grid
+import androidx.compose.foundation.gestures.snapping.singleAxisViewportSize
import androidx.compose.foundation.lazy.layout.LazyLayoutBeyondBoundsState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
@@ -40,4 +41,12 @@
override val lastPlacedIndex: Int
get() = state.layoutInfo.visibleItemsInfo.last().index
+
+ /** In grids this is lines per viewport */
+ override fun itemsPerViewport(): Int {
+ if (state.layoutInfo.visibleItemsInfo.isEmpty()) return 0
+ val viewportSize = state.layoutInfo.singleAxisViewportSize
+ val lineAverageSize = state.layoutInfo.visibleLinesAverageMainAxisSize()
+ return (viewportSize / lineAverageSize).coerceAtLeast(1)
+ }
}
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridLayoutInfo.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridLayoutInfo.kt
index d971eab..bdff83b 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridLayoutInfo.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridLayoutInfo.kt
@@ -18,6 +18,7 @@
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.ui.unit.IntSize
+import kotlin.math.max
/**
* Contains useful information about the currently displayed layout state of lazy grids like
@@ -87,3 +88,45 @@
*/
val maxSpan: Int
}
+
+internal fun LazyGridLayoutInfo.visibleLinesAverageMainAxisSize(): Int {
+ val isVertical = orientation == Orientation.Vertical
+ val visibleItems = visibleItemsInfo
+ fun lineOf(index: Int): Int =
+ if (isVertical) visibleItemsInfo[index].row else visibleItemsInfo[index].column
+
+ var totalLinesMainAxisSize = 0
+ var linesCount = 0
+
+ var lineStartIndex = 0
+ while (lineStartIndex < visibleItems.size) {
+ val currentLine = lineOf(lineStartIndex)
+ if (currentLine == -1) {
+ // Filter out exiting items.
+ ++lineStartIndex
+ continue
+ }
+
+ var lineMainAxisSize = 0
+ var lineEndIndex = lineStartIndex
+ while (lineEndIndex < visibleItems.size && lineOf(lineEndIndex) == currentLine) {
+ lineMainAxisSize =
+ max(
+ lineMainAxisSize,
+ if (isVertical) {
+ visibleItems[lineEndIndex].size.height
+ } else {
+ visibleItems[lineEndIndex].size.width
+ }
+ )
+ ++lineEndIndex
+ }
+
+ totalLinesMainAxisSize += lineMainAxisSize
+ ++linesCount
+
+ lineStartIndex = lineEndIndex
+ }
+
+ return totalLinesMainAxisSize / linesCount + mainAxisItemSpacing
+}
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridScrollScope.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridScrollScope.kt
index 7174f5c..81b5104 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridScrollScope.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/grid/LazyGridScrollScope.kt
@@ -20,7 +20,6 @@
import androidx.compose.foundation.gestures.ScrollScope
import androidx.compose.foundation.lazy.layout.LazyLayoutScrollScope
import androidx.compose.ui.util.fastFirstOrNull
-import kotlin.math.max
/**
* An implementation of [LazyLayoutScrollScope] that can be used with LazyGrids.
@@ -55,7 +54,7 @@
if (layoutInfo.visibleItemsInfo.isEmpty()) return 0
return if (targetIndex !in firstVisibleItemIndex..lastVisibleItemIndex) {
val slotsPerLine = state.slotsPerLine
- val averageLineMainAxisSize = calculateLineAverageMainAxisSize(layoutInfo)
+ val averageLineMainAxisSize = layoutInfo.visibleLinesAverageMainAxisSize()
val before = targetIndex < firstVisibleItemIndex
val linesDiff =
(targetIndex - firstVisibleItemIndex +
@@ -71,48 +70,5 @@
} ?: 0
} + targetOffset
}
-
- private fun calculateLineAverageMainAxisSize(layoutInfo: LazyGridLayoutInfo): Int {
- val isVertical = layoutInfo.orientation == Orientation.Vertical
- val visibleItems = layoutInfo.visibleItemsInfo
- val lineOf: (Int) -> Int = {
- if (isVertical) visibleItems[it].row else visibleItems[it].column
- }
-
- var totalLinesMainAxisSize = 0
- var linesCount = 0
-
- var lineStartIndex = 0
- while (lineStartIndex < visibleItems.size) {
- val currentLine = lineOf(lineStartIndex)
- if (currentLine == -1) {
- // Filter out exiting items.
- ++lineStartIndex
- continue
- }
-
- var lineMainAxisSize = 0
- var lineEndIndex = lineStartIndex
- while (lineEndIndex < visibleItems.size && lineOf(lineEndIndex) == currentLine) {
- lineMainAxisSize =
- max(
- lineMainAxisSize,
- if (isVertical) {
- visibleItems[lineEndIndex].size.height
- } else {
- visibleItems[lineEndIndex].size.width
- }
- )
- ++lineEndIndex
- }
-
- totalLinesMainAxisSize += lineMainAxisSize
- ++linesCount
-
- lineStartIndex = lineEndIndex
- }
-
- return totalLinesMainAxisSize / linesCount + layoutInfo.mainAxisItemSpacing
- }
}
}
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutBeyondBoundsModifierLocal.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutBeyondBoundsModifierLocal.kt
index 93084ad..de6de83 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutBeyondBoundsModifierLocal.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutBeyondBoundsModifierLocal.kt
@@ -46,6 +46,9 @@
/**
* This modifier is used to measure and place additional items when the lazy layout receives a
* request to layout items beyond the visible bounds.
+ *
+ * We will layout a limited number of items (currently the number of items in the viewport times a
+ * constant) so the focus search may give up if focusable items are too far apart.
*/
internal fun Modifier.lazyLayoutBeyondBoundsModifier(
state: LazyLayoutBeyondBoundsState,
@@ -146,12 +149,21 @@
}
var interval = beyondBoundsInfo.addInterval(startIndex, startIndex)
var found: T? = null
- while (found == null && interval.hasMoreContent(direction)) {
+ // Layout at most one viewport worth of items (times BeyondBoundsViewportFactor).
+ val maxItemsToLayout =
+ (BeyondBoundsViewportFactor * state.itemsPerViewport()).coerceAtMost(state.itemCount)
+ var itemsCreatedSoFar = 0
+ while (
+ found == null &&
+ interval.hasMoreContent(direction) &&
+ itemsCreatedSoFar < maxItemsToLayout
+ ) {
// Add one extra beyond bounds item.
interval =
addNextInterval(interval, direction).also {
beyondBoundsInfo.removeInterval(interval)
}
+ itemsCreatedSoFar++
remeasureSync()
// When we invoke this block, the beyond bounds items are present.
@@ -235,3 +247,5 @@
private fun unsupportedDirection(): Nothing =
error("Lazy list does not support beyond bounds layout for the specified direction")
+
+private const val BeyondBoundsViewportFactor = 2
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutBeyondBoundsState.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutBeyondBoundsState.kt
index c0dbc69..1eaeccb 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutBeyondBoundsState.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutBeyondBoundsState.kt
@@ -29,6 +29,8 @@
val firstPlacedIndex: Int
val lastPlacedIndex: Int
+
+ fun itemsPerViewport(): Int
}
@OptIn(ExperimentalFoundationApi::class)
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridBeyondBoundsModifier.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridBeyondBoundsModifier.kt
index c29f54c..36c72d4 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridBeyondBoundsModifier.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridBeyondBoundsModifier.kt
@@ -42,4 +42,11 @@
override val lastPlacedIndex: Int
get() = state.layoutInfo.visibleItemsInfo.last().index
+
+ override fun itemsPerViewport(): Int {
+ if (state.layoutInfo.visibleItemsInfo.isEmpty()) return 0
+ val viewportSize = state.layoutInfo.singleAxisViewportSize
+ val lineAverageSize = state.layoutInfo.visibleItemsAverageSize()
+ return (viewportSize / lineAverageSize).coerceAtLeast(1)
+ }
}
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridMeasureResult.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridMeasureResult.kt
index 85ec1fc..c62ec47 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridMeasureResult.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridMeasureResult.kt
@@ -24,6 +24,7 @@
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntSize
import androidx.compose.ui.util.fastForEach
+import androidx.compose.ui.util.fastSumBy
import kotlin.coroutines.EmptyCoroutineContext
import kotlinx.coroutines.CoroutineScope
@@ -271,3 +272,25 @@
scrollBackAmount = 0f,
coroutineScope = CoroutineScope(EmptyCoroutineContext)
)
+
+internal fun LazyStaggeredGridLayoutInfo.visibleItemsAverageSize(): Int {
+ val visibleItems = visibleItemsInfo
+ if (visibleItems.isEmpty()) return 0
+ val itemSizeSum =
+ visibleItems.fastSumBy {
+ if (orientation == Orientation.Vertical) {
+ it.size.height
+ } else {
+ it.size.width
+ }
+ }
+ return itemSizeSum / visibleItems.size + mainAxisItemSpacing
+}
+
+internal val LazyStaggeredGridLayoutInfo.singleAxisViewportSize: Int
+ get() =
+ if (orientation == Orientation.Vertical) {
+ viewportSize.height
+ } else {
+ viewportSize.width
+ }
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridScrollScope.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridScrollScope.kt
index c0ed4b2..aa6e2e1 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridScrollScope.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/lazy/staggeredgrid/LazyStaggeredGridScrollScope.kt
@@ -20,7 +20,6 @@
import androidx.compose.foundation.gestures.ScrollScope
import androidx.compose.foundation.lazy.layout.LazyLayoutScrollScope
import androidx.compose.ui.util.fastFirstOrNull
-import androidx.compose.ui.util.fastSumBy
/**
* An implementation of [LazyLayoutScrollScope] that can be used with LazyStaggeredGrids.
@@ -60,8 +59,7 @@
val visibleItem =
layoutInfo.visibleItemsInfo.fastFirstOrNull { it.index == targetIndex }
return if (visibleItem == null) {
- val averageMainAxisItemSize = calculateVisibleItemsAverageSize(layoutInfo)
-
+ val averageMainAxisItemSize = layoutInfo.visibleItemsAverageSize()
val laneCount = state.laneCount
val lineDiff = targetIndex / laneCount - firstVisibleItemIndex / laneCount
averageMainAxisItemSize * lineDiff - firstVisibleItemScrollOffset
@@ -73,18 +71,5 @@
}
} + targetOffset
}
-
- private fun calculateVisibleItemsAverageSize(layoutInfo: LazyStaggeredGridLayoutInfo): Int {
- val visibleItems = layoutInfo.visibleItemsInfo
- val itemSizeSum =
- visibleItems.fastSumBy {
- if (layoutInfo.orientation == Orientation.Vertical) {
- it.size.height
- } else {
- it.size.width
- }
- }
- return itemSizeSum / visibleItems.size + layoutInfo.mainAxisItemSpacing
- }
}
}
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/pager/PagerBeyondBoundsModifier.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/pager/PagerBeyondBoundsModifier.kt
index 0be75d97..7d37386 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/pager/PagerBeyondBoundsModifier.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/pager/PagerBeyondBoundsModifier.kt
@@ -49,4 +49,12 @@
itemCount - 1,
state.layoutInfo.visiblePagesInfo.last().index + beyondViewportPageCount
)
+
+ override fun itemsPerViewport(): Int {
+ val visibleItemCount = state.layoutInfo.visiblePagesInfo.size
+ if (visibleItemCount == 0) return 0
+ val viewportSize = state.layoutInfo.mainAxisViewportSize
+ val averageItemSize = state.layoutInfo.pageSize + state.layoutInfo.pageSpacing
+ return (viewportSize / averageItemSize).coerceAtLeast(1)
+ }
}
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/BasicText.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/BasicText.kt
index 56e2025..372f73d 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/BasicText.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/BasicText.kt
@@ -16,8 +16,6 @@
package androidx.compose.foundation.text
-import androidx.compose.foundation.ComposeFoundationFlags
-import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.text.modifiers.SelectableTextAnnotatedStringElement
import androidx.compose.foundation.text.modifiers.SelectionController
import androidx.compose.foundation.text.modifiers.TextAnnotatedStringElement
@@ -39,7 +37,6 @@
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Rect
import androidx.compose.ui.graphics.ColorProducer
-import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.layout.Layout
import androidx.compose.ui.layout.Measurable
import androidx.compose.ui.layout.MeasurePolicy
@@ -119,26 +116,24 @@
}
val finalModifier =
if (selectionController != null || onTextLayout != null) {
- modifier
- .optionalGraphicsLayer()
- .textModifier(
- AnnotatedString(text = text),
- style = style,
- onTextLayout = onTextLayout,
- overflow = overflow,
- softWrap = softWrap,
- maxLines = maxLines,
- minLines = minLines,
- fontFamilyResolver = LocalFontFamilyResolver.current,
- placeholders = null,
- onPlaceholderLayout = null,
- selectionController = selectionController,
- color = color,
- onShowTranslation = null,
- autoSize = requireAutoSizeInternalImplementationOrNull(autoSize)
- )
+ modifier.textModifier(
+ AnnotatedString(text = text),
+ style = style,
+ onTextLayout = onTextLayout,
+ overflow = overflow,
+ softWrap = softWrap,
+ maxLines = maxLines,
+ minLines = minLines,
+ fontFamilyResolver = LocalFontFamilyResolver.current,
+ placeholders = null,
+ onPlaceholderLayout = null,
+ selectionController = selectionController,
+ color = color,
+ onShowTranslation = null,
+ autoSize = requireAutoSizeInternalImplementationOrNull(autoSize)
+ )
} else {
- modifier.optionalGraphicsLayer() then
+ modifier then
TextStringSimpleElement(
text = text,
style = style,
@@ -218,24 +213,22 @@
// this is the same as text: String, use all the early exits
Layout(
modifier =
- modifier
- .optionalGraphicsLayer()
- .textModifier(
- text = text,
- style = style,
- onTextLayout = onTextLayout,
- overflow = overflow,
- softWrap = softWrap,
- maxLines = maxLines,
- minLines = minLines,
- fontFamilyResolver = LocalFontFamilyResolver.current,
- placeholders = null,
- onPlaceholderLayout = null,
- selectionController = selectionController,
- color = color,
- onShowTranslation = null,
- autoSize = requireAutoSizeInternalImplementationOrNull(autoSize)
- ),
+ modifier.textModifier(
+ text = text,
+ style = style,
+ onTextLayout = onTextLayout,
+ overflow = overflow,
+ softWrap = softWrap,
+ maxLines = maxLines,
+ minLines = minLines,
+ fontFamilyResolver = LocalFontFamilyResolver.current,
+ placeholders = null,
+ onPlaceholderLayout = null,
+ selectionController = selectionController,
+ color = color,
+ onShowTranslation = null,
+ autoSize = requireAutoSizeInternalImplementationOrNull(autoSize)
+ ),
EmptyMeasurePolicy
)
} else {
@@ -672,27 +665,25 @@
inlineComposables?.let { InlineChildren(text = text, inlineContents = it) }
},
modifier =
- modifier
- .optionalGraphicsLayer()
- .textModifier(
- text = styledText(),
- style = style,
- onTextLayout = {
- textScope?.textLayoutResult = it
- onTextLayout?.invoke(it)
- },
- overflow = overflow,
- softWrap = softWrap,
- maxLines = maxLines,
- minLines = minLines,
- fontFamilyResolver = fontFamilyResolver,
- placeholders = placeholders,
- onPlaceholderLayout = onPlaceholderLayout,
- selectionController = selectionController,
- color = color,
- onShowTranslation = onShowTranslation,
- autoSize = autoSize
- ),
+ modifier.textModifier(
+ text = styledText(),
+ style = style,
+ onTextLayout = {
+ textScope?.textLayoutResult = it
+ onTextLayout?.invoke(it)
+ },
+ overflow = overflow,
+ softWrap = softWrap,
+ maxLines = maxLines,
+ minLines = minLines,
+ fontFamilyResolver = fontFamilyResolver,
+ placeholders = placeholders,
+ onPlaceholderLayout = onPlaceholderLayout,
+ selectionController = selectionController,
+ color = color,
+ onShowTranslation = onShowTranslation,
+ autoSize = autoSize
+ ),
measurePolicy =
if (!hasInlineContent) {
LinksTextMeasurePolicy(
@@ -708,18 +699,6 @@
}
/**
- * Applies a full [graphicsLayer] modifier only if the associated flag
- * [ComposeFoundationFlags.RemoveBasicTextGraphicsLayerEnabled] is disabled.
- */
-@OptIn(ExperimentalFoundationApi::class)
-private fun Modifier.optionalGraphicsLayer() =
- if (ComposeFoundationFlags.RemoveBasicTextGraphicsLayerEnabled) {
- this
- } else {
- this.graphicsLayer()
- }
-
-/**
* [AutoSize], our public type, is a sealed interface. Our internal representation is not sealed.
* This is an extra validity check to ensure we are receiving the correct type; in practice it
* should never happen.
diff --git a/compose/material3/material3/api/current.txt b/compose/material3/material3/api/current.txt
index a324a55..84aafba 100644
--- a/compose/material3/material3/api/current.txt
+++ b/compose/material3/material3/api/current.txt
@@ -702,11 +702,6 @@
field public static final androidx.compose.material3.DefaultNavigationBarComponentOverride INSTANCE;
}
- @SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3Api public final class DefaultNavigationBarItemComponentOverride implements androidx.compose.material3.NavigationBarItemComponentOverride {
- method @androidx.compose.runtime.Composable public void NavigationBarItem(androidx.compose.material3.NavigationBarItemComponentOverrideContext);
- field public static final androidx.compose.material3.DefaultNavigationBarItemComponentOverride INSTANCE;
- }
-
@SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3Api public final class DefaultNavigationRailComponentOverride implements androidx.compose.material3.NavigationRailComponentOverride {
method @androidx.compose.runtime.Composable public void NavigationRail(androidx.compose.material3.NavigationRailComponentOverrideContext);
field public static final androidx.compose.material3.DefaultNavigationRailComponentOverride INSTANCE;
@@ -1541,31 +1536,6 @@
property public final long unselectedTextColor;
}
- @SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3Api public interface NavigationBarItemComponentOverride {
- method @androidx.compose.runtime.Composable public void NavigationBarItem(androidx.compose.material3.NavigationBarItemComponentOverrideContext);
- }
-
- @SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3Api public final class NavigationBarItemComponentOverrideContext implements androidx.compose.foundation.layout.RowScope {
- method public androidx.compose.material3.NavigationBarItemColors getColors();
- method public kotlin.jvm.functions.Function0<kotlin.Unit> getIcon();
- method public androidx.compose.foundation.interaction.MutableInteractionSource? getInteractionSource();
- method public kotlin.jvm.functions.Function0<kotlin.Unit>? getLabel();
- method public androidx.compose.ui.Modifier getModifier();
- method public kotlin.jvm.functions.Function0<kotlin.Unit> getOnClick();
- method public boolean getShouldAlwaysShowLabel();
- method public boolean isEnabled();
- method public boolean isSelected();
- property public final androidx.compose.material3.NavigationBarItemColors colors;
- property public final kotlin.jvm.functions.Function0<kotlin.Unit> icon;
- property public final androidx.compose.foundation.interaction.MutableInteractionSource? interactionSource;
- property public final boolean isEnabled;
- property public final boolean isSelected;
- property public final kotlin.jvm.functions.Function0<kotlin.Unit>? label;
- property public final androidx.compose.ui.Modifier modifier;
- property public final kotlin.jvm.functions.Function0<kotlin.Unit> onClick;
- property public final boolean shouldAlwaysShowLabel;
- }
-
public final class NavigationBarItemDefaults {
method @androidx.compose.runtime.Composable public androidx.compose.material3.NavigationBarItemColors colors();
method @Deprecated @androidx.compose.runtime.Composable public androidx.compose.material3.NavigationBarItemColors colors(optional long selectedIconColor, optional long selectedTextColor, optional long indicatorColor, optional long unselectedIconColor, optional long unselectedTextColor);
@@ -1577,9 +1547,7 @@
method @androidx.compose.runtime.Composable public static void NavigationBar(optional androidx.compose.ui.Modifier modifier, optional long containerColor, optional long contentColor, optional float tonalElevation, optional androidx.compose.foundation.layout.WindowInsets windowInsets, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.runtime.Composable public static void NavigationBarItem(androidx.compose.foundation.layout.RowScope, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, kotlin.jvm.functions.Function0<kotlin.Unit> icon, optional androidx.compose.ui.Modifier modifier, optional boolean enabled, optional kotlin.jvm.functions.Function0<kotlin.Unit>? label, optional boolean alwaysShowLabel, optional androidx.compose.material3.NavigationBarItemColors colors, optional androidx.compose.foundation.interaction.MutableInteractionSource? interactionSource);
method @SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3Api public static androidx.compose.runtime.ProvidableCompositionLocal<androidx.compose.material3.NavigationBarComponentOverride> getLocalNavigationBarComponentOverride();
- method @SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3Api public static androidx.compose.runtime.ProvidableCompositionLocal<androidx.compose.material3.NavigationBarItemComponentOverride> getLocalNavigationBarItemComponentOverride();
property @SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3Api public static final androidx.compose.runtime.ProvidableCompositionLocal<androidx.compose.material3.NavigationBarComponentOverride> LocalNavigationBarComponentOverride;
- property @SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3Api public static final androidx.compose.runtime.ProvidableCompositionLocal<androidx.compose.material3.NavigationBarItemComponentOverride> LocalNavigationBarItemComponentOverride;
}
@androidx.compose.runtime.Stable public interface NavigationDrawerItemColors {
@@ -2282,12 +2250,8 @@
method @SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3ExpressiveApi @androidx.compose.runtime.Composable public static void SplitButtonLayout(kotlin.jvm.functions.Function0<kotlin.Unit> leadingButton, kotlin.jvm.functions.Function0<kotlin.Unit> trailingButton, optional androidx.compose.ui.Modifier modifier, optional float spacing);
}
- public final class SplitButtonShapes {
+ @SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3ExpressiveApi public final class SplitButtonShapes {
ctor public SplitButtonShapes(androidx.compose.ui.graphics.Shape shape, androidx.compose.ui.graphics.Shape? pressedShape, androidx.compose.ui.graphics.Shape? checkedShape);
- method public androidx.compose.ui.graphics.Shape component1();
- method public androidx.compose.ui.graphics.Shape? component2();
- method public androidx.compose.ui.graphics.Shape? component3();
- method public androidx.compose.material3.SplitButtonShapes copy(androidx.compose.ui.graphics.Shape shape, androidx.compose.ui.graphics.Shape? pressedShape, androidx.compose.ui.graphics.Shape? checkedShape);
method public androidx.compose.ui.graphics.Shape? getCheckedShape();
method public androidx.compose.ui.graphics.Shape? getPressedShape();
method public androidx.compose.ui.graphics.Shape getShape();
diff --git a/compose/material3/material3/api/restricted_current.txt b/compose/material3/material3/api/restricted_current.txt
index a324a55..84aafba 100644
--- a/compose/material3/material3/api/restricted_current.txt
+++ b/compose/material3/material3/api/restricted_current.txt
@@ -702,11 +702,6 @@
field public static final androidx.compose.material3.DefaultNavigationBarComponentOverride INSTANCE;
}
- @SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3Api public final class DefaultNavigationBarItemComponentOverride implements androidx.compose.material3.NavigationBarItemComponentOverride {
- method @androidx.compose.runtime.Composable public void NavigationBarItem(androidx.compose.material3.NavigationBarItemComponentOverrideContext);
- field public static final androidx.compose.material3.DefaultNavigationBarItemComponentOverride INSTANCE;
- }
-
@SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3Api public final class DefaultNavigationRailComponentOverride implements androidx.compose.material3.NavigationRailComponentOverride {
method @androidx.compose.runtime.Composable public void NavigationRail(androidx.compose.material3.NavigationRailComponentOverrideContext);
field public static final androidx.compose.material3.DefaultNavigationRailComponentOverride INSTANCE;
@@ -1541,31 +1536,6 @@
property public final long unselectedTextColor;
}
- @SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3Api public interface NavigationBarItemComponentOverride {
- method @androidx.compose.runtime.Composable public void NavigationBarItem(androidx.compose.material3.NavigationBarItemComponentOverrideContext);
- }
-
- @SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3Api public final class NavigationBarItemComponentOverrideContext implements androidx.compose.foundation.layout.RowScope {
- method public androidx.compose.material3.NavigationBarItemColors getColors();
- method public kotlin.jvm.functions.Function0<kotlin.Unit> getIcon();
- method public androidx.compose.foundation.interaction.MutableInteractionSource? getInteractionSource();
- method public kotlin.jvm.functions.Function0<kotlin.Unit>? getLabel();
- method public androidx.compose.ui.Modifier getModifier();
- method public kotlin.jvm.functions.Function0<kotlin.Unit> getOnClick();
- method public boolean getShouldAlwaysShowLabel();
- method public boolean isEnabled();
- method public boolean isSelected();
- property public final androidx.compose.material3.NavigationBarItemColors colors;
- property public final kotlin.jvm.functions.Function0<kotlin.Unit> icon;
- property public final androidx.compose.foundation.interaction.MutableInteractionSource? interactionSource;
- property public final boolean isEnabled;
- property public final boolean isSelected;
- property public final kotlin.jvm.functions.Function0<kotlin.Unit>? label;
- property public final androidx.compose.ui.Modifier modifier;
- property public final kotlin.jvm.functions.Function0<kotlin.Unit> onClick;
- property public final boolean shouldAlwaysShowLabel;
- }
-
public final class NavigationBarItemDefaults {
method @androidx.compose.runtime.Composable public androidx.compose.material3.NavigationBarItemColors colors();
method @Deprecated @androidx.compose.runtime.Composable public androidx.compose.material3.NavigationBarItemColors colors(optional long selectedIconColor, optional long selectedTextColor, optional long indicatorColor, optional long unselectedIconColor, optional long unselectedTextColor);
@@ -1577,9 +1547,7 @@
method @androidx.compose.runtime.Composable public static void NavigationBar(optional androidx.compose.ui.Modifier modifier, optional long containerColor, optional long contentColor, optional float tonalElevation, optional androidx.compose.foundation.layout.WindowInsets windowInsets, kotlin.jvm.functions.Function1<? super androidx.compose.foundation.layout.RowScope,kotlin.Unit> content);
method @androidx.compose.runtime.Composable public static void NavigationBarItem(androidx.compose.foundation.layout.RowScope, boolean selected, kotlin.jvm.functions.Function0<kotlin.Unit> onClick, kotlin.jvm.functions.Function0<kotlin.Unit> icon, optional androidx.compose.ui.Modifier modifier, optional boolean enabled, optional kotlin.jvm.functions.Function0<kotlin.Unit>? label, optional boolean alwaysShowLabel, optional androidx.compose.material3.NavigationBarItemColors colors, optional androidx.compose.foundation.interaction.MutableInteractionSource? interactionSource);
method @SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3Api public static androidx.compose.runtime.ProvidableCompositionLocal<androidx.compose.material3.NavigationBarComponentOverride> getLocalNavigationBarComponentOverride();
- method @SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3Api public static androidx.compose.runtime.ProvidableCompositionLocal<androidx.compose.material3.NavigationBarItemComponentOverride> getLocalNavigationBarItemComponentOverride();
property @SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3Api public static final androidx.compose.runtime.ProvidableCompositionLocal<androidx.compose.material3.NavigationBarComponentOverride> LocalNavigationBarComponentOverride;
- property @SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3Api public static final androidx.compose.runtime.ProvidableCompositionLocal<androidx.compose.material3.NavigationBarItemComponentOverride> LocalNavigationBarItemComponentOverride;
}
@androidx.compose.runtime.Stable public interface NavigationDrawerItemColors {
@@ -2282,12 +2250,8 @@
method @SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3ExpressiveApi @androidx.compose.runtime.Composable public static void SplitButtonLayout(kotlin.jvm.functions.Function0<kotlin.Unit> leadingButton, kotlin.jvm.functions.Function0<kotlin.Unit> trailingButton, optional androidx.compose.ui.Modifier modifier, optional float spacing);
}
- public final class SplitButtonShapes {
+ @SuppressCompatibility @androidx.compose.material3.ExperimentalMaterial3ExpressiveApi public final class SplitButtonShapes {
ctor public SplitButtonShapes(androidx.compose.ui.graphics.Shape shape, androidx.compose.ui.graphics.Shape? pressedShape, androidx.compose.ui.graphics.Shape? checkedShape);
- method public androidx.compose.ui.graphics.Shape component1();
- method public androidx.compose.ui.graphics.Shape? component2();
- method public androidx.compose.ui.graphics.Shape? component3();
- method public androidx.compose.material3.SplitButtonShapes copy(androidx.compose.ui.graphics.Shape shape, androidx.compose.ui.graphics.Shape? pressedShape, androidx.compose.ui.graphics.Shape? checkedShape);
method public androidx.compose.ui.graphics.Shape? getCheckedShape();
method public androidx.compose.ui.graphics.Shape? getPressedShape();
method public androidx.compose.ui.graphics.Shape getShape();
diff --git a/compose/material3/material3/src/androidInstrumentedTest/kotlin/androidx/compose/material3/SplitButtonTest.kt b/compose/material3/material3/src/androidInstrumentedTest/kotlin/androidx/compose/material3/SplitButtonTest.kt
index e11e8ad..1029be4 100644
--- a/compose/material3/material3/src/androidInstrumentedTest/kotlin/androidx/compose/material3/SplitButtonTest.kt
+++ b/compose/material3/material3/src/androidInstrumentedTest/kotlin/androidx/compose/material3/SplitButtonTest.kt
@@ -20,28 +20,38 @@
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Edit
import androidx.compose.material.icons.outlined.KeyboardArrowDown
+import androidx.compose.material3.SplitButtonDefaults.InnerCornerSize
+import androidx.compose.material3.SplitButtonDefaults.OuterCornerSize
+import androidx.compose.material3.tokens.SplitButtonSmallTokens
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
+import androidx.compose.ui.geometry.Size
+import androidx.compose.ui.layout.layout
+import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.SemanticsProperties
+import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.test.SemanticsMatcher
import androidx.compose.ui.test.assert
import androidx.compose.ui.test.assertHasClickAction
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsEnabled
+import androidx.compose.ui.test.assertIsEqualTo
import androidx.compose.ui.test.assertIsNotEnabled
import androidx.compose.ui.test.assertIsOff
import androidx.compose.ui.test.assertIsOn
+import androidx.compose.ui.test.getUnclippedBoundsInRoot
import androidx.compose.ui.test.isToggleable
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
+import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.dp
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
@@ -303,4 +313,96 @@
rule.onNodeWithContentDescription("Leading Icon").assertIsDisplayed()
rule.onNodeWithContentDescription("Trailing Icon").assertIsDisplayed()
}
+
+ @Test
+ fun FilledSplitButton_contentPadding() {
+ lateinit var density: Density
+ var trailingButtonSize by mutableStateOf(Size(0f, 0f))
+
+ rule.setMaterialContent(lightColorScheme()) {
+ density = LocalDensity.current
+ SplitButtonLayout(
+ leadingButton = {
+ SplitButtonDefaults.LeadingButton(
+ onClick = { /* Do Nothing */ },
+ modifier = Modifier.testTag("leading button"),
+ enabled = false
+ ) {
+ Text(
+ "My Button",
+ modifier =
+ Modifier.testTag(TextTag).semantics(mergeDescendants = true) {}
+ )
+ }
+ },
+ trailingButton = {
+ SplitButtonDefaults.TrailingButton(
+ onCheckedChange = {},
+ checked = false,
+ modifier =
+ Modifier.layout { measurable, constraints ->
+ val placeable = measurable.measure(constraints)
+ val width = placeable.width
+ val height = placeable.height
+ trailingButtonSize = Size(width.toFloat(), height.toFloat())
+ layout(width, height) { placeable.place(0, 0) }
+ }
+ .testTag("trailing button"),
+ enabled = false,
+ ) {
+ Icon(
+ Icons.Outlined.KeyboardArrowDown,
+ contentDescription = "Trailing Icon",
+ modifier =
+ Modifier.testTag(IconTag).semantics(mergeDescendants = true) {}
+ )
+ }
+ }
+ )
+ }
+
+ val trailingButtonTopStartPx = InnerCornerSize.toPx(trailingButtonSize, density)
+ val trailingButtonTopEndPx = OuterCornerSize.toPx(trailingButtonSize, density) / 2
+
+ val paddingPxCorrection =
+ CenterOpticallyCoefficient * (trailingButtonTopStartPx - trailingButtonTopEndPx)
+
+ val expectedTrailingButtonStartPadding =
+ with(density) {
+ SplitButtonSmallTokens.TrailingButtonLeadingSpace + paddingPxCorrection.toDp()
+ }
+
+ val expectedTrailingButtonEndPadding =
+ with(density) {
+ SplitButtonSmallTokens.TrailingButtonTrailingSpace - paddingPxCorrection.toDp()
+ }
+
+ val leadingButtonBounds = rule.onNodeWithTag("leading button").getUnclippedBoundsInRoot()
+
+ val textBounds = rule.onNodeWithTag(TextTag).getUnclippedBoundsInRoot()
+
+ val trailingButtonBounds = rule.onNodeWithTag("trailing button").getUnclippedBoundsInRoot()
+
+ val iconBounds = rule.onNodeWithTag(IconTag).getUnclippedBoundsInRoot()
+
+ (textBounds.left - leadingButtonBounds.left).assertIsEqualTo(
+ SplitButtonSmallTokens.LeadingButtonLeadingSpace,
+ "start padding for leading button"
+ )
+ (leadingButtonBounds.right - textBounds.right).assertIsEqualTo(
+ SplitButtonSmallTokens.LeadingButtonTrailingSpace,
+ "end padding for leading button"
+ )
+ (iconBounds.left - trailingButtonBounds.left).assertIsEqualTo(
+ expectedTrailingButtonStartPadding,
+ "start padding for trailing button"
+ )
+ (trailingButtonBounds.right - iconBounds.right).assertIsEqualTo(
+ expectedTrailingButtonEndPadding,
+ "end padding for trailing button"
+ )
+ }
}
+
+private const val TextTag = "text tag"
+private const val IconTag = "icon tag"
diff --git a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/AppBar.kt b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/AppBar.kt
index 286b0150..de92be1 100644
--- a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/AppBar.kt
+++ b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/AppBar.kt
@@ -2226,18 +2226,19 @@
): Offset {
if (!canScroll()) return Offset.Zero
state.contentOffset += consumed.y
- if (state.heightOffset == 0f || state.heightOffset == state.heightOffsetLimit) {
- if (consumed.y == 0f && available.y > 0f) {
- // Reset the total content offset to zero when scrolling all the way down.
- // This will eliminate some float precision inaccuracies.
- state.contentOffset = 0f
- }
- }
state.heightOffset = state.heightOffset + consumed.y
return Offset.Zero
}
override suspend fun onPostFling(consumed: Velocity, available: Velocity): Velocity {
+ if (
+ available.y > 0f &&
+ (state.heightOffset == 0f || state.heightOffset == state.heightOffsetLimit)
+ ) {
+ // Reset the total content offset to zero when scrolling all the way down.
+ // This will eliminate some float precision inaccuracies.
+ state.contentOffset = 0f
+ }
val superConsumed = super.onPostFling(consumed, available)
return superConsumed +
settleAppBarBottom(state, available.y, flingAnimationSpec, snapAnimationSpec)
@@ -2837,14 +2838,17 @@
source: NestedScrollSource
): Offset {
if (!canScroll()) return Offset.Zero
- if (consumed.y == 0f && available.y > 0f) {
+ state.contentOffset += consumed.y
+ return Offset.Zero
+ }
+
+ override suspend fun onPostFling(consumed: Velocity, available: Velocity): Velocity {
+ if (available.y > 0f) {
// Reset the total content offset to zero when scrolling all the way down.
// This will eliminate some float precision inaccuracies.
state.contentOffset = 0f
- } else {
- state.contentOffset += consumed.y
}
- return Offset.Zero
+ return super.onPostFling(consumed, available)
}
}
}
@@ -2904,18 +2908,19 @@
): Offset {
if (!canScroll()) return Offset.Zero
state.contentOffset += consumed.y
- if (state.heightOffset == 0f || state.heightOffset == state.heightOffsetLimit) {
- if (consumed.y == 0f && available.y > 0f) {
- // Reset the total content offset to zero when scrolling all the way down.
- // This will eliminate some float precision inaccuracies.
- state.contentOffset = 0f
- }
- }
if (!reverseLayout) state.heightOffset += consumed.y
return Offset.Zero
}
override suspend fun onPostFling(consumed: Velocity, available: Velocity): Velocity {
+ if (
+ available.y > 0f &&
+ (state.heightOffset == 0f || state.heightOffset == state.heightOffsetLimit)
+ ) {
+ // Reset the total content offset to zero when scrolling all the way down.
+ // This will eliminate some float precision inaccuracies.
+ state.contentOffset = 0f
+ }
val superConsumed = super.onPostFling(consumed, available)
return superConsumed +
settleAppBar(state, available.y, flingAnimationSpec, snapAnimationSpec)
@@ -2980,12 +2985,6 @@
return Offset(0f, state.heightOffset - oldHeightOffset)
}
- if (consumed.y == 0f && available.y > 0) {
- // Reset the total content offset to zero when scrolling all the way down. This
- // will eliminate some float precision inaccuracies.
- state.contentOffset = 0f
- }
-
if (available.y > 0f) {
// Adjust the height offset in case the consumed delta Y is less than what was
// recorded as available delta Y in the pre-scroll.
@@ -2997,6 +2996,11 @@
}
override suspend fun onPostFling(consumed: Velocity, available: Velocity): Velocity {
+ if (available.y > 0) {
+ // Reset the total content offset to zero when scrolling all the way down. This
+ // will eliminate some float precision inaccuracies.
+ state.contentOffset = 0f
+ }
val superConsumed = super.onPostFling(consumed, available)
return superConsumed +
settleAppBar(state, available.y, flingAnimationSpec, snapAnimationSpec)
diff --git a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/NavigationBar.kt b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/NavigationBar.kt
index 659ea38..8c95113 100644
--- a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/NavigationBar.kt
+++ b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/NavigationBar.kt
@@ -165,7 +165,6 @@
* preview the item in different states. Note that if `null` is provided, interactions will still
* happen internally.
*/
-@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun RowScope.NavigationBarItem(
selected: Boolean,
@@ -178,20 +177,117 @@
colors: NavigationBarItemColors = NavigationBarItemDefaults.colors(),
interactionSource: MutableInteractionSource? = null
) {
- val context =
- NavigationBarItemComponentOverrideContext(
- isSelected = selected,
- onClick = onClick,
- icon = icon,
- modifier = modifier,
- isEnabled = enabled,
- label = label,
- shouldAlwaysShowLabel = alwaysShowLabel,
- colors = colors,
- interactionSource = interactionSource,
- scope = this
+ @Suppress("NAME_SHADOWING")
+ val interactionSource = interactionSource ?: remember { MutableInteractionSource() }
+ // TODO Load the motionScheme tokens from the component tokens file
+ val colorAnimationSpec = MotionSchemeKeyTokens.DefaultEffects.value<Color>()
+ val styledIcon =
+ @Composable {
+ val iconColor by
+ animateColorAsState(
+ targetValue = colors.iconColor(selected = selected, enabled = enabled),
+ animationSpec = colorAnimationSpec
+ )
+ // If there's a label, don't have a11y services repeat the icon description.
+ val clearSemantics = label != null && (alwaysShowLabel || selected)
+ Box(modifier = if (clearSemantics) Modifier.clearAndSetSemantics {} else Modifier) {
+ CompositionLocalProvider(LocalContentColor provides iconColor, content = icon)
+ }
+ }
+
+ val styledLabel: @Composable (() -> Unit)? =
+ label?.let {
+ @Composable {
+ val style = NavigationBarTokens.LabelTextFont.value
+ val textColor by
+ animateColorAsState(
+ targetValue = colors.textColor(selected = selected, enabled = enabled),
+ animationSpec = colorAnimationSpec
+ )
+ ProvideContentColorTextStyle(
+ contentColor = textColor,
+ textStyle = style,
+ content = label
+ )
+ }
+ }
+
+ var itemWidth by remember { mutableIntStateOf(0) }
+
+ Box(
+ modifier
+ .selectable(
+ selected = selected,
+ onClick = onClick,
+ enabled = enabled,
+ role = Role.Tab,
+ interactionSource = interactionSource,
+ indication = null,
+ )
+ .defaultMinSize(minHeight = NavigationBarHeight)
+ .weight(1f)
+ .onSizeChanged { itemWidth = it.width },
+ contentAlignment = Alignment.Center,
+ propagateMinConstraints = true,
+ ) {
+ val alphaAnimationProgress: State<Float> =
+ animateFloatAsState(
+ targetValue = if (selected) 1f else 0f,
+ // TODO Load the motionScheme tokens from the component tokens file
+ animationSpec = MotionSchemeKeyTokens.DefaultEffects.value()
+ )
+ val sizeAnimationProgress: State<Float> =
+ animateFloatAsState(
+ targetValue = if (selected) 1f else 0f,
+ // TODO Load the motionScheme tokens from the component tokens file
+ animationSpec = MotionSchemeKeyTokens.FastSpatial.value()
+ )
+ // The entire item is selectable, but only the indicator pill shows the ripple. To achieve
+ // this, we re-map the coordinates of the item's InteractionSource into the coordinates of
+ // the indicator.
+ val deltaOffset: Offset
+ with(LocalDensity.current) {
+ val indicatorWidth = NavigationBarVerticalItemTokens.ActiveIndicatorWidth.roundToPx()
+ deltaOffset =
+ Offset((itemWidth - indicatorWidth).toFloat() / 2, IndicatorVerticalOffset.toPx())
+ }
+ val offsetInteractionSource =
+ remember(interactionSource, deltaOffset) {
+ MappedInteractionSource(interactionSource, deltaOffset)
+ }
+
+ // The indicator has a width-expansion animation which interferes with the timing of the
+ // ripple, which is why they are separate composables
+ val indicatorRipple =
+ @Composable {
+ Box(
+ Modifier.layoutId(IndicatorRippleLayoutIdTag)
+ .clip(NavigationBarTokens.ItemActiveIndicatorShape.value)
+ .indication(offsetInteractionSource, ripple())
+ )
+ }
+ val indicator =
+ @Composable {
+ Box(
+ Modifier.layoutId(IndicatorLayoutIdTag)
+ .graphicsLayer { alpha = alphaAnimationProgress.value }
+ .background(
+ color = colors.indicatorColor,
+ shape = NavigationBarTokens.ItemActiveIndicatorShape.value,
+ )
+ )
+ }
+
+ NavigationBarItemLayout(
+ indicatorRipple = indicatorRipple,
+ indicator = indicator,
+ icon = styledIcon,
+ label = styledLabel,
+ alwaysShowLabel = alwaysShowLabel,
+ alphaAnimationProgress = { alphaAnimationProgress.value },
+ sizeAnimationProgress = { sizeAnimationProgress.value }
)
- with(LocalNavigationBarItemComponentOverride.current) { context.NavigationBarItem() }
+ }
}
/** Defaults used in [NavigationBar]. */
@@ -637,187 +733,6 @@
private val IndicatorVerticalOffset: Dp = 12.dp
-/* Interface that allows libraries to override the behavior of the [NavigationBarItem] component. */
-@ExperimentalMaterial3Api
-interface NavigationBarItemComponentOverride {
- /** Behavior function that is called by the [NavigationBarItem] component. */
- @Composable fun NavigationBarItemComponentOverrideContext.NavigationBarItem()
-}
-
-/**
- * Parameters available to [NavigationBarItem].
- *
- * @param isSelected whether this item is selected
- * @param onClick called when this item is clicked
- * @param icon icon for this item, typically an [Icon]
- * @param modifier the [Modifier] to be applied to this item
- * @param isEnabled controls the enabled state of this item. When `false`, this component will not
- * respond to user input, and it will appear visually disabled and disabled to accessibility
- * services.
- * @param label optional text label for this item
- * @param shouldAlwaysShowLabel whether to always show the label for this item. If `false`, the
- * label will only be shown when this item is selected.
- * @param colors [NavigationBarItemColors] that will be used to resolve the colors used for this
- * item in different states. See [NavigationBarItemDefaults.colors].
- * @param interactionSource an optional hoisted [MutableInteractionSource] for observing and
- * emitting [Interaction]s for this item. You can use this to change the item's appearance or
- * preview the item in different states. Note that if `null` is provided, interactions will still
- * happen internally.
- */
-@ExperimentalMaterial3Api
-class NavigationBarItemComponentOverrideContext
-internal constructor(
- val isSelected: Boolean,
- val onClick: () -> Unit,
- val icon: @Composable () -> Unit,
- val modifier: Modifier,
- val isEnabled: Boolean,
- val label: @Composable (() -> Unit)?,
- val shouldAlwaysShowLabel: Boolean,
- val colors: NavigationBarItemColors,
- val interactionSource: MutableInteractionSource?,
- scope: RowScope
-) : RowScope by scope
-
-/** [NavigationBarItemComponentOverride] used when no override is specified. */
-@ExperimentalMaterial3Api
-object DefaultNavigationBarItemComponentOverride : NavigationBarItemComponentOverride {
- @Composable
- override fun NavigationBarItemComponentOverrideContext.NavigationBarItem() {
- @Suppress("NAME_SHADOWING")
- val interactionSource = interactionSource ?: remember { MutableInteractionSource() }
- // TODO Load the motionScheme tokens from the component tokens file
- val colorAnimationSpec = MotionSchemeKeyTokens.DefaultEffects.value<Color>()
- val styledIcon =
- @Composable {
- val iconColor by
- animateColorAsState(
- targetValue = colors.iconColor(selected = isSelected, enabled = isEnabled),
- animationSpec = colorAnimationSpec
- )
- // If there's a label, don't have a11y services repeat the icon description.
- val clearSemantics = label != null && (shouldAlwaysShowLabel || isSelected)
- Box(modifier = if (clearSemantics) Modifier.clearAndSetSemantics {} else Modifier) {
- CompositionLocalProvider(
- LocalContentColor provides iconColor,
- content = [email protected]
- )
- }
- }
-
- val styledLabel: @Composable (() -> Unit)? =
- label?.let {
- @Composable {
- val style = NavigationBarTokens.LabelTextFont.value
- val textColor by
- animateColorAsState(
- targetValue =
- colors.textColor(selected = isSelected, enabled = isEnabled),
- animationSpec = colorAnimationSpec
- )
- ProvideContentColorTextStyle(
- contentColor = textColor,
- textStyle = style,
- content = label
- )
- }
- }
-
- var itemWidth by remember { mutableIntStateOf(0) }
-
- Box(
- modifier
- .selectable(
- selected = isSelected,
- onClick = onClick,
- enabled = isEnabled,
- role = Role.Tab,
- interactionSource = interactionSource,
- indication = null,
- )
- .defaultMinSize(minHeight = NavigationBarHeight)
- .weight(1f)
- .onSizeChanged { itemWidth = it.width },
- contentAlignment = Alignment.Center,
- propagateMinConstraints = true,
- ) {
- val alphaAnimationProgress: State<Float> =
- animateFloatAsState(
- targetValue = if ([email protected]) 1f else 0f,
- // TODO Load the motionScheme tokens from the component tokens file
- animationSpec = MotionSchemeKeyTokens.DefaultEffects.value()
- )
- val sizeAnimationProgress: State<Float> =
- animateFloatAsState(
- targetValue = if ([email protected]) 1f else 0f,
- // TODO Load the motionScheme tokens from the component tokens file
- animationSpec = MotionSchemeKeyTokens.FastSpatial.value()
- )
- // The entire item is selectable, but only the indicator pill shows the ripple. To
- // achieve
- // this, we re-map the coordinates of the item's InteractionSource into the coordinates
- // of
- // the indicator.
- val deltaOffset: Offset
- with(LocalDensity.current) {
- val indicatorWidth =
- NavigationBarVerticalItemTokens.ActiveIndicatorWidth.roundToPx()
- deltaOffset =
- Offset(
- (itemWidth - indicatorWidth).toFloat() / 2,
- IndicatorVerticalOffset.toPx()
- )
- }
- val offsetInteractionSource =
- remember(interactionSource, deltaOffset) {
- MappedInteractionSource(interactionSource, deltaOffset)
- }
-
- // The indicator has a width-expansion animation which interferes with the timing of the
- // ripple, which is why they are separate composables
- val indicatorRipple =
- @Composable {
- Box(
- Modifier.layoutId(IndicatorRippleLayoutIdTag)
- .clip(NavigationBarTokens.ItemActiveIndicatorShape.value)
- .indication(offsetInteractionSource, ripple())
- )
- }
- val indicator =
- @Composable {
- Box(
- Modifier.layoutId(IndicatorLayoutIdTag)
- .graphicsLayer { alpha = alphaAnimationProgress.value }
- .background(
- color = [email protected],
- shape = NavigationBarTokens.ItemActiveIndicatorShape.value,
- )
- )
- }
-
- NavigationBarItemLayout(
- indicatorRipple = indicatorRipple,
- indicator = indicator,
- icon = styledIcon,
- label = styledLabel,
- alwaysShowLabel = [email protected],
- alphaAnimationProgress = { alphaAnimationProgress.value },
- sizeAnimationProgress = { sizeAnimationProgress.value }
- )
- }
- }
-}
-
-/** CompositionLocal containing the currently-selected [NavigationBarItemComponentOverride]. */
-@Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
-@get:ExperimentalMaterial3Api
-@ExperimentalMaterial3Api
-val LocalNavigationBarItemComponentOverride:
- ProvidableCompositionLocal<NavigationBarItemComponentOverride> =
- compositionLocalOf {
- DefaultNavigationBarItemComponentOverride
- }
-
/** Interface that allows libraries to override the behavior of the [NavigationBar] component. */
@ExperimentalMaterial3Api
interface NavigationBarComponentOverride {
diff --git a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/SplitButton.kt b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/SplitButton.kt
index d0f7dd7..d4c416f 100644
--- a/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/SplitButton.kt
+++ b/compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/SplitButton.kt
@@ -445,10 +445,11 @@
)
}
else -> {
- Modifier.padding(contentPadding)
+ Modifier
}
}
- ),
+ )
+ .padding(contentPadding),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
content = content
@@ -570,10 +571,11 @@
)
}
else -> {
- Modifier.padding(contentPadding)
+ Modifier
}
}
- ),
+ )
+ .padding(contentPadding),
horizontalArrangement = Arrangement.Center,
verticalAlignment = Alignment.CenterVertically,
content = content
@@ -946,6 +948,7 @@
}
}
+@OptIn(ExperimentalMaterial3ExpressiveApi::class)
@Composable
private fun shapeByInteraction(
shapes: SplitButtonShapes,
@@ -974,9 +977,34 @@
* @property pressedShape is the pressed shape.
* @property checkedShape is the checked shape.
*/
-data class SplitButtonShapes(val shape: Shape, val pressedShape: Shape?, val checkedShape: Shape?)
+@ExperimentalMaterial3ExpressiveApi
+class SplitButtonShapes(val shape: Shape, val pressedShape: Shape?, val checkedShape: Shape?) {
+ override fun equals(other: Any?): Boolean {
+ if (this === other) return true
+ if (other == null || other !is SplitButtonShapes) return false
-internal val SplitButtonShapes.hasRoundedCornerShapes: Boolean
+ if (shape != other.shape) return false
+ if (pressedShape != other.pressedShape) return false
+ if (checkedShape != other.checkedShape) return false
+
+ return true
+ }
+
+ override fun hashCode(): Int {
+ var result = shape.hashCode()
+ if (pressedShape != null) {
+ result = 31 * result + pressedShape.hashCode()
+ }
+ if (checkedShape != null) {
+ result = 31 * result + checkedShape.hashCode()
+ }
+
+ return result
+ }
+}
+
+@OptIn(ExperimentalMaterial3ExpressiveApi::class)
+private val SplitButtonShapes.hasRoundedCornerShapes: Boolean
get() {
// Ignore null shapes and only check default shape for RoundedCorner
if (pressedShape != null && pressedShape !is RoundedCornerShape) return false
diff --git a/compose/ui/ui-graphics/src/androidInstrumentedTest/kotlin/androidx/compose/ui/graphics/PaintTest.kt b/compose/ui/ui-graphics/src/androidInstrumentedTest/kotlin/androidx/compose/ui/graphics/PaintTest.kt
index 717ea76..e842ab1 100644
--- a/compose/ui/ui-graphics/src/androidInstrumentedTest/kotlin/androidx/compose/ui/graphics/PaintTest.kt
+++ b/compose/ui/ui-graphics/src/androidInstrumentedTest/kotlin/androidx/compose/ui/graphics/PaintTest.kt
@@ -16,6 +16,8 @@
package androidx.compose.ui.graphics
+import android.os.Build
+import androidx.compose.ui.graphics.colorspace.ColorSpaces
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import org.junit.Assert.assertEquals
@@ -46,6 +48,30 @@
}
@Test
+ fun testColorLongConfiguration() {
+ val paint = Paint()
+ val red = 0.8916f
+ val green = 0.4980f
+ val blue = 0.1168f
+ val adobeColor = Color(red, green, blue, colorSpace = ColorSpaces.AdobeRgb)
+ paint.color = adobeColor
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ val delta = 0.001f
+ val colorLong = paint.asFrameworkPaint().colorLong
+ assertEquals(1f, android.graphics.Color.alpha(colorLong), delta)
+ assertEquals(red, android.graphics.Color.red(colorLong), delta)
+ assertEquals(green, android.graphics.Color.green(colorLong), delta)
+ assertEquals(blue, android.graphics.Color.blue(colorLong), delta)
+ assertEquals(
+ ColorSpaces.AdobeRgb,
+ android.graphics.Color.colorSpace(colorLong).toComposeColorSpace()
+ )
+ } else {
+ assertEquals(paint.asFrameworkPaint().color, adobeColor.toArgb())
+ }
+ }
+
+ @Test
fun testPathGetterSetter() {
val paint = Paint()
val pathEffect = PathEffect.dashPathEffect(floatArrayOf(10f, 5f), 20f)
diff --git a/compose/ui/ui-graphics/src/androidInstrumentedTest/kotlin/androidx/compose/ui/graphics/ShaderTest.kt b/compose/ui/ui-graphics/src/androidInstrumentedTest/kotlin/androidx/compose/ui/graphics/ShaderTest.kt
index 5f7dc09..e2113fb 100644
--- a/compose/ui/ui-graphics/src/androidInstrumentedTest/kotlin/androidx/compose/ui/graphics/ShaderTest.kt
+++ b/compose/ui/ui-graphics/src/androidInstrumentedTest/kotlin/androidx/compose/ui/graphics/ShaderTest.kt
@@ -16,8 +16,11 @@
package androidx.compose.ui.graphics
+import android.os.Build
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
+import androidx.compose.ui.graphics.colorspace.ColorSpace
+import androidx.compose.ui.graphics.colorspace.ColorSpaces
import androidx.compose.ui.graphics.drawscope.CanvasDrawScope
import androidx.compose.ui.graphics.drawscope.DrawScope
import androidx.compose.ui.unit.Density
@@ -31,6 +34,9 @@
import org.junit.Test
import org.junit.runner.RunWith
+val RedDisplayP3 = Color(red = 1f, green = 0f, blue = 0f, colorSpace = ColorSpaces.DisplayP3)
+val BlueDisplayP3 = Color(red = 0f, green = 0f, blue = 1f, colorSpace = ColorSpaces.DisplayP3)
+
@SmallTest
@RunWith(AndroidJUnit4::class)
class ShaderTest {
@@ -65,6 +71,37 @@
}
@Test
+ fun testLinearGradientColorLong() {
+ val imageBitmap = ImageBitmap(100, 100, ImageBitmapConfig.F16)
+ imageBitmap.drawInto {
+ drawRect(
+ brush =
+ Brush.linearGradient(
+ 0.0f to RedDisplayP3,
+ 0.5f to RedDisplayP3,
+ 0.5f to BlueDisplayP3,
+ 1.0f to BlueDisplayP3,
+ start = Offset.Zero,
+ end = Offset(0.0f, 100f),
+ tileMode = TileMode.Clamp
+ )
+ )
+ }
+
+ val centerX = imageBitmap.width / 2
+ val centerY = imageBitmap.height / 2
+ val bitmapColorSpace = imageBitmap.colorSpace
+ val convertedRed = RedDisplayP3.convertColorCompat(bitmapColorSpace)
+ val convertedBlue = BlueDisplayP3.convertColorCompat(bitmapColorSpace)
+ verifyColor(convertedRed, imageBitmap.getComposeColor(centerX, centerY - 5))
+ verifyColor(convertedBlue, imageBitmap.getComposeColor(centerX, centerY + 5))
+ verifyColor(convertedRed, imageBitmap.getComposeColor(5, centerY - 5))
+ verifyColor(convertedBlue, imageBitmap.getComposeColor(5, centerY + 5))
+ verifyColor(convertedRed, imageBitmap.getComposeColor(imageBitmap.width - 5, centerY - 5))
+ verifyColor(convertedBlue, imageBitmap.getComposeColor(imageBitmap.width - 5, centerY + 5))
+ }
+
+ @Test
fun testRadialGradient() {
val imageBitmap = ImageBitmap(100, 100)
@@ -98,6 +135,40 @@
}
@Test
+ fun testRadialGradientColorLong() {
+ val imageBitmap = ImageBitmap(100, 100, config = ImageBitmapConfig.F16)
+
+ imageBitmap.drawInto {
+ drawCircle(
+ brush =
+ Brush.radialGradient(
+ 0.0f to RedDisplayP3,
+ 0.5f to RedDisplayP3,
+ 0.5f to BlueDisplayP3,
+ 1.0f to BlueDisplayP3,
+ center = Offset(50f, 50f),
+ radius = 50f,
+ tileMode = TileMode.Clamp
+ )
+ )
+ }
+
+ val bitmapColorSpace = imageBitmap.colorSpace
+ val convertedRed = RedDisplayP3.convertColorCompat(bitmapColorSpace)
+ val convertedBlue = BlueDisplayP3.convertColorCompat(bitmapColorSpace)
+ verifyColor(convertedRed, imageBitmap.getComposeColor(50, 50))
+ verifyColor(convertedRed, imageBitmap.getComposeColor(50, 30))
+ verifyColor(convertedRed, imageBitmap.getComposeColor(70, 50))
+ verifyColor(convertedRed, imageBitmap.getComposeColor(50, 70))
+ verifyColor(convertedRed, imageBitmap.getComposeColor(30, 50))
+
+ verifyColor(convertedBlue, imageBitmap.getComposeColor(50, 20))
+ verifyColor(convertedBlue, imageBitmap.getComposeColor(80, 50))
+ verifyColor(convertedBlue, imageBitmap.getComposeColor(50, 80))
+ verifyColor(convertedBlue, imageBitmap.getComposeColor(20, 50))
+ }
+
+ @Test
fun testSweepGradient() {
val imageBitmap = ImageBitmap(100, 100)
val center = Offset(50f, 50f)
@@ -126,6 +197,69 @@
}
@Test
+ fun testSweepGradientColorLong() {
+ val imageBitmap = ImageBitmap(100, 100, config = ImageBitmapConfig.F16)
+ val center = Offset(50f, 50f)
+ imageBitmap.drawInto {
+ drawRect(
+ brush =
+ Brush.sweepGradient(
+ 0.0f to RedDisplayP3,
+ 0.5f to RedDisplayP3,
+ 0.5f to BlueDisplayP3,
+ 1.0f to BlueDisplayP3,
+ center = center
+ )
+ )
+ }
+
+ val bitmapColorSpace = imageBitmap.colorSpace
+ val convertedRed = RedDisplayP3.convertColorCompat(bitmapColorSpace)
+ val convertedBlue = BlueDisplayP3.convertColorCompat(bitmapColorSpace)
+ val centerX = center.x.roundToInt()
+ val centerY = center.y.roundToInt()
+
+ verifyColor(convertedRed, imageBitmap.getComposeColor(centerX, centerY + 5))
+ verifyColor(convertedBlue, imageBitmap.getComposeColor(centerX, centerY - 5))
+ verifyColor(convertedRed, imageBitmap.getComposeColor(centerX * 2 - 5, centerY + 5))
+ verifyColor(convertedBlue, imageBitmap.getComposeColor(centerX * 2 - 5, centerY - 5))
+ verifyColor(convertedRed, imageBitmap.getComposeColor(5, centerY + 5))
+ verifyColor(convertedBlue, imageBitmap.getComposeColor(5, centerY - 5))
+ }
+
+ private fun Color.convertColorCompat(dst: ColorSpace): Color {
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ convert(dst)
+ } else {
+ // Bitmap#getColor was not introduced until Android Q, so convert to argb for these
+ // platform versions ad Bitmap#getPixel is the only fallback
+ Color(this.toArgb())
+ }
+ }
+
+ private fun ImageBitmap.getComposeColor(x: Int, y: Int): Color {
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ val androidColor = asAndroidBitmap().getColor(x, y)
+ Color(
+ red = androidColor.red(),
+ green = androidColor.green(),
+ blue = androidColor.blue(),
+ alpha = androidColor.alpha(),
+ colorSpace = androidColor.colorSpace.toComposeColorSpace()
+ )
+ } else {
+ Color(this.asAndroidBitmap().getPixel(x, y))
+ }
+ }
+
+ private fun verifyColor(expected: Color, actual: Color) {
+ assertEquals(expected.red, actual.red, 0.01f)
+ assertEquals(expected.green, actual.green, 0.01f)
+ assertEquals(expected.blue, actual.blue, 0.01f)
+ assertEquals(expected.colorSpace, actual.colorSpace)
+ }
+
+ @Test
fun testLinearGradientIntrinsicSize() {
assertEquals(
Size(100f, 200f),
diff --git a/compose/ui/ui-graphics/src/androidMain/kotlin/androidx/compose/ui/graphics/AndroidPaint.android.kt b/compose/ui/ui-graphics/src/androidMain/kotlin/androidx/compose/ui/graphics/AndroidPaint.android.kt
index 6070726..1aa37ff 100644
--- a/compose/ui/ui-graphics/src/androidMain/kotlin/androidx/compose/ui/graphics/AndroidPaint.android.kt
+++ b/compose/ui/ui-graphics/src/androidMain/kotlin/androidx/compose/ui/graphics/AndroidPaint.android.kt
@@ -18,6 +18,7 @@
import android.graphics.PorterDuffXfermode
import android.os.Build
+import androidx.annotation.DoNotInline
import androidx.annotation.RequiresApi
actual typealias NativePaint = android.graphics.Paint
@@ -165,7 +166,12 @@
internal fun NativePaint.getNativeColor(): Color = Color(this.color)
internal fun NativePaint.setNativeColor(value: Color) {
- this.color = value.toArgb()
+ // ColorSpace support was introduced in Android Q
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ WrapperVerificationHelperMethods.setColor(this, value)
+ } else {
+ this.color = value.toArgb()
+ }
}
internal fun NativePaint.setNativeStyle(value: PaintingStyle) {
@@ -262,7 +268,16 @@
*/
@RequiresApi(Build.VERSION_CODES.Q)
internal object WrapperVerificationHelperMethods {
+
+ @DoNotInline
fun setBlendMode(paint: NativePaint, mode: BlendMode) {
paint.blendMode = mode.toAndroidBlendMode()
}
+
+ @DoNotInline
+ fun setColor(paint: NativePaint, color: Color) {
+ // Must use function call syntax instead of property syntax as get/setColor invokes only
+ // the setColor(int) overload instead of setColor(long)
+ paint.setColor(color.value.toLong())
+ }
}
diff --git a/compose/ui/ui-graphics/src/androidMain/kotlin/androidx/compose/ui/graphics/AndroidShader.android.kt b/compose/ui/ui-graphics/src/androidMain/kotlin/androidx/compose/ui/graphics/AndroidShader.android.kt
index 95a0d91..afe0e69 100644
--- a/compose/ui/ui-graphics/src/androidMain/kotlin/androidx/compose/ui/graphics/AndroidShader.android.kt
+++ b/compose/ui/ui-graphics/src/androidMain/kotlin/androidx/compose/ui/graphics/AndroidShader.android.kt
@@ -16,11 +16,14 @@
package androidx.compose.ui.graphics
+import android.annotation.SuppressLint
import android.graphics.BitmapShader
import android.graphics.LinearGradient
import android.graphics.RadialGradient
import android.graphics.SweepGradient
import android.os.Build
+import androidx.annotation.DoNotInline
+import androidx.annotation.RequiresApi
import androidx.annotation.VisibleForTesting
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.util.fastForEachIndexed
@@ -35,16 +38,26 @@
tileMode: TileMode
): Shader {
validateColorStops(colors, colorStops)
- val numTransparentColors = countTransparentColors(colors)
- return LinearGradient(
- from.x,
- from.y,
- to.x,
- to.y,
- makeTransparentColors(colors, numTransparentColors),
- makeTransparentStops(colorStops, colors, numTransparentColors),
- tileMode.toAndroidTileMode()
- )
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ GradientColorLongVerifier.createLinearGradientColorLong(
+ from,
+ to,
+ colors.toLongArray(),
+ colorStops?.toFloatArray(),
+ tileMode
+ )
+ } else {
+ val numTransparentColors = countTransparentColors(colors)
+ LinearGradient(
+ from.x,
+ from.y,
+ to.x,
+ to.y,
+ makeTransparentColors(colors, numTransparentColors),
+ makeTransparentStops(colorStops, colors, numTransparentColors),
+ tileMode.toAndroidTileMode()
+ )
+ }
}
internal actual fun ActualRadialGradientShader(
@@ -55,15 +68,58 @@
tileMode: TileMode
): Shader {
validateColorStops(colors, colorStops)
- val numTransparentColors = countTransparentColors(colors)
- return RadialGradient(
- center.x,
- center.y,
- radius,
- makeTransparentColors(colors, numTransparentColors),
- makeTransparentStops(colorStops, colors, numTransparentColors),
- tileMode.toAndroidTileMode()
- )
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ GradientColorLongVerifier.createRadialGradientColorLong(
+ center,
+ radius,
+ colors.toLongArray(),
+ colorStops?.toFloatArray(),
+ tileMode
+ )
+ } else {
+ val numTransparentColors = countTransparentColors(colors)
+ RadialGradient(
+ center.x,
+ center.y,
+ radius,
+ makeTransparentColors(colors, numTransparentColors),
+ makeTransparentStops(colorStops, colors, numTransparentColors),
+ tileMode.toAndroidTileMode()
+ )
+ }
+}
+
+/**
+ * Internal helper method used to maintain the API surface and convert to a LongArray for creating
+ * gradients within the Android platform
+ */
+@SuppressLint("PrimitiveInCollection")
+private fun List<Color>.toLongArray(): LongArray = LongArray(size) { i -> this[i].value.toLong() }
+
+@RequiresApi(Build.VERSION_CODES.Q)
+private object GradientColorLongVerifier {
+
+ @DoNotInline
+ fun createRadialGradientColorLong(
+ center: Offset,
+ radius: Float,
+ colors: LongArray,
+ colorStops: FloatArray?,
+ tileMode: TileMode
+ ) = RadialGradient(center.x, center.y, radius, colors, colorStops, tileMode.toAndroidTileMode())
+
+ @DoNotInline
+ fun createSweepGradientColorLong(center: Offset, colors: LongArray, colorStops: FloatArray?) =
+ SweepGradient(center.x, center.y, colors, colorStops)
+
+ @DoNotInline
+ fun createLinearGradientColorLong(
+ from: Offset,
+ to: Offset,
+ colors: LongArray,
+ colorStops: FloatArray?,
+ tileMode: TileMode
+ ) = LinearGradient(from.x, from.y, to.x, to.y, colors, colorStops, tileMode.toAndroidTileMode())
}
internal actual fun ActualSweepGradientShader(
@@ -72,13 +128,21 @@
colorStops: List<Float>?
): Shader {
validateColorStops(colors, colorStops)
- val numTransparentColors = countTransparentColors(colors)
- return SweepGradient(
- center.x,
- center.y,
- makeTransparentColors(colors, numTransparentColors),
- makeTransparentStops(colorStops, colors, numTransparentColors),
- )
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ GradientColorLongVerifier.createSweepGradientColorLong(
+ center,
+ colors.toLongArray(),
+ colorStops?.toFloatArray()
+ )
+ } else {
+ val numTransparentColors = countTransparentColors(colors)
+ SweepGradient(
+ center.x,
+ center.y,
+ makeTransparentColors(colors, numTransparentColors),
+ makeTransparentStops(colorStops, colors, numTransparentColors),
+ )
+ }
}
internal actual fun ActualImageShader(
diff --git a/compose/ui/ui-inspection/src/androidTest/AndroidManifest.xml b/compose/ui/ui-inspection/src/androidTest/AndroidManifest.xml
index 63c0b01c..60d7747 100644
--- a/compose/ui/ui-inspection/src/androidTest/AndroidManifest.xml
+++ b/compose/ui/ui-inspection/src/androidTest/AndroidManifest.xml
@@ -16,6 +16,7 @@
<application>
<activity android:name="androidx.compose.ui.inspection.testdata.AndroidViewTestActivity" />
+ <activity android:name="androidx.compose.ui.inspection.testdata.BoxWithConstraintsDialogTestActivity" />
<activity android:name="androidx.compose.ui.inspection.testdata.ComposeViewTestActivity" />
<activity android:name="androidx.compose.ui.inspection.testdata.DialogTestActivity" />
<activity android:name="androidx.compose.ui.inspection.testdata.ParametersTestActivity" />
diff --git a/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/BoxWithConstraintsDialogTest.kt b/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/BoxWithConstraintsDialogTest.kt
new file mode 100644
index 0000000..87c3278
--- /dev/null
+++ b/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/BoxWithConstraintsDialogTest.kt
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.compose.ui.inspection
+
+import android.view.inspector.WindowInspector
+import androidx.compose.ui.inspection.inspector.InspectorNode
+import androidx.compose.ui.inspection.inspector.MutableInspectorNode
+import androidx.compose.ui.inspection.rules.JvmtiRule
+import androidx.compose.ui.inspection.rules.sendCommand
+import androidx.compose.ui.inspection.testdata.BoxWithConstraintsDialogTestActivity
+import androidx.compose.ui.inspection.util.GetComposablesCommand
+import androidx.compose.ui.inspection.util.GetUpdateSettingsCommand
+import androidx.compose.ui.inspection.util.toMap
+import androidx.compose.ui.test.junit4.createAndroidComposeRule
+import androidx.compose.ui.unit.IntRect
+import androidx.inspection.testing.InspectorTester
+import androidx.test.filters.LargeTest
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.runBlocking
+import layoutinspector.compose.inspection.LayoutInspectorComposeProtocol.ComposableNode
+import layoutinspector.compose.inspection.LayoutInspectorComposeProtocol.GetComposablesResponse
+import org.junit.After
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.rules.RuleChain
+
+@LargeTest
+class BoxWithConstraintsDialogTest {
+ private val rule = createAndroidComposeRule<BoxWithConstraintsDialogTestActivity>()
+
+ @get:Rule val chain = RuleChain.outerRule(JvmtiRule()).around(rule)!!
+
+ private lateinit var inspectorTester: InspectorTester
+
+ @Before
+ fun before() {
+ runBlocking {
+ inspectorTester = InspectorTester(inspectorId = "layoutinspector.compose.inspection")
+ }
+ }
+
+ @After
+ fun after() {
+ inspectorTester.dispose()
+ }
+
+ @Test
+ fun openDialog(): Unit = runBlocking {
+ inspectorTester.sendCommand(GetUpdateSettingsCommand()).updateSettingsResponse
+
+ val roots = WindowInspector.getGlobalWindowViews()
+ assertThat(roots).hasSize(2)
+ val appViewId = roots.first().uniqueDrawingId
+ val dialogViewId = roots.last().uniqueDrawingId
+ val app =
+ inspectorTester.sendCommand(GetComposablesCommand(appViewId)).getComposablesResponse
+ val appRoots = app.roots()
+ val column = appRoots.single()
+ assertThat(column.name).isEqualTo("Column")
+ val text = column.children.single()
+ assertThat(text.name).isEqualTo("Text")
+ assertThat(text.children).isEmpty()
+
+ val dialog =
+ inspectorTester.sendCommand(GetComposablesCommand(dialogViewId)).getComposablesResponse
+ val dialogRoots = dialog.roots()
+ val box = dialogRoots.single()
+ assertThat(box.name).isEqualTo("BoxWithConstraints")
+ val alert = box.children.single()
+ assertThat(alert.name).isEqualTo("AlertDialog")
+ val button = alert.children.single()
+ assertThat(button.name).isEqualTo("Button")
+ val buttonText = button.children.single()
+ assertThat(buttonText.name).isEqualTo("Text")
+ }
+
+ private fun GetComposablesResponse.roots(): List<InspectorNode> {
+ val strings = stringsList.toMap()
+ return rootsList.flatMap { it.nodesList.convert(strings) }
+ }
+
+ private fun List<ComposableNode>.convert(strings: Map<Int, String>): List<InspectorNode> = map {
+ val node = MutableInspectorNode()
+ node.name = strings[it.name] ?: ""
+ node.box =
+ IntRect(
+ it.bounds.layout.x,
+ it.bounds.layout.y,
+ it.bounds.layout.x + it.bounds.layout.w,
+ it.bounds.layout.y + it.bounds.layout.h
+ )
+ node.children.addAll(it.childrenList.convert(strings))
+ node.inlined = (it.flags and ComposableNode.Flags.INLINED_VALUE) != 0
+ node.build()
+ }
+}
diff --git a/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/ComposeViewTest.kt b/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/ComposeViewTest.kt
index 14c73c3..fe1e562 100644
--- a/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/ComposeViewTest.kt
+++ b/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/ComposeViewTest.kt
@@ -55,16 +55,22 @@
assertThat(secondText?.textParameter).isEqualTo("two")
assertThat(thirdText?.textParameter).isEqualTo("three")
- val nested1 = roots[2].nodesList.single()
+ val thirdRoot = roots[2].nodesList.single()
+ assertThat(strings[thirdRoot.name]).isEqualTo("createAndroidViewNodeFactory")
+ assertThat(thirdRoot.flags)
+ .isEqualTo(
+ ComposableNode.Flags.NESTED_SINGLE_CHILDREN_VALUE or
+ ComposableNode.Flags.SYSTEM_CREATED_VALUE
+ )
+ assertThat(thirdRoot.childrenList.size).isAtLeast(4)
+ val nested1 = thirdRoot.childrenList[0]
assertThat(strings[nested1.name]).isEqualTo("Nested")
- assertThat(nested1.flags).isEqualTo(ComposableNode.Flags.NESTED_SINGLE_CHILDREN_VALUE)
- assertThat(nested1.childrenList.size).isAtLeast(3)
- val nested2 = nested1.childrenList[0]
+ val nested2 = thirdRoot.childrenList[1]
assertThat(nested2.name).isEqualTo(nested1.name)
- val nested3 = nested1.childrenList[1]
+ val nested3 = thirdRoot.childrenList[2]
assertThat(nested3.name).isEqualTo(nested1.name)
- val nested4 = nested1.childrenList[2]
- assertThat(nested4.name).isEqualTo(thirdText?.name)
+ val text = thirdRoot.childrenList[3]
+ assertThat(text.name).isEqualTo(thirdText?.name)
}
private fun Iterable<ComposableNode>.findNode(
diff --git a/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTreeTest.kt b/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTreeTest.kt
index 1718fa8..52a10ab 100644
--- a/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTreeTest.kt
+++ b/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTreeTest.kt
@@ -565,7 +565,8 @@
val builder = LayoutInspectorTree()
- val appNodes = builder.convert(appView)
+ val allNodes = builder.convert(listOf(appView, dialogView))
+ val appNodes = allNodes[appView.uniqueDrawingId] ?: emptyList()
dumpSlotTableSet(slotTableRecord)
dumpNodes(appNodes, appView, builder)
@@ -585,8 +586,7 @@
)
}
- val dialogContentNodes = builder.convert(dialogView)
- val dialogNodes = builder.addSubCompositionRoots(dialogView, dialogContentNodes)
+ val dialogNodes = allNodes[dialogView.uniqueDrawingId] ?: emptyList()
dumpNodes(dialogNodes, dialogView, builder)
// Verify that the AlertDialog is captured with content
@@ -629,7 +629,8 @@
popupView.setTag(R.id.inspection_slot_table_set, slotTableRecord.store)
val builder = LayoutInspectorTree()
- val appNodes = builder.convert(appView)
+ val allNodes = builder.convert(listOf(appView, popupView))
+ val appNodes = allNodes[appView.uniqueDrawingId] ?: emptyList()
dumpNodes(appNodes, appView, builder)
// Verify that the main app does not contain the Popup
@@ -648,8 +649,7 @@
)
}
- val popupContentNodes = builder.convert(popupView)
- val popupNodes = builder.addSubCompositionRoots(popupView, popupContentNodes)
+ val popupNodes = allNodes[popupView.uniqueDrawingId] ?: emptyList()
dumpNodes(popupNodes, popupView, builder)
// Verify that the Popup is captured with content
@@ -772,6 +772,7 @@
val firstTextView = textViews.filterIsInstance<TextView>().first { it.text == "first" }
val secondTextView = textViews.filterIsInstance<TextView>().first { it.text == "second" }
val composeNodes = nodes.flatMap { it.flatten() }.filter { it.name == "ComposeNode" }
+ assertThat(composeNodes).hasSize(2)
assertThat(composeNodes[0].viewId).isEqualTo(viewParent(secondTextView)?.uniqueDrawingId)
assertThat(composeNodes[1].viewId).isEqualTo(viewParent(firstTextView)?.uniqueDrawingId)
}
@@ -1343,3 +1344,6 @@
fun InlineParameters(size: Dp, fontSize: TextUnit) {
Text("$size $fontSize")
}
+
+fun LayoutInspectorTree.convert(view: View): List<InspectorNode> =
+ convert(listOf(view))[view.uniqueDrawingId] ?: emptyList()
diff --git a/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/testdata/BoxWithConstraintsDialogTestActivity.kt b/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/testdata/BoxWithConstraintsDialogTestActivity.kt
new file mode 100644
index 0000000..5a4efde
--- /dev/null
+++ b/compose/ui/ui-inspection/src/androidTest/java/androidx/compose/ui/inspection/testdata/BoxWithConstraintsDialogTestActivity.kt
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.compose.ui.inspection.testdata
+
+import android.os.Bundle
+import androidx.activity.ComponentActivity
+import androidx.activity.compose.setContent
+import androidx.compose.foundation.layout.BoxWithConstraints
+import androidx.compose.foundation.layout.Column
+import androidx.compose.material.AlertDialog
+import androidx.compose.material.Button
+import androidx.compose.material.Text
+
+class BoxWithConstraintsDialogTestActivity : ComponentActivity() {
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContent {
+ Column {
+ Text("one")
+ BoxWithConstraints {
+ AlertDialog(
+ onDismissRequest = {},
+ confirmButton = { Button({}) { Text("Confirm Button") } }
+ )
+ }
+ }
+ }
+ }
+}
diff --git a/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/ComposeLayoutInspector.kt b/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/ComposeLayoutInspector.kt
index 8f37b41..0f7d892 100644
--- a/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/ComposeLayoutInspector.kt
+++ b/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/ComposeLayoutInspector.kt
@@ -412,13 +412,17 @@
val data =
ThreadUtils.runOnMainThread {
- layoutInspectorTree.resetAccumulativeState()
layoutInspectorTree.includeAllParameters = includeAllParameters
- val composeViews =
+ val composeViewWrappers =
getAndroidComposeViews(rootViewId, skipSystemComposables, generation)
+ val composeViews = composeViewWrappers.map { it.composeView }
+ val nodesByComposeView =
+ layoutInspectorTree
+ .apply { this.hideSystemNodes = skipSystemComposables }
+ .convert(composeViews)
val composeViewsByRoot =
mutableLongObjectMapOf<MutableList<AndroidComposeViewWrapper>>()
- composeViews.groupByToLongObjectMap(composeViewsByRoot) {
+ composeViewWrappers.groupByToLongObjectMap(composeViewsByRoot) {
it.rootView.uniqueDrawingId
}
val data = mutableLongObjectMapOf<CacheData>()
@@ -428,12 +432,14 @@
CacheData(
value.first().rootView,
value.map {
- CacheTree(it.viewParent, it.createNodes(), it.viewsToSkip)
+ val nodes =
+ nodesByComposeView[it.composeView.uniqueDrawingId]
+ ?: emptyList()
+ CacheTree(it.viewParent, nodes, it.viewsToSkip)
}
)
)
}
- layoutInspectorTree.resetAccumulativeState()
data
}
.get()
@@ -455,10 +461,11 @@
*/
private fun getComposableFromAnchor(anchorId: Int): InspectorNode? =
ThreadUtils.runOnMainThread {
- layoutInspectorTree.resetAccumulativeState()
layoutInspectorTree.includeAllParameters = false
val composeViews = getAndroidComposeViews(-1L, false, 1)
- composeViews.firstNotNullOfOrNull { it.findParameters(anchorId) }
+ composeViews.firstNotNullOfOrNull {
+ layoutInspectorTree.findParameters(it.composeView, anchorId)
+ }
}
.get()
@@ -480,12 +487,7 @@
val wrappers = mutableListOf<AndroidComposeViewWrapper>()
roots.forEach { root ->
root.flatten().mapNotNullTo(wrappers) { view ->
- AndroidComposeViewWrapper.tryCreateFor(
- layoutInspectorTree,
- root,
- view,
- skipSystemComposables
- )
+ AndroidComposeViewWrapper.tryCreateFor(root, view, skipSystemComposables)
}
}
return wrappers
diff --git a/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/compose/AndroidComposeViewWrapper.kt b/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/compose/AndroidComposeViewWrapper.kt
index f6c9c3a..1923e91 100644
--- a/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/compose/AndroidComposeViewWrapper.kt
+++ b/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/compose/AndroidComposeViewWrapper.kt
@@ -26,8 +26,6 @@
import androidx.compose.ui.inspection.framework.getChildren
import androidx.compose.ui.inspection.framework.isAndroidComposeView
import androidx.compose.ui.inspection.framework.isRoot
-import androidx.compose.ui.inspection.inspector.InspectorNode
-import androidx.compose.ui.inspection.inspector.LayoutInspectorTree
import androidx.compose.ui.inspection.util.ThreadUtils
/**
@@ -63,25 +61,18 @@
* UI thread.
*/
class AndroidComposeViewWrapper(
- private val layoutInspectorTree: LayoutInspectorTree,
val rootView: View,
- private val composeView: ViewGroup,
+ val composeView: ViewGroup,
skipSystemComposables: Boolean
) {
companion object {
fun tryCreateFor(
- layoutInspectorTree: LayoutInspectorTree,
rootView: View,
composeView: View,
skipSystemComposables: Boolean
): AndroidComposeViewWrapper? {
return if (composeView.isAndroidComposeView()) {
- AndroidComposeViewWrapper(
- layoutInspectorTree,
- rootView,
- composeView as ViewGroup,
- skipSystemComposables
- )
+ AndroidComposeViewWrapper(rootView, composeView as ViewGroup, skipSystemComposables)
} else {
null
}
@@ -99,17 +90,6 @@
val viewsToSkip: LongList = createViewsToSkip(composeView)
- private val inspectorNodes =
- layoutInspectorTree
- .apply { this.hideSystemNodes = skipSystemComposables }
- .convert(composeView)
-
- fun createNodes(): List<InspectorNode> =
- layoutInspectorTree.addSubCompositionRoots(composeView, inspectorNodes)
-
- fun findParameters(anchorId: Int): InspectorNode? =
- layoutInspectorTree.findParameters(composeView, anchorId)
-
private fun createViewsToSkip(viewGroup: ViewGroup): LongList {
val result = mutableLongListOf()
viewGroup.getChildren().forEach { view ->
diff --git a/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/inspector/CompositionBuilder.kt b/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/inspector/CompositionBuilder.kt
new file mode 100644
index 0000000..20dedc9
--- /dev/null
+++ b/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/inspector/CompositionBuilder.kt
@@ -0,0 +1,428 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@file:OptIn(UiToolingDataApi::class)
+
+package androidx.compose.ui.inspection.inspector
+
+import android.view.View
+import androidx.annotation.VisibleForTesting
+import androidx.collection.MutableIntObjectMap
+import androidx.compose.runtime.tooling.CompositionData
+import androidx.compose.runtime.tooling.CompositionGroup
+import androidx.compose.runtime.tooling.CompositionInstance
+import androidx.compose.ui.InternalComposeUiApi
+import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.inspection.util.AnchorMap
+import androidx.compose.ui.inspection.util.NO_ANCHOR_ID
+import androidx.compose.ui.inspection.util.isPrimitiveClass
+import androidx.compose.ui.layout.GraphicLayerInfo
+import androidx.compose.ui.layout.LayoutInfo
+import androidx.compose.ui.node.InteroperableComposeUiNode
+import androidx.compose.ui.tooling.data.ContextCache
+import androidx.compose.ui.tooling.data.ParameterInformation
+import androidx.compose.ui.tooling.data.SourceContext
+import androidx.compose.ui.tooling.data.SourceLocation
+import androidx.compose.ui.tooling.data.UiToolingDataApi
+import androidx.compose.ui.tooling.data.mapTree
+import androidx.compose.ui.unit.IntOffset
+import androidx.compose.ui.unit.IntRect
+import androidx.compose.ui.unit.toSize
+import java.util.ArrayDeque
+import kotlin.math.roundToInt
+
+/**
+ * The [InspectorNode.id] will be populated with:
+ * - the layerId from a LayoutNode if this exists
+ * - an id generated from an Anchor instance from the SlotTree if this exists
+ * - a generated id if none of the above ids are available
+ *
+ * The interval -10000..-2 is reserved for the generated ids.
+ */
+@VisibleForTesting const val RESERVED_FOR_GENERATED_IDS = -10000L
+
+private val unwantedCalls =
+ setOf(
+ "CompositionLocalProvider",
+ "Content",
+ "Inspectable",
+ "ProvideAndroidCompositionLocals",
+ "ProvideCommonCompositionLocals",
+ )
+
+/** Builder of [InspectorNode] trees from [root] compositions. */
+@OptIn(UiToolingDataApi::class)
+internal class CompositionBuilder(
+ private val info: SharedBuilderData,
+) : SharedBuilderData by info {
+ private var ownerView: View? = null
+ private var subCompositionsFound = 0
+ private val subCompositions = mutableMapOf<Any?, SubCompositionResult>()
+ private var capturingSubCompositions =
+ mutableMapOf<MutableInspectorNode, SubCompositionResult>()
+
+ /**
+ * Build a list of [InspectorNode] trees from a single [root] composition, and insert the
+ * already built child compositions in the proper location in the tree.
+ */
+ fun convert(
+ composition: CompositionInstance,
+ root: CompositionData,
+ childCompositions: List<SubCompositionResult>
+ ): SubCompositionResult {
+ reset(root, childCompositions)
+ val node = root.mapTree(::convert, contextCache) ?: newNode()
+ updateSubCompositionsAtEnd(node)
+ val result = SubCompositionResult(composition, ownerView, node.children.toList())
+ release(node)
+ reset(null, emptyList())
+ return result
+ }
+
+ private fun reset(root: CompositionData?, childCompositions: List<SubCompositionResult>) {
+ ownerView = root?.let { findOwnerView(it) }
+ subCompositionsFound = 0
+ subCompositions.clear()
+ childCompositions
+ .filter { it.group != null && it.nodes.isNotEmpty() }
+ .associateByTo(subCompositions) { it.group }
+ capturingSubCompositions.clear()
+ }
+
+ /**
+ * We do NOT know which [View] a composition belongs to. Perform an initial tree walk to find
+ * the composition owner.
+ */
+ private fun findOwnerView(root: CompositionData): View? {
+ root.compositionGroups.forEach { group ->
+ if (group.sourceInfo?.contains("(ProvideAndroidCompositionLocals)") == true) {
+ group.data.filterIsInstance<View>().singleOrNull()?.let {
+ return it
+ }
+ }
+ findOwnerView(group)?.let {
+ return it
+ }
+ }
+ return null
+ }
+
+ /** This function is called recursively from [CompositionData.mapTree] in Post-Order (LRN). */
+ private fun convert(
+ group: CompositionGroup,
+ context: SourceContext,
+ children: List<MutableInspectorNode>
+ ): MutableInspectorNode {
+ val parent = parse(group, context, children)
+ addToParent(parent, children)
+ addSubCompositions(group, parent)
+ return parent
+ }
+
+ /**
+ * Adds the nodes in [input] to the children of [parentNode]. Nodes without a reference to a
+ * wanted Composable are skipped. A single skipped render id will be added to [parentNode].
+ */
+ private fun addToParent(
+ parentNode: MutableInspectorNode,
+ input: List<MutableInspectorNode>,
+ ) {
+ // If we're adding an unwanted node from the `input` to the parent node and it has a
+ // View ID, then assign it to the parent view so that we don't lose the context that we
+ // found a View as a descendant of the parent node. Most likely, there were one or more
+ // unwanted intermediate nodes between the node that actually owns the Android View
+ // and the desired node that the View should be associated with in the inspector. If
+ // there's more than one input node with a View ID, we skip this step since it's
+ // unclear how these views would be related.
+ input
+ .singleOrNull { it.hostingAndroidView }
+ ?.takeIf { node -> node.isUnwanted }
+ ?.let { nodeHostingAndroidView -> parentNode.viewId = nodeHostingAndroidView.viewId }
+
+ var id: Long? = null
+ input.forEach { node ->
+ if (node.isUnwanted) {
+ parentNode.children.addAll(node.children)
+ if (node.hasLayerId) {
+ // If multiple siblings with a render ids are dropped:
+ // Ignore them all. And delegate the drawing to a parent in the inspector.
+ id = if (id == null) node.id else UNDEFINED_ID
+ }
+ } else {
+ node.id = if (node.hasAssignedId) node.id else --generatedId
+ val withSemantics = node.packageHash !in systemPackages
+ val resultNode = node.build(withSemantics)
+ parentNode.children.add(resultNode)
+ if (withSemantics) {
+ node.mergedSemantics.clear()
+ node.unmergedSemantics.clear()
+ }
+ }
+ if (node.bounds != null && parentNode.box == node.box) {
+ parentNode.bounds = node.bounds
+ }
+ parentNode.mergedSemantics.addAll(node.mergedSemantics)
+ parentNode.unmergedSemantics.addAll(node.unmergedSemantics)
+ release(node)
+ }
+ val nodeId = id
+ parentNode.id = if (!parentNode.hasLayerId && nodeId != null) nodeId else parentNode.id
+ }
+
+ private fun addSubCompositions(group: CompositionGroup, parent: MutableInspectorNode) {
+ // Note: Minimize the number of calls to identity by only looking for a fixed number of
+ // sub-composition parents. Calling identity may create an anchor for the group.
+ if (subCompositions.size > subCompositionsFound) {
+ subCompositions[group.identity]?.let { subComposition ->
+ subCompositionsFound++
+
+ // Steal all the nodes from the sub-composition and add them to the parent.
+ parent.children.addAll(subComposition.nodes)
+ subComposition.nodes = emptyList()
+
+ if (subComposition.ownerView != ownerView) {
+ // If the sub-composition belongs to a different view we may later
+ // move the compositions back to the sub-composition with a few extra
+ // parent nodes.
+ parent.box = subComposition.ownerViewBox ?: emptyBox
+ capturingSubCompositions[parent] = subComposition
+ }
+ }
+ }
+ }
+
+ @OptIn(InternalComposeUiApi::class)
+ private fun parse(
+ group: CompositionGroup,
+ context: SourceContext,
+ children: List<MutableInspectorNode>
+ ): MutableInspectorNode {
+ val node = newNode()
+ node.name = context.name ?: ""
+ node.key = group.key as? Int ?: 0
+ node.inlined = context.isInline
+ node.box = context.bounds.emptyCheck()
+
+ // If this node is associated with an android View, set the node's viewId to point to
+ // the hosted view. We use the parent's uniqueDrawingId since the interopView returned here
+ // will be the view itself, but we want to use the `AndroidViewHolder` that hosts the view
+ // instead of the view directly.
+ (group.node as? InteroperableComposeUiNode?)?.getInteropView()?.let { interopView ->
+ (interopView.parent as? View)?.uniqueDrawingId?.let { viewId -> node.viewId = viewId }
+ }
+
+ checkCapturingSubCompositions(node, children)
+
+ val layoutInfo = group.node as? LayoutInfo
+ if (layoutInfo != null) {
+ return parseLayoutInfo(layoutInfo, context, node)
+ }
+ if (node.box == emptyBox || unwantedName(node.name)) {
+ return node.markUnwanted()
+ }
+ parseCallLocation(context.location, node)
+ if (isHiddenSystemNode(node)) {
+ return node.markUnwanted()
+ }
+ node.anchorId = anchorMap[group.identity]
+ node.id = syntheticId(node.anchorId)
+ if (includeAllParameters) {
+ addParameters(context, node)
+ }
+ return node
+ }
+
+ private fun checkCapturingSubCompositions(
+ node: MutableInspectorNode,
+ children: List<MutableInspectorNode>
+ ) {
+ if (capturingSubCompositions.isEmpty()) {
+ return
+ }
+ val subCompositionChildren = children.intersect(capturingSubCompositions.keys)
+ val child = subCompositionChildren.singleOrNull() ?: return
+ val subComposition = capturingSubCompositions.remove(child)!!
+ if (node.box == emptyBox) {
+ node.box = subComposition.ownerViewBox ?: emptyBox
+ children.forEach {
+ if (it !== child) {
+ it.markUnwanted()
+ }
+ }
+ capturingSubCompositions[node] = subComposition
+ } else {
+ subComposition.nodes = listOf(child.build(withSemantics = true))
+ child.markUnwanted()
+ child.children.clear()
+ }
+ }
+
+ private fun updateSubCompositionsAtEnd(node: MutableInspectorNode?) {
+ val subComposition = node?.let { capturingSubCompositions.remove(node) } ?: return
+ subComposition.nodes = node.children.toList()
+ node.children.clear()
+ }
+
+ private fun parseLayoutInfo(
+ layoutInfo: LayoutInfo,
+ context: SourceContext,
+ node: MutableInspectorNode
+ ): MutableInspectorNode {
+ val box = context.bounds
+ val size = box.size.toSize()
+ val coordinates = layoutInfo.coordinates
+ var bounds: QuadBounds? = null
+ if (layoutInfo.isAttached && coordinates.isAttached) {
+ val topLeft = toIntOffset(coordinates.localToWindow(Offset.Zero))
+ val topRight = toIntOffset(coordinates.localToWindow(Offset(size.width, 0f)))
+ val bottomRight =
+ toIntOffset(coordinates.localToWindow(Offset(size.width, size.height)))
+ val bottomLeft = toIntOffset(coordinates.localToWindow(Offset(0f, size.height)))
+
+ if (
+ topLeft.x != box.left ||
+ topLeft.y != box.top ||
+ topRight.x != box.right ||
+ topRight.y != box.top ||
+ bottomRight.x != box.right ||
+ bottomRight.y != box.bottom ||
+ bottomLeft.x != box.left ||
+ bottomLeft.y != box.bottom
+ ) {
+ bounds =
+ QuadBounds(
+ topLeft.x,
+ topLeft.y,
+ topRight.x,
+ topRight.y,
+ bottomRight.x,
+ bottomRight.y,
+ bottomLeft.x,
+ bottomLeft.y,
+ )
+ }
+ }
+
+ node.box = box.emptyCheck()
+ node.bounds = bounds
+ node.layoutNodes.add(layoutInfo)
+ val modifierInfo = layoutInfo.getModifierInfo()
+
+ val unmergedSemantics = unmergedSemanticsMap[layoutInfo.semanticsId]
+ if (unmergedSemantics != null) {
+ node.unmergedSemantics.addAll(unmergedSemantics)
+ }
+
+ val mergedSemantics = semanticsMap[layoutInfo.semanticsId]
+ if (mergedSemantics != null) {
+ node.mergedSemantics.addAll(mergedSemantics)
+ }
+
+ val layerInfo =
+ modifierInfo.map { it.extra }.filterIsInstance<GraphicLayerInfo>().firstOrNull()
+ node.id = layerInfo?.layerId ?: UNDEFINED_ID
+ return node
+ }
+
+ private fun parseCallLocation(location: SourceLocation?, node: MutableInspectorNode) {
+ val fileName = location?.sourceFile ?: return
+ node.fileName = fileName
+ node.packageHash = location.packageHash
+ node.lineNumber = location.lineNumber
+ node.offset = location.offset
+ }
+
+ private fun addParameters(context: SourceContext, node: MutableInspectorNode) {
+ context.parameters.forEach {
+ val castedValue = castValue(it)
+ node.parameters.add(RawParameter(it.name, castedValue))
+ }
+ }
+
+ private fun castValue(parameter: ParameterInformation): Any? {
+ val value = parameter.value ?: return null
+ if (parameter.inlineClass == null || !value.javaClass.isPrimitiveClass()) return value
+ return inlineClassConverter.castParameterValue(parameter.inlineClass, value)
+ }
+
+ private fun isHiddenSystemNode(node: MutableInspectorNode): Boolean =
+ hideSystemNodes && node.packageHash in systemPackages
+
+ private fun unwantedName(name: String): Boolean =
+ name.isEmpty() || name.startsWith("remember") || name in unwantedCalls
+
+ private fun syntheticId(anchorId: Int): Long {
+ if (anchorId == NO_ANCHOR_ID) {
+ return UNDEFINED_ID
+ }
+ // The anchorId is an Int
+ return anchorId.toLong() - Int.MAX_VALUE.toLong() + RESERVED_FOR_GENERATED_IDS
+ }
+
+ private fun IntRect.emptyCheck(): IntRect =
+ if (left >= right && top >= bottom) emptyBox else this
+
+ private fun toIntOffset(offset: Offset): IntOffset =
+ IntOffset(offset.x.roundToInt(), offset.y.roundToInt())
+
+ private fun newNode(): MutableInspectorNode =
+ if (cache.isNotEmpty()) cache.pop() else MutableInspectorNode()
+
+ private fun release(node: MutableInspectorNode) {
+ node.reset()
+ cache.add(node)
+ }
+}
+
+@OptIn(UiToolingDataApi::class)
+internal interface SharedBuilderData {
+ val cache: ArrayDeque<MutableInspectorNode>
+ val contextCache: ContextCache
+ val anchorMap: AnchorMap
+
+ /** Map from semantics id to a list of merged semantics information */
+ val semanticsMap: MutableIntObjectMap<List<RawParameter>>
+
+ /** Map of semantics id to a list of unmerged semantics information */
+ val unmergedSemanticsMap: MutableIntObjectMap<List<RawParameter>>
+
+ val inlineClassConverter: InlineClassConverter
+ val parameterFactory: ParameterFactory
+ val hideSystemNodes: Boolean
+ val includeAllParameters: Boolean
+ var generatedId: Long
+}
+
+/** Sub-Compositions of the composition being parsed. */
+internal class SubCompositionResult(
+ /** The sub-composition instance */
+ composition: CompositionInstance,
+
+ /** The ownerView of this composition */
+ val ownerView: View?,
+
+ /** The parsed sub-composition, that may be replaced later */
+ var nodes: List<InspectorNode>
+) {
+ /**
+ * The identity of the parent [CompositionGroup] where this composition belongs in a parent
+ * composition.
+ */
+ val group = composition.findContextGroup()?.identity
+
+ /** The size of the owner view */
+ val ownerViewBox = ownerView?.let { IntRect(0, 0, it.width, it.height) }
+}
diff --git a/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/inspector/InspectorNode.kt b/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/inspector/InspectorNode.kt
index cfd50d8..3fb298d 100644
--- a/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/inspector/InspectorNode.kt
+++ b/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/inspector/InspectorNode.kt
@@ -22,7 +22,6 @@
internal const val UNDEFINED_ID = 0L
internal val emptyBox = IntRect(0, 0, 0, 0)
-internal val outsideBox = IntRect(Int.MAX_VALUE, Int.MIN_VALUE, Int.MAX_VALUE, Int.MIN_VALUE)
/** Node representing a Composable for the Layout Inspector. */
class InspectorNode
@@ -67,9 +66,6 @@
/** The UTF-16 offset in the file where the Composable was called */
val offset: Int,
- /** The number of UTF-16 code point comprise the Composable call */
- val length: Int,
-
/** The bounding box of the Composable. */
internal val box: IntRect,
@@ -127,22 +123,7 @@
val y2: Int,
val x3: Int,
val y3: Int,
-) {
- val xMin: Int
- get() = sequenceOf(x0, x1, x2, x3).minOrNull()!!
-
- val xMax: Int
- get() = sequenceOf(x0, x1, x2, x3).maxOrNull()!!
-
- val yMin: Int
- get() = sequenceOf(y0, y1, y2, y3).minOrNull()!!
-
- val yMax: Int
- get() = sequenceOf(y0, y1, y2, y3).maxOrNull()!!
-
- val outerBox: IntRect
- get() = IntRect(xMin, yMin, xMax, yMax)
-}
+)
/** Parameter definition with a raw value reference. */
class RawParameter(val name: String, val value: Any?)
@@ -160,14 +141,12 @@
var packageHash = -1
var lineNumber = 0
var offset = 0
- var length = 0
var box: IntRect = emptyBox
var bounds: QuadBounds? = null
var inlined = false
val parameters = mutableListOf<RawParameter>()
var viewId = UNDEFINED_ID
val children = mutableListOf<InspectorNode>()
- var outerBox: IntRect = outsideBox
fun reset() {
markUnwanted()
@@ -181,39 +160,30 @@
box = emptyBox
bounds = null
inlined = false
- outerBox = outsideBox
children.clear()
}
- fun markUnwanted() {
+ fun markUnwanted(): MutableInspectorNode {
name = ""
fileName = ""
packageHash = -1
lineNumber = 0
offset = 0
- length = 0
parameters.clear()
+ return this
}
- fun shallowCopy(node: InspectorNode): MutableInspectorNode = apply {
- id = node.id
- key = node.key
- anchorId = node.anchorId
- mergedSemantics.addAll(node.mergedSemantics)
- unmergedSemantics.addAll(node.unmergedSemantics)
- name = node.name
- fileName = node.fileName
- packageHash = node.packageHash
- lineNumber = node.lineNumber
- offset = node.offset
- length = node.length
- box = node.box
- bounds = node.bounds
- inlined = node.inlined
- parameters.addAll(node.parameters)
- viewId = node.viewId
- children.addAll(node.children)
- }
+ val isUnwanted: Boolean
+ get() = name.isEmpty()
+
+ val hostingAndroidView: Boolean
+ get() = viewId != UNDEFINED_ID
+
+ val hasLayerId: Boolean
+ get() = id > UNDEFINED_ID
+
+ val hasAssignedId: Boolean
+ get() = id != UNDEFINED_ID
fun build(withSemantics: Boolean = true): InspectorNode =
InspectorNode(
@@ -225,7 +195,6 @@
packageHash,
lineNumber,
offset,
- length,
box,
bounds,
inlined,
diff --git a/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTree.kt b/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTree.kt
index 8214bcb..4b7e817 100644
--- a/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTree.kt
+++ b/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/inspector/LayoutInspectorTree.kt
@@ -17,138 +17,135 @@
package androidx.compose.ui.inspection.inspector
import android.view.View
-import androidx.annotation.VisibleForTesting
-import androidx.collection.LongList
+import androidx.collection.LongObjectMap
import androidx.collection.mutableIntObjectMapOf
-import androidx.collection.mutableLongListOf
import androidx.collection.mutableLongObjectMapOf
import androidx.compose.runtime.tooling.CompositionData
-import androidx.compose.runtime.tooling.CompositionGroup
-import androidx.compose.ui.InternalComposeUiApi
+import androidx.compose.runtime.tooling.CompositionInstance
+import androidx.compose.runtime.tooling.findCompositionInstance
import androidx.compose.ui.R
-import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.inspection.util.AnchorMap
-import androidx.compose.ui.inspection.util.NO_ANCHOR_ID
-import androidx.compose.ui.layout.GraphicLayerInfo
-import androidx.compose.ui.layout.LayoutInfo
-import androidx.compose.ui.node.InteroperableComposeUiNode
-import androidx.compose.ui.node.Ref
+import androidx.compose.ui.inspection.util.isPrimitiveClass
import androidx.compose.ui.node.RootForTest
-import androidx.compose.ui.platform.AbstractComposeView
-import androidx.compose.ui.platform.ComposeView
-import androidx.compose.ui.platform.ViewRootForInspector
import androidx.compose.ui.semantics.getAllSemanticsNodes
import androidx.compose.ui.tooling.data.ContextCache
import androidx.compose.ui.tooling.data.ParameterInformation
-import androidx.compose.ui.tooling.data.SourceContext
-import androidx.compose.ui.tooling.data.SourceLocation
import androidx.compose.ui.tooling.data.UiToolingDataApi
import androidx.compose.ui.tooling.data.findParameters
-import androidx.compose.ui.tooling.data.mapTree
import androidx.compose.ui.unit.Density
-import androidx.compose.ui.unit.IntOffset
-import androidx.compose.ui.unit.IntRect
-import androidx.compose.ui.unit.IntSize
-import androidx.compose.ui.unit.toSize
import java.util.ArrayDeque
-import java.util.Collections
-import java.util.IdentityHashMap
-import kotlin.math.max
-import kotlin.math.min
-import kotlin.math.roundToInt
-
-/**
- * The [InspectorNode.id] will be populated with:
- * - the layerId from a LayoutNode if this exists
- * - an id generated from an Anchor instance from the SlotTree if this exists
- * - a generated id if none of the above ids are available
- *
- * The interval -10000..-2 is reserved for the generated ids.
- */
-@VisibleForTesting const val RESERVED_FOR_GENERATED_IDS = -10000L
-const val PLACEHOLDER_ID = Long.MAX_VALUE
-
-private val emptySize = IntSize(0, 0)
-
-private val unwantedCalls =
- setOf(
- "CompositionLocalProvider",
- "Content",
- "Inspectable",
- "ProvideAndroidCompositionLocals",
- "ProvideCommonCompositionLocals",
- )
/** Generator of a tree for the Layout Inspector. */
@OptIn(UiToolingDataApi::class)
class LayoutInspectorTree {
- @Suppress("MemberVisibilityCanBePrivate") var hideSystemNodes = true
- var includeNodesOutsizeOfWindow = true
- var includeAllParameters = true
- private var foundNode: InspectorNode? = null
- private var windowSize = emptySize
- private val inlineClassConverter = InlineClassConverter()
- private val parameterFactory = ParameterFactory(inlineClassConverter)
- private val cache = ArrayDeque<MutableInspectorNode>()
- private var generatedId = -1L
- private val subCompositions = SubCompositionRoots()
- /** Map from [LayoutInfo] to the nearest [InspectorNode] that contains it */
- private val claimedNodes = IdentityHashMap<LayoutInfo, InspectorNode>()
- /** Map from parent tree to child trees that are about to be stitched together */
- private val treeMap = IdentityHashMap<MutableInspectorNode, MutableList<MutableInspectorNode>>()
- /** Map from owner node to child trees that are about to be stitched to this owner */
- private val ownerMap = IdentityHashMap<InspectorNode, MutableList<MutableInspectorNode>>()
- /** Map from semantics id to a list of merged semantics information */
- private val semanticsMap = mutableIntObjectMapOf<List<RawParameter>>()
- /* Map of seemantics id to a list of unmerged semantics information */
- private val unmergedSemanticsMap = mutableIntObjectMapOf<List<RawParameter>>()
- /** Set of tree nodes that were stitched into another tree */
- private val stitched =
- Collections.newSetFromMap(IdentityHashMap<MutableInspectorNode, Boolean>())
- private val contextCache = ContextCache()
- private val anchorMap = AnchorMap()
+ private val builderData = SharedBuilderDataImpl()
+ private val builder = CompositionBuilder(builderData)
+ private val rootByComposition = mutableMapOf<CompositionInstance, CompositionData>()
+ private val hierarchy = mutableMapOf<CompositionInstance, MutableList<CompositionInstance>>()
+ private val resultByComposition = mutableMapOf<CompositionInstance, SubCompositionResult>()
+ private val compositions = mutableSetOf<CompositionInstance>()
- /** Converts the [CompositionData] set held by [view] into a list of root nodes. */
- fun convert(view: View): List<InspectorNode> {
- windowSize = IntSize(view.width, view.height)
- parameterFactory.density = Density(view.context)
- @Suppress("UNCHECKED_CAST")
- val tables =
- view.getTag(R.id.inspection_slot_table_set) as? Set<CompositionData>
- ?: return emptyList()
+ /** If true, system nodes are excluded from the resulting tree */
+ var hideSystemNodes: Boolean by builderData::hideSystemNodes
+
+ /** If true, all parameters are parsed and included for each node */
+ var includeAllParameters: Boolean by builderData::includeAllParameters
+
+ /** Converts the [CompositionData] held by [views] into a list of root nodes per view id. */
+ fun convert(views: List<View>): LongObjectMap<MutableList<InspectorNode>> {
clear()
- collectSemantics(view)
- val result = convert(tables, view)
+ val defaultView = views.first()
+ builderData.setDensity(defaultView)
+ val defaultViewId = defaultView.uniqueDrawingId
+ buildCompositionLookups(views)
+ while (compositions.isNotEmpty()) {
+ buildNodesFor(compositions.first())
+ }
+ val result = mutableLongObjectMapOf<MutableList<InspectorNode>>()
+ resultByComposition.values.forEach {
+ val viewId = it.ownerView?.uniqueDrawingId ?: defaultViewId
+ result.getOrPut(viewId) { mutableListOf() }.addAll(it.nodes)
+ }
clear()
return result
}
- fun findParameters(view: View, anchorId: Int): InspectorNode? {
- windowSize = IntSize(view.width, view.height)
- parameterFactory.density = Density(view.context)
- val identity = anchorMap[anchorId] ?: return null
+ private fun buildCompositionLookups(views: List<View>) {
+ for (view in views) {
+ val roots = view.compositionRoots
+ for (root in roots) {
+ root.findCompositionInstance()?.let { composition ->
+ rootByComposition[composition] = root
+ buildCompositionHierarchy(composition)
+ }
+ }
+ collectSemantics(view)
+ }
+ }
- @Suppress("UNCHECKED_CAST")
- val tables =
- view.getTag(R.id.inspection_slot_table_set) as? Set<CompositionData> ?: return null
- val node = newNode().apply { this.anchorId = anchorId }
- val group = tables.firstNotNullOfOrNull { it.find(identity) } ?: return null
- group.findParameters(contextCache).forEach {
+ private val View.compositionRoots: Set<CompositionData>
+ get() {
+ @Suppress("UNCHECKED_CAST")
+ return getTag(R.id.inspection_slot_table_set) as? Set<CompositionData> ?: emptySet()
+ }
+
+ private fun buildCompositionHierarchy(root: CompositionInstance) {
+ compositions.add(root)
+ var composition = root
+ var parent = composition.parent
+ while (parent != null) {
+ compositions.add(parent)
+ val children = hierarchy.getOrPut(parent) { mutableListOf() }
+ if (children.contains(composition)) {
+ return
+ }
+ children.add(composition)
+ composition = parent
+ parent = composition.parent
+ }
+ }
+
+ /** Build nodes for the specified [composition]. */
+ private fun buildNodesFor(composition: CompositionInstance) {
+ if (!compositions.contains(composition)) {
+ // We have already built the nodes for this composition.
+ return
+ }
+ // Mark this composition done:
+ compositions.remove(composition)
+
+ // We must build nodes for the child compositions first:
+ val children = hierarchy[composition] ?: emptyList()
+ children.forEach { buildNodesFor(it) }
+
+ val root = rootByComposition[composition] ?: return
+ val subCompositions = children.mapNotNull { resultByComposition[it] }
+ var result = builder.convert(composition, root, subCompositions)
+ val singleSubComposition = children.singleOrNull()
+ if (result.nodes.isEmpty() && result.ownerView == null && singleSubComposition != null) {
+ // Special case:
+ // Everything from this unowned composition was pushed to its single sub-composition.
+ // Remove the result of the sub-composition and use that result for this composition.
+ resultByComposition.remove(singleSubComposition)?.let {
+ result = SubCompositionResult(composition, it.ownerView, it.nodes)
+ }
+ }
+ resultByComposition[composition] = result
+ }
+
+ fun findParameters(view: View, anchorId: Int): InspectorNode? {
+ val identity = builderData.anchorMap[anchorId] ?: return null
+ val roots = view.compositionRoots
+ val node = MutableInspectorNode().apply { this.anchorId = anchorId }
+ val group = roots.firstNotNullOfOrNull { it.find(identity) } ?: return null
+ group.findParameters(builderData.contextCache).forEach {
val castedValue = castValue(it)
node.parameters.add(RawParameter(it.name, castedValue))
}
- return buildAndRelease(node)
+ return node.build()
}
/**
- * Add the roots to sub compositions that may have been collected from a different SlotTree.
- *
- * See [SubCompositionRoots] for details.
- */
- fun addSubCompositionRoots(view: View, nodes: List<InspectorNode>): List<InspectorNode> =
- subCompositions.addRoot(view, nodes)
-
- /**
* Extract the merged semantics for this semantics owner such that they can be added to compose
* nodes during the conversion of Group nodes.
*/
@@ -156,6 +153,8 @@
val root = view as? RootForTest ?: return
val nodes = root.semanticsOwner.getAllSemanticsNodes(mergingEnabled = true)
val unmergedNodes = root.semanticsOwner.getAllSemanticsNodes(mergingEnabled = false)
+ val semanticsMap = builderData.semanticsMap
+ val unmergedSemanticsMap = builderData.unmergedSemanticsMap
nodes.forEach { node ->
semanticsMap[node.id] = node.config.map { RawParameter(it.key.name, it.value) }
}
@@ -174,7 +173,7 @@
): List<NodeParameter> {
val parameters = node.parametersByKind(kind)
return parameters.mapIndexed { index, parameter ->
- parameterFactory.create(
+ builderData.parameterFactory.create(
rootId,
node.id,
node.anchorId,
@@ -207,7 +206,7 @@
return null
}
val parameter = parameters[reference.parameterIndex]
- return parameterFactory.expand(
+ return builderData.parameterFactory.expand(
rootId,
node.id,
node.anchorId,
@@ -221,665 +220,43 @@
)
}
- /** Reset any state accumulated between windows. */
- @Suppress("unused")
- fun resetAccumulativeState() {
- subCompositions.resetAccumulativeState()
- parameterFactory.clearReferenceCache()
- // Reset the generated id. Nodes are assigned an id if there isn't a layout node id present.
- generatedId = -1L
+ private fun castValue(parameter: ParameterInformation): Any? {
+ val value = parameter.value ?: return null
+ if (parameter.inlineClass == null || !value.javaClass.isPrimitiveClass()) return value
+ return builderData.inlineClassConverter.castParameterValue(parameter.inlineClass, value)
}
private fun clear() {
- cache.clear()
- inlineClassConverter.clear()
- claimedNodes.clear()
- treeMap.clear()
- ownerMap.clear()
- semanticsMap.clear()
- unmergedSemanticsMap.clear()
- stitched.clear()
- subCompositions.clear()
- foundNode = null
+ builderData.clear()
+ rootByComposition.clear()
+ hierarchy.clear()
+ resultByComposition.clear()
+ compositions.clear()
}
- private fun convert(tables: Set<CompositionData>, view: View): List<InspectorNode> {
- val trees = tables.mapNotNull { convert(view, it) }
- return when (trees.size) {
- 0 -> listOf()
- 1 -> addTree(mutableListOf(), trees.single())
- else -> stitchTreesByLayoutInfo(trees)
- }
- }
+ private class SharedBuilderDataImpl : SharedBuilderData {
+ override val cache = ArrayDeque<MutableInspectorNode>()
+ override val contextCache = ContextCache()
+ override val anchorMap = AnchorMap()
+ override val semanticsMap = mutableIntObjectMapOf<List<RawParameter>>()
+ override val unmergedSemanticsMap = mutableIntObjectMapOf<List<RawParameter>>()
+ override val inlineClassConverter = InlineClassConverter()
+ override val parameterFactory = ParameterFactory(inlineClassConverter)
+ override var generatedId = -1L
+ override var hideSystemNodes = true
+ override var includeAllParameters = true
- /**
- * Stitch separate trees together using the [LayoutInfo]s found in the [CompositionData]s.
- *
- * Some constructs in Compose (e.g. ModalDrawer) will result is multiple [CompositionData]s.
- * This code will attempt to stitch the resulting [InspectorNode] trees together by looking at
- * the parent of each [LayoutInfo].
- *
- * If this algorithm is successful the result of this function will be a list with a single
- * tree.
- */
- private fun stitchTreesByLayoutInfo(trees: List<MutableInspectorNode>): List<InspectorNode> {
- val layoutToTreeMap = IdentityHashMap<LayoutInfo, MutableInspectorNode>()
- trees.forEach { tree -> tree.layoutNodes.forEach { layoutToTreeMap[it] = tree } }
- trees.forEach { tree ->
- val layout = tree.layoutNodes.lastOrNull()
- val parentLayout =
- generateSequence(layout) { it.parentInfo }
- .firstOrNull {
- val otherTree = layoutToTreeMap[it]
- otherTree != null && otherTree != tree
- }
- if (parentLayout != null) {
- val ownerNode = claimedNodes[parentLayout]
- val ownerTree = layoutToTreeMap[parentLayout]
- if (ownerNode != null && ownerTree != null) {
- ownerMap.getOrPut(ownerNode) { mutableListOf() }.add(tree)
- treeMap.getOrPut(ownerTree) { mutableListOf() }.add(tree)
- }
- }
- }
- var parentTree = findDeepParentTree()
- while (parentTree != null) {
- addSubTrees(parentTree)
- treeMap.remove(parentTree)
- parentTree = findDeepParentTree()
- }
- val result = mutableListOf<InspectorNode>()
- trees.asSequence().filter { !stitched.contains(it) }.forEach { addTree(result, it) }
- return result
- }
-
- /**
- * Return a parent tree where the children trees (to be stitched under the parent) are not a
- * parent themselves. Do this to avoid rebuilding the same tree more than once.
- */
- private fun findDeepParentTree(): MutableInspectorNode? =
- treeMap.entries
- .asSequence()
- .filter { (_, children) -> children.none { treeMap.containsKey(it) } }
- .firstOrNull()
- ?.key
-
- private fun addSubTrees(tree: MutableInspectorNode) {
- for ((index, child) in tree.children.withIndex()) {
- tree.children[index] = addSubTrees(child) ?: child
- }
- }
-
- /**
- * Rebuild [node] with any possible sub trees added (stitched in). Return the rebuild node, or
- * null if no changes were found in this node or its children. Lazily allocate the new node to
- * avoid unnecessary allocations.
- */
- private fun addSubTrees(node: InspectorNode): InspectorNode? {
- var newNode: MutableInspectorNode? = null
- for ((index, child) in node.children.withIndex()) {
- val newChild = addSubTrees(child)
- if (newChild != null) {
- val newCopy = newNode ?: newNode(node)
- newCopy.children[index] = newChild
- newNode = newCopy
- }
- }
- val trees = ownerMap[node]
- if (trees == null && newNode == null) {
- return null
- }
- val newCopy = newNode ?: newNode(node)
- if (trees != null) {
- trees.forEach { addTree(newCopy.children, it) }
- stitched.addAll(trees)
- }
- return buildAndRelease(newCopy)
- }
-
- /**
- * Add [tree] to the end of the [out] list. The root nodes of [tree] may be a fake node that
- * hold a list of [LayoutInfo].
- */
- private fun addTree(
- out: MutableList<InspectorNode>,
- tree: MutableInspectorNode
- ): List<InspectorNode> {
- tree.children.forEach {
- if (it.name.isNotEmpty()) {
- out.add(it)
- } else {
- out.addAll(it.children)
- }
- }
- return out
- }
-
- private fun convert(view: View, table: CompositionData): MutableInspectorNode? {
- val fakeParent = newNode()
- val group = table.mapTree(::convert, contextCache) ?: return null
- addToParent(fakeParent, listOf(group), buildFakeChildNodes = true)
- return if (belongsToView(fakeParent.layoutNodes, view)) fakeParent else null
- }
-
- private fun convert(
- group: CompositionGroup,
- context: SourceContext,
- children: List<MutableInspectorNode>
- ): MutableInspectorNode {
- val parent = parse(group, context, children)
- subCompositions.captureNode(parent, context)
- addToParent(parent, children)
- return parent
- }
-
- /**
- * Adds the nodes in [input] to the children of [parentNode]. Nodes without a reference to a
- * wanted Composable are skipped unless [buildFakeChildNodes]. A single skipped render id and
- * layoutNode will be added to [parentNode].
- */
- private fun addToParent(
- parentNode: MutableInspectorNode,
- input: List<MutableInspectorNode>,
- buildFakeChildNodes: Boolean = false
- ) {
- // If we're adding an unwanted node from the `input` to the parent node and it has a
- // View ID, then assign it to the parent view so that we don't lose the context that we
- // found a View as a descendant of the parent node. Most likely, there were one or more
- // unwanted intermediate nodes between the node that actually owns the Android View
- // and the desired node that the View should be associated with in the inspector. If
- // there's more than one input node with a View ID, we skip this step since it's
- // unclear how these views would be related.
- input
- .singleOrNull { it.viewId != UNDEFINED_ID }
- ?.takeIf { node ->
- // Take if the node has been marked as unwanted
- node.name.isEmpty()
- }
- ?.let { nodeWithView -> parentNode.viewId = nodeWithView.viewId }
-
- var id: Long? = null
- input.forEach { node ->
- if (node.name.isEmpty() && !(buildFakeChildNodes && node.layoutNodes.isNotEmpty())) {
- parentNode.children.addAll(node.children)
- if (node.id > UNDEFINED_ID) {
- // If multiple siblings with a render ids are dropped:
- // Ignore them all. And delegate the drawing to a parent in the inspector.
- id = if (id == null) node.id else UNDEFINED_ID
- }
- } else {
- node.id = if (node.id != UNDEFINED_ID) node.id else --generatedId
- val withSemantics = node.packageHash !in systemPackages
- val resultNode = node.build(withSemantics)
- // TODO: replace getOrPut with putIfAbsent which requires API level 24
- node.layoutNodes.forEach { claimedNodes.getOrPut(it) { resultNode } }
- parentNode.children.add(resultNode)
- if (withSemantics) {
- node.mergedSemantics.clear()
- node.unmergedSemantics.clear()
- }
- }
- if (node.bounds != null && parentNode.box == node.box) {
- parentNode.bounds = node.bounds
- }
- parentNode.layoutNodes.addAll(node.layoutNodes)
- parentNode.mergedSemantics.addAll(node.mergedSemantics)
- parentNode.unmergedSemantics.addAll(node.unmergedSemantics)
- release(node)
- }
- val nodeId = id
- parentNode.id =
- if (parentNode.id <= UNDEFINED_ID && nodeId != null) nodeId else parentNode.id
- }
-
- @OptIn(InternalComposeUiApi::class)
- private fun parse(
- group: CompositionGroup,
- context: SourceContext,
- children: List<MutableInspectorNode>
- ): MutableInspectorNode {
- val node = newNode()
- node.name = context.name ?: ""
- node.key = group.key as? Int ?: 0
- node.inlined = context.isInline
-
- // If this node is associated with an android View, set the node's viewId to point to
- // the hosted view. We use the parent's uniqueDrawingId since the interopView returned here
- // will be the view itself, but we want to use the `AndroidViewHolder` that hosts the view
- // instead of the view directly.
- (group.node as? InteroperableComposeUiNode?)?.getInteropView()?.let { interopView ->
- (interopView.parent as? View)?.uniqueDrawingId?.let { viewId -> node.viewId = viewId }
+ fun setDensity(view: View) {
+ parameterFactory.density = Density(view.context)
}
- val layoutInfo = group.node as? LayoutInfo
- if (layoutInfo != null) {
- return parseLayoutInfo(layoutInfo, context, node)
- }
- if (unwantedOutsideWindow(node, children)) {
- return markUnwanted(group, context, node)
- }
- node.box = context.bounds.emptyCheck()
- if (unwantedName(node.name) || (node.box == emptyBox && !subCompositions.capturing)) {
- return markUnwanted(group, context, node)
- }
- parseCallLocation(node, context.location)
- if (isHiddenSystemNode(node)) {
- return markUnwanted(group, context, node)
- }
- node.anchorId = anchorMap[group.identity]
- node.id = syntheticId(node.anchorId)
- if (includeAllParameters) {
- addParameters(context, node)
- }
- return node
- }
-
- private fun IntRect.emptyCheck(): IntRect =
- if (left >= right && top >= bottom) emptyBox else this
-
- private fun IntRect.inWindow(): Boolean =
- !(left > windowSize.width || right < 0 || top > windowSize.height || bottom < 0)
-
- private fun IntRect.union(other: IntRect): IntRect {
- if (this == outsideBox) return other else if (other == outsideBox) return this
-
- return IntRect(
- left = min(left, other.left),
- top = min(top, other.top),
- bottom = max(bottom, other.bottom),
- right = max(right, other.right)
- )
- }
-
- private fun parseLayoutInfo(
- layoutInfo: LayoutInfo,
- context: SourceContext,
- node: MutableInspectorNode
- ): MutableInspectorNode {
- val box = context.bounds
- val size = box.size.toSize()
- val coordinates = layoutInfo.coordinates
- var bounds: QuadBounds? = null
- if (layoutInfo.isAttached && coordinates.isAttached) {
- val topLeft = toIntOffset(coordinates.localToWindow(Offset.Zero))
- val topRight = toIntOffset(coordinates.localToWindow(Offset(size.width, 0f)))
- val bottomRight =
- toIntOffset(coordinates.localToWindow(Offset(size.width, size.height)))
- val bottomLeft = toIntOffset(coordinates.localToWindow(Offset(0f, size.height)))
-
- if (
- topLeft.x != box.left ||
- topLeft.y != box.top ||
- topRight.x != box.right ||
- topRight.y != box.top ||
- bottomRight.x != box.right ||
- bottomRight.y != box.bottom ||
- bottomLeft.x != box.left ||
- bottomLeft.y != box.bottom
- ) {
- bounds =
- QuadBounds(
- topLeft.x,
- topLeft.y,
- topRight.x,
- topRight.y,
- bottomRight.x,
- bottomRight.y,
- bottomLeft.x,
- bottomLeft.y,
- )
- }
- }
- if (!includeNodesOutsizeOfWindow) {
- // Ignore this node if the bounds are completely outside the window
- node.outerBox = bounds?.outerBox ?: box
- if (!node.outerBox.inWindow()) {
- return node
- }
- }
-
- node.box = box.emptyCheck()
- node.bounds = bounds
- node.layoutNodes.add(layoutInfo)
- val modifierInfo = layoutInfo.getModifierInfo()
-
- val unmergedSemantics = unmergedSemanticsMap[layoutInfo.semanticsId]
- if (unmergedSemantics != null) {
- node.unmergedSemantics.addAll(unmergedSemantics)
- }
-
- val mergedSemantics = semanticsMap[layoutInfo.semanticsId]
- if (mergedSemantics != null) {
- node.mergedSemantics.addAll(mergedSemantics)
- }
-
- node.id =
- modifierInfo
- .asSequence()
- .map { it.extra }
- .filterIsInstance<GraphicLayerInfo>()
- .map { it.layerId }
- .firstOrNull() ?: UNDEFINED_ID
-
- return node
- }
-
- private fun syntheticId(anchorId: Int): Long {
- if (anchorId == NO_ANCHOR_ID) {
- return UNDEFINED_ID
- }
- // The anchorId is an Int
- return anchorId.toLong() - Int.MAX_VALUE.toLong() + RESERVED_FOR_GENERATED_IDS
- }
-
- /**
- * Returns true if the [layoutNodes] belong under the specified [view].
- *
- * For: popups & Dialogs we may encounter parts of a compose tree that belong under a different
- * sub-composition. Consider these nodes to "belong" to the current sub-composition under [view]
- * if the ownerViews contains [view] or doesn't contain any owner views at all.
- */
- private fun belongsToView(layoutNodes: List<LayoutInfo>, view: View): Boolean {
- val ownerViewIds = ownerViews(layoutNodes)
- return ownerViewIds.isEmpty() || ownerViewIds.contains(view.uniqueDrawingId)
- }
-
- private fun ownerViews(layoutNodes: List<LayoutInfo>): LongList {
- val ownerViewIds = mutableLongListOf()
- layoutNodes.forEach { node ->
- node.getModifierInfo().forEach { info ->
- val extra = info.extra
- if (extra is GraphicLayerInfo) {
- ownerViewIds.add(extra.ownerViewId)
- }
- }
- }
- return ownerViewIds
- }
-
- private fun addParameters(context: SourceContext, node: MutableInspectorNode) {
- context.parameters.forEach {
- val castedValue = castValue(it)
- node.parameters.add(RawParameter(it.name, castedValue))
- }
- }
-
- private fun castValue(parameter: ParameterInformation): Any? {
- val value = parameter.value ?: return null
- if (parameter.inlineClass == null || !isPrimitive(value.javaClass)) return value
- return inlineClassConverter.castParameterValue(parameter.inlineClass, value)
- }
-
- private fun isPrimitive(cls: Class<*>): Boolean = cls.kotlin.javaPrimitiveType != null
-
- private fun toIntOffset(offset: Offset): IntOffset =
- IntOffset(offset.x.roundToInt(), offset.y.roundToInt())
-
- private fun markUnwanted(
- group: CompositionGroup,
- context: SourceContext,
- node: MutableInspectorNode
- ): MutableInspectorNode =
- when (node.name) {
- "rememberCompositionContext" ->
- subCompositions.rememberCompositionContext(node, context)
- "remember" -> subCompositions.remember(node, group)
- else -> node.apply { markUnwanted() }
- }
-
- private fun parseCallLocation(node: MutableInspectorNode, location: SourceLocation?) {
- val fileName = location?.sourceFile ?: return
- node.fileName = fileName
- node.packageHash = location.packageHash
- node.lineNumber = location.lineNumber
- node.offset = location.offset
- node.length = location.length
- }
-
- private fun isHiddenSystemNode(node: MutableInspectorNode): Boolean =
- node.packageHash in systemPackages && hideSystemNodes
-
- private fun unwantedName(name: String): Boolean =
- name.isEmpty() || name.startsWith("remember") || name in unwantedCalls
-
- private fun unwantedOutsideWindow(
- node: MutableInspectorNode,
- children: List<MutableInspectorNode>
- ): Boolean {
- if (includeNodesOutsizeOfWindow) {
- return false
- }
- node.outerBox =
- if (children.isEmpty()) outsideBox
- else children.map { g -> g.outerBox }.reduce { acc, box -> box.union(acc) }
- return !node.outerBox.inWindow()
- }
-
- private fun newNode(): MutableInspectorNode =
- if (cache.isNotEmpty()) cache.pop() else MutableInspectorNode()
-
- private fun newNode(copyFrom: InspectorNode): MutableInspectorNode =
- newNode().shallowCopy(copyFrom)
-
- private fun release(node: MutableInspectorNode) {
- node.reset()
- cache.add(node)
- }
-
- private fun buildAndRelease(node: MutableInspectorNode): InspectorNode {
- val result = node.build()
- release(node)
- return result
- }
-
- /**
- * Keep track of sub-composition roots.
- *
- * Examples:
- * - Popup, Dialog: When one of these is open an extra Android Window is created with its own
- * AndroidComposeView. The contents of the Composable is a sub-composition that will be
- * computed by calling convert.
- *
- * The Popup/Dialog composable itself, and a few helping composables (the root) will not be
- * included in the SlotTree with the contents, instead these composables will be found in the
- * SlotTree for the main app and they all have empty sizes. The aim is to collect these
- * sub-composition roots such that they can be added to the [InspectorNode]s of the contents.
- * - AndroidView: When this is used in a compose app we will see a similar pattern in the
- * SlotTree except there isn't a sub-composition to stitch in. But we need to collect the view
- * id separately from the "AndroidView" node itself.
- */
- private inner class SubCompositionRoots {
- /** Set to true when the nodes found should be added to a sub-composition root */
- var capturing = false
- private set
-
- /** The `uniqueDrawingId` of the `AndroidComposeView` that owns the root being captured */
- private var ownerView = UNDEFINED_ID
-
- /** The node that represent the root of the sub-composition */
- private var rootNode: MutableInspectorNode? = null
-
- /** The depth of the parse tree the [rootNode] was found at */
- private var rootNodeDepth = 0
-
- /** Last captured view that is believed to be an embbed View under an AndroidView node */
- private var androidView = UNDEFINED_ID
-
- /**
- * The sub-composition roots found.
- *
- * Map from View owner to a pair of [InspectorNode] indicating the actual root, and the node
- * where the content should be stitched in.
- */
- private val found = mutableLongObjectMapOf<InspectorNode>()
-
- /** Call this before converting a SlotTree for an AndroidComposeView */
fun clear() {
- capturing = false
- ownerView = UNDEFINED_ID
- rootNode?.markUnwanted()
- rootNode?.id = UNDEFINED_ID
- rootNode = null
- rootNodeDepth = 0
+ cache.clear()
+ semanticsMap.clear()
+ unmergedSemanticsMap.clear()
+ inlineClassConverter.clear()
+ parameterFactory.clearReferenceCache()
+ generatedId = -1L
}
-
- /** Call this when starting converting a new set of windows */
- fun resetAccumulativeState() {
- found.clear()
- }
-
- /**
- * When a "rememberCompositionContext" is found in the slot tree, it indicates that a
- * sub-composition was started. We should capture all parent nodes with an empty size as the
- * "root" of the sub-composition.
- */
- fun rememberCompositionContext(
- node: MutableInspectorNode,
- context: SourceContext
- ): MutableInspectorNode {
- if (capturing) {
- save()
- }
- capturing = true
- rootNode = node
- rootNodeDepth = context.depth
- node.id = PLACEHOLDER_ID
- return node
- }
-
- /**
- * When "remember" is found in the slot tree and we are currently capturing, the data of the
- * [group] may contain the owner of the sub-composition.
- */
- fun remember(node: MutableInspectorNode, group: CompositionGroup): MutableInspectorNode {
- node.markUnwanted()
- if (!capturing) {
- return node
- }
- val root = findSingleRootInGroupData(group) ?: return node
-
- val view = root.subCompositionView
- if (view != null) {
- val composeOwner = if (view.childCount == 1) view.getChildAt(0) else return node
- ownerView = composeOwner.uniqueDrawingId
- } else {
- androidView = root.viewRoot?.uniqueDrawingId ?: UNDEFINED_ID
- // Store the viewRoot such that we can move the View under the compose node
- // in Studio. We do not need to capture the Groups found for this case, so
- // we call "reset" here to stop capturing.
- clear()
- }
- return node
- }
-
- private fun findSingleRootInGroupData(group: CompositionGroup): ViewRootForInspector? {
- group.data.filterIsInstance<ViewRootForInspector>().singleOrNull()?.let {
- return it
- }
- group.data.filterIsInstance<ComposeView>().singleOrNull()?.let {
- return object : ViewRootForInspector {
- override val subCompositionView: AbstractComposeView
- get() = it
- }
- }
- val refs = group.data.filterIsInstance<Ref<*>>().map { it.value }
- return refs.filterIsInstance<ViewRootForInspector>().singleOrNull()
- }
-
- /** Capture the top node of the sub-composition root until a non empty node is found. */
- fun captureNode(node: MutableInspectorNode, context: SourceContext) {
- if (!capturing) {
- return
- }
- if (node.box != emptyBox) {
- save()
- return
- }
- val depth = context.depth
- if (depth < rootNodeDepth) {
- rootNode = node
- rootNodeDepth = depth
- }
- }
-
- fun latestViewId(): Long {
- val id = androidView
- androidView = UNDEFINED_ID
- return id
- }
-
- /** If a sub-composition root has been captured, save it now. */
- private fun save() {
- val node = rootNode
- if (node != null && ownerView != UNDEFINED_ID) {
- found[ownerView] = node.build()
- }
- node?.markUnwanted()
- node?.id = UNDEFINED_ID
- node?.children?.clear()
- clear()
- }
-
- /**
- * Add the root of the sub-composition to the found tree.
- *
- * If a root is not found for this [owner] or if the stitching fails just return [nodes].
- */
- fun addRoot(owner: View, nodes: List<InspectorNode>): List<InspectorNode> {
- val root = found[owner.uniqueDrawingId]?.let { skipEmptyRoot(it) } ?: return nodes
- val box = IntRect(0, 0, owner.width, owner.height)
- val info = StitchInfo(nodes, box)
- val result = listOf(stitch(root, info))
- return if (info.added) result else nodes
- }
-
- /**
- * The root of a sub-composition often has a root with an empty name. If the root has a
- * single child: skip the empty node. Otherwise: select an arbitrary child node name and use
- * for the root (prefer functions with an uppercase name).
- */
- private fun skipEmptyRoot(node: InspectorNode): InspectorNode =
- when {
- node.name.isNotEmpty() -> node
- node.children.isEmpty() -> node // This should not happen
- node.children.size == 1 -> node.children.single()
- else -> {
- val newNode = newNode()
- newNode.shallowCopy(node)
- val firstUpperCaseNamedChild =
- node.children.firstOrNull { it.name.firstOrNull()?.isUpperCase() ?: false }
- newNode.name = firstUpperCaseNamedChild?.name ?: node.children.first().name
- buildAndRelease(newNode)
- }
- }
-
- private fun stitch(node: InspectorNode, info: StitchInfo): InspectorNode {
- val children = node.children.map { stitch(it, info) }
- val index = children.indexOfFirst { it.id == PLACEHOLDER_ID }
- val newNode = newNode()
- newNode.shallowCopy(node)
- newNode.children.clear()
- if (index < 0) {
- newNode.children.addAll(children)
- } else {
- newNode.children.addAll(children.subList(0, index))
- newNode.children.addAll(info.nodes)
- newNode.children.addAll(children.subList(index + 1, children.size))
- info.added = true
- }
- newNode.box = info.bounds
- return buildAndRelease(newNode)
- }
- }
-
- private class StitchInfo(
- /** The nodes found that should be stitched into a sub-composition root. */
- val nodes: List<InspectorNode>,
-
- /** The bounds of the View containing the sub-composition */
- val bounds: IntRect
- ) {
- /** Set this to true when the [nodes] have been added to a sub-composition root */
- var added: Boolean = false
}
}
diff --git a/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/proto/ComposeExtensions.kt b/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/proto/ComposeExtensions.kt
index 2ba469d..8af6aca 100644
--- a/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/proto/ComposeExtensions.kt
+++ b/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/proto/ComposeExtensions.kt
@@ -36,7 +36,7 @@
import layoutinspector.compose.inspection.LayoutInspectorComposeProtocol.Rect
internal fun InspectorNode.toComposableNode(context: ConversionContext): ComposableNode {
- return toNodeBuilder(context).resetSystemFlag().build()
+ return toNodeBuilder(context).build()
}
private val SELECTOR_EXPR = Regex("(\\\$(lambda-)?[0-9]+)+$")
diff --git a/lifecycle/lifecycle-viewmodel-testing/src/nonJvmCommonMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.nonJvm.kt b/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/util/Primitive.kt
similarity index 70%
copy from lifecycle/lifecycle-viewmodel-testing/src/nonJvmCommonMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.nonJvm.kt
copy to compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/util/Primitive.kt
index e220c67..3d2e5184 100644
--- a/lifecycle/lifecycle-viewmodel-testing/src/nonJvmCommonMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.nonJvm.kt
+++ b/compose/ui/ui-inspection/src/main/java/androidx/compose/ui/inspection/util/Primitive.kt
@@ -14,9 +14,7 @@
* limitations under the License.
*/
-package androidx.lifecycle.viewmodel.testing
+package androidx.compose.ui.inspection.util
-import androidx.lifecycle.viewmodel.CreationExtras
-import androidx.lifecycle.viewmodel.CreationExtras.Empty
-
-@Suppress("FunctionName") public actual fun DefaultCreationExtras(): CreationExtras = Empty
+/** Returns true if a class is a primitive class */
+fun Class<*>.isPrimitiveClass(): Boolean = this.kotlin.javaPrimitiveType != null
diff --git a/compose/ui/ui-inspection/src/main/proto/compose_layout_inspection.proto b/compose/ui/ui-inspection/src/main/proto/compose_layout_inspection.proto
index af96d0d..fe643a8 100644
--- a/compose/ui/ui-inspection/src/main/proto/compose_layout_inspection.proto
+++ b/compose/ui/ui-inspection/src/main/proto/compose_layout_inspection.proto
@@ -91,7 +91,7 @@
INLINED = 0x8;
// If a node has the NESTED_SINGLE_CHILDREN flag, it means the children should be
// interpreted as a subtree of single nodes.
- NESTED_SINGLE_CHILDREN = 0x16;
+ NESTED_SINGLE_CHILDREN = 0x10;
}
int32 flags = 9;
diff --git a/compose/ui/ui/api/current.txt b/compose/ui/ui/api/current.txt
index ee772c6..ecec976 100644
--- a/compose/ui/ui/api/current.txt
+++ b/compose/ui/ui/api/current.txt
@@ -2458,6 +2458,7 @@
method public int getHeight();
method public androidx.compose.ui.unit.LayoutDirection getLayoutDirection();
method public java.util.List<androidx.compose.ui.layout.ModifierInfo> getModifierInfo();
+ method public default Object? getOpaqueOwner();
method public androidx.compose.ui.layout.LayoutInfo? getParentInfo();
method public int getSemanticsId();
method public androidx.compose.ui.platform.ViewConfiguration getViewConfiguration();
@@ -2472,6 +2473,7 @@
property public default boolean isDeactivated;
property public abstract boolean isPlaced;
property public abstract androidx.compose.ui.unit.LayoutDirection layoutDirection;
+ property public default Object? opaqueOwner;
property public abstract androidx.compose.ui.layout.LayoutInfo? parentInfo;
property public abstract int semanticsId;
property public abstract androidx.compose.ui.platform.ViewConfiguration viewConfiguration;
diff --git a/compose/ui/ui/api/restricted_current.txt b/compose/ui/ui/api/restricted_current.txt
index 74a28d7..95de030 100644
--- a/compose/ui/ui/api/restricted_current.txt
+++ b/compose/ui/ui/api/restricted_current.txt
@@ -2459,6 +2459,7 @@
method public int getHeight();
method public androidx.compose.ui.unit.LayoutDirection getLayoutDirection();
method public java.util.List<androidx.compose.ui.layout.ModifierInfo> getModifierInfo();
+ method public default Object? getOpaqueOwner();
method public androidx.compose.ui.layout.LayoutInfo? getParentInfo();
method public int getSemanticsId();
method public androidx.compose.ui.platform.ViewConfiguration getViewConfiguration();
@@ -2473,6 +2474,7 @@
property public default boolean isDeactivated;
property public abstract boolean isPlaced;
property public abstract androidx.compose.ui.unit.LayoutDirection layoutDirection;
+ property public default Object? opaqueOwner;
property public abstract androidx.compose.ui.layout.LayoutInfo? parentInfo;
property public abstract int semanticsId;
property public abstract androidx.compose.ui.platform.ViewConfiguration viewConfiguration;
diff --git a/compose/ui/ui/build.gradle b/compose/ui/ui/build.gradle
index a2623dd..74982c0 100644
--- a/compose/ui/ui/build.gradle
+++ b/compose/ui/ui/build.gradle
@@ -73,6 +73,7 @@
jvmMain {
dependsOn(commonMain)
dependencies {
+ api(libs.jspecify)
}
}
diff --git a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/input/focus/FocusAwareEventPropagationTest.kt b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/input/focus/FocusAwareEventPropagationTest.kt
index 3abff91..fffc232 100644
--- a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/input/focus/FocusAwareEventPropagationTest.kt
+++ b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/input/focus/FocusAwareEventPropagationTest.kt
@@ -35,6 +35,7 @@
import androidx.compose.ui.input.key.onPreInterceptKeyBeforeSoftKeyboard
import androidx.compose.ui.input.key.onPreviewKeyEvent
import androidx.compose.ui.input.rotary.RotaryScrollEvent
+import androidx.compose.ui.input.rotary.findRotaryInputDevice
import androidx.compose.ui.input.rotary.onPreRotaryScrollEvent
import androidx.compose.ui.input.rotary.onRotaryScrollEvent
import androidx.compose.ui.test.ExperimentalTestApi
@@ -62,7 +63,7 @@
when (nodeType) {
KeyInput,
InterruptedSoftKeyboardInput -> KeyEvent(AndroidKeyEvent(ACTION_DOWN, KEYCODE_A))
- RotaryInput -> RotaryScrollEvent(1f, 1f, 0L, 0)
+ RotaryInput -> RotaryScrollEvent(1f, 1f, 0L, findRotaryInputDevice())
}
private var receivedEvent: Any? = null
private val initialFocus = FocusRequester()
diff --git a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/input/rotary/RotaryScrollEventTest.kt b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/input/rotary/RotaryScrollEventTest.kt
index aa17a438..f087a90 100644
--- a/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/input/rotary/RotaryScrollEventTest.kt
+++ b/compose/ui/ui/src/androidInstrumentedTest/kotlin/androidx/compose/ui/input/rotary/RotaryScrollEventTest.kt
@@ -45,6 +45,7 @@
import androidx.core.view.InputDeviceCompat.SOURCE_ROTARY_ENCODER
import androidx.core.view.ViewConfigurationCompat.getScaledHorizontalScrollFactor
import androidx.core.view.ViewConfigurationCompat.getScaledVerticalScrollFactor
+import androidx.test.core.app.ApplicationProvider
import androidx.test.core.view.MotionEventBuilder
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
@@ -280,6 +281,9 @@
@Test
fun verticalRotaryEventContainsDeviceId() {
+ // Ignore on all devices which doesn't have rotary input.
+ Assume.assumeTrue(findRotaryInputDevice() != 0)
+
// Arrange.
ContentWithInitialFocus {
Box(
@@ -291,8 +295,6 @@
.focusable(initiallyFocused = true)
)
}
- // Ignore on all devices which doesn't have rotary input.
- Assume.assumeTrue(hasRotaryInputDevice())
// Act.
@OptIn(ExperimentalTestApi::class)
@@ -304,6 +306,9 @@
@Test
fun horizontalRotaryEventContainsDeviceId() {
+ // Ignore on all devices which doesn't have rotary input.
+ Assume.assumeTrue(findRotaryInputDevice() != 0)
+
// Arrange.
ContentWithInitialFocus {
Box(
@@ -315,8 +320,6 @@
.focusable(initiallyFocused = true)
)
}
- // Ignore on all devices which doesn't have rotary input.
- Assume.assumeTrue(hasRotaryInputDevice())
// Act.
@OptIn(ExperimentalTestApi::class)
@@ -562,19 +565,22 @@
private val verticalScrollFactor: Float
get() =
getScaledVerticalScrollFactor(ViewConfiguration.get(rootView.context), rootView.context)
+}
- private fun hasRotaryInputDevice(): Boolean {
- with(rootView.context.getSystemService(Context.INPUT_SERVICE) as InputManager) {
- inputDeviceIds.forEach { deviceId ->
- getInputDevice(deviceId)?.apply {
- motionRanges
- .find { it.source == SOURCE_ROTARY_ENCODER }
- ?.let {
- return true
- }
- }
+internal fun findRotaryInputDevice(): Int {
+ with(
+ ApplicationProvider.getApplicationContext<Context>().getSystemService(Context.INPUT_SERVICE)
+ as InputManager
+ ) {
+ inputDeviceIds.forEach { deviceId ->
+ getInputDevice(deviceId)?.apply {
+ motionRanges
+ .find { it.source == SOURCE_ROTARY_ENCODER }
+ ?.let {
+ return deviceId
+ }
}
}
- return false
}
+ return 0
}
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/LayoutInfo.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/LayoutInfo.kt
index 1cae860..03f792d 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/LayoutInfo.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/layout/LayoutInfo.kt
@@ -69,6 +69,13 @@
*/
val isDeactivated: Boolean
get() = false
+
+ /**
+ * The owner this layout info. This is used by tooling to match a layer to the associated
+ * AndroidComposeView.
+ */
+ val opaqueOwner: Any?
+ get() = null
}
/** Used by tooling to examine the modifiers on a [LayoutInfo]. */
diff --git a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/LayoutNode.kt b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/LayoutNode.kt
index 52b158e..319995a 100644
--- a/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/LayoutNode.kt
+++ b/compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/node/LayoutNode.kt
@@ -1288,6 +1288,9 @@
override var isDeactivated = false
private set
+ override val opaqueOwner: Any?
+ get() = owner
+
override fun onReuse() {
requirePrecondition(isAttached) { "onReuse is only expected on attached node" }
interopViewFactoryHolder?.onReuse()
diff --git a/compose/ui/ui/src/main/java/androidx/compose/ui/platform/coreshims/AutofillIdCompat.java b/compose/ui/ui/src/main/java/androidx/compose/ui/platform/coreshims/AutofillIdCompat.java
index 53360b6..76a6dcc 100644
--- a/compose/ui/ui/src/main/java/androidx/compose/ui/platform/coreshims/AutofillIdCompat.java
+++ b/compose/ui/ui/src/main/java/androidx/compose/ui/platform/coreshims/AutofillIdCompat.java
@@ -18,10 +18,11 @@
import android.view.autofill.AutofillId;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Helper for accessing features in {@link AutofillId}.
*/
@@ -45,8 +46,7 @@
* @return wrapped class
*/
@RequiresApi(26)
- @NonNull
- public static AutofillIdCompat toAutofillIdCompat(@NonNull AutofillId autofillId) {
+ public static @NonNull AutofillIdCompat toAutofillIdCompat(@NonNull AutofillId autofillId) {
return new AutofillIdCompat(autofillId);
}
@@ -60,8 +60,7 @@
* @see AutofillIdCompat#toAutofillIdCompat(AutofillId)
*/
@RequiresApi(26)
- @NonNull
- public AutofillId toAutofillId() {
+ public @NonNull AutofillId toAutofillId() {
return (AutofillId) mWrappedObj;
}
}
diff --git a/compose/ui/ui/src/main/java/androidx/compose/ui/platform/coreshims/ContentCaptureSessionCompat.java b/compose/ui/ui/src/main/java/androidx/compose/ui/platform/coreshims/ContentCaptureSessionCompat.java
index a62dd2a..476a580 100644
--- a/compose/ui/ui/src/main/java/androidx/compose/ui/platform/coreshims/ContentCaptureSessionCompat.java
+++ b/compose/ui/ui/src/main/java/androidx/compose/ui/platform/coreshims/ContentCaptureSessionCompat.java
@@ -24,11 +24,12 @@
import android.view.autofill.AutofillId;
import android.view.contentcapture.ContentCaptureSession;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
import java.util.Objects;
@@ -55,8 +56,7 @@
* @return wrapped class
*/
@RequiresApi(29)
- @NonNull
- public static ContentCaptureSessionCompat toContentCaptureSessionCompat(
+ public static @NonNull ContentCaptureSessionCompat toContentCaptureSessionCompat(
@NonNull ContentCaptureSession contentCaptureSession, @NonNull View host) {
return new ContentCaptureSessionCompat(contentCaptureSession, host);
}
@@ -71,8 +71,7 @@
* @see ContentCaptureSessionCompat#toContentCaptureSessionCompat(ContentCaptureSession, View)
*/
@RequiresApi(29)
- @NonNull
- public ContentCaptureSession toContentCaptureSession() {
+ public @NonNull ContentCaptureSession toContentCaptureSession() {
return (ContentCaptureSession) mWrappedObj;
}
@@ -103,8 +102,7 @@
*
* @return {@link AutofillId} for the virtual child
*/
- @Nullable
- public AutofillId newAutofillId(long virtualChildId) {
+ public @Nullable AutofillId newAutofillId(long virtualChildId) {
if (SDK_INT >= 29) {
return Api29Impl.newAutofillId(
(ContentCaptureSession) mWrappedObj,
@@ -130,8 +128,7 @@
*
* @return a new {@link ViewStructure} that can be used for Content Capture purposes.
*/
- @Nullable
- public ViewStructureCompat newVirtualViewStructure(
+ public @Nullable ViewStructureCompat newVirtualViewStructure(
@NonNull AutofillId parentId, long virtualId) {
if (SDK_INT >= 29) {
return ViewStructureCompat.toViewStructureCompat(
@@ -194,7 +191,7 @@
*
* @param virtualIds ids of the virtual children.
*/
- public void notifyViewsDisappeared(@NonNull long[] virtualIds) {
+ public void notifyViewsDisappeared(long @NonNull [] virtualIds) {
if (SDK_INT >= 34) {
Api29Impl.notifyViewsDisappeared(
(ContentCaptureSession) mWrappedObj,
diff --git a/compose/ui/ui/src/main/java/androidx/compose/ui/platform/coreshims/ViewCompatShims.java b/compose/ui/ui/src/main/java/androidx/compose/ui/platform/coreshims/ViewCompatShims.java
index e6cc549..0a87f79d 100644
--- a/compose/ui/ui/src/main/java/androidx/compose/ui/platform/coreshims/ViewCompatShims.java
+++ b/compose/ui/ui/src/main/java/androidx/compose/ui/platform/coreshims/ViewCompatShims.java
@@ -22,11 +22,12 @@
import android.view.contentcapture.ContentCaptureSession;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -117,8 +118,7 @@
* inherited by ancestors, default session or {@code null} if content capture is disabled for
* this view.
*/
- @Nullable
- public static ContentCaptureSessionCompat getContentCaptureSession(@NonNull View v) {
+ public static @Nullable ContentCaptureSessionCompat getContentCaptureSession(@NonNull View v) {
if (Build.VERSION.SDK_INT >= 29) {
ContentCaptureSession session = Api29Impl.getContentCaptureSession(v);
if (session == null) {
@@ -146,8 +146,7 @@
* @param v The View against which to invoke the method.
* @return The View's autofill id.
*/
- @Nullable
- public static AutofillIdCompat getAutofillId(@NonNull View v) {
+ public static @Nullable AutofillIdCompat getAutofillId(@NonNull View v) {
if (Build.VERSION.SDK_INT >= 26) {
return AutofillIdCompat.toAutofillIdCompat(Api26Impl.getAutofillId(v));
}
diff --git a/compose/ui/ui/src/main/java/androidx/compose/ui/platform/coreshims/ViewStructureCompat.java b/compose/ui/ui/src/main/java/androidx/compose/ui/platform/coreshims/ViewStructureCompat.java
index 8bc0994..71f2d7f 100644
--- a/compose/ui/ui/src/main/java/androidx/compose/ui/platform/coreshims/ViewStructureCompat.java
+++ b/compose/ui/ui/src/main/java/androidx/compose/ui/platform/coreshims/ViewStructureCompat.java
@@ -21,11 +21,12 @@
import android.os.Bundle;
import android.view.ViewStructure;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Helper for accessing features in {@link ViewStructure}.
* <p>
@@ -48,8 +49,7 @@
* @return wrapped class
*/
@RequiresApi(23)
- @NonNull
- public static ViewStructureCompat toViewStructureCompat(
+ public static @NonNull ViewStructureCompat toViewStructureCompat(
@NonNull ViewStructure contentCaptureSession) {
return new ViewStructureCompat(contentCaptureSession);
}
@@ -64,8 +64,7 @@
* @see ViewStructureCompat#toViewStructureCompat(ViewStructure)
*/
@RequiresApi(23)
- @NonNull
- public ViewStructure toViewStructure() {
+ public @NonNull ViewStructure toViewStructure() {
return (ViewStructure) mWrappedObj;
}
@@ -200,8 +199,7 @@
* <li>SDK 22 and below, this method returns null.
* </ul>
*/
- @Nullable
- public Bundle getExtras() {
+ public @Nullable Bundle getExtras() {
if (SDK_INT >= 23) {
return Api23Impl.getExtras((ViewStructure) mWrappedObj);
}
diff --git a/constraintlayout/constraintlayout-compose/src/androidInstrumentedTest/kotlin/androidx/constraintlayout/compose/ChainsTest.kt b/constraintlayout/constraintlayout-compose/src/androidInstrumentedTest/kotlin/androidx/constraintlayout/compose/ChainsTest.kt
index d5fd8d1..763e7dc 100644
--- a/constraintlayout/constraintlayout-compose/src/androidInstrumentedTest/kotlin/androidx/constraintlayout/compose/ChainsTest.kt
+++ b/constraintlayout/constraintlayout-compose/src/androidInstrumentedTest/kotlin/androidx/constraintlayout/compose/ChainsTest.kt
@@ -39,119 +39,136 @@
@get:Rule val rule = createComposeRule()
@Test
- fun testHorizontalPacked_withConstraintSet() {
- val rootSize = 100.dp
- val boxSizes = arrayOf(10.dp, 20.dp, 30.dp)
- val margin = 10.dp
- val constraintSet = ConstraintSet {
- val box0 = createRefFor("box0")
- val box1 = createRefFor("box1")
- val box2 = createRefFor("box2")
- val chain0 = createHorizontalChain(box0, box1, chainStyle = ChainStyle.Packed)
+ fun testHorizontalPacked_withConstraintSet(): Unit =
+ with(rule.density) {
+ val rootSizePx = 100f
+ val boxSizesPx = arrayOf(10, 20, 30)
+ val marginPx = 10
+ val constraintSet = ConstraintSet {
+ val box0 = createRefFor("box0")
+ val box1 = createRefFor("box1")
+ val box2 = createRefFor("box2")
+ val chain0 = createHorizontalChain(box0, box1, chainStyle = ChainStyle.Packed)
- constrain(box0) {
- width = Dimension.value(boxSizes[0])
- height = Dimension.value(boxSizes[0])
- centerVerticallyTo(parent)
+ constrain(box0) {
+ width = Dimension.value(boxSizesPx[0].toDp())
+ height = Dimension.value(boxSizesPx[0].toDp())
+ centerVerticallyTo(parent)
+ }
+ constrain(box1) {
+ width = Dimension.value(boxSizesPx[1].toDp())
+ height = Dimension.value(boxSizesPx[1].toDp())
+ centerVerticallyTo(box0)
+ }
+ constrain(box2) {
+ width = Dimension.value(boxSizesPx[2].toDp())
+ height = Dimension.value(boxSizesPx[2].toDp())
+ top.linkTo(parent.top, marginPx.toDp())
+ start.linkTo(parent.start, marginPx.toDp())
+ }
+ constrain(chain0) { start.linkTo(box2.end, marginPx.toDp()) }
}
- constrain(box1) {
- width = Dimension.value(boxSizes[1])
- height = Dimension.value(boxSizes[1])
- centerVerticallyTo(box0)
+ rule.setContent {
+ ConstraintLayout(
+ modifier = Modifier.size(rootSizePx.toDp()),
+ constraintSet = constraintSet
+ ) {
+ Box(modifier = Modifier.background(Color.Red).layoutTestId("box0"))
+ Box(modifier = Modifier.background(Color.Blue).layoutTestId("box1"))
+ Box(modifier = Modifier.background(Color.Green).layoutTestId("box2"))
+ }
}
- constrain(box2) {
- width = Dimension.value(boxSizes[2])
- height = Dimension.value(boxSizes[2])
- top.linkTo(parent.top, margin)
- start.linkTo(parent.start, margin)
- }
- constrain(chain0) { start.linkTo(box2.end, margin) }
+ rule.waitForIdle()
+
+ val spaceForChain = rootSizePx - boxSizesPx[2] - (marginPx * 2)
+ val spaceAroundChain = spaceForChain - boxSizesPx[0] - boxSizesPx[1]
+ val spaceAtLeftOfChain = spaceAroundChain * 0.5f
+ val offsetFromBox2 = marginPx + boxSizesPx[2] + marginPx
+
+ val box0Left = offsetFromBox2 + spaceAtLeftOfChain
+ val box0Top = (rootSizePx - boxSizesPx[0]) * 0.5f
+
+ val box1Left = box0Left + boxSizesPx[0]
+ val box1Top = box0Top - ((boxSizesPx[1] - boxSizesPx[0]) * 0.5f)
+
+ rule
+ .onNodeWithTag("box0")
+ .assertPositionInRootIsEqualTo(box0Left.toDp(), box0Top.toDp())
+ rule
+ .onNodeWithTag("box1")
+ .assertPositionInRootIsEqualTo(box1Left.toDp(), box1Top.toDp())
+ rule
+ .onNodeWithTag("box2")
+ .assertPositionInRootIsEqualTo(marginPx.toDp(), marginPx.toDp())
}
- rule.setContent {
- ConstraintLayout(modifier = Modifier.size(rootSize), constraintSet = constraintSet) {
- Box(modifier = Modifier.background(Color.Red).layoutTestId("box0"))
- Box(modifier = Modifier.background(Color.Blue).layoutTestId("box1"))
- Box(modifier = Modifier.background(Color.Green).layoutTestId("box2"))
- }
- }
- rule.waitForIdle()
-
- val spaceForChain = rootSize - boxSizes[2] - (margin * 2)
- val spaceAroundChain = spaceForChain - boxSizes[0] - boxSizes[1]
- val spaceAtLeftOfChain = spaceAroundChain * 0.5f
- val offsetFromBox2 = margin + boxSizes[2] + margin
-
- val box0Left = offsetFromBox2 + spaceAtLeftOfChain
- val box0Top = (rootSize - boxSizes[0]) * 0.5f
-
- val box1Left = box0Left + boxSizes[0] + 0.5.dp // 0.5dp, compensate for a small solver error
- val box1Top = box0Top - ((boxSizes[1] - boxSizes[0]) * 0.5f)
-
- rule.onNodeWithTag("box0").assertPositionInRootIsEqualTo(box0Left, box0Top)
- rule.onNodeWithTag("box1").assertPositionInRootIsEqualTo(box1Left, box1Top)
- rule.onNodeWithTag("box2").assertPositionInRootIsEqualTo(margin, margin)
- }
@Test
- fun testHorizontalPacked_withModifier() {
- val rootSize = 100.dp
- val boxSizes = arrayOf(10.dp, 20.dp, 30.dp)
- val margin = 10.dp
- rule.setContent {
- ConstraintLayout(Modifier.background(Color.LightGray).size(rootSize)) {
- val (box0, box1, box2) = createRefs()
- val chain0 = createHorizontalChain(box0, box1, chainStyle = ChainStyle.Packed)
- constrain(chain0) { start.linkTo(box2.end, margin) }
- Box(
- modifier =
- Modifier.background(Color.Red)
- .constrainAs(box0) {
- width = Dimension.value(boxSizes[0])
- height = Dimension.value(boxSizes[0])
- centerVerticallyTo(parent)
- }
- .layoutTestId("box0")
- )
- Box(
- modifier =
- Modifier.background(Color.Blue)
- .constrainAs(box1) {
- width = Dimension.value(boxSizes[1])
- height = Dimension.value(boxSizes[1])
- centerVerticallyTo(box0)
- }
- .layoutTestId("box1")
- )
- Box(
- modifier =
- Modifier.background(Color.Green)
- .constrainAs(box2) {
- width = Dimension.value(boxSizes[2])
- height = Dimension.value(boxSizes[2])
- top.linkTo(parent.top, margin)
- start.linkTo(parent.start, margin)
- }
- .layoutTestId("box2")
- )
+ fun testHorizontalPacked_withModifier(): Unit =
+ with(rule.density) {
+ val rootSizePx = 100f
+ val boxSizesPx = arrayOf(10, 20, 30)
+ val marginPx = 10f
+ rule.setContent {
+ ConstraintLayout(Modifier.background(Color.LightGray).size(rootSizePx.toDp())) {
+ val (box0, box1, box2) = createRefs()
+ val chain0 = createHorizontalChain(box0, box1, chainStyle = ChainStyle.Packed)
+ constrain(chain0) { start.linkTo(box2.end, marginPx.toDp()) }
+ Box(
+ modifier =
+ Modifier.background(Color.Red)
+ .constrainAs(box0) {
+ width = Dimension.value(boxSizesPx[0].toDp())
+ height = Dimension.value(boxSizesPx[0].toDp())
+ centerVerticallyTo(parent)
+ }
+ .layoutTestId("box0")
+ )
+ Box(
+ modifier =
+ Modifier.background(Color.Blue)
+ .constrainAs(box1) {
+ width = Dimension.value(boxSizesPx[1].toDp())
+ height = Dimension.value(boxSizesPx[1].toDp())
+ centerVerticallyTo(box0)
+ }
+ .layoutTestId("box1")
+ )
+ Box(
+ modifier =
+ Modifier.background(Color.Green)
+ .constrainAs(box2) {
+ width = Dimension.value(boxSizesPx[2].toDp())
+ height = Dimension.value(boxSizesPx[2].toDp())
+ top.linkTo(parent.top, marginPx.toDp())
+ start.linkTo(parent.start, marginPx.toDp())
+ }
+ .layoutTestId("box2")
+ )
+ }
}
+ rule.waitForIdle()
+
+ val spaceForChain = rootSizePx - boxSizesPx[2] - (marginPx * 2)
+ val spaceAroundChain = spaceForChain - boxSizesPx[0] - boxSizesPx[1]
+ val spaceAtLeftOfChain = spaceAroundChain * 0.5f
+ val offsetFromBox2 = marginPx + boxSizesPx[2] + marginPx
+
+ val box0Left = offsetFromBox2 + spaceAtLeftOfChain
+ val box0Top = (rootSizePx - boxSizesPx[0]) * 0.5f
+
+ val box1Left = box0Left + boxSizesPx[0]
+ val box1Top = box0Top - ((boxSizesPx[1] - boxSizesPx[0]) * 0.5f)
+
+ rule
+ .onNodeWithTag("box0")
+ .assertPositionInRootIsEqualTo(box0Left.toDp(), box0Top.toDp())
+ rule
+ .onNodeWithTag("box1")
+ .assertPositionInRootIsEqualTo(box1Left.toDp(), box1Top.toDp())
+ rule
+ .onNodeWithTag("box2")
+ .assertPositionInRootIsEqualTo(marginPx.toDp(), marginPx.toDp())
}
- rule.waitForIdle()
-
- val spaceForChain = rootSize - boxSizes[2] - (margin * 2)
- val spaceAroundChain = spaceForChain - boxSizes[0] - boxSizes[1]
- val spaceAtLeftOfChain = spaceAroundChain * 0.5f
- val offsetFromBox2 = margin + boxSizes[2] + margin
-
- val box0Left = offsetFromBox2 + spaceAtLeftOfChain
- val box0Top = (rootSize - boxSizes[0]) * 0.5f
-
- val box1Left = box0Left + boxSizes[0] + 0.5.dp // 0.5dp, compensate for a small solver error
- val box1Top = box0Top - ((boxSizes[1] - boxSizes[0]) * 0.5f)
-
- rule.onNodeWithTag("box0").assertPositionInRootIsEqualTo(box0Left, box0Top)
- rule.onNodeWithTag("box1").assertPositionInRootIsEqualTo(box1Left, box1Top)
- rule.onNodeWithTag("box2").assertPositionInRootIsEqualTo(margin, margin)
- }
@Test
fun testHorizontalPacked_withMargins() {
diff --git a/core/core-telecom/src/androidTest/java/androidx/core/telecom/test/BasicCallControlsTest.kt b/core/core-telecom/src/androidTest/java/androidx/core/telecom/test/BasicCallControlsTest.kt
index 18e8fdc..08ba9ea 100644
--- a/core/core-telecom/src/androidTest/java/androidx/core/telecom/test/BasicCallControlsTest.kt
+++ b/core/core-telecom/src/androidTest/java/androidx/core/telecom/test/BasicCallControlsTest.kt
@@ -281,6 +281,21 @@
}
}
+ /** Add test coverage for [CallControlScope.getCallId] */
+ @SdkSuppress(minSdkVersion = VERSION_CODES.O)
+ @LargeTest
+ @Test
+ fun testGetCallId() {
+ runBlocking {
+ assertWithinTimeout_addCall(TestUtils.OUTGOING_CALL_ATTRIBUTES) {
+ launch {
+ assertNotNull(getCallId())
+ disconnect(DisconnectCause(DisconnectCause.LOCAL))
+ }
+ }
+ }
+ }
+
/**
* ********************************************************************************************
* Helpers
diff --git a/core/core-telecom/src/androidTest/java/androidx/core/telecom/test/CallAttributesCompatTest.kt b/core/core-telecom/src/androidTest/java/androidx/core/telecom/test/CallAttributesCompatTest.kt
new file mode 100644
index 0000000..2ffea83
--- /dev/null
+++ b/core/core-telecom/src/androidTest/java/androidx/core/telecom/test/CallAttributesCompatTest.kt
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.core.telecom.test
+
+import android.net.Uri
+import android.os.Build.VERSION_CODES
+import androidx.annotation.RequiresApi
+import androidx.core.telecom.CallAttributesCompat
+import androidx.core.telecom.CallAttributesCompat.Companion.SUPPORTS_SET_INACTIVE
+import androidx.core.telecom.CallAttributesCompat.Companion.SUPPORTS_STREAM
+import androidx.core.telecom.CallAttributesCompat.Companion.SUPPORTS_TRANSFER
+import androidx.core.telecom.internal.utils.Utils
+import androidx.core.telecom.test.utils.TestUtils.ALL_CALL_CAPABILITIES
+import androidx.core.telecom.test.utils.TestUtils.CUSTOM_TEST_APP_SCHEME
+import androidx.core.telecom.test.utils.TestUtils.OUTGOING_NAME
+import androidx.core.telecom.test.utils.TestUtils.TEST_ADDRESS
+import androidx.core.telecom.test.utils.TestUtils.TEST_CALL_ATTRIB_NAME
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+@RequiresApi(VERSION_CODES.O)
+class CallAttributesCompatTest {
+
+ @Test
+ fun testCallAttributesCompatRequired() {
+ val callAttributesCompat =
+ CallAttributesCompat(
+ OUTGOING_NAME,
+ TEST_ADDRESS,
+ CallAttributesCompat.DIRECTION_OUTGOING
+ )
+ assertEquals(OUTGOING_NAME, callAttributesCompat.displayName)
+ assertEquals(TEST_ADDRESS, callAttributesCompat.address)
+ assertEquals(CallAttributesCompat.DIRECTION_OUTGOING, callAttributesCompat.direction)
+ assertEquals(CallAttributesCompat.CALL_TYPE_AUDIO_CALL, callAttributesCompat.callType)
+ assertTrue(
+ Utils.hasCapability(SUPPORTS_SET_INACTIVE, callAttributesCompat.callCapabilities)
+ )
+ assertFalse(Utils.hasCapability(SUPPORTS_STREAM, callAttributesCompat.callCapabilities))
+ assertFalse(Utils.hasCapability(SUPPORTS_TRANSFER, callAttributesCompat.callCapabilities))
+ }
+
+ @Test
+ fun testCallAttributesCompatAll() {
+ val callAttributesCompat =
+ CallAttributesCompat(
+ TEST_CALL_ATTRIB_NAME,
+ TEST_ADDRESS,
+ CallAttributesCompat.DIRECTION_INCOMING,
+ CallAttributesCompat.CALL_TYPE_VIDEO_CALL,
+ ALL_CALL_CAPABILITIES
+ )
+ assertEquals(TEST_CALL_ATTRIB_NAME, callAttributesCompat.displayName)
+ assertEquals(TEST_ADDRESS, callAttributesCompat.address)
+ assertEquals(CallAttributesCompat.DIRECTION_INCOMING, callAttributesCompat.direction)
+ assertEquals(CallAttributesCompat.CALL_TYPE_VIDEO_CALL, callAttributesCompat.callType)
+ assertTrue(
+ Utils.hasCapability(SUPPORTS_SET_INACTIVE, callAttributesCompat.callCapabilities)
+ )
+ assertTrue(Utils.hasCapability(SUPPORTS_STREAM, callAttributesCompat.callCapabilities))
+ assertTrue(Utils.hasCapability(SUPPORTS_TRANSFER, callAttributesCompat.callCapabilities))
+ }
+
+ @Test
+ fun testCallAttributesCompatCompareDiff() {
+ val outgoing =
+ CallAttributesCompat(
+ OUTGOING_NAME,
+ TEST_ADDRESS,
+ CallAttributesCompat.DIRECTION_OUTGOING
+ )
+
+ val incoming =
+ CallAttributesCompat(
+ TEST_CALL_ATTRIB_NAME,
+ Uri.parse(CUSTOM_TEST_APP_SCHEME + "123"),
+ CallAttributesCompat.DIRECTION_INCOMING
+ )
+
+ assertFalse(outgoing.toString() == incoming.toString())
+ assertFalse(outgoing == incoming)
+ assertFalse(outgoing.hashCode() == incoming.hashCode())
+ }
+
+ @Test
+ fun testCallAttributesCompatCompareSame() {
+ val outgoing1 =
+ CallAttributesCompat(
+ OUTGOING_NAME,
+ TEST_ADDRESS,
+ CallAttributesCompat.DIRECTION_OUTGOING
+ )
+
+ val outgoing2 =
+ CallAttributesCompat(
+ OUTGOING_NAME,
+ TEST_ADDRESS,
+ CallAttributesCompat.DIRECTION_OUTGOING
+ )
+
+ assertEquals(outgoing1, outgoing2)
+ assertEquals(outgoing1.toString(), outgoing2.toString())
+ assertEquals(outgoing1.hashCode(), outgoing2.hashCode())
+ }
+}
diff --git a/core/core-telecom/src/androidTest/java/androidx/core/telecom/test/CallExceptionTest.kt b/core/core-telecom/src/androidTest/java/androidx/core/telecom/test/CallExceptionTest.kt
new file mode 100644
index 0000000..c0614960
--- /dev/null
+++ b/core/core-telecom/src/androidTest/java/androidx/core/telecom/test/CallExceptionTest.kt
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.core.telecom.test
+
+import android.os.Build.VERSION_CODES
+import androidx.annotation.RequiresApi
+import androidx.core.telecom.CallException
+import androidx.core.telecom.CallException.Companion.ERROR_BLUETOOTH_DEVICE_IS_NULL
+import androidx.core.telecom.CallException.Companion.ERROR_CALL_CANNOT_BE_SET_TO_ACTIVE
+import androidx.core.telecom.CallException.Companion.ERROR_CALL_DOES_NOT_SUPPORT_HOLD
+import androidx.core.telecom.CallException.Companion.ERROR_CALL_IS_NOT_BEING_TRACKED
+import androidx.core.telecom.CallException.Companion.ERROR_CALL_NOT_PERMITTED_AT_PRESENT_TIME
+import androidx.core.telecom.CallException.Companion.ERROR_CANNOT_HOLD_CURRENT_ACTIVE_CALL
+import androidx.core.telecom.CallException.Companion.ERROR_OPERATION_TIMED_OUT
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNotNull
+import org.junit.Assert.assertNull
+import org.junit.Test
+
+@RequiresApi(VERSION_CODES.O)
+class CallExceptionTest {
+
+ @Test
+ fun testCallExceptionUnknown() {
+ val e = CallException()
+ assertCallExceptionProperties(e, e.code)
+ }
+
+ @Test
+ fun testCallExceptionCannotHold() {
+ val e = CallException(ERROR_CANNOT_HOLD_CURRENT_ACTIVE_CALL)
+ assertCallExceptionProperties(e, ERROR_CANNOT_HOLD_CURRENT_ACTIVE_CALL)
+ }
+
+ @Test
+ fun testCallExceptionCallIsNotBeingTracked() {
+ val e = CallException(ERROR_CALL_IS_NOT_BEING_TRACKED)
+ assertCallExceptionProperties(e, ERROR_CALL_IS_NOT_BEING_TRACKED)
+ }
+
+ @Test
+ fun testCallExceptionCallCannotBeSetToActive() {
+ val e = CallException(ERROR_CALL_CANNOT_BE_SET_TO_ACTIVE)
+ assertCallExceptionProperties(e, ERROR_CALL_CANNOT_BE_SET_TO_ACTIVE)
+ }
+
+ @Test
+ fun testCallExceptionCallNotPermittedAtPresentTime() {
+ val e = CallException(ERROR_CALL_NOT_PERMITTED_AT_PRESENT_TIME)
+ assertCallExceptionProperties(e, ERROR_CALL_NOT_PERMITTED_AT_PRESENT_TIME)
+ }
+
+ @Test
+ fun testCallExceptionTimedOut() {
+ val e = CallException(ERROR_OPERATION_TIMED_OUT)
+ assertCallExceptionProperties(e, ERROR_OPERATION_TIMED_OUT)
+ }
+
+ @Test
+ fun testCallExceptionErrorCallDoesNotSupportHold() {
+ val e = CallException(ERROR_CALL_DOES_NOT_SUPPORT_HOLD)
+ assertCallExceptionProperties(e, ERROR_CALL_DOES_NOT_SUPPORT_HOLD)
+ }
+
+ @Test
+ fun testCallExceptionErrorBluetoothDeviceIsNull() {
+ val e = CallException(ERROR_BLUETOOTH_DEVICE_IS_NULL)
+ assertCallExceptionProperties(e, ERROR_BLUETOOTH_DEVICE_IS_NULL)
+ }
+
+ private fun assertCallExceptionProperties(e: CallException, code: Int) {
+ assertEquals(e.code, code)
+ assertNull(e.message)
+ assertEquals(e, CallException(code))
+ assertNotNull(e.toString())
+ assertEquals(e.hashCode(), CallException(code).hashCode())
+ }
+}
diff --git a/core/core-telecom/src/main/java/androidx/core/telecom/CallsManager.kt b/core/core-telecom/src/main/java/androidx/core/telecom/CallsManager.kt
index 6548961..afcd9bc 100644
--- a/core/core-telecom/src/main/java/androidx/core/telecom/CallsManager.kt
+++ b/core/core-telecom/src/main/java/androidx/core/telecom/CallsManager.kt
@@ -57,11 +57,9 @@
import androidx.core.telecom.internal.utils.Utils.Companion.remapJetpackCapsToPlatformCaps
import androidx.core.telecom.util.ExperimentalAppActions
import java.util.UUID
-import java.util.concurrent.CancellationException
import java.util.concurrent.Executor
import kotlin.coroutines.coroutineContext
import kotlinx.coroutines.CompletableDeferred
-import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.TimeoutCancellationException
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.channels.awaitClose
@@ -170,7 +168,6 @@
internal const val PLACEHOLDER_VALUE_ACCOUNT_BUNDLE = "isCoreTelecomAccount"
// fail messages specific to addCall
- internal const val CALL_CREATION_FAILURE_MSG = "The call failed to be added."
internal const val ADD_CALL_TIMEOUT = 5000L
internal const val SWITCH_TO_SPEAKER_TIMEOUT = 1000L
private val TAG: String = CallsManager::class.java.simpleName.toString()
@@ -265,7 +262,8 @@
* @throws UnsupportedOperationException if the device is on an invalid build
* @throws CallException if the platform cannot add the call (e.g. reached max # of calls) or
* failed with an exception (e.g. call was already removed)
- * @throws CancellationException if the call failed to be added within 5000 milliseconds
+ * @throws androidx.core.telecom.CallException.ERROR_OPERATION_TIMED_OUT if the call failed to
+ * be added within 5000 milliseconds
*/
@RequiresPermission(value = "android.permission.MANAGE_OWN_CALLS")
public suspend fun addCall(
@@ -421,7 +419,6 @@
* @see addCall For more documentation on the operations/parameters of this class
*/
@Suppress("ClassVerificationFailure")
- @OptIn(ExperimentalCoroutinesApi::class)
@RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY)
internal suspend fun addCall(
callAttributes: CallAttributesCompat,
@@ -535,9 +532,14 @@
mConnectionService.createConnectionRequest(mTelecomManager, request)
- pauseExecutionUntilCallIsReadyOrTimeout(openResult, blockingSessionExecution, request)
+ val result =
+ pauseExecutionUntilCallIsReadyOrTimeout(
+ openResult,
+ blockingSessionExecution,
+ request
+ )
+ as AddCallResult.SuccessCallSessionLegacy
- val result = openResult.getCompleted() as AddCallResult.SuccessCallSessionLegacy
closableCallSession = result.callSessionLegacy
val scope =
CallSessionLegacy.CallControlScopeImpl(
@@ -555,13 +557,13 @@
closableCallSession.close()
}
- @ExperimentalCoroutinesApi
@VisibleForTesting
internal suspend fun pauseExecutionUntilCallIsReadyOrTimeout(
openResult: CompletableDeferred<AddCallResult>,
blockingSessionExecution: CompletableDeferred<Unit>? = null,
request: JetpackConnectionService.PendingConnectionRequest? = null,
- ) {
+ ): AddCallResult {
+ var result: AddCallResult
try {
withTimeout(ADD_CALL_TIMEOUT) {
// This log will print once a request is sent to the platform to add a new call.
@@ -572,7 +574,16 @@
"addCall: pausing [$coroutineContext] execution" +
" until the CallControl or Connection is ready"
)
- openResult.await()
+ result = openResult.await()
+ // In the event the platform encountered an exception while adding the call request,
+ // re-throw the call exception out to the client
+ if (result is AddCallResult.Error) {
+ blockingSessionExecution?.complete(Unit)
+ val error = result as AddCallResult.Error
+ throw CallException(
+ androidx.core.telecom.CallException.fromTelecomCode(error.errorCode)
+ )
+ }
}
} catch (timeout: TimeoutCancellationException) {
// If this block is entered, the platform failed to create the call in time and hung.
@@ -581,21 +592,13 @@
JetpackConnectionService.mPendingConnectionRequests.remove(request)
}
blockingSessionExecution?.complete(Unit)
- openResult.cancel(CancellationException(CALL_CREATION_FAILURE_MSG))
- }
- // In the event the platform encountered an exception while adding the call request,
- // re-throw the call exception out to the client
- val result = openResult.getCompleted()
- if (result is AddCallResult.Error) {
- blockingSessionExecution?.complete(Unit)
- throw CallException(
- androidx.core.telecom.CallException.fromTelecomCode(result.errorCode)
- )
+ throw CallException(androidx.core.telecom.CallException.ERROR_OPERATION_TIMED_OUT)
}
// This log will print once the CallControl object or Connection is returned from the
// the platform. This means the call was added successfully and Core-Telecom is ready to
// run the clients CallControlScope block.
Log.i(TAG, "addCall: creating call session and running the clients scope")
+ return result
}
internal fun getPhoneAccountHandleForPackage(): PhoneAccountHandle {
diff --git a/core/core-telecom/src/main/java/androidx/core/telecom/internal/CallSession.kt b/core/core-telecom/src/main/java/androidx/core/telecom/internal/CallSession.kt
index 5e3b4f2..14c8903 100644
--- a/core/core-telecom/src/main/java/androidx/core/telecom/internal/CallSession.kt
+++ b/core/core-telecom/src/main/java/androidx/core/telecom/internal/CallSession.kt
@@ -49,7 +49,6 @@
import kotlinx.coroutines.withTimeout
@RequiresApi(34)
-@OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
@Suppress("ClassVerificationFailure")
internal class CallSession(
val coroutineContext: CoroutineContext,
@@ -379,8 +378,7 @@
suspend fun setActive(): CallControlResult {
val result: CompletableDeferred<CallControlResult> = CompletableDeferred()
mPlatformInterface?.setActive(Runnable::run, CallControlReceiver(result))
- result.await()
- val callControlResult = result.getCompleted()
+ val callControlResult = result.await()
moveState(callControlResult, CallStateEvent.ACTIVE)
return callControlResult
}
@@ -388,8 +386,7 @@
suspend fun setInactive(): CallControlResult {
val result: CompletableDeferred<CallControlResult> = CompletableDeferred()
mPlatformInterface?.setInactive(Runnable::run, CallControlReceiver(result))
- result.await()
- val callControlResult = result.getCompleted()
+ val callControlResult = result.await()
moveState(callControlResult, CallStateEvent.INACTIVE)
return callControlResult
}
@@ -397,8 +394,7 @@
suspend fun answer(videoState: Int): CallControlResult {
val result: CompletableDeferred<CallControlResult> = CompletableDeferred()
mPlatformInterface?.answer(videoState, Runnable::run, CallControlReceiver(result))
- result.await()
- val callControlResult = result.getCompleted()
+ val callControlResult = result.await()
moveState(callControlResult, CallStateEvent.ACTIVE)
return callControlResult
}
@@ -432,8 +428,7 @@
Runnable::run,
CallControlReceiver(job)
)
- job.await()
- val platformResult = job.getCompleted()
+ val platformResult = job.await()
if (platformResult != CallControlResult.Success()) {
mLastClientRequestedEndpoint = null
}
@@ -443,10 +438,9 @@
suspend fun disconnect(disconnectCause: DisconnectCause): CallControlResult {
val result: CompletableDeferred<CallControlResult> = CompletableDeferred()
mPlatformInterface?.disconnect(disconnectCause, Runnable::run, CallControlReceiver(result))
- result.await()
- val callControlResult = result.getCompleted()
+ val callControlResult = result.await()
moveState(callControlResult, CallStateEvent.DISCONNECTED)
- return result.getCompleted()
+ return callControlResult
}
/** CallControlCallback */
diff --git a/credentials/credentials/src/androidTest/java/androidx/credentials/TestUtils.kt b/credentials/credentials/src/androidTest/java/androidx/credentials/TestUtils.kt
index 1c6aa3f..402df12 100644
--- a/credentials/credentials/src/androidTest/java/androidx/credentials/TestUtils.kt
+++ b/credentials/credentials/src/androidTest/java/androidx/credentials/TestUtils.kt
@@ -494,6 +494,28 @@
equals(getCredentialResponse1.credential, getCredentialResponse2.credential)
}
+@RequiresApi(34)
+fun assertEquals(
+ actual: android.credentials.CreateCredentialResponse,
+ expected: CreatePasswordResponse
+) {
+ assertEquals(actual.data, expected.data)
+}
+
+@RequiresApi(34)
+fun assertEquals(
+ actual: android.credentials.GetCredentialResponse,
+ expected: GetCredentialResponse
+) {
+ equals(actual.credential, expected.credential)
+}
+
+@RequiresApi(34)
+fun equals(actual: android.credentials.Credential, expected: Credential) {
+ assertThat(actual.type).isEqualTo(expected.type)
+ equals(actual.data, expected.data)
+}
+
fun equals(credential1: Credential, credential2: Credential) {
assertThat(credential1.type).isEqualTo(credential2.type)
equals(credential1.data, credential2.data)
diff --git a/credentials/credentials/src/androidTest/java/androidx/credentials/provider/PendingIntentHandlerApi34JavaTest.java b/credentials/credentials/src/androidTest/java/androidx/credentials/provider/PendingIntentHandlerApi34JavaTest.java
index 031750f..d1d5a32 100644
--- a/credentials/credentials/src/androidTest/java/androidx/credentials/provider/PendingIntentHandlerApi34JavaTest.java
+++ b/credentials/credentials/src/androidTest/java/androidx/credentials/provider/PendingIntentHandlerApi34JavaTest.java
@@ -21,6 +21,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import android.content.Context;
import android.content.Intent;
import android.content.pm.SigningInfo;
import android.credentials.CredentialOption;
@@ -38,6 +39,7 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
+import androidx.test.platform.app.InstrumentationRegistry;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -69,6 +71,8 @@
private static final String BIOMETRIC_AUTHENTICATOR_ERROR_MSG = "error";
+ private final Context mContext = InstrumentationRegistry.getInstrumentation().getContext();
+
@Test
public void test_retrieveProviderCreateCredReqWithSuccessBpAuthJetpack_retrieveJetpackResult() {
for (int jetpackResult :
@@ -292,12 +296,7 @@
@Test
public void test_setGetCreateCredentialException() {
- if (Build.VERSION.SDK_INT >= 34) {
- return;
- }
-
Intent intent = new Intent();
-
CreateCredentialInterruptedException initialException =
new CreateCredentialInterruptedException("message");
@@ -307,26 +306,16 @@
IntentHandlerConverters.getCreateCredentialException(intent);
assertThat(finalException).isNotNull();
assertThat(finalException.getMessage()).isEqualTo(initialException.getMessage());
+ assertThat(finalException.getType()).isEqualTo(initialException.getType());
}
@Test
- public void test_setGetCreateCredentialException_throwsWhenEmptyIntent() {
- if (Build.VERSION.SDK_INT >= 34) {
- return;
- }
-
- assertThat(
- IntentHandlerConverters.getCreateCredentialException(
- BLANK_INTENT))
- .isNull();
+ public void test_setGetCreateCredentialException_nullWhenEmptyIntent() {
+ assertThat(IntentHandlerConverters.getCreateCredentialException(BLANK_INTENT)).isNull();
}
@Test
public void test_credentialException() {
- if (Build.VERSION.SDK_INT >= 34) {
- return;
- }
-
Intent intent = new Intent();
GetCredentialInterruptedException initialException =
new GetCredentialInterruptedException("message");
@@ -336,25 +325,17 @@
android.credentials.GetCredentialException finalException =
IntentHandlerConverters.getGetCredentialException(intent);
assertThat(finalException).isNotNull();
- assertThat(finalException).isEqualTo(initialException);
+ assertThat(finalException.getMessage()).isEqualTo(initialException.getMessage());
+ assertThat(finalException.getType()).isEqualTo(initialException.getType());
}
@Test
- public void test_credentialException_throwsWhenEmptyIntent() {
- if (Build.VERSION.SDK_INT >= 34) {
- return;
- }
-
- assertThat(IntentHandlerConverters.getGetCredentialException(BLANK_INTENT))
- .isNull();
+ public void test_credentialException_nullWhenEmptyIntent() {
+ assertThat(IntentHandlerConverters.getGetCredentialException(BLANK_INTENT)).isNull();
}
@Test
public void test_beginGetResponse() {
- if (Build.VERSION.SDK_INT >= 34) {
- return;
- }
-
Intent intent = new Intent();
BeginGetCredentialResponse initialResponse =
new BeginGetCredentialResponse.Builder().build();
@@ -364,25 +345,17 @@
BeginGetCredentialResponse finalResponse =
IntentHandlerConverters.getBeginGetResponse(intent);
assertThat(finalResponse).isNotNull();
- assertThat(finalResponse).isEqualTo(initialResponse);
+ TestUtilsKt.assertEquals(mContext, finalResponse, initialResponse);
}
@Test
public void test_beginGetResponse_throwsWhenEmptyIntent() {
- if (Build.VERSION.SDK_INT >= 34) {
- return;
- }
-
assertThat(IntentHandlerConverters.getBeginGetResponse(BLANK_INTENT))
.isNull();
}
@Test
public void test_credentialResponse() {
- if (Build.VERSION.SDK_INT >= 34) {
- return;
- }
-
Intent intent = new Intent();
PasswordCredential credential = new PasswordCredential("a", "b");
GetCredentialResponse initialResponse = new GetCredentialResponse(credential);
@@ -392,15 +365,11 @@
android.credentials.GetCredentialResponse finalResponse =
IntentHandlerConverters.getGetCredentialResponse(intent);
assertThat(finalResponse).isNotNull();
- assertThat(finalResponse).isEqualTo(initialResponse);
+ TestUtilsKt.assertEquals(finalResponse, initialResponse);
}
@Test
- public void test_credentialResponse_throwsWhenEmptyIntent() {
- if (Build.VERSION.SDK_INT >= 34) {
- return;
- }
-
+ public void test_credentialResponse_nullWhenEmptyIntent() {
assertThat(IntentHandlerConverters.getGetCredentialResponse(BLANK_INTENT))
.isNull();
}
@@ -519,10 +488,6 @@
@Test
public void test_createCredentialCredentialResponse() {
- if (Build.VERSION.SDK_INT >= 34) {
- return;
- }
-
Intent intent = new Intent();
CreatePasswordResponse initialResponse = new CreatePasswordResponse();
@@ -532,18 +497,12 @@
IntentHandlerConverters.getCreateCredentialCredentialResponse(
intent);
assertThat(finalResponse).isNotNull();
- assertThat(finalResponse).isEqualTo(initialResponse);
+ TestUtilsKt.assertEquals(finalResponse, initialResponse);
}
@Test
- public void test_createCredentialCredentialResponse_throwsWhenEmptyIntent() {
- if (Build.VERSION.SDK_INT >= 34) {
- return;
- }
-
- assertThat(
- IntentHandlerConverters
- .getCreateCredentialCredentialResponse(BLANK_INTENT))
+ public void test_createCredentialCredentialResponse_nullWhenEmptyIntent() {
+ assertThat(IntentHandlerConverters.getCreateCredentialCredentialResponse(BLANK_INTENT))
.isNull();
}
}
diff --git a/credentials/credentials/src/androidTest/java/androidx/credentials/provider/PendingIntentHandlerApi34Test.kt b/credentials/credentials/src/androidTest/java/androidx/credentials/provider/PendingIntentHandlerApi34Test.kt
index 9d9daee..59acd5d 100644
--- a/credentials/credentials/src/androidTest/java/androidx/credentials/provider/PendingIntentHandlerApi34Test.kt
+++ b/credentials/credentials/src/androidTest/java/androidx/credentials/provider/PendingIntentHandlerApi34Test.kt
@@ -18,7 +18,6 @@
import android.content.Intent
import android.content.pm.SigningInfo
import android.credentials.CredentialOption
-import android.os.Build
import android.os.Bundle
import android.service.credentials.CallingAppInfo
import android.service.credentials.CreateCredentialRequest
@@ -27,6 +26,7 @@
import androidx.credentials.CreatePasswordResponse
import androidx.credentials.GetCredentialResponse
import androidx.credentials.PasswordCredential
+import androidx.credentials.assertEquals
import androidx.credentials.equals
import androidx.credentials.exceptions.CreateCredentialInterruptedException
import androidx.credentials.exceptions.GetCredentialInterruptedException
@@ -34,6 +34,7 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SdkSuppress
import androidx.test.filters.SmallTest
+import androidx.test.platform.app.InstrumentationRegistry
import com.google.common.truth.Truth.assertThat
import org.junit.Assert
import org.junit.Test
@@ -68,6 +69,8 @@
private const val FRAMEWORK_EXPECTED_CONSTANT_AUTH_RESULT =
"androidx.credentials.provider.BIOMETRIC_AUTH_RESULT"
+
+ private val context = InstrumentationRegistry.getInstrumentation().context
}
@Test
@@ -278,10 +281,6 @@
@Test
fun test_createCredentialException() {
- if (Build.VERSION.SDK_INT >= 34) {
- return
- }
-
val intent = Intent()
val initialException = CreateCredentialInterruptedException("message")
@@ -289,16 +288,14 @@
val finalException = intent.getCreateCredentialException()
assertThat(finalException).isNotNull()
- assertThat(finalException).isEqualTo(initialException)
+ assertThat(finalException!!.type).isEqualTo(initialException.type)
+ assertThat(finalException.message).isEqualTo(initialException.message)
}
@Test
- fun test_createCredentialException_throwsWhenEmptyIntent() {
- if (Build.VERSION.SDK_INT >= 34) {
- return
- }
-
+ fun test_createCredentialException_nullExceptionWhenEmptyIntent() {
val intent = Intent()
+
assertThat(intent.getCreateCredentialException()).isNull()
}
@@ -417,10 +414,6 @@
@Test
fun test_credentialException() {
- if (Build.VERSION.SDK_INT >= 34) {
- return
- }
-
val intent = Intent()
val initialException = GetCredentialInterruptedException("message")
@@ -428,25 +421,19 @@
val finalException = intent.getGetCredentialException()
assertThat(finalException).isNotNull()
- assertThat(finalException).isEqualTo(initialException)
+ assertThat(finalException!!.type).isEqualTo(initialException.type)
+ assertThat(finalException.message).isEqualTo(initialException.message)
}
@Test
- fun test_credentialException_throwsWhenEmptyIntent() {
- if (Build.VERSION.SDK_INT >= 34) {
- return
- }
-
+ fun test_credentialException_nullWhenEmptyIntent() {
val intent = Intent()
+
assertThat(intent.getGetCredentialException()).isNull()
}
@Test
fun test_beginGetResponse() {
- if (Build.VERSION.SDK_INT >= 34) {
- return
- }
-
val intent = Intent()
val initialResponse = BeginGetCredentialResponse.Builder().build()
@@ -454,25 +441,18 @@
val finalResponse = intent.getBeginGetResponse()
assertThat(finalResponse).isNotNull()
- assertThat(finalResponse).isEqualTo(initialResponse)
+ assertEquals(context, finalResponse!!, initialResponse)
}
@Test
- fun test_beginGetResponse_throwsWhenEmptyIntent() {
- if (Build.VERSION.SDK_INT >= 34) {
- return
- }
-
+ fun test_beginGetResponse_nullWhenEmptyIntent() {
val intent = Intent()
+
assertThat(intent.getBeginGetResponse()).isNull()
}
@Test
fun test_credentialResponse() {
- if (Build.VERSION.SDK_INT >= 34) {
- return
- }
-
val intent = Intent()
val credential = PasswordCredential("a", "b")
val initialResponse = GetCredentialResponse(credential)
@@ -481,25 +461,18 @@
val finalResponse = intent.getGetCredentialResponse()
assertThat(finalResponse).isNotNull()
- assertThat(finalResponse).isEqualTo(initialResponse)
+ assertEquals(finalResponse!!, initialResponse)
}
@Test
- fun test_credentialResponse_throwsWhenEmptyIntent() {
- if (Build.VERSION.SDK_INT >= 34) {
- return
- }
-
+ fun test_credentialResponse_nullWhenEmptyIntent() {
val intent = Intent()
+
assertThat(intent.getGetCredentialResponse()).isNull()
}
@Test
fun test_createCredentialCredentialResponse() {
- if (Build.VERSION.SDK_INT >= 34) {
- return
- }
-
val intent = Intent()
val initialResponse = CreatePasswordResponse()
@@ -507,17 +480,13 @@
val finalResponse = intent.getCreateCredentialCredentialResponse()
assertThat(finalResponse).isNotNull()
- assertThat(finalResponse).isEqualTo(initialResponse)
+ assertThat(equals(finalResponse!!.data, initialResponse.data))
}
@Test
- fun test_createCredentialCredentialResponse_throwsWhenEmptyIntent() {
- if (Build.VERSION.SDK_INT >= 34) {
- return
- }
-
+ fun test_createCredentialCredentialResponse_nullWhenEmptyIntent() {
val intent = Intent()
- val r = intent.getCreateCredentialCredentialResponse()
- assertThat(r).isNull()
+
+ assertThat(intent.getCreateCredentialCredentialResponse()).isNull()
}
}
diff --git a/development/build_log_simplifier/message-flakes.ignore b/development/build_log_simplifier/message-flakes.ignore
index e392a20..fab5a86 100644
--- a/development/build_log_simplifier/message-flakes.ignore
+++ b/development/build_log_simplifier/message-flakes.ignore
@@ -160,5 +160,7 @@
# When we change gradle.properties, we can get this error in incremental builds:
Calculating task graph as configuration cache cannot be reused because the set of Gradle properties has changed\.
Calculating task graph as configuration cache cannot be reused because properties file .*local\.properties has changed\.
-# b/347233852
-e: java.rmi.NoSuchObjectException: no such object in table
\ No newline at end of file
+# https://youtrack.jetbrains.com/issue/KT-73311
+Unable to release compile session, maybe daemon is already down.*
+java\.net\.SocketException: Connection reset
+java\.io\.EOFException
\ No newline at end of file
diff --git a/docs-public/build.gradle b/docs-public/build.gradle
index 758bdaf..2748c15 100644
--- a/docs-public/build.gradle
+++ b/docs-public/build.gradle
@@ -238,32 +238,32 @@
docs("androidx.media2:media2-widget:1.3.0")
docs("androidx.media:media:1.7.0")
// androidx.media3 is not hosted in androidx
- docsWithoutApiSince("androidx.media3:media3-cast:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-common:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-common-ktx:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-container:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-database:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-datasource:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-datasource-cronet:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-datasource-okhttp:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-datasource-rtmp:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-decoder:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-effect:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-exoplayer:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-exoplayer-dash:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-exoplayer-hls:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-exoplayer-ima:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-exoplayer-rtsp:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-exoplayer-smoothstreaming:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-exoplayer-workmanager:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-extractor:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-muxer:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-session:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-test-utils:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-test-utils-robolectric:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-transformer:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-ui:1.5.0-rc02")
- docsWithoutApiSince("androidx.media3:media3-ui-leanback:1.5.0-rc02")
+ docsWithoutApiSince("androidx.media3:media3-cast:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-common:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-common-ktx:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-container:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-database:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-datasource:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-datasource-cronet:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-datasource-okhttp:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-datasource-rtmp:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-decoder:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-effect:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-exoplayer:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-exoplayer-dash:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-exoplayer-hls:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-exoplayer-ima:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-exoplayer-rtsp:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-exoplayer-smoothstreaming:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-exoplayer-workmanager:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-extractor:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-muxer:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-session:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-test-utils:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-test-utils-robolectric:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-transformer:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-ui:1.5.0")
+ docsWithoutApiSince("androidx.media3:media3-ui-leanback:1.5.0")
docs("androidx.mediarouter:mediarouter:1.7.0")
docs("androidx.mediarouter:mediarouter-testing:1.7.0")
docs("androidx.metrics:metrics-performance:1.0.0-beta01")
diff --git a/docs-tip-of-tree/build.gradle b/docs-tip-of-tree/build.gradle
index a9b3cab..e6aa801 100644
--- a/docs-tip-of-tree/build.gradle
+++ b/docs-tip-of-tree/build.gradle
@@ -67,6 +67,7 @@
docs(project(":camera:camera-testing"))
docs(project(":camera:camera-video"))
docs(project(":camera:camera-view"))
+ docs(project(":camera:media3:media3-effect"))
docs(project(":camera:viewfinder:viewfinder-compose"))
docs(project(":camera:viewfinder:viewfinder-core"))
docs(project(":camera:viewfinder:viewfinder-view"))
diff --git a/graphics/integration-tests/testapp-compose/src/main/java/androidx/graphics/shapes/testcompose/MaterialShapes.kt b/graphics/integration-tests/testapp-compose/src/main/java/androidx/graphics/shapes/testcompose/MaterialShapes.kt
index 96dc524..d4a6aba 100644
--- a/graphics/integration-tests/testapp-compose/src/main/java/androidx/graphics/shapes/testcompose/MaterialShapes.kt
+++ b/graphics/integration-tests/testapp-compose/src/main/java/androidx/graphics/shapes/testcompose/MaterialShapes.kt
@@ -641,27 +641,27 @@
* use. Refer to [FeatureSerializer] for proper usage of svg path import.
* *************************************************************************************
*/
- CustomShapeParameters("1") {
+ CustomShapeParameters("Park") {
val svgPathNotSuitableForProductionCodeImport =
- "M -327.65 -440 h -24.31 q -25.95 0 -43.93 -17.98 q -17.98 -17.97 -17.98 -43.93 t 17.98 -43.93 q 17.98 -17.98 43.93 -17.98 h 102.63 q 19.16 0 32.33 13.17 q 13.17 13.17 13.17 32.33 V -260 q 0 25.96 -17.98 43.93 q -17.97 17.98 -43.93 17.98 t -43.93 -17.98 q -17.98 -17.97 -17.98 -43.93 Z"
+ "M 397.93 -231.87 H 190.22 q -27.35 0 -40.79 -23.87 q -13.43 -23.87 2.24 -46.74 l 113.26 -169.39 h -2.28 q -24.48 0 -36.1 -21.74 q -11.62 -21.74 2.62 -41.98 l 213.29 -304.82 q 6.95 -9.44 17.03 -14.42 q 10.08 -4.97 20.51 -4.97 q 10.43 0 20.51 4.97 q 10.08 4.98 17.03 14.42 l 213.29 304.82 q 14.24 20.24 2.62 41.98 q -11.62 21.74 -36.1 21.74 h -2.28 l 113.26 169.39 q 15.67 22.87 2.24 46.74 q -13.44 23.87 -40.79 23.87 H 562.07 v 114.5 q 0 19.15 -13.18 32.33 q -13.17 13.17 -32.32 13.17 h -73.14 q -19.15 0 -32.32 -13.17 q -13.18 -13.18 -13.18 -32.33 v -114.5 Z"
RoundedPolygon(SvgPathParser.parseFeatures(svgPathNotSuitableForProductionCodeImport))
.normalized()
},
- CustomShapeParameters("2") {
+ CustomShapeParameters("Bedtime") {
val svgPathNotSuitableForProductionCodeImport =
- "M 801.2 -192.59 H 511.33 q -12.8 0 -21.86 -9.06 q -9.06 -9.06 -9.06 -21.85 v -47.25 q 0 -3.29 8.24 -22.01 l 192.96 -201.22 q 32.52 -35 45.66 -57.42 q 13.14 -22.43 13.14 -50.51 q 0 -27.45 -20.94 -49.69 q -20.95 -22.25 -62.84 -22.25 q -24.62 0 -42.13 9.9 q -17.52 9.91 -30.04 26.19 q -11.2 15.43 -28.37 21.03 q -17.18 5.6 -34.01 -1.09 q -19.07 -7.79 -27.49 -25.06 q -8.42 -17.27 0.78 -32.95 q 22.43 -37.39 63.25 -64.49 q 40.81 -27.09 99.8 -27.09 q 84.41 0 131.98 48.92 q 47.58 48.92 47.58 115.86 q 0 46.67 -21.72 84.51 t -65.72 84.27 l -139.3 148.42 l 1.52 3.28 H 801.2 q 19.03 0 31.9 12.87 q 12.88 12.88 12.88 31.91 t -12.88 31.91 q -12.87 12.87 -31.9 12.87"
+ "M 484 -75.22 q -84.96 0 -159.29 -32.36 q -74.34 -32.35 -129.56 -87.57 q -55.22 -55.22 -87.57 -129.56 Q 75.22 -399.04 75.22 -484 q 0 -126.8 70.44 -230.57 q 70.45 -103.76 189.06 -148.86 q 26.06 -10.87 49.49 4.54 q 23.42 15.41 23.62 43.43 q -0.61 82.61 28.79 157.7 q 29.4 75.09 87.73 133.41 q 58.32 58.33 133.29 87.61 t 157.34 28.91 q 30.06 0.44 45.31 22.41 q 15.25 21.96 5.34 47.83 q -45.91 119.05 -149.77 190.71 Q 612 -75.22 484 -75.22 Z"
RoundedPolygon(SvgPathParser.parseFeatures(svgPathNotSuitableForProductionCodeImport))
.normalized()
},
- CustomShapeParameters("Thin 3") {
+ CustomShapeParameters("Send") {
val svgPathNotSuitableForProductionCodeImport =
- "M 570.77 -235.38 H 380 q -10.38 0 -17.5 -7.12 q -7.12 -7.12 -7.12 -17.5 q 0 -10.38 7.12 -17.5 q 7.12 -7.12 17.5 -7.12 h 190.77 q 10.77 0 17.69 -6.92 q 6.92 -6.92 6.92 -17.69 v -121.54 q 0 -10.77 -6.92 -17.69 q -6.92 -6.92 -17.69 -6.92 H 420 q -10.38 0 -17.5 -7.12 q -7.12 -7.12 -7.12 -17.5 q 0 -10.38 7.12 -17.5 q 7.12 -7.12 17.5 -7.12 h 150.77 q 10.77 0 17.69 -6.92 q 6.92 -6.92 6.92 -17.69 v -121.54 q 0 -10.77 -6.92 -17.69 q -6.92 -6.92 -17.69 -6.92 H 380 q -10.38 0 -17.5 -7.12 q -7.12 -7.12 -7.12 -17.5 q 0 -10.38 7.12 -17.5 q 7.12 -7.12 17.5 -7.12 h 190.77 q 30.77 0 52.31 21.54 q 21.54 21.54 21.54 52.31 v 122.15 q 0 19.62 -12.2 34.12 q -12.19 14.5 -31.04 14.5 q 18.85 0 31.04 14.5 q 12.2 14.5 12.2 34.12 v 122.15 q 0 30.77 -21.54 52.31 q -21.54 21.54 -52.31 21.54 Z"
+ "M 176.24 -178.7 q -22.87 9.44 -43.26 -3.85 q -20.39 -13.3 -20.39 -38.17 V -393.3 l 331 -86.7 l -331 -86.7 v -172.58 q 0 -24.87 20.39 -38.17 q 20.39 -13.29 43.26 -3.85 l 613.61 259.28 q 28.11 12.43 28.11 42.02 q 0 29.59 -28.11 42.02 L 176.24 -178.7 Z"
RoundedPolygon(SvgPathParser.parseFeatures(svgPathNotSuitableForProductionCodeImport))
.normalized()
},
- CustomShapeParameters("Thick 3") {
+ CustomShapeParameters("Humidity") {
val svgPathNotSuitableForProductionCodeImport =
- "M 558.33 -198.09 H 380 q -25.96 0 -43.82 -17.98 q -17.85 -17.97 -17.85 -43.93 t 17.97 -43.93 q 17.98 -17.98 43.94 -17.98 h 177.85 v -96.18 H 420 q -25.96 0 -43.82 -17.98 q -17.85 -17.97 -17.85 -43.93 t 17.97 -43.93 q 17.98 -17.98 43.94 -17.98 h 137.85 v -96.18 H 380 q -25.96 0 -43.82 -17.98 q -17.85 -17.97 -17.85 -43.93 t 17.97 -43.93 q 17.98 -17.98 43.94 -17.98 h 178.09 q 51.67 0 87.63 36.11 q 35.95 36.12 35.95 87.71 V -564 q 0 33.57 -22.34 57.83 q -22.35 24.26 -55.68 26.17 q 33.33 1.91 55.68 26.17 q 22.34 24.26 22.34 57.83 v 74.09 q 0 51.59 -35.95 87.71 q -35.96 36.11 -87.63 36.11 Z"
+ "M 480 -91.87 q -136.11 0 -232.12 -94.15 q -96.01 -94.15 -96.01 -229.5 q 0 -64.91 25.1 -124.09 q 25.1 -59.17 71.53 -104.37 l 167.85 -164.85 q 13.67 -12.67 30.08 -19.39 q 16.42 -6.71 33.57 -6.71 t 33.57 6.71 q 16.41 6.72 30.08 19.39 L 711.5 -643.98 q 46.43 45.2 71.53 104.37 q 25.1 59.18 25.1 124.09 q 0 135.35 -96.01 229.5 T 480 -91.87 Z"
RoundedPolygon(SvgPathParser.parseFeatures(svgPathNotSuitableForProductionCodeImport))
.normalized()
},
diff --git a/graphics/integration-tests/testapp-compose/src/main/java/androidx/graphics/shapes/testcompose/ShapeParameters.kt b/graphics/integration-tests/testapp-compose/src/main/java/androidx/graphics/shapes/testcompose/ShapeParameters.kt
index d989266..74560e3 100644
--- a/graphics/integration-tests/testapp-compose/src/main/java/androidx/graphics/shapes/testcompose/ShapeParameters.kt
+++ b/graphics/integration-tests/testapp-compose/src/main/java/androidx/graphics/shapes/testcompose/ShapeParameters.kt
@@ -432,7 +432,7 @@
fun serialized(): String =
"""
val features: List<Feature> = FeatureSerializer.parse("${FeatureSerializer.serialize(genShape().features)}")
- val triangle: RoundedPolygon = RoundedPolygon(features, centerX = <recommended to add>, centerY = <recommended to add>)
+ val shape: RoundedPolygon = RoundedPolygon(features, centerX = <recommended to add>, centerY = <recommended to add>)
"""
.trimIndent()
diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/ProtoToRecordUtils.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/ProtoToRecordUtils.kt
index 566a61b..f6a7b08 100644
--- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/ProtoToRecordUtils.kt
+++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/ProtoToRecordUtils.kt
@@ -119,7 +119,7 @@
return valuesList.map {
SkinTemperatureRecord.Delta(
time = Instant.ofEpochMilli(it.startTimeMillis),
- delta = TemperatureDelta.celsius(it.valuesMap["delta"]?.doubleVal ?: 0.0),
+ delta = TemperatureDelta.celsius(it.valuesMap["temperatureDelta"]?.doubleVal ?: 0.0),
)
}
}
diff --git a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/RecordToProtoUtils.kt b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/RecordToProtoUtils.kt
index 8ce8f01..3461316 100644
--- a/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/RecordToProtoUtils.kt
+++ b/health/connect/connect-client/src/main/java/androidx/health/connect/client/impl/converters/records/RecordToProtoUtils.kt
@@ -97,7 +97,7 @@
return DataProto.SubTypeDataValue.newBuilder()
.setStartTimeMillis(time.toEpochMilli())
.setEndTimeMillis(time.toEpochMilli())
- .putValues("delta", doubleVal(delta.inCelsius))
+ .putValues("temperatureDelta", doubleVal(delta.inCelsius))
.build()
}
diff --git a/health/connect/connect-testing/api/current.txt b/health/connect/connect-testing/api/current.txt
index df213f9..8a08ff1 100644
--- a/health/connect/connect-testing/api/current.txt
+++ b/health/connect/connect-testing/api/current.txt
@@ -40,36 +40,36 @@
public final class FakeHealthConnectClientOverrides {
ctor public FakeHealthConnectClientOverrides();
- ctor public FakeHealthConnectClientOverrides(optional androidx.health.connect.client.testing.stubs.Stub? getChanges, optional androidx.health.connect.client.testing.stubs.Stub? getChangesToken, optional androidx.health.connect.client.testing.stubs.Stub? readRecords, optional androidx.health.connect.client.testing.stubs.Stub? readRecord, optional androidx.health.connect.client.testing.stubs.Stub? insertRecords, optional androidx.health.connect.client.testing.stubs.Stub? updateRecords, optional androidx.health.connect.client.testing.stubs.Stub? deleteRecords, optional androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.AggregateRequest,androidx.health.connect.client.aggregate.AggregationResult>? aggregate, optional androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.AggregateGroupByDurationRequest,? extends java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByDuration>>? aggregateGroupByDuration, optional androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.AggregateGroupByPeriodRequest,? extends java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByPeriod>>? aggregateGroupByPeriod);
+ ctor public FakeHealthConnectClientOverrides(optional androidx.health.connect.client.testing.stubs.Stub<? super java.lang.String,androidx.health.connect.client.response.ChangesResponse>? getChanges, optional androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.ChangesTokenRequest,java.lang.String>? getChangesToken, optional androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.ReadRecordsRequest<? extends java.lang.Object?>,? extends androidx.health.connect.client.response.ReadRecordsResponse<? extends java.lang.Object?>>? readRecords, optional androidx.health.connect.client.testing.stubs.Stub<? super java.lang.String,? extends androidx.health.connect.client.response.ReadRecordResponse<? extends java.lang.Object?>>? readRecord, optional androidx.health.connect.client.testing.stubs.Stub<? super java.util.List<? extends java.lang.Object?>,androidx.health.connect.client.response.InsertRecordsResponse>? insertRecords, optional androidx.health.connect.client.testing.stubs.Stub? updateRecords, optional androidx.health.connect.client.testing.stubs.Stub? deleteRecords, optional androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.AggregateRequest,androidx.health.connect.client.aggregate.AggregationResult>? aggregate, optional androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.AggregateGroupByDurationRequest,? extends java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByDuration>>? aggregateGroupByDuration, optional androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.AggregateGroupByPeriodRequest,? extends java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByPeriod>>? aggregateGroupByPeriod);
method public androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.AggregateRequest,androidx.health.connect.client.aggregate.AggregationResult>? getAggregate();
method public androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.AggregateGroupByDurationRequest,java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByDuration>>? getAggregateGroupByDuration();
method public androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.AggregateGroupByPeriodRequest,java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByPeriod>>? getAggregateGroupByPeriod();
method public androidx.health.connect.client.testing.stubs.Stub? getDeleteRecords();
- method public androidx.health.connect.client.testing.stubs.Stub? getGetChanges();
- method public androidx.health.connect.client.testing.stubs.Stub? getGetChangesToken();
- method public androidx.health.connect.client.testing.stubs.Stub? getInsertRecords();
- method public androidx.health.connect.client.testing.stubs.Stub? getReadRecord();
- method public androidx.health.connect.client.testing.stubs.Stub? getReadRecords();
+ method public androidx.health.connect.client.testing.stubs.Stub<java.lang.String,androidx.health.connect.client.response.ChangesResponse>? getGetChanges();
+ method public androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.ChangesTokenRequest,java.lang.String>? getGetChangesToken();
+ method public androidx.health.connect.client.testing.stubs.Stub<java.util.List<? extends java.lang.Object?>,androidx.health.connect.client.response.InsertRecordsResponse>? getInsertRecords();
+ method public androidx.health.connect.client.testing.stubs.Stub<java.lang.String,androidx.health.connect.client.response.ReadRecordResponse<? extends java.lang.Object?>>? getReadRecord();
+ method public androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.ReadRecordsRequest<? extends java.lang.Object?>,androidx.health.connect.client.response.ReadRecordsResponse<? extends java.lang.Object?>>? getReadRecords();
method public androidx.health.connect.client.testing.stubs.Stub? getUpdateRecords();
method public void setAggregate(androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.AggregateRequest,androidx.health.connect.client.aggregate.AggregationResult>?);
method public void setAggregateGroupByDuration(androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.AggregateGroupByDurationRequest,? extends java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByDuration>>?);
method public void setAggregateGroupByPeriod(androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.AggregateGroupByPeriodRequest,? extends java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByPeriod>>?);
method public void setDeleteRecords(androidx.health.connect.client.testing.stubs.Stub?);
- method public void setGetChanges(androidx.health.connect.client.testing.stubs.Stub?);
- method public void setGetChangesToken(androidx.health.connect.client.testing.stubs.Stub?);
- method public void setInsertRecords(androidx.health.connect.client.testing.stubs.Stub?);
- method public void setReadRecord(androidx.health.connect.client.testing.stubs.Stub?);
- method public void setReadRecords(androidx.health.connect.client.testing.stubs.Stub?);
+ method public void setGetChanges(androidx.health.connect.client.testing.stubs.Stub<? super java.lang.String,androidx.health.connect.client.response.ChangesResponse>?);
+ method public void setGetChangesToken(androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.ChangesTokenRequest,java.lang.String>?);
+ method public void setInsertRecords(androidx.health.connect.client.testing.stubs.Stub<? super java.util.List<? extends java.lang.Object?>,androidx.health.connect.client.response.InsertRecordsResponse>?);
+ method public void setReadRecord(androidx.health.connect.client.testing.stubs.Stub<? super java.lang.String,? extends androidx.health.connect.client.response.ReadRecordResponse<? extends java.lang.Object?>>?);
+ method public void setReadRecords(androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.ReadRecordsRequest<? extends java.lang.Object?>,? extends androidx.health.connect.client.response.ReadRecordsResponse<? extends java.lang.Object?>>?);
method public void setUpdateRecords(androidx.health.connect.client.testing.stubs.Stub?);
property public final androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.AggregateRequest,androidx.health.connect.client.aggregate.AggregationResult>? aggregate;
property public final androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.AggregateGroupByDurationRequest,java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByDuration>>? aggregateGroupByDuration;
property public final androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.AggregateGroupByPeriodRequest,java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByPeriod>>? aggregateGroupByPeriod;
property public final androidx.health.connect.client.testing.stubs.Stub? deleteRecords;
- property public final androidx.health.connect.client.testing.stubs.Stub? getChanges;
- property public final androidx.health.connect.client.testing.stubs.Stub? getChangesToken;
- property public final androidx.health.connect.client.testing.stubs.Stub? insertRecords;
- property public final androidx.health.connect.client.testing.stubs.Stub? readRecord;
- property public final androidx.health.connect.client.testing.stubs.Stub? readRecords;
+ property public final androidx.health.connect.client.testing.stubs.Stub<java.lang.String,androidx.health.connect.client.response.ChangesResponse>? getChanges;
+ property public final androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.ChangesTokenRequest,java.lang.String>? getChangesToken;
+ property public final androidx.health.connect.client.testing.stubs.Stub<java.util.List<? extends java.lang.Object?>,androidx.health.connect.client.response.InsertRecordsResponse>? insertRecords;
+ property public final androidx.health.connect.client.testing.stubs.Stub<java.lang.String,androidx.health.connect.client.response.ReadRecordResponse<? extends java.lang.Object?>>? readRecord;
+ property public final androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.ReadRecordsRequest<? extends java.lang.Object?>,androidx.health.connect.client.response.ReadRecordsResponse<? extends java.lang.Object?>>? readRecords;
property public final androidx.health.connect.client.testing.stubs.Stub? updateRecords;
}
diff --git a/health/connect/connect-testing/api/restricted_current.txt b/health/connect/connect-testing/api/restricted_current.txt
index df213f9..8a08ff1 100644
--- a/health/connect/connect-testing/api/restricted_current.txt
+++ b/health/connect/connect-testing/api/restricted_current.txt
@@ -40,36 +40,36 @@
public final class FakeHealthConnectClientOverrides {
ctor public FakeHealthConnectClientOverrides();
- ctor public FakeHealthConnectClientOverrides(optional androidx.health.connect.client.testing.stubs.Stub? getChanges, optional androidx.health.connect.client.testing.stubs.Stub? getChangesToken, optional androidx.health.connect.client.testing.stubs.Stub? readRecords, optional androidx.health.connect.client.testing.stubs.Stub? readRecord, optional androidx.health.connect.client.testing.stubs.Stub? insertRecords, optional androidx.health.connect.client.testing.stubs.Stub? updateRecords, optional androidx.health.connect.client.testing.stubs.Stub? deleteRecords, optional androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.AggregateRequest,androidx.health.connect.client.aggregate.AggregationResult>? aggregate, optional androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.AggregateGroupByDurationRequest,? extends java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByDuration>>? aggregateGroupByDuration, optional androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.AggregateGroupByPeriodRequest,? extends java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByPeriod>>? aggregateGroupByPeriod);
+ ctor public FakeHealthConnectClientOverrides(optional androidx.health.connect.client.testing.stubs.Stub<? super java.lang.String,androidx.health.connect.client.response.ChangesResponse>? getChanges, optional androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.ChangesTokenRequest,java.lang.String>? getChangesToken, optional androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.ReadRecordsRequest<? extends java.lang.Object?>,? extends androidx.health.connect.client.response.ReadRecordsResponse<? extends java.lang.Object?>>? readRecords, optional androidx.health.connect.client.testing.stubs.Stub<? super java.lang.String,? extends androidx.health.connect.client.response.ReadRecordResponse<? extends java.lang.Object?>>? readRecord, optional androidx.health.connect.client.testing.stubs.Stub<? super java.util.List<? extends java.lang.Object?>,androidx.health.connect.client.response.InsertRecordsResponse>? insertRecords, optional androidx.health.connect.client.testing.stubs.Stub? updateRecords, optional androidx.health.connect.client.testing.stubs.Stub? deleteRecords, optional androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.AggregateRequest,androidx.health.connect.client.aggregate.AggregationResult>? aggregate, optional androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.AggregateGroupByDurationRequest,? extends java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByDuration>>? aggregateGroupByDuration, optional androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.AggregateGroupByPeriodRequest,? extends java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByPeriod>>? aggregateGroupByPeriod);
method public androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.AggregateRequest,androidx.health.connect.client.aggregate.AggregationResult>? getAggregate();
method public androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.AggregateGroupByDurationRequest,java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByDuration>>? getAggregateGroupByDuration();
method public androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.AggregateGroupByPeriodRequest,java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByPeriod>>? getAggregateGroupByPeriod();
method public androidx.health.connect.client.testing.stubs.Stub? getDeleteRecords();
- method public androidx.health.connect.client.testing.stubs.Stub? getGetChanges();
- method public androidx.health.connect.client.testing.stubs.Stub? getGetChangesToken();
- method public androidx.health.connect.client.testing.stubs.Stub? getInsertRecords();
- method public androidx.health.connect.client.testing.stubs.Stub? getReadRecord();
- method public androidx.health.connect.client.testing.stubs.Stub? getReadRecords();
+ method public androidx.health.connect.client.testing.stubs.Stub<java.lang.String,androidx.health.connect.client.response.ChangesResponse>? getGetChanges();
+ method public androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.ChangesTokenRequest,java.lang.String>? getGetChangesToken();
+ method public androidx.health.connect.client.testing.stubs.Stub<java.util.List<? extends java.lang.Object?>,androidx.health.connect.client.response.InsertRecordsResponse>? getInsertRecords();
+ method public androidx.health.connect.client.testing.stubs.Stub<java.lang.String,androidx.health.connect.client.response.ReadRecordResponse<? extends java.lang.Object?>>? getReadRecord();
+ method public androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.ReadRecordsRequest<? extends java.lang.Object?>,androidx.health.connect.client.response.ReadRecordsResponse<? extends java.lang.Object?>>? getReadRecords();
method public androidx.health.connect.client.testing.stubs.Stub? getUpdateRecords();
method public void setAggregate(androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.AggregateRequest,androidx.health.connect.client.aggregate.AggregationResult>?);
method public void setAggregateGroupByDuration(androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.AggregateGroupByDurationRequest,? extends java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByDuration>>?);
method public void setAggregateGroupByPeriod(androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.AggregateGroupByPeriodRequest,? extends java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByPeriod>>?);
method public void setDeleteRecords(androidx.health.connect.client.testing.stubs.Stub?);
- method public void setGetChanges(androidx.health.connect.client.testing.stubs.Stub?);
- method public void setGetChangesToken(androidx.health.connect.client.testing.stubs.Stub?);
- method public void setInsertRecords(androidx.health.connect.client.testing.stubs.Stub?);
- method public void setReadRecord(androidx.health.connect.client.testing.stubs.Stub?);
- method public void setReadRecords(androidx.health.connect.client.testing.stubs.Stub?);
+ method public void setGetChanges(androidx.health.connect.client.testing.stubs.Stub<? super java.lang.String,androidx.health.connect.client.response.ChangesResponse>?);
+ method public void setGetChangesToken(androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.ChangesTokenRequest,java.lang.String>?);
+ method public void setInsertRecords(androidx.health.connect.client.testing.stubs.Stub<? super java.util.List<? extends java.lang.Object?>,androidx.health.connect.client.response.InsertRecordsResponse>?);
+ method public void setReadRecord(androidx.health.connect.client.testing.stubs.Stub<? super java.lang.String,? extends androidx.health.connect.client.response.ReadRecordResponse<? extends java.lang.Object?>>?);
+ method public void setReadRecords(androidx.health.connect.client.testing.stubs.Stub<? super androidx.health.connect.client.request.ReadRecordsRequest<? extends java.lang.Object?>,? extends androidx.health.connect.client.response.ReadRecordsResponse<? extends java.lang.Object?>>?);
method public void setUpdateRecords(androidx.health.connect.client.testing.stubs.Stub?);
property public final androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.AggregateRequest,androidx.health.connect.client.aggregate.AggregationResult>? aggregate;
property public final androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.AggregateGroupByDurationRequest,java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByDuration>>? aggregateGroupByDuration;
property public final androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.AggregateGroupByPeriodRequest,java.util.List<androidx.health.connect.client.aggregate.AggregationResultGroupedByPeriod>>? aggregateGroupByPeriod;
property public final androidx.health.connect.client.testing.stubs.Stub? deleteRecords;
- property public final androidx.health.connect.client.testing.stubs.Stub? getChanges;
- property public final androidx.health.connect.client.testing.stubs.Stub? getChangesToken;
- property public final androidx.health.connect.client.testing.stubs.Stub? insertRecords;
- property public final androidx.health.connect.client.testing.stubs.Stub? readRecord;
- property public final androidx.health.connect.client.testing.stubs.Stub? readRecords;
+ property public final androidx.health.connect.client.testing.stubs.Stub<java.lang.String,androidx.health.connect.client.response.ChangesResponse>? getChanges;
+ property public final androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.ChangesTokenRequest,java.lang.String>? getChangesToken;
+ property public final androidx.health.connect.client.testing.stubs.Stub<java.util.List<? extends java.lang.Object?>,androidx.health.connect.client.response.InsertRecordsResponse>? insertRecords;
+ property public final androidx.health.connect.client.testing.stubs.Stub<java.lang.String,androidx.health.connect.client.response.ReadRecordResponse<? extends java.lang.Object?>>? readRecord;
+ property public final androidx.health.connect.client.testing.stubs.Stub<androidx.health.connect.client.request.ReadRecordsRequest<? extends java.lang.Object?>,androidx.health.connect.client.response.ReadRecordsResponse<? extends java.lang.Object?>>? readRecords;
property public final androidx.health.connect.client.testing.stubs.Stub? updateRecords;
}
diff --git a/health/connect/connect-testing/src/main/java/androidx/health/connect/client/testing/FakeHealthConnectClient.kt b/health/connect/connect-testing/src/main/java/androidx/health/connect/client/testing/FakeHealthConnectClient.kt
index a3c359d2..c810147 100644
--- a/health/connect/connect-testing/src/main/java/androidx/health/connect/client/testing/FakeHealthConnectClient.kt
+++ b/health/connect/connect-testing/src/main/java/androidx/health/connect/client/testing/FakeHealthConnectClient.kt
@@ -40,7 +40,6 @@
import androidx.health.connect.client.response.InsertRecordsResponse
import androidx.health.connect.client.response.ReadRecordResponse
import androidx.health.connect.client.response.ReadRecordsResponse
-import androidx.health.connect.client.testing.stubs.throwOrContinue
import androidx.health.connect.client.time.TimeRangeFilter
import java.time.Clock
import kotlin.reflect.KClass
@@ -114,8 +113,10 @@
* precedence.
*/
override suspend fun insertRecords(records: List<Record>): InsertRecordsResponse {
- // Stub that only throws
- overrides.insertRecords?.throwOrContinue(null)
+ // Stubs
+ overrides.insertRecords?.next(records)?.let {
+ return it
+ }
// Fake implementation
val recordIdsList = mutableListOf<String>()
@@ -145,8 +146,8 @@
}
override suspend fun updateRecords(records: List<Record>) {
- // Stub that throws if set
- overrides.updateRecords?.throwOrContinue(null)
+ // Stubs
+ overrides.updateRecords?.next(records)
// Check if all records belong to the package
if (records.any { it.packageName != packageName }) {
@@ -171,8 +172,8 @@
recordIdsList: List<String>,
clientRecordIdsList: List<String>
) {
- // Stub that throws if set
- overrides.deleteRecords?.throwOrContinue(null)
+ // Stubs
+ overrides.deleteRecords?.next(Unit)
// Check if all records belong to the package
if (
@@ -213,8 +214,8 @@
recordType: KClass<out Record>,
timeRangeFilter: TimeRangeFilter
) {
- // Stub that throws if set
- overrides.deleteRecords?.throwOrContinue(null)
+ // Stubs
+ overrides.deleteRecords?.next(Unit)
// Fake implementation
val recordIdsToRemove =
@@ -237,7 +238,9 @@
recordId: String
): ReadRecordResponse<T> {
// Stubs
- overrides.readRecord?.throwOrContinue(null)
+ overrides.readRecord?.next(recordId)?.let {
+ return it as ReadRecordResponse<T>
+ }
// Fake implementation
return ReadRecordResponse(idsToRecords[recordId.toRecordId(packageName)] as T)
@@ -258,7 +261,9 @@
TODO("Not yet implemented")
}
// Stubs
- overrides.readRecords?.throwOrContinue(null)
+ overrides.readRecords?.next(request)?.let {
+ return it as ReadRecordsResponse<T>
+ }
// Fake implementation
val startIndex = request.pageToken?.toIntOrNull() ?: 0
@@ -333,7 +338,10 @@
* track changes from the moment this function is called.
*/
override suspend fun getChangesToken(request: ChangesTokenRequest): String {
- overrides.getChangesToken?.throwOrContinue(null)
+ // Stubs
+ overrides.getChangesToken?.next(request)?.let {
+ return it
+ }
if (request.recordTypes.isEmpty()) {
throw IllegalArgumentException("Record types must not be empty")
@@ -373,7 +381,9 @@
override suspend fun getChanges(changesToken: String): ChangesResponse {
// Stubs
- overrides.getChanges?.throwOrContinue(null)
+ overrides.getChanges?.next(changesToken)?.let {
+ return it
+ }
// Fake implementation
diff --git a/health/connect/connect-testing/src/main/java/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides.kt b/health/connect/connect-testing/src/main/java/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides.kt
index f41c46b..814a599 100644
--- a/health/connect/connect-testing/src/main/java/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides.kt
+++ b/health/connect/connect-testing/src/main/java/androidx/health/connect/client/testing/FakeHealthConnectClientOverrides.kt
@@ -22,6 +22,12 @@
import androidx.health.connect.client.request.AggregateGroupByDurationRequest
import androidx.health.connect.client.request.AggregateGroupByPeriodRequest
import androidx.health.connect.client.request.AggregateRequest
+import androidx.health.connect.client.request.ChangesTokenRequest
+import androidx.health.connect.client.request.ReadRecordsRequest
+import androidx.health.connect.client.response.ChangesResponse
+import androidx.health.connect.client.response.InsertRecordsResponse
+import androidx.health.connect.client.response.ReadRecordResponse
+import androidx.health.connect.client.response.ReadRecordsResponse
import androidx.health.connect.client.testing.stubs.Stub
/**
@@ -53,16 +59,29 @@
* [FakeHealthConnectClient.aggregateGroupByPeriod].
*/
public class FakeHealthConnectClientOverrides(
- /* Changes stubs, only used to throw exceptions */
- public var getChanges: Stub<Nothing?, Nothing>? = null,
- public var getChangesToken: Stub<Nothing?, Nothing>? = null,
- /* Records stubs, only used to throw exceptions */
- public var readRecords: Stub<Nothing?, Nothing>? = null,
- public var readRecord: Stub<Nothing?, Nothing>? = null,
- public var insertRecords: Stub<Nothing?, Nothing>? = null,
- public var updateRecords: Stub<Nothing?, Nothing>? = null,
- public var deleteRecords: Stub<Nothing?, Nothing>? = null,
+ /** A [Stub] used to set the next responses used in [getChanges]. */
+ public var getChanges: Stub<String, ChangesResponse>? = null,
+
+ /** A [Stub] used to set the next responses used in [getChangesToken]. */
+ public var getChangesToken: Stub<ChangesTokenRequest, String>? = null,
+
+ /* Records stubs */
+
+ /** A [Stub] used to set the next responses used in [readRecords]. */
+ public var readRecords: Stub<ReadRecordsRequest<*>, ReadRecordsResponse<*>>? = null,
+
+ /** A [Stub] used to set the next responses used in [readRecord]. */
+ public var readRecord: Stub<String, ReadRecordResponse<*>>? = null,
+
+ /** A [Stub] used to set the next responses used in [insertRecords]. */
+ public var insertRecords: Stub<List<*>, InsertRecordsResponse>? = null,
+
+ /** A [Stub] used only to throw exceptions in [updateRecords]. */
+ public var updateRecords: Stub<Any, Nothing>? = null,
+
+ /** A [Stub] used only to throw exceptions in [deleteRecords]. */
+ public var deleteRecords: Stub<Any, Nothing>? = null,
/* Aggregation stubs */
/**
diff --git a/health/connect/connect-testing/src/test/java/androidx/health/connect/client/testing/FakeHealthConnectClientOverridesTest.kt b/health/connect/connect-testing/src/test/java/androidx/health/connect/client/testing/FakeHealthConnectClientOverridesTest.kt
index 48c17d1..cbea9a0 100644
--- a/health/connect/connect-testing/src/test/java/androidx/health/connect/client/testing/FakeHealthConnectClientOverridesTest.kt
+++ b/health/connect/connect-testing/src/test/java/androidx/health/connect/client/testing/FakeHealthConnectClientOverridesTest.kt
@@ -18,9 +18,16 @@
import androidx.health.connect.client.aggregate.AggregationResultGroupedByDuration
import androidx.health.connect.client.aggregate.AggregationResultGroupedByPeriod
+import androidx.health.connect.client.changes.UpsertionChange
import androidx.health.connect.client.records.HeartRateRecord
import androidx.health.connect.client.records.StepsCadenceRecord
+import androidx.health.connect.client.records.StepsRecord
import androidx.health.connect.client.request.ChangesTokenRequest
+import androidx.health.connect.client.response.ChangesResponse
+import androidx.health.connect.client.response.InsertRecordsResponse
+import androidx.health.connect.client.response.ReadRecordResponse
+import androidx.health.connect.client.response.ReadRecordsResponse
+import androidx.health.connect.client.testing.stubs.Stub
import androidx.health.connect.client.testing.stubs.stub
import androidx.health.connect.client.testing.testdata.dummyAggregateGbdRequest
import androidx.health.connect.client.testing.testdata.dummyAggregateGbpRequest
@@ -60,6 +67,32 @@
}
}
+ /* Records stubbed elements */
+
+ @Test
+ fun readRecord_stubbedElement() = runTest {
+ fake.overrides.readRecord = stub(ReadRecordResponse(runRecord1))
+ val response =
+ fake.readRecord(recordType = runRecord1::class, recordId = runRecord1.metadata.id)
+ assertThat(response.record).isEqualTo(runRecord1)
+ }
+
+ @Test
+ fun readRecords_stubbedElement() = runTest {
+ fake.overrides.readRecords =
+ stub(ReadRecordsResponse(records = listOf(runRecord1), pageToken = "test"))
+ val response = fake.readRecords(dummyReadRecordsRequest)
+ assertThat(response.records).hasSize(1)
+ assertThat(response.records.first().title).isEqualTo(runRecord1.title)
+ }
+
+ @Test
+ fun insertRecords_stubbedElement() = runTest {
+ fake.overrides.insertRecords = stub(InsertRecordsResponse(listOf("test")))
+ val response = fake.insertRecords(emptyList())
+ assertThat(response.recordIdsList.first()).isEqualTo("test")
+ }
+
/* Record exceptions */
@Test
@@ -118,6 +151,22 @@
}
}
+ @Test
+ fun deleteRecordsIds_stubbedException_throws() = runTest {
+ val expectedException = Exception()
+ fake.overrides.deleteRecords = stub { throw expectedException }
+
+ assertThrows(expectedException::class.java) {
+ runBlocking {
+ fake.deleteRecords(
+ recordType = runRecord1::class,
+ recordIdsList = emptyList(),
+ clientRecordIdsList = emptyList()
+ )
+ }
+ }
+ }
+
/* Aggregation exceptions */
@Test
@@ -241,4 +290,34 @@
runBlocking { fake.getChangesToken(ChangesTokenRequest(recordTypes = emptySet())) }
}
}
+
+ @Test
+ fun getChangesToken_stubbedElement() = runTest {
+ val changesToken = "test_token"
+ fake.overrides.getChangesToken = stub(changesToken)
+ val response = fake.getChangesToken(ChangesTokenRequest(setOf(StepsRecord::class)))
+
+ assertThat(response).isEqualTo(changesToken)
+ }
+
+ @Test
+ fun getChanges_stubbedElement() = runTest {
+ val changesToken = "test_token"
+ fake.overrides.getChanges = Stub { token ->
+ if (token == changesToken) {
+ ChangesResponse(
+ changes = listOf(UpsertionChange(runRecord1)),
+ hasMore = true,
+ changesTokenExpired = false,
+ nextChangesToken = "next"
+ )
+ } else {
+ throw IllegalStateException()
+ }
+ }
+ val response = fake.getChanges(changesToken)
+
+ assertThat(response.changes).hasSize(1)
+ assertThat(response.nextChangesToken).isEqualTo("next")
+ }
}
diff --git a/libraryversions.toml b/libraryversions.toml
index 7139a8e..1e1ac97 100644
--- a/libraryversions.toml
+++ b/libraryversions.toml
@@ -13,9 +13,9 @@
BROWSER = "1.9.0-alpha01"
BUILDSRC_TESTS = "1.0.0-alpha01"
CAMERA = "1.5.0-alpha04"
+CAMERA_MEDIA3 = "1.0.0-alpha01"
CAMERA_PIPE = "1.0.0-alpha01"
CAMERA_TESTING = "1.0.0-alpha01"
-CAMERA_MEDIA3 = "1.0.0-alpha01"
CAMERA_VIEWFINDER = "1.4.0-alpha11"
CARDVIEW = "1.1.0-alpha01"
CAR_APP = "1.7.0-beta03"
@@ -194,9 +194,9 @@
BUILDSRC_TESTS_MAX_DEP_VERSIONS_DEP = { group = "androidx.buildSrc-tests-max-dep-versions-dep", atomicGroupVersion = "versions.BUILDSRC_TESTS", overrideInclude = [ ":buildSrc-tests:max-dep-versions:buildSrc-tests-max-dep-versions-dep" ] }
BUILDSRC_TESTS_MAX_DEP_VERSIONS_MAIN = { group = "androidx.buildSrc-tests-max-dep-versions-main", atomicGroupVersion = "versions.BUILDSRC_TESTS", overrideInclude = [ ":buildSrc-tests:max-dep-versions:buildSrc-tests-max-dep-versions-main" ] }
CAMERA = { group = "androidx.camera", atomicGroupVersion = "versions.CAMERA" }
+CAMERA_MEDIA3 = { group = "androidx.camera.media3", atomicGroupVersion = "versions.CAMERA_MEDIA3" }
CAMERA_PIPE = { group = "androidx.camera", atomicGroupVersion = "versions.CAMERA_PIPE", overrideInclude = [ ":camera:camera-camera2-pipe", ":camera:camera-camera2-pipe-integration" ] }
CAMERA_TESTING = { group = "androidx.camera", atomicGroupVersion = "versions.CAMERA_TESTING", overrideInclude = [ ":camera:camera-testing" ] }
-CAMERA_MEDIA3 = { group = "androidx.camera", atomicGroupVersion = "versions.CAMERA_MEDIA3", overrideInclude = [ ":camera:camera-media3-effect" ] }
CAMERA_VIEWFINDER = { group = "androidx.camera.viewfinder", atomicGroupVersion = "versions.CAMERA_VIEWFINDER" }
CARDVIEW = { group = "androidx.cardview", atomicGroupVersion = "versions.CARDVIEW" }
CAR_APP = { group = "androidx.car.app", atomicGroupVersion = "versions.CAR_APP" }
diff --git a/lifecycle/lifecycle-viewmodel-testing/bcv/native/current.txt b/lifecycle/lifecycle-viewmodel-testing/bcv/native/current.txt
index 23fa7e1..887b927 100644
--- a/lifecycle/lifecycle-viewmodel-testing/bcv/native/current.txt
+++ b/lifecycle/lifecycle-viewmodel-testing/bcv/native/current.txt
@@ -16,5 +16,6 @@
}
final fun androidx.lifecycle.viewmodel.testing/DefaultCreationExtras(): androidx.lifecycle.viewmodel/CreationExtras // androidx.lifecycle.viewmodel.testing/DefaultCreationExtras|DefaultCreationExtras(){}[0]
+final fun androidx.lifecycle.viewmodel.testing/DefaultCreationExtras(androidx.savedstate/SavedState): androidx.lifecycle.viewmodel/CreationExtras // androidx.lifecycle.viewmodel.testing/DefaultCreationExtras|DefaultCreationExtras(androidx.savedstate.SavedState){}[0]
final inline fun <#A: reified androidx.lifecycle/ViewModel> androidx.lifecycle.viewmodel.testing/viewModelScenario(androidx.lifecycle.viewmodel/CreationExtras = ..., noinline kotlin/Function1<androidx.lifecycle.viewmodel/CreationExtras, #A>): androidx.lifecycle.viewmodel.testing/ViewModelScenario<#A> // androidx.lifecycle.viewmodel.testing/viewModelScenario|viewModelScenario(androidx.lifecycle.viewmodel.CreationExtras;kotlin.Function1<androidx.lifecycle.viewmodel.CreationExtras,0:0>){0§<androidx.lifecycle.ViewModel>}[0]
final inline fun <#A: reified androidx.lifecycle/ViewModel> androidx.lifecycle.viewmodel.testing/viewModelScenario(androidx.lifecycle/ViewModelProvider.Factory, androidx.lifecycle.viewmodel/CreationExtras = ...): androidx.lifecycle.viewmodel.testing/ViewModelScenario<#A> // androidx.lifecycle.viewmodel.testing/viewModelScenario|viewModelScenario(androidx.lifecycle.ViewModelProvider.Factory;androidx.lifecycle.viewmodel.CreationExtras){0§<androidx.lifecycle.ViewModel>}[0]
diff --git a/lifecycle/lifecycle-viewmodel-testing/build.gradle b/lifecycle/lifecycle-viewmodel-testing/build.gradle
index 6c99a18a..7b8469f 100644
--- a/lifecycle/lifecycle-viewmodel-testing/build.gradle
+++ b/lifecycle/lifecycle-viewmodel-testing/build.gradle
@@ -58,6 +58,9 @@
api(project(":lifecycle:lifecycle-viewmodel"))
api(libs.kotlinStdlib)
api(libs.kotlinCoroutinesCore)
+ implementation(project(":lifecycle:lifecycle-runtime"))
+ implementation(project(":lifecycle:lifecycle-runtime-testing"))
+ implementation(project(":lifecycle:lifecycle-viewmodel-savedstate"))
}
}
@@ -71,11 +74,6 @@
androidMain {
dependsOn(commonMain)
- dependencies {
- implementation(project(":lifecycle:lifecycle-runtime"))
- implementation(project(":lifecycle:lifecycle-runtime-testing"))
- implementation(project(":lifecycle:lifecycle-viewmodel-savedstate"))
- }
}
androidInstrumentedTest {
diff --git a/lifecycle/lifecycle-viewmodel-testing/src/androidMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.android.kt b/lifecycle/lifecycle-viewmodel-testing/src/androidMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.android.kt
deleted file mode 100644
index 6e5a48c..0000000
--- a/lifecycle/lifecycle-viewmodel-testing/src/androidMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.android.kt
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-@file:JvmName("DefaultCreationExtrasKt")
-
-package androidx.lifecycle.viewmodel.testing
-
-import android.os.Bundle
-import androidx.lifecycle.DEFAULT_ARGS_KEY
-import androidx.lifecycle.Lifecycle
-import androidx.lifecycle.LifecycleOwner
-import androidx.lifecycle.LifecycleRegistry
-import androidx.lifecycle.SAVED_STATE_REGISTRY_OWNER_KEY
-import androidx.lifecycle.SavedStateHandle
-import androidx.lifecycle.VIEW_MODEL_STORE_OWNER_KEY
-import androidx.lifecycle.ViewModelStore
-import androidx.lifecycle.ViewModelStoreOwner
-import androidx.lifecycle.enableSavedStateHandles
-import androidx.lifecycle.testing.TestLifecycleOwner
-import androidx.lifecycle.viewmodel.CreationExtras
-import androidx.lifecycle.viewmodel.MutableCreationExtras
-import androidx.savedstate.SavedStateRegistryController
-import androidx.savedstate.SavedStateRegistryOwner
-
-/**
- * Creates a default instance of [CreationExtras] pre-configured with all keys required to use
- * [SavedStateHandle].
- *
- * This function sets up the instance with:
- * - A fake [SavedStateRegistryOwner] assigned to [SAVED_STATE_REGISTRY_OWNER_KEY], delegating the
- * [LifecycleOwner] to a [TestLifecycleOwner].
- * - A fake [ViewModelStoreOwner] assigned to [VIEW_MODEL_STORE_OWNER_KEY], containing an empty
- * [ViewModelStore].
- */
-@Suppress("FunctionName")
-public actual fun DefaultCreationExtras(): CreationExtras {
- return DefaultCreationExtras(defaultArgs = Bundle())
-}
-
-/**
- * Creates a default instance of [CreationExtras] pre-configured with all keys required to use
- * [SavedStateHandle], with the specified [defaultArgs] as the [DEFAULT_ARGS_KEY].
- *
- * This function sets up the instance with:
- * - A fake [SavedStateRegistryOwner] assigned to [SAVED_STATE_REGISTRY_OWNER_KEY], delegating the
- * [LifecycleOwner] to a [TestLifecycleOwner].
- * - A fake [ViewModelStoreOwner] assigned to [VIEW_MODEL_STORE_OWNER_KEY], containing an empty
- * [ViewModelStore].
- */
-@Suppress("FunctionName")
-public fun DefaultCreationExtras(defaultArgs: Bundle): CreationExtras {
- val owner =
- object : ViewModelStoreOwner, LifecycleOwner, SavedStateRegistryOwner {
- override val viewModelStore = ViewModelStore()
-
- val lifecycleRegistry = LifecycleRegistry.createUnsafe(owner = this)
- override val lifecycle: Lifecycle = lifecycleRegistry
-
- val savedStateRegistryController = SavedStateRegistryController.create(owner = this)
- override val savedStateRegistry = savedStateRegistryController.savedStateRegistry
- }
-
- owner.savedStateRegistryController.performAttach()
- owner.savedStateRegistryController.performRestore(savedState = null)
- owner.enableSavedStateHandles()
-
- owner.lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START)
-
- return MutableCreationExtras().apply {
- this[SAVED_STATE_REGISTRY_OWNER_KEY] = owner
- this[VIEW_MODEL_STORE_OWNER_KEY] = owner
- this[DEFAULT_ARGS_KEY] = defaultArgs
- }
-}
diff --git a/lifecycle/lifecycle-viewmodel-testing/src/commonMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.kt b/lifecycle/lifecycle-viewmodel-testing/src/commonMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.kt
index 5ca4b56..ca17de5 100644
--- a/lifecycle/lifecycle-viewmodel-testing/src/commonMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.kt
+++ b/lifecycle/lifecycle-viewmodel-testing/src/commonMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.kt
@@ -16,7 +16,71 @@
package androidx.lifecycle.viewmodel.testing
+import androidx.lifecycle.DEFAULT_ARGS_KEY
+import androidx.lifecycle.Lifecycle
+import androidx.lifecycle.LifecycleOwner
+import androidx.lifecycle.LifecycleRegistry
+import androidx.lifecycle.SAVED_STATE_REGISTRY_OWNER_KEY
+import androidx.lifecycle.SavedStateHandle
+import androidx.lifecycle.VIEW_MODEL_STORE_OWNER_KEY
+import androidx.lifecycle.ViewModelStore
+import androidx.lifecycle.ViewModelStoreOwner
+import androidx.lifecycle.enableSavedStateHandles
+import androidx.lifecycle.testing.TestLifecycleOwner
import androidx.lifecycle.viewmodel.CreationExtras
+import androidx.lifecycle.viewmodel.MutableCreationExtras
+import androidx.savedstate.SavedState
+import androidx.savedstate.SavedStateRegistryController
+import androidx.savedstate.SavedStateRegistryOwner
+import androidx.savedstate.savedState
-/** Creates a default instance of [CreationExtras]. */
-@Suppress("FunctionName") public expect fun DefaultCreationExtras(): CreationExtras
+/**
+ * Creates a default instance of [CreationExtras] pre-configured with all keys required to use
+ * [SavedStateHandle].
+ *
+ * This function sets up the instance with:
+ * - A fake [SavedStateRegistryOwner] assigned to [SAVED_STATE_REGISTRY_OWNER_KEY], delegating the
+ * [LifecycleOwner] to a [TestLifecycleOwner].
+ * - A fake [ViewModelStoreOwner] assigned to [VIEW_MODEL_STORE_OWNER_KEY], containing an empty
+ * [ViewModelStore].
+ */
+@Suppress("FunctionName")
+public fun DefaultCreationExtras(): CreationExtras {
+ return DefaultCreationExtras(defaultArgs = savedState())
+}
+
+/**
+ * Creates a default instance of [CreationExtras] pre-configured with all keys required to use
+ * [SavedStateHandle], with the specified [defaultArgs] as the [DEFAULT_ARGS_KEY].
+ *
+ * This function sets up the instance with:
+ * - A fake [SavedStateRegistryOwner] assigned to [SAVED_STATE_REGISTRY_OWNER_KEY], delegating the
+ * [LifecycleOwner] to a [TestLifecycleOwner].
+ * - A fake [ViewModelStoreOwner] assigned to [VIEW_MODEL_STORE_OWNER_KEY], containing an empty
+ * [ViewModelStore].
+ */
+@Suppress("FunctionName")
+public fun DefaultCreationExtras(defaultArgs: SavedState): CreationExtras {
+ val owner =
+ object : ViewModelStoreOwner, LifecycleOwner, SavedStateRegistryOwner {
+ override val viewModelStore = ViewModelStore()
+
+ val lifecycleRegistry = LifecycleRegistry.createUnsafe(owner = this)
+ override val lifecycle: Lifecycle = lifecycleRegistry
+
+ val savedStateRegistryController = SavedStateRegistryController.create(owner = this)
+ override val savedStateRegistry = savedStateRegistryController.savedStateRegistry
+ }
+
+ owner.savedStateRegistryController.performAttach()
+ owner.savedStateRegistryController.performRestore(savedState = null)
+ owner.enableSavedStateHandles()
+
+ owner.lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START)
+
+ return MutableCreationExtras().apply {
+ this[SAVED_STATE_REGISTRY_OWNER_KEY] = owner
+ this[VIEW_MODEL_STORE_OWNER_KEY] = owner
+ this[DEFAULT_ARGS_KEY] = defaultArgs
+ }
+}
diff --git a/lifecycle/lifecycle-viewmodel-testing/src/desktopMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.desktop.kt b/lifecycle/lifecycle-viewmodel-testing/src/desktopMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.desktop.kt
deleted file mode 100644
index 43f80b4..0000000
--- a/lifecycle/lifecycle-viewmodel-testing/src/desktopMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.desktop.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2024 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-@file:JvmName("DefaultCreationExtrasKt")
-
-package androidx.lifecycle.viewmodel.testing
-
-import androidx.lifecycle.viewmodel.CreationExtras
-import androidx.lifecycle.viewmodel.CreationExtras.Empty
-
-@Suppress("FunctionName") public actual fun DefaultCreationExtras(): CreationExtras = Empty
diff --git a/mediarouter/OWNERS b/mediarouter/OWNERS
index a34ddce..bab58bd 100644
--- a/mediarouter/OWNERS
+++ b/mediarouter/OWNERS
@@ -1,4 +1,4 @@
-# Bug component: 1611600
+# Bug component: 137631
[email protected]
[email protected]
[email protected]
diff --git a/mediarouter/mediarouter/api/current.txt b/mediarouter/mediarouter/api/current.txt
index 45aff505..6ed85777 100644
--- a/mediarouter/mediarouter/api/current.txt
+++ b/mediarouter/mediarouter/api/current.txt
@@ -514,6 +514,7 @@
public class MediaRouterParams {
method public int getDialogType();
method public boolean isMediaTransferReceiverEnabled();
+ method public boolean isMediaTransferRestrictedToSelfProviders();
method public boolean isOutputSwitcherEnabled();
method public boolean isTransferToLocalEnabled();
field public static final int DIALOG_TYPE_DEFAULT = 1; // 0x1
@@ -527,6 +528,7 @@
method public androidx.mediarouter.media.MediaRouterParams build();
method public androidx.mediarouter.media.MediaRouterParams.Builder setDialogType(int);
method public androidx.mediarouter.media.MediaRouterParams.Builder setMediaTransferReceiverEnabled(boolean);
+ method public androidx.mediarouter.media.MediaRouterParams.Builder setMediaTransferRestrictedToSelfProviders(boolean);
method public androidx.mediarouter.media.MediaRouterParams.Builder setOutputSwitcherEnabled(boolean);
method public androidx.mediarouter.media.MediaRouterParams.Builder setTransferToLocalEnabled(boolean);
}
diff --git a/mediarouter/mediarouter/api/restricted_current.txt b/mediarouter/mediarouter/api/restricted_current.txt
index 45aff505..6ed85777 100644
--- a/mediarouter/mediarouter/api/restricted_current.txt
+++ b/mediarouter/mediarouter/api/restricted_current.txt
@@ -514,6 +514,7 @@
public class MediaRouterParams {
method public int getDialogType();
method public boolean isMediaTransferReceiverEnabled();
+ method public boolean isMediaTransferRestrictedToSelfProviders();
method public boolean isOutputSwitcherEnabled();
method public boolean isTransferToLocalEnabled();
field public static final int DIALOG_TYPE_DEFAULT = 1; // 0x1
@@ -527,6 +528,7 @@
method public androidx.mediarouter.media.MediaRouterParams build();
method public androidx.mediarouter.media.MediaRouterParams.Builder setDialogType(int);
method public androidx.mediarouter.media.MediaRouterParams.Builder setMediaTransferReceiverEnabled(boolean);
+ method public androidx.mediarouter.media.MediaRouterParams.Builder setMediaTransferRestrictedToSelfProviders(boolean);
method public androidx.mediarouter.media.MediaRouterParams.Builder setOutputSwitcherEnabled(boolean);
method public androidx.mediarouter.media.MediaRouterParams.Builder setTransferToLocalEnabled(boolean);
}
diff --git a/mediarouter/mediarouter/src/androidTest/AndroidManifest.xml b/mediarouter/mediarouter/src/androidTest/AndroidManifest.xml
index 7961fb1..9d5f182 100644
--- a/mediarouter/mediarouter/src/androidTest/AndroidManifest.xml
+++ b/mediarouter/mediarouter/src/androidTest/AndroidManifest.xml
@@ -36,6 +36,14 @@
</intent-filter>
</service>
<service
+ android:name="androidx.mediarouter.media.StubMediaRoute2ProviderService"
+ android:exported="false">
+ <intent-filter>
+ <action android:name="android.media.MediaRouteProviderService"/>
+ <action android:name="android.media.MediaRoute2ProviderService"/>
+ </intent-filter>
+ </service>
+ <service
android:name="androidx.mediarouter.media.StubDynamicMediaRouteProviderService"
android:exported="true">
<intent-filter>
@@ -54,7 +62,7 @@
android:exported="true"
android:enabled="true">
<intent-filter>
- <action android:name="aandroid.media.MediaRouteProviderService"/>
+ <action android:name="android.media.MediaRouteProviderService"/>
</intent-filter>
</service>
</application>
diff --git a/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/MediaRouteProviderServiceTest.java b/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/MediaRouteProviderServiceTest.java
index 9fd3cc8..43ebd03 100644
--- a/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/MediaRouteProviderServiceTest.java
+++ b/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/MediaRouteProviderServiceTest.java
@@ -33,6 +33,8 @@
import android.os.Messenger;
import android.text.TextUtils;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.mediarouter.media.MediaRouteProviderService.ClientInfo;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -68,8 +70,8 @@
private static final String FAKE_MEDIA_ROUTE_NAME_4 = "fakeMediaRouteName4";
private static final long TIME_OUT_MS = 3000;
- @Rule
- public final ServiceTestRule mServiceRule = new ServiceTestRule();
+ @Rule public final ServiceTestRule mServiceRule = new ServiceTestRule();
+
private IBinder mService;
private Messenger mServiceMessenger;
private Messenger mReceiveMessenger1;
@@ -81,8 +83,10 @@
private static CountDownLatch sPassiveScanCountDownLatch;
private static CountDownLatch sClientInfoListenerAdditionCountDownLatch;
private static CountDownLatch sClientInfoListenerRemovalCountDownLatch;
+ private static CountDownLatch sRouteCreationCountDownLatch;
private static MediaRouteDiscoveryRequest sLastDiscoveryRequest;
private static List<ClientInfo> sLatestClientInfo = new ArrayList<>();
+ private static MediaRouteProvider.RouteControllerOptions sRouteControllerOptions;
@Before
public void setUp() throws Exception {
@@ -97,12 +101,15 @@
mServiceMessenger = new Messenger(mService);
mReceiveMessenger1 = new Messenger(new Handler(Looper.getMainLooper()));
mReceiveMessenger2 = new Messenger(new Handler(Looper.getMainLooper()));
- mSelector = new MediaRouteSelector.Builder()
- .addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO).build();
+ mSelector =
+ new MediaRouteSelector.Builder()
+ .addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO)
+ .build();
registerClient(mReceiveMessenger1);
registerClient(mReceiveMessenger2);
- assertTrue(sClientInfoListenerAdditionCountDownLatch.await(
- TIME_OUT_MS, TimeUnit.MILLISECONDS));
+ assertTrue(
+ sClientInfoListenerAdditionCountDownLatch.await(
+ TIME_OUT_MS, TimeUnit.MILLISECONDS));
}
@After
@@ -111,21 +118,13 @@
unregisterClient(mReceiveMessenger2);
mServiceRule.unbindService();
sLastDiscoveryRequest = null;
+ sRouteControllerOptions = null;
}
@Test
@SmallTest
- public void testCreateDescriptorBundleForClientVersion() {
- MediaRouteProviderDescriptor.Builder builder = new MediaRouteProviderDescriptor.Builder();
- builder.addRoute(new MediaRouteDescriptor.Builder(FAKE_MEDIA_ROUTE_ID_1,
- FAKE_MEDIA_ROUTE_NAME_1).setMaxClientVersion(15).setMinClientVersion(10).build());
- builder.addRoute(new MediaRouteDescriptor.Builder(FAKE_MEDIA_ROUTE_ID_2,
- FAKE_MEDIA_ROUTE_NAME_2).setMaxClientVersion(18).setMinClientVersion(11).build());
- builder.addRoute(new MediaRouteDescriptor.Builder(FAKE_MEDIA_ROUTE_ID_3,
- FAKE_MEDIA_ROUTE_NAME_3).setMaxClientVersion(25).setMinClientVersion(16).build());
- builder.addRoute(new MediaRouteDescriptor.Builder(FAKE_MEDIA_ROUTE_ID_4,
- FAKE_MEDIA_ROUTE_NAME_4).setMaxClientVersion(12).setMinClientVersion(4).build());
- MediaRouteProviderDescriptor descriptor = builder.build();
+ public void createDescriptorBundleForClientVersion() {
+ MediaRouteProviderDescriptor descriptor = createMediaRouteProviderDescriptor();
Bundle bundle = MediaRouteProviderService
.createDescriptorBundleForClientVersion(descriptor, 3);
@@ -193,7 +192,8 @@
@LargeTest
@Test
public void testSetEmptyPassiveDiscoveryRequest_shouldNotRequestScan() throws Exception {
- sendDiscoveryRequest(mReceiveMessenger1,
+ sendDiscoveryRequest(
+ mReceiveMessenger1,
new MediaRouteDiscoveryRequest(MediaRouteSelector.EMPTY, false));
Thread.sleep(TIME_OUT_MS);
@@ -203,10 +203,11 @@
@LargeTest
@Test
- public void testSetEmptyActiveDiscoveryRequest_shouldRequestScan() throws Exception {
+ public void setEmptyActiveDiscoveryRequest_shouldRequestScan() throws Exception {
resetActiveAndPassiveScanCountDownLatches();
- sendDiscoveryRequest(mReceiveMessenger1,
- new MediaRouteDiscoveryRequest(MediaRouteSelector.EMPTY, true));
+ sendDiscoveryRequest(
+ mReceiveMessenger1,
+ new MediaRouteDiscoveryRequest(mSelector, /* activeScan= */ true));
assertTrue(sActiveScanCountDownLatch.await(TIME_OUT_MS, TimeUnit.MILLISECONDS));
}
@@ -216,15 +217,18 @@
public void testRequestActiveScan_suppressActiveScanAfter30Seconds() throws Exception {
// Request active discovery.
resetActiveAndPassiveScanCountDownLatches();
- sendDiscoveryRequest(mReceiveMessenger1, new MediaRouteDiscoveryRequest(mSelector, true));
+ sendDiscoveryRequest(
+ mReceiveMessenger1,
+ new MediaRouteDiscoveryRequest(mSelector, /* activeScane= */ true));
// Active scan should be true.
assertTrue(sActiveScanCountDownLatch.await(TIME_OUT_MS, TimeUnit.MILLISECONDS));
// Right before active scan duration passes, active scan flag should still be true.
resetActiveAndPassiveScanCountDownLatches();
- assertFalse(sPassiveScanCountDownLatch.await(
- MAX_ACTIVE_SCAN_DURATION_MS - 1000, TimeUnit.MILLISECONDS));
+ assertFalse(
+ sPassiveScanCountDownLatch.await(
+ MAX_ACTIVE_SCAN_DURATION_MS - 1000, TimeUnit.MILLISECONDS));
// After active scan duration passed, active scan flag should be false.
resetActiveAndPassiveScanCountDownLatches();
@@ -240,8 +244,9 @@
// Right before active scan duration passes, active scan flag should still be true.
resetActiveAndPassiveScanCountDownLatches();
- assertFalse(sPassiveScanCountDownLatch.await(
- MAX_ACTIVE_SCAN_DURATION_MS - 1000, TimeUnit.MILLISECONDS));
+ assertFalse(
+ sPassiveScanCountDownLatch.await(
+ MAX_ACTIVE_SCAN_DURATION_MS - 1000, TimeUnit.MILLISECONDS));
// After active scan duration passed, active scan flag should be false.
resetActiveAndPassiveScanCountDownLatches();
@@ -264,8 +269,9 @@
// Right before the last client times out, active scan flag should still be true.
resetActiveAndPassiveScanCountDownLatches();
- assertFalse(sActiveScanCountDownLatch.await(
- MAX_ACTIVE_SCAN_DURATION_MS - 1000, TimeUnit.MILLISECONDS));
+ assertFalse(
+ sActiveScanCountDownLatch.await(
+ MAX_ACTIVE_SCAN_DURATION_MS - 1000, TimeUnit.MILLISECONDS));
// Right after the active scan duration passed, active scan flag should be false.
resetActiveAndPassiveScanCountDownLatches();
@@ -287,8 +293,7 @@
assertEquals(1, sLatestClientInfo.size() - initialCount);
Context context = ApplicationProvider.getApplicationContext();
for (ClientInfo clientInfo : sLatestClientInfo) {
- assertTrue(TextUtils.equals(
- context.getPackageName(), clientInfo.getPackageName()));
+ assertTrue(TextUtils.equals(context.getPackageName(), clientInfo.getPackageName()));
}
unregisterClient(messenger);
@@ -297,6 +302,38 @@
assertEquals(initialCount, sLatestClientInfo.size());
}
+ @LargeTest
+ @Test
+ public void onCreateDynamicGroupRouteController_shouldProvideRouteControllerOptions()
+ throws Exception {
+ sRouteCreationCountDownLatch = new CountDownLatch(1);
+ // Request active discovery.
+ resetActiveAndPassiveScanCountDownLatches();
+ sendDiscoveryRequest(
+ mReceiveMessenger1,
+ new MediaRouteDiscoveryRequest(mSelector, /* activeScan= */ true));
+
+ // Active scan should be true.
+ assertTrue(sActiveScanCountDownLatch.await(TIME_OUT_MS, TimeUnit.MILLISECONDS));
+
+ final String key = "key";
+ final String value = "value";
+ Bundle controlHints = new Bundle();
+ controlHints.putString(key, value);
+ MediaRouteProvider.RouteControllerOptions routeControllerOptions =
+ new MediaRouteProvider.RouteControllerOptions.Builder()
+ .setControlHints(controlHints)
+ .build();
+
+ sendCreateDynamicGroupRouteController(
+ mReceiveMessenger1, FAKE_MEDIA_ROUTE_ID_1, routeControllerOptions);
+
+ // A dynamic group route controller is created.
+ assertTrue(sRouteCreationCountDownLatch.await(TIME_OUT_MS, TimeUnit.MILLISECONDS));
+
+ assertEquals(value, sRouteControllerOptions.getControlHints().getString(key));
+ }
+
private void registerClient(Messenger receiveMessenger) throws Exception {
Message msg = Message.obtain();
msg.what = MediaRouteProviderProtocol.CLIENT_MSG_REGISTER;
@@ -315,8 +352,8 @@
mServiceMessenger.send(msg);
}
- private void sendDiscoveryRequest(Messenger receiveMessenger,
- MediaRouteDiscoveryRequest request) throws Exception {
+ private void sendDiscoveryRequest(
+ Messenger receiveMessenger, MediaRouteDiscoveryRequest request) throws Exception {
Message msg = Message.obtain();
msg.what = MediaRouteProviderProtocol.CLIENT_MSG_SET_DISCOVERY_REQUEST;
msg.arg1 = mRequestId++;
@@ -326,23 +363,44 @@
mServiceMessenger.send(msg);
}
+ private void sendCreateDynamicGroupRouteController(
+ Messenger receiveMessenger,
+ String routeId,
+ MediaRouteProvider.RouteControllerOptions routeControllerOptions)
+ throws Exception {
+ Bundle data = new Bundle();
+ data.putString(MediaRouteProviderProtocol.CLIENT_DATA_MEMBER_ROUTE_ID, routeId);
+ data.putParcelable(
+ MediaRouteProviderProtocol.CLIENT_DATA_ROUTE_CONTROLLER_OPTIONS,
+ routeControllerOptions.asBundle());
+
+ Message msg = Message.obtain();
+ msg.what = MediaRouteProviderProtocol.CLIENT_MSG_CREATE_DYNAMIC_GROUP_ROUTE_CONTROLLER;
+ msg.arg1 = mRequestId++;
+ msg.setData(data);
+ msg.replyTo = receiveMessenger;
+
+ mServiceMessenger.send(msg);
+ }
+
/** Fake {@link MediaRouteProviderService} implementation. */
public static final class MediaRouteProviderServiceImpl extends MediaRouteProviderService {
-
@Override
public void onCreate() {
super.onCreate();
sLatestClientInfo.clear();
- addClientInfoListener(Executors.newSingleThreadExecutor(), clients -> {
- int previousSize = sLatestClientInfo.size();
- int newSize = clients.size();
- sLatestClientInfo = clients;
- if (newSize > previousSize) {
- sClientInfoListenerAdditionCountDownLatch.countDown();
- } else if (previousSize > newSize) {
- sClientInfoListenerRemovalCountDownLatch.countDown();
- }
- });
+ addClientInfoListener(
+ Executors.newSingleThreadExecutor(),
+ clients -> {
+ int previousSize = sLatestClientInfo.size();
+ int newSize = clients.size();
+ sLatestClientInfo = clients;
+ if (newSize > previousSize) {
+ sClientInfoListenerAdditionCountDownLatch.countDown();
+ } else if (previousSize > newSize) {
+ sClientInfoListenerRemovalCountDownLatch.countDown();
+ }
+ });
}
@Override
@@ -365,13 +423,52 @@
(discoveryRequest != null) ? discoveryRequest.isActiveScan() : false;
if (wasActiveScan != isActiveScan) {
if (isActiveScan) {
+ setDescriptor(createMediaRouteProviderDescriptor());
sActiveScanCountDownLatch.countDown();
} else {
+ MediaRouteProviderDescriptor emptyDescriptor =
+ new MediaRouteProviderDescriptor.Builder().build();
+ setDescriptor(emptyDescriptor);
sPassiveScanCountDownLatch.countDown();
}
}
sLastDiscoveryRequest = discoveryRequest;
}
+
+ @Override
+ @Nullable
+ public DynamicGroupRouteController onCreateDynamicGroupRouteController(
+ @NonNull String initialMemberRouteId,
+ @NonNull RouteControllerOptions routeControllerOptions) {
+ sRouteControllerOptions = routeControllerOptions;
+ sRouteCreationCountDownLatch.countDown();
+ return null;
+ }
+ }
+
+ private static MediaRouteProviderDescriptor createMediaRouteProviderDescriptor() {
+ MediaRouteProviderDescriptor.Builder builder = new MediaRouteProviderDescriptor.Builder();
+ builder.addRoute(
+ new MediaRouteDescriptor.Builder(FAKE_MEDIA_ROUTE_ID_1, FAKE_MEDIA_ROUTE_NAME_1)
+ .setMaxClientVersion(15)
+ .setMinClientVersion(10)
+ .build());
+ builder.addRoute(
+ new MediaRouteDescriptor.Builder(FAKE_MEDIA_ROUTE_ID_2, FAKE_MEDIA_ROUTE_NAME_2)
+ .setMaxClientVersion(18)
+ .setMinClientVersion(11)
+ .build());
+ builder.addRoute(
+ new MediaRouteDescriptor.Builder(FAKE_MEDIA_ROUTE_ID_3, FAKE_MEDIA_ROUTE_NAME_3)
+ .setMaxClientVersion(25)
+ .setMinClientVersion(16)
+ .build());
+ builder.addRoute(
+ new MediaRouteDescriptor.Builder(FAKE_MEDIA_ROUTE_ID_4, FAKE_MEDIA_ROUTE_NAME_4)
+ .setMaxClientVersion(12)
+ .setMinClientVersion(4)
+ .build());
+ return builder.build();
}
private void resetActiveAndPassiveScanCountDownLatches() {
diff --git a/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/MediaRouteProviderTest.java b/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/MediaRouteProviderTest.java
index 69aa500..d4655d9 100644
--- a/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/MediaRouteProviderTest.java
+++ b/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/MediaRouteProviderTest.java
@@ -60,7 +60,7 @@
@Test
@SmallTest
- public void onCreateDynamicGroupRouteControllerWithParameters_shouldProvideParameters() {
+ public void onCreateDynamicGroupRouteControllerWithOptions_shouldProvideOptions() {
MediaRouteProvider mediaRouteProvider = new TestMediaRouteProvider(mContext);
TestDynamicGroupRouteController groupRouteController =
(TestDynamicGroupRouteController)
@@ -71,6 +71,7 @@
groupRouteController.getRouteControllerOptions();
assertEquals(ROUTE_ID, groupRouteController.getInitialMemberRouteId());
assertEquals(mRouteControllerOptions, routeControllerOptions);
+ assertEquals(mRouteControllerOptions.asBundle(), routeControllerOptions.asBundle());
assertEquals(
mRouteControllerOptions.getControlHints(),
routeControllerOptions.getControlHints());
@@ -78,9 +79,8 @@
@Test
@SmallTest
- public void onCreateDynamicGroupRouteController_shouldWorkWithoutParameters() {
- MediaRouteProvider mediaRouteProvider =
- new TestMediaRouteProviderWithoutParameters(mContext);
+ public void onCreateDynamicGroupRouteController_shouldWorkWithoutOptions() {
+ MediaRouteProvider mediaRouteProvider = new TestMediaRouteProviderWithoutOptions(mContext);
TestDynamicGroupRouteController groupRouteController =
(TestDynamicGroupRouteController)
mediaRouteProvider.onCreateDynamicGroupRouteController(
@@ -109,9 +109,9 @@
}
}
- private static class TestMediaRouteProviderWithoutParameters extends MediaRouteProvider {
+ private static class TestMediaRouteProviderWithoutOptions extends MediaRouteProvider {
- TestMediaRouteProviderWithoutParameters(Context context) {
+ TestMediaRouteProviderWithoutOptions(Context context) {
super(context);
}
diff --git a/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/MediaRouterParamsTest.java b/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/MediaRouterParamsTest.java
new file mode 100644
index 0000000..98bf620
--- /dev/null
+++ b/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/MediaRouterParamsTest.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.mediarouter.media;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+
+import android.os.Build;
+import android.os.Bundle;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
+import androidx.test.filters.SmallTest;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/** Test {@link MediaRouterParams}. */
+@RunWith(AndroidJUnit4.class)
+public class MediaRouterParamsTest {
+
+ private static final String TEST_KEY = "test_key";
+ private static final String TEST_VALUE = "test_value";
+
+ @Test
+ @SmallTest
+ @SdkSuppress(maxSdkVersion = Build.VERSION_CODES.Q)
+ public void mediaRouterParamsBuilder_androidQOrBelow() {
+ verifyMediaRouterParamsBuilder(/* isAndroidROrAbove= */ false);
+ }
+
+ @Test
+ @SmallTest
+ @SdkSuppress(minSdkVersion = Build.VERSION_CODES.R)
+ public void mediaRouterParamsBuilder_androidROrAbove() {
+ verifyMediaRouterParamsBuilder(/* isAndroidROrAbove= */ true);
+ }
+
+ private void verifyMediaRouterParamsBuilder(boolean isAndroidROrAbove) {
+ final int dialogType = MediaRouterParams.DIALOG_TYPE_DYNAMIC_GROUP;
+ final boolean isOutputSwitcherEnabled = true;
+ final boolean transferToLocalEnabled = true;
+ final boolean transferReceiverEnabled = false;
+ final boolean mediaTransferRestrictedToSelfProviders = true;
+ final Bundle extras = new Bundle();
+ extras.putString(TEST_KEY, TEST_VALUE);
+
+ MediaRouterParams params =
+ new MediaRouterParams.Builder()
+ .setDialogType(dialogType)
+ .setOutputSwitcherEnabled(isOutputSwitcherEnabled)
+ .setTransferToLocalEnabled(transferToLocalEnabled)
+ .setMediaTransferReceiverEnabled(transferReceiverEnabled)
+ .setMediaTransferRestrictedToSelfProviders(
+ mediaTransferRestrictedToSelfProviders)
+ .setExtras(extras)
+ .build();
+
+ assertEquals(dialogType, params.getDialogType());
+
+ if (isAndroidROrAbove) {
+ assertEquals(isOutputSwitcherEnabled, params.isOutputSwitcherEnabled());
+ assertEquals(transferToLocalEnabled, params.isTransferToLocalEnabled());
+ assertEquals(transferReceiverEnabled, params.isMediaTransferReceiverEnabled());
+ assertEquals(
+ mediaTransferRestrictedToSelfProviders,
+ params.isMediaTransferRestrictedToSelfProviders());
+ } else {
+ // Earlier than Android R, output switcher cannot be enabled.
+ // Same for transfer to local.
+ assertFalse(params.isOutputSwitcherEnabled());
+ assertFalse(params.isTransferToLocalEnabled());
+ assertFalse(params.isMediaTransferReceiverEnabled());
+ assertFalse(params.isMediaTransferRestrictedToSelfProviders());
+ }
+
+ extras.remove(TEST_KEY);
+ assertEquals(TEST_VALUE, params.getExtras().getString(TEST_KEY));
+
+ // Tests copy constructor of builder
+ MediaRouterParams copiedParams = new MediaRouterParams.Builder(params).build();
+ assertEquals(params.getDialogType(), copiedParams.getDialogType());
+ assertEquals(params.isOutputSwitcherEnabled(), copiedParams.isOutputSwitcherEnabled());
+ assertEquals(params.isTransferToLocalEnabled(), copiedParams.isTransferToLocalEnabled());
+ assertEquals(
+ params.isMediaTransferReceiverEnabled(),
+ copiedParams.isMediaTransferReceiverEnabled());
+ assertEquals(
+ params.isMediaTransferRestrictedToSelfProviders(),
+ copiedParams.isMediaTransferRestrictedToSelfProviders());
+ assertBundleEquals(params.getExtras(), copiedParams.getExtras());
+ }
+
+ /** Asserts that two Bundles are equal. */
+ @SuppressWarnings("deprecation")
+ public static void assertBundleEquals(Bundle expected, Bundle observed) {
+ if (expected == null || observed == null) {
+ assertSame(expected, observed);
+ }
+ assertEquals(expected.size(), observed.size());
+ for (String key : expected.keySet()) {
+ assertEquals(expected.get(key), observed.get(key));
+ }
+ }
+}
diff --git a/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/MediaRouterTest.java b/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/MediaRouterTest.java
index 6f7b964..6a54716 100644
--- a/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/MediaRouterTest.java
+++ b/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/MediaRouterTest.java
@@ -24,7 +24,6 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import android.content.Context;
@@ -37,6 +36,7 @@
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
+import androidx.test.filters.SdkSuppress;
import androidx.test.filters.SmallTest;
import org.junit.After;
@@ -70,7 +70,7 @@
private CountDownLatch mPassiveScanCountDownLatch;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
resetActiveAndPassiveScanCountDownLatches();
getInstrumentation()
.runOnMainSync(
@@ -80,10 +80,11 @@
mSession = new MediaSessionCompat(mContext, SESSION_TAG);
mProvider = new MediaRouteProviderImpl(mContext);
});
+ assertTrue(MediaTransferReceiver.isDeclared(mContext));
}
@After
- public void tearDown() throws Exception {
+ public void tearDown() {
mSession.release();
getInstrumentation().runOnMainSync(() -> MediaRouterTestHelper.resetMediaRouter());
}
@@ -119,67 +120,26 @@
@Test
@SmallTest
- public void mediaRouterParamsBuilder() {
- final int dialogType = MediaRouterParams.DIALOG_TYPE_DYNAMIC_GROUP;
- final boolean isOutputSwitcherEnabled = true;
- final boolean transferToLocalEnabled = true;
- final boolean transferReceiverEnabled = false;
- final Bundle extras = new Bundle();
- extras.putString(TEST_KEY, TEST_VALUE);
-
- MediaRouterParams params = new MediaRouterParams.Builder()
- .setDialogType(dialogType)
- .setOutputSwitcherEnabled(isOutputSwitcherEnabled)
- .setTransferToLocalEnabled(transferToLocalEnabled)
- .setMediaTransferReceiverEnabled(transferReceiverEnabled)
- .setExtras(extras)
- .build();
-
- assertEquals(dialogType, params.getDialogType());
-
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
- assertEquals(isOutputSwitcherEnabled, params.isOutputSwitcherEnabled());
- assertEquals(transferToLocalEnabled, params.isTransferToLocalEnabled());
- assertEquals(transferReceiverEnabled, params.isMediaTransferReceiverEnabled());
- } else {
- // Earlier than Android R, output switcher cannot be enabled.
- // Same for transfer to local.
- assertFalse(params.isOutputSwitcherEnabled());
- assertFalse(params.isTransferToLocalEnabled());
- assertFalse(params.isMediaTransferReceiverEnabled());
- }
-
- extras.remove(TEST_KEY);
- assertEquals(TEST_VALUE, params.getExtras().getString(TEST_KEY));
-
- // Tests copy constructor of builder
- MediaRouterParams copiedParams = new MediaRouterParams.Builder(params).build();
- assertEquals(params.getDialogType(), copiedParams.getDialogType());
- assertEquals(params.isOutputSwitcherEnabled(), copiedParams.isOutputSwitcherEnabled());
- assertEquals(params.isTransferToLocalEnabled(), copiedParams.isTransferToLocalEnabled());
- assertEquals(params.isMediaTransferReceiverEnabled(),
- copiedParams.isMediaTransferReceiverEnabled());
- assertBundleEquals(params.getExtras(), copiedParams.getExtras());
- }
-
- @Test
- @SmallTest
@UiThreadTest
public void getRouterParams_afterSetRouterParams_returnsSetParams() {
final int dialogType = MediaRouterParams.DIALOG_TYPE_DYNAMIC_GROUP;
final boolean isOutputSwitcherEnabled = true;
final boolean transferToLocalEnabled = true;
final boolean transferReceiverEnabled = false;
+ final boolean mediaTransferRestrictedToSelfProviders = true;
final Bundle paramExtras = new Bundle();
paramExtras.putString(TEST_KEY, TEST_VALUE);
- MediaRouterParams expectedParams = new MediaRouterParams.Builder()
- .setDialogType(dialogType)
- .setOutputSwitcherEnabled(isOutputSwitcherEnabled)
- .setTransferToLocalEnabled(transferToLocalEnabled)
- .setMediaTransferReceiverEnabled(transferReceiverEnabled)
- .setExtras(paramExtras)
- .build();
+ MediaRouterParams expectedParams =
+ new MediaRouterParams.Builder()
+ .setDialogType(dialogType)
+ .setOutputSwitcherEnabled(isOutputSwitcherEnabled)
+ .setTransferToLocalEnabled(transferToLocalEnabled)
+ .setMediaTransferReceiverEnabled(transferReceiverEnabled)
+ .setMediaTransferRestrictedToSelfProviders(
+ mediaTransferRestrictedToSelfProviders)
+ .setExtras(paramExtras)
+ .build();
paramExtras.remove(TEST_KEY);
mRouter.setRouterParams(expectedParams);
@@ -188,6 +148,29 @@
assertEquals(expectedParams, actualParams);
}
+ @SmallTest
+ @Test
+ @SdkSuppress(minSdkVersion = Build.VERSION_CODES.R)
+ public void setRouterParams_shouldSetMediaTransferRestrictToSelfProviders() {
+ MediaRouterParams params =
+ new MediaRouterParams.Builder()
+ .setMediaTransferRestrictedToSelfProviders(true)
+ .build();
+ getInstrumentation()
+ .runOnMainSync(
+ () -> {
+ mRouter.setRouterParams(params);
+ });
+ assertTrue(
+ MediaRouter.getGlobalRouter()
+ .mRegisteredProviderWatcher
+ .isMediaTransferRestrictedToSelfProvidersForTesting());
+ assertTrue(
+ MediaRouter.getGlobalRouter()
+ .getMediaRoute2ProviderForTesting()
+ .isMediaTransferRestrictedToSelfProviders());
+ }
+
@Test
@LargeTest
public void testRegisterActiveScanCallback_suppressActiveScanAfter30Seconds() throws Exception {
@@ -289,20 +272,6 @@
assertFalse(newInstance.getRoutes().isEmpty());
}
- /**
- * Asserts that two Bundles are equal.
- */
- @SuppressWarnings("deprecation")
- public static void assertBundleEquals(Bundle expected, Bundle observed) {
- if (expected == null || observed == null) {
- assertSame(expected, observed);
- }
- assertEquals(expected.size(), observed.size());
- for (String key : expected.keySet()) {
- assertEquals(expected.get(key), observed.get(key));
- }
- }
-
private class MediaSessionCallback extends MediaSessionCompat.Callback {
private boolean mOnPlayCalled;
private boolean mOnPauseCalled;
@@ -348,7 +317,6 @@
}
}
}
-
}
private void resetActiveAndPassiveScanCountDownLatches() {
diff --git a/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/RegisteredMediaRouteProviderWatcherTest.java b/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/RegisteredMediaRouteProviderWatcherTest.java
new file mode 100644
index 0000000..a132e52
--- /dev/null
+++ b/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/RegisteredMediaRouteProviderWatcherTest.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.mediarouter.media;
+
+import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import android.content.Context;
+import android.content.pm.ServiceInfo;
+import android.os.Build;
+import android.text.TextUtils;
+
+import androidx.annotation.NonNull;
+import androidx.test.core.app.ApplicationProvider;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SdkSuppress;
+import androidx.test.filters.SmallTest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.List;
+
+/** Test {@link RegisteredMediaRouteProviderWatcher}. */
+@RunWith(AndroidJUnit4.class)
+public class RegisteredMediaRouteProviderWatcherTest {
+ private Context mContext;
+ private RegisteredMediaRouteProviderWatcher mProviderWatcher;
+
+ @Before
+ public void setUp() {
+ mContext = ApplicationProvider.getApplicationContext();
+ RegisteredMediaRouteProviderWatcher.Callback callback =
+ new RegisteredMediaRouteProviderWatcher.Callback() {
+ @Override
+ public void addProvider(@NonNull MediaRouteProvider provider) {}
+
+ @Override
+ public void removeProvider(@NonNull MediaRouteProvider provider) {}
+
+ @Override
+ public void releaseProviderController(
+ @NonNull RegisteredMediaRouteProvider provider,
+ @NonNull MediaRouteProvider.RouteController controller) {}
+ };
+
+ getInstrumentation()
+ .runOnMainSync(
+ () -> {
+ mProviderWatcher =
+ new RegisteredMediaRouteProviderWatcher(mContext, callback);
+ });
+ }
+
+ @SmallTest
+ @Test
+ @SdkSuppress(minSdkVersion = Build.VERSION_CODES.R)
+ public void getMediaRoute2ProviderServices_restrictedToSelfProviders_shouldGetSelfProviders() {
+ mProviderWatcher.setMediaTransferRestrictedToSelfProviders(true);
+ assertTrue(mProviderWatcher.isMediaTransferRestrictedToSelfProvidersForTesting());
+ List<ServiceInfo> serviceInfos = mProviderWatcher.getMediaRoute2ProviderServices();
+ assertTrue(isSelfProvidersContained(serviceInfos));
+ }
+
+ @SmallTest
+ @Test
+ @SdkSuppress(minSdkVersion = Build.VERSION_CODES.R)
+ public void getMediaRoute2ProviderServices_notRestrictedToSelfProviders_shouldGetAllProvider() {
+ mProviderWatcher.setMediaTransferRestrictedToSelfProviders(false);
+ assertFalse(mProviderWatcher.isMediaTransferRestrictedToSelfProvidersForTesting());
+ List<ServiceInfo> serviceInfos = mProviderWatcher.getMediaRoute2ProviderServices();
+ assertTrue(isSelfProvidersContained(serviceInfos));
+ }
+
+ private boolean isSelfProvidersContained(List<ServiceInfo> serviceInfos) {
+ for (ServiceInfo serviceInfo : serviceInfos) {
+ if (TextUtils.equals(serviceInfo.packageName, mContext.getPackageName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/StubMediaRoute2ProviderService.java b/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/StubMediaRoute2ProviderService.java
new file mode 100644
index 0000000..01026cd
--- /dev/null
+++ b/mediarouter/mediarouter/src/androidTest/java/androidx/mediarouter/media/StubMediaRoute2ProviderService.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package androidx.mediarouter.media;
+
+import android.content.Context;
+
+import androidx.annotation.NonNull;
+
+public class StubMediaRoute2ProviderService extends MediaRouteProviderService {
+ @Override
+ public MediaRouteProvider onCreateMediaRouteProvider() {
+ return new StubMediaRoute2Provider(this);
+ }
+
+ class StubMediaRoute2Provider extends MediaRouteProvider {
+
+ StubMediaRoute2Provider(@NonNull Context context) {
+ super(context);
+ }
+ }
+}
diff --git a/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/GlobalMediaRouter.java b/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/GlobalMediaRouter.java
index f95695e..2cfa782 100644
--- a/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/GlobalMediaRouter.java
+++ b/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/GlobalMediaRouter.java
@@ -285,8 +285,13 @@
addProvider(mMr2Provider, /* treatRouteDescriptorIdsAsUnique= */ true);
// Make sure mDiscoveryRequestForMr2Provider is updated
updateDiscoveryRequest();
- mRegisteredProviderWatcher.rescan();
}
+ boolean mediaTransferRestrictedToSelfProviders =
+ params != null && params.isMediaTransferRestrictedToSelfProviders();
+ mMr2Provider.setMediaTransferRestrictedToSelfProviders(
+ mediaTransferRestrictedToSelfProviders);
+ mRegisteredProviderWatcher.setMediaTransferRestrictedToSelfProviders(
+ mediaTransferRestrictedToSelfProviders);
boolean oldTransferToLocalEnabled =
oldParams != null && oldParams.isTransferToLocalEnabled();
@@ -1343,6 +1348,11 @@
}
}
+ @VisibleForTesting
+ /* package */ MediaRoute2Provider getMediaRoute2ProviderForTesting() {
+ return mMr2Provider;
+ }
+
private final class ProviderCallback extends MediaRouteProvider.Callback {
ProviderCallback() {
}
diff --git a/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRoute2Provider.java b/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRoute2Provider.java
index eb1009c..8d3eae2 100644
--- a/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRoute2Provider.java
+++ b/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRoute2Provider.java
@@ -47,6 +47,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
+import androidx.annotation.VisibleForTesting;
import androidx.mediarouter.R;
import androidx.mediarouter.media.MediaRouteProvider.DynamicGroupRouteController.DynamicRouteDescriptor;
import androidx.mediarouter.media.MediaRouter.ControlRequestCallback;
@@ -67,6 +68,7 @@
class MediaRoute2Provider extends MediaRouteProvider {
static final String TAG = "MR2Provider";
static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
+ private static final String PACKAGE_NAME_SEPARATOR = "/";
final MediaRouter2 mMediaRouter2;
final Callback mCallback;
@@ -77,9 +79,10 @@
private final MediaRouter2.ControllerCallback mControllerCallback = new ControllerCallback();
private final Handler mHandler;
private final Executor mHandlerExecutor;
-
+ private boolean mMediaTransferRestrictedToSelfProviders;
private List<MediaRoute2Info> mRoutes = new ArrayList<>();
private Map<String, String> mRouteIdToOriginalRouteIdMap = new ArrayMap<>();
+
@SuppressWarnings({"SyntheticAccessor"})
MediaRoute2Provider(@NonNull Context context, @NonNull Callback callback) {
super(context);
@@ -153,6 +156,17 @@
return null;
}
+ /* package */ void setMediaTransferRestrictedToSelfProviders(
+ boolean mediaTransferRestrictedToSelfProviders) {
+ mMediaTransferRestrictedToSelfProviders = mediaTransferRestrictedToSelfProviders;
+ refreshRoutes();
+ }
+
+ @VisibleForTesting
+ /* package */ boolean isMediaTransferRestrictedToSelfProviders() {
+ return mMediaTransferRestrictedToSelfProviders;
+ }
+
public void transferTo(@NonNull String routeId) {
MediaRoute2Info route = getRouteById(routeId);
if (route == null) {
@@ -171,6 +185,17 @@
if (route == null || route2InfoSet.contains(route) || route.isSystemRoute()) {
continue;
}
+
+ if (mMediaTransferRestrictedToSelfProviders) {
+ // The routeId is created by Android framework with the provider's package name.
+ boolean isRoutePublishedBySelfProviders =
+ route.getId()
+ .startsWith(getContext().getPackageName() + PACKAGE_NAME_SEPARATOR);
+ if (!isRoutePublishedBySelfProviders) {
+ continue;
+ }
+ }
+
route2InfoSet.add(route);
// Not using new ArrayList(route2InfoSet) here for preserving the order.
diff --git a/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRouteProvider.java b/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRouteProvider.java
index e08d4ea..174169b 100644
--- a/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRouteProvider.java
+++ b/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRouteProvider.java
@@ -907,14 +907,22 @@
/** Holds parameters for creating {@link RouteController}. */
public static final class RouteControllerOptions {
static final RouteControllerOptions EMPTY = new RouteControllerOptions.Builder().build();
-
+ private static final String KEY_CONTROL_HINTS = "controlHints";
+ private final Bundle mBundle;
// The controlHints is passed by the client application for creating the route controller,
// or {@code null} if the client has not provided control hints. The controlHints may be
// provided by {@link android.media.MediaRouter2.OnGetControllerHintsListener}.
private final Bundle mControlHints;
- private RouteControllerOptions(Builder builder) {
- mControlHints = (builder.mControlHints != null) ? builder.mControlHints : Bundle.EMPTY;
+ /* package */ RouteControllerOptions(Bundle bundle) {
+ mBundle = new Bundle(bundle);
+ Bundle controlHints = mBundle.getParcelable(KEY_CONTROL_HINTS);
+ mControlHints = (controlHints != null) ? controlHints : Bundle.EMPTY;
+ }
+
+ /** Returns the contents of this object represented as a bundle. */
+ /* package */ @NonNull Bundle asBundle() {
+ return mBundle;
}
@NonNull
@@ -924,19 +932,19 @@
/** Builder for {@link RouteControllerOptions}. */
public static final class Builder {
- @Nullable private Bundle mControlHints;
+ private final Bundle mBundle = new Bundle();
/** Sets controlHints passed by the client application. */
@NonNull
public Builder setControlHints(@Nullable Bundle controlHints) {
- mControlHints = controlHints;
+ mBundle.putParcelable(KEY_CONTROL_HINTS, controlHints);
return this;
}
/** Builds the {@link RouteControllerOptions}. */
@NonNull
- public RouteControllerOptions build() {
- return new RouteControllerOptions(this);
+ public RouteControllerOptions build() {
+ return new RouteControllerOptions(mBundle);
}
}
}
diff --git a/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRouteProviderProtocol.java b/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRouteProviderProtocol.java
index d82e4d1..90cd379 100644
--- a/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRouteProviderProtocol.java
+++ b/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRouteProviderProtocol.java
@@ -162,6 +162,7 @@
public static final String CLIENT_DATA_UNSELECT_REASON = "unselectReason";
public static final String CLIENT_DATA_MEMBER_ROUTE_IDS = "memberRouteIds";
public static final String CLIENT_DATA_MEMBER_ROUTE_ID = "memberRouteId";
+ public static final String CLIENT_DATA_ROUTE_CONTROLLER_OPTIONS = "routeControllerOptions";
public static final String DATA_KEY_GROUPABLE_SECION_TITLE = "groupableTitle";
public static final String DATA_KEY_TRANSFERABLE_SECTION_TITLE = "transferableTitle";
diff --git a/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRouteProviderService.java b/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRouteProviderService.java
index c5393f4..eac2b09 100644
--- a/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRouteProviderService.java
+++ b/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRouteProviderService.java
@@ -18,6 +18,7 @@
import static androidx.mediarouter.media.MediaRouteProviderProtocol.CLIENT_DATA_MEMBER_ROUTE_ID;
import static androidx.mediarouter.media.MediaRouteProviderProtocol.CLIENT_DATA_MEMBER_ROUTE_IDS;
+import static androidx.mediarouter.media.MediaRouteProviderProtocol.CLIENT_DATA_ROUTE_CONTROLLER_OPTIONS;
import static androidx.mediarouter.media.MediaRouteProviderProtocol.CLIENT_DATA_ROUTE_ID;
import static androidx.mediarouter.media.MediaRouteProviderProtocol.CLIENT_DATA_ROUTE_LIBRARY_GROUP;
import static androidx.mediarouter.media.MediaRouteProviderProtocol.CLIENT_DATA_UNSELECT_REASON;
@@ -85,6 +86,7 @@
import androidx.mediarouter.media.MediaRouteProvider.DynamicGroupRouteController.DynamicRouteDescriptor;
import androidx.mediarouter.media.MediaRouteProvider.DynamicGroupRouteController.OnDynamicRoutesChangedListener;
import androidx.mediarouter.media.MediaRouteProvider.RouteController;
+import androidx.mediarouter.media.MediaRouteProvider.RouteControllerOptions;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -154,8 +156,14 @@
boolean onUnregisterClient(Messenger messenger, int requestId);
boolean onCreateRouteController(Messenger messenger, int requestId,
int controllerId, String routeId, String routeGroupId);
- boolean onCreateDynamicGroupRouteController(Messenger messenger, int requestId,
- int controllerId, String initialMemberRouteId);
+
+ boolean onCreateDynamicGroupRouteController(
+ Messenger messenger,
+ int requestId,
+ int controllerId,
+ String initialMemberRouteId,
+ RouteControllerOptions routeControllerOptions);
+
boolean onAddMemberRoute(Messenger messenger, int requestId, int controllerId,
String memberId);
boolean onRemoveMemberRoute(Messenger messenger, int requestId, int controllerId,
@@ -468,9 +476,20 @@
case CLIENT_MSG_CREATE_DYNAMIC_GROUP_ROUTE_CONTROLLER: {
String initialMemberId = data.getString(CLIENT_DATA_MEMBER_ROUTE_ID);
+ Bundle routeControllerOptionsBundle =
+ data.getParcelable(CLIENT_DATA_ROUTE_CONTROLLER_OPTIONS);
+ RouteControllerOptions routeControllerOptions =
+ (routeControllerOptionsBundle != null)
+ ? new RouteControllerOptions(
+ routeControllerOptionsBundle)
+ : RouteControllerOptions.EMPTY;
if (initialMemberId != null) {
return service.mImpl.onCreateDynamicGroupRouteController(
- messenger, requestId, arg, initialMemberId);
+ messenger,
+ requestId,
+ arg,
+ initialMemberId,
+ routeControllerOptions);
}
break;
}
@@ -662,9 +681,15 @@
if (client != null) {
if (client.createRouteController(routeId, routeGroupId, controllerId)) {
if (DEBUG) {
- Log.d(TAG, client + ": Route controller created, controllerId="
- + controllerId + ", routeId=" + routeId
- + ", routeGroupId=" + routeGroupId);
+ Log.d(
+ TAG,
+ client
+ + ": Route controller created, controllerId="
+ + controllerId
+ + ", routeId="
+ + routeId
+ + ", routeGroupId="
+ + routeGroupId);
}
sendGenericSuccess(messenger, requestId);
return true;
@@ -674,12 +699,17 @@
}
@Override
- public boolean onCreateDynamicGroupRouteController(Messenger messenger, int requestId,
- int controllerId, String initialMemberRouteId) {
+ public boolean onCreateDynamicGroupRouteController(
+ Messenger messenger,
+ int requestId,
+ int controllerId,
+ String initialMemberRouteId,
+ RouteControllerOptions routeControllerOptions) {
ClientRecord client = getClient(messenger);
if (client != null) {
- Bundle bundle = client.createDynamicGroupRouteController(
- initialMemberRouteId, controllerId);
+ Bundle bundle =
+ client.createDynamicGroupRouteController(
+ initialMemberRouteId, routeControllerOptions, controllerId);
if (bundle != null) {
if (DEBUG) {
Log.d(TAG, client + ": Route controller created, controllerId="
@@ -1082,13 +1112,14 @@
}
public Bundle createDynamicGroupRouteController(
- String initialMemberRouteId, int controllerId) {
+ String initialMemberRouteId,
+ RouteControllerOptions routeControllerOptions,
+ int controllerId) {
if (mControllers.indexOfKey(controllerId) < 0) {
MediaRouteProvider.DynamicGroupRouteController controller =
mService.getMediaRouteProvider()
.onCreateDynamicGroupRouteController(
- initialMemberRouteId,
- MediaRouteProvider.RouteControllerOptions.EMPTY);
+ initialMemberRouteId, routeControllerOptions);
if (controller != null) {
controller.setOnDynamicRoutesChangedListener(
ContextCompat.getMainExecutor(mService.getApplicationContext()),
@@ -1356,9 +1387,12 @@
@Override
public Bundle createDynamicGroupRouteController(
- String initialMemberRouteId, int controllerId) {
+ String initialMemberRouteId,
+ RouteControllerOptions routeControllerOptions,
+ int controllerId) {
Bundle result =
- super.createDynamicGroupRouteController(initialMemberRouteId, controllerId);
+ super.createDynamicGroupRouteController(
+ initialMemberRouteId, routeControllerOptions, controllerId);
if (result != null && mPackageName != null) {
mMR2ProviderServiceAdapter.notifyRouteControllerAdded(
this, mControllers.get(controllerId),
diff --git a/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRouterParams.java b/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRouterParams.java
index a799b00..30c78c1 100644
--- a/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRouterParams.java
+++ b/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/MediaRouterParams.java
@@ -72,11 +72,11 @@
public static final String EXTRAS_KEY_FIXED_CAST_ICON =
"androidx.mediarouter.media.MediaRouterParams.FIXED_CAST_ICON";
- @DialogType
- final int mDialogType;
+ @DialogType final int mDialogType;
final boolean mMediaTransferReceiverEnabled;
final boolean mOutputSwitcherEnabled;
final boolean mTransferToLocalEnabled;
+ final boolean mMediaTransferRestrictedToSelfProviders;
final Bundle mExtras;
MediaRouterParams(@NonNull Builder builder) {
@@ -84,6 +84,7 @@
mMediaTransferReceiverEnabled = builder.mMediaTransferEnabled;
mOutputSwitcherEnabled = builder.mOutputSwitcherEnabled;
mTransferToLocalEnabled = builder.mTransferToLocalEnabled;
+ mMediaTransferRestrictedToSelfProviders = builder.mMediaTransferRestrictedToSelfProviders;
Bundle extras = builder.mExtras;
mExtras = extras == null ? Bundle.EMPTY : new Bundle(extras);
@@ -120,8 +121,8 @@
/**
* Returns whether transferring media from remote to local is enabled.
- * <p>
- * Note that it always returns {@code false} for Android versions earlier than Android R.
+ *
+ * <p>Note that it always returns {@code false} for Android versions earlier than Android R.
*
* @see Builder#setTransferToLocalEnabled(boolean)
*/
@@ -130,6 +131,16 @@
}
/**
+ * Returns whether the declared {@link MediaTransferReceiver} feature is restricted to the app's
+ * own media route providers.
+ *
+ * @see Builder#setMediaTransferRestrictedToSelfProviders(boolean)
+ */
+ public boolean isMediaTransferRestrictedToSelfProviders() {
+ return mMediaTransferRestrictedToSelfProviders;
+ }
+
+ /**
*/
@NonNull
@RestrictTo(RestrictTo.Scope.LIBRARY)
@@ -141,11 +152,11 @@
* Builder class for {@link MediaRouterParams}.
*/
public static final class Builder {
- @DialogType
- int mDialogType = DIALOG_TYPE_DEFAULT;
+ @DialogType int mDialogType = DIALOG_TYPE_DEFAULT;
boolean mMediaTransferEnabled = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R;
boolean mOutputSwitcherEnabled;
boolean mTransferToLocalEnabled;
+ boolean mMediaTransferRestrictedToSelfProviders;
Bundle mExtras;
/**
@@ -154,8 +165,8 @@
public Builder() {}
/**
- * Constructor for builder to create {@link MediaRouterParams} with existing
- * {@link MediaRouterParams} instance.
+ * Constructor for builder to create {@link MediaRouterParams} with existing {@link
+ * MediaRouterParams} instance.
*
* @param params the existing instance to copy data from.
*/
@@ -168,15 +179,17 @@
mOutputSwitcherEnabled = params.mOutputSwitcherEnabled;
mTransferToLocalEnabled = params.mTransferToLocalEnabled;
mMediaTransferEnabled = params.mMediaTransferReceiverEnabled;
+ mMediaTransferRestrictedToSelfProviders =
+ params.mMediaTransferRestrictedToSelfProviders;
mExtras = params.mExtras == null ? null : new Bundle(params.mExtras);
}
/**
- * Sets the media route controller dialog type. Default value is
- * {@link #DIALOG_TYPE_DEFAULT}.
- * <p>
- * Note that from Android R, output switcher will be used rather than the dialog type set by
- * this method if both {@link #setOutputSwitcherEnabled(boolean)} output switcher} and
+ * Sets the media route controller dialog type. Default value is {@link
+ * #DIALOG_TYPE_DEFAULT}.
+ *
+ * <p>Note that from Android R, output switcher will be used rather than the dialog type set
+ * by this method if both {@link #setOutputSwitcherEnabled(boolean)} output switcher} and
* {@link MediaTransferReceiver media transfer feature} are enabled.
*
* @param dialogType the dialog type
@@ -255,9 +268,30 @@
}
/**
- * Set extras. Default value is {@link Bundle#EMPTY} if not set.
+ * Sets whether the declared {@link MediaTransferReceiver} feature is restricted to {@link
+ * MediaRouteProviderService} provider services that handle the action {@code
+ * android.media.MediaRoute2ProviderService} declared by this app.
*
+ * <p>If this app restricts the {@link MediaTransferReceiver} feature to its own {@link
+ * MediaRouteProviderService} provider service that handles the action {@code
+ * android.media.MediaRoute2ProviderService}, then all other media route providers that
+ * declare both the {@code android.media.MediaRouteProviderService} action and the {@code
+ * android.media.MediaRoute2ProviderService} action would be treated as {@link
+ * MediaRouteProviderService} provider services with only the action {@code
+ * android.media.MediaRouteProviderService}.
+ *
+ * <p>For {@link MediaRouteProviderService} provider services that only handle the action
+ * {@code android.media.MediaRouteProviderService}, they are not affected by this flag.
*/
+ @NonNull
+ public Builder setMediaTransferRestrictedToSelfProviders(boolean enabled) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+ mMediaTransferRestrictedToSelfProviders = enabled;
+ }
+ return this;
+ }
+
+ /** Set extras. Default value is {@link Bundle#EMPTY} if not set. */
@RestrictTo(RestrictTo.Scope.LIBRARY)
@NonNull
public Builder setExtras(@Nullable Bundle extras) {
diff --git a/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/RegisteredMediaRouteProvider.java b/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/RegisteredMediaRouteProvider.java
index 9588cec..5074a7e 100644
--- a/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/RegisteredMediaRouteProvider.java
+++ b/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/RegisteredMediaRouteProvider.java
@@ -18,6 +18,7 @@
import static androidx.mediarouter.media.MediaRouteProviderProtocol.CLIENT_DATA_MEMBER_ROUTE_ID;
import static androidx.mediarouter.media.MediaRouteProviderProtocol.CLIENT_DATA_MEMBER_ROUTE_IDS;
+import static androidx.mediarouter.media.MediaRouteProviderProtocol.CLIENT_DATA_ROUTE_CONTROLLER_OPTIONS;
import static androidx.mediarouter.media.MediaRouteProviderProtocol.CLIENT_DATA_ROUTE_ID;
import static androidx.mediarouter.media.MediaRouteProviderProtocol.CLIENT_DATA_ROUTE_LIBRARY_GROUP;
import static androidx.mediarouter.media.MediaRouteProviderProtocol.CLIENT_DATA_UNSELECT_REASON;
@@ -135,7 +136,7 @@
if (initialMemberRouteId == null) {
throw new IllegalArgumentException("initialMemberRouteId cannot be null.");
}
- return createDynamicGroupRouteController(initialMemberRouteId);
+ return createDynamicGroupRouteController(initialMemberRouteId, routeControllerOptions);
}
@Override
@@ -311,7 +312,8 @@
}
private DynamicGroupRouteController createDynamicGroupRouteController(
- String initialMemberRouteId) {
+ @NonNull String initialMemberRouteId,
+ @NonNull RouteControllerOptions routeControllerOptions) {
MediaRouteProviderDescriptor descriptor = getDescriptor();
if (descriptor != null) {
List<MediaRouteDescriptor> routes = descriptor.getRoutes();
@@ -320,7 +322,8 @@
final MediaRouteDescriptor route = routes.get(i);
if (route.getId().equals(initialMemberRouteId)) {
DynamicGroupRouteController controller =
- new RegisteredDynamicController(initialMemberRouteId);
+ new RegisteredDynamicController(
+ initialMemberRouteId, routeControllerOptions);
mControllerConnections.add((ControllerConnection) controller);
if (mConnectionReady) {
((ControllerConnection) controller).attachConnection(mActiveConnection);
@@ -445,7 +448,8 @@
private final class RegisteredDynamicController extends DynamicGroupRouteController
implements ControllerConnection {
- private final String mInitialMemberRouteId;
+ @NonNull private final String mInitialMemberRouteId;
+ @NonNull private final RouteControllerOptions mRouteControllerOptions;
String mGroupableSectionTitle;
String mTransferableSectionTitle;
@@ -456,8 +460,11 @@
private Connection mConnection;
private int mControllerId = -1;
- RegisteredDynamicController(String initialMemberRouteId) {
+ RegisteredDynamicController(
+ @NonNull String initialMemberRouteId,
+ @NonNull RouteControllerOptions routeControllerOptions) {
mInitialMemberRouteId = initialMemberRouteId;
+ mRouteControllerOptions = routeControllerOptions;
}
/////////////////////////////////////
@@ -469,20 +476,25 @@
@Override
public void attachConnection(Connection connection) {
- ControlRequestCallback callback = new ControlRequestCallback() {
- @Override
- public void onResult(Bundle data) {
- mGroupableSectionTitle = data.getString(DATA_KEY_GROUPABLE_SECION_TITLE);
- mTransferableSectionTitle = data.getString(DATA_KEY_TRANSFERABLE_SECTION_TITLE);
- }
- @Override
- public void onError(String error, Bundle data) {
- Log.d(TAG, "Error: " + error + ", data: " + data);
- }
- };
+ ControlRequestCallback callback =
+ new ControlRequestCallback() {
+ @Override
+ public void onResult(Bundle data) {
+ mGroupableSectionTitle =
+ data.getString(DATA_KEY_GROUPABLE_SECION_TITLE);
+ mTransferableSectionTitle =
+ data.getString(DATA_KEY_TRANSFERABLE_SECTION_TITLE);
+ }
+
+ @Override
+ public void onError(String error, Bundle data) {
+ Log.d(TAG, "Error: " + error + ", data: " + data);
+ }
+ };
mConnection = connection;
- mControllerId = connection.createDynamicGroupRouteController(
- mInitialMemberRouteId, callback);
+ mControllerId =
+ connection.createDynamicGroupRouteController(
+ mInitialMemberRouteId, mRouteControllerOptions, callback);
if (mSelected) {
connection.selectRoute(mControllerId);
if (mPendingSetVolume >= 0) {
@@ -870,17 +882,21 @@
Bundle data = new Bundle();
data.putString(CLIENT_DATA_ROUTE_ID, routeId);
data.putString(CLIENT_DATA_ROUTE_LIBRARY_GROUP, routeGroupId);
- sendRequest(CLIENT_MSG_CREATE_ROUTE_CONTROLLER,
- mNextRequestId++, controllerId, null, data);
+ sendRequest(
+ CLIENT_MSG_CREATE_ROUTE_CONTROLLER, mNextRequestId++, controllerId, null, data);
return controllerId;
}
public int createDynamicGroupRouteController(
- String initialMemberRouteId, ControlRequestCallback callback) {
+ @NonNull String initialMemberRouteId,
+ @NonNull RouteControllerOptions routeControllerOptions,
+ ControlRequestCallback callback) {
int controllerId = mNextControllerId++;
int requestId = mNextRequestId++;
Bundle data = new Bundle();
data.putString(CLIENT_DATA_MEMBER_ROUTE_ID, initialMemberRouteId);
+ data.putParcelable(
+ CLIENT_DATA_ROUTE_CONTROLLER_OPTIONS, routeControllerOptions.asBundle());
sendRequest(CLIENT_MSG_CREATE_DYNAMIC_GROUP_ROUTE_CONTROLLER,
requestId, controllerId, null, data);
mPendingCallbacks.put(requestId, callback);
diff --git a/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/RegisteredMediaRouteProviderWatcher.java b/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/RegisteredMediaRouteProviderWatcher.java
index f80c24e0..82c5ca3 100644
--- a/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/RegisteredMediaRouteProviderWatcher.java
+++ b/mediarouter/mediarouter/src/main/java/androidx/mediarouter/media/RegisteredMediaRouteProviderWatcher.java
@@ -27,9 +27,11 @@
import android.media.MediaRoute2ProviderService;
import android.os.Build;
import android.os.Handler;
+import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
+import androidx.annotation.VisibleForTesting;
import java.util.ArrayList;
import java.util.Collections;
@@ -48,6 +50,7 @@
private final PackageManager mPackageManager;
private final ArrayList<RegisteredMediaRouteProvider> mProviders = new ArrayList<>();
+ private boolean mMediaTransferRestrictedToSelfProviders;
private boolean mRunning;
RegisteredMediaRouteProviderWatcher(Context context, Callback callback) {
@@ -97,6 +100,17 @@
}
}
+ /* package */ void setMediaTransferRestrictedToSelfProviders(
+ boolean mediaTransferRestrictedToSelfProviders) {
+ mMediaTransferRestrictedToSelfProviders = mediaTransferRestrictedToSelfProviders;
+ rescan();
+ }
+
+ @VisibleForTesting
+ /* package */ boolean isMediaTransferRestrictedToSelfProvidersForTesting() {
+ return mMediaTransferRestrictedToSelfProviders;
+ }
+
void scanPackages() {
if (!mRunning) {
return;
@@ -171,7 +185,13 @@
List<ServiceInfo> serviceInfoList = new ArrayList<>();
for (ResolveInfo resolveInfo : mPackageManager.queryIntentServices(intent, 0)) {
- serviceInfoList.add(resolveInfo.serviceInfo);
+ ServiceInfo serviceInfo = resolveInfo.serviceInfo;
+ if (mMediaTransferRestrictedToSelfProviders
+ && !TextUtils.equals(mContext.getPackageName(), serviceInfo.packageName)) {
+ // The app only allows its own Media Router provider to be a MediaRoute2 provider.
+ continue;
+ }
+ serviceInfoList.add(serviceInfo);
}
return serviceInfoList;
}
diff --git a/mediarouter/mediarouter/src/main/res/values-ja/strings.xml b/mediarouter/mediarouter/src/main/res/values-ja/strings.xml
index d1589d9..75786f1 100644
--- a/mediarouter/mediarouter/src/main/res/values-ja/strings.xml
+++ b/mediarouter/mediarouter/src/main/res/values-ja/strings.xml
@@ -43,7 +43,7 @@
<string name="mr_dialog_transferable_header" msgid="6068257520605505468">"グループで再生"</string>
<string name="mr_cast_dialog_title_view_placeholder" msgid="2175930138959078155">"情報がありません"</string>
<string name="mr_chooser_zero_routes_found_title" msgid="5213435473397442608">"利用可能なデバイスがありません"</string>
- <string name="mr_chooser_wifi_warning_description_phone" msgid="2555886884770958244">"他のデバイスがこのスマートフォンと同じ Wi-Fi ネットワークに接続していることを確認してください"</string>
+ <string name="mr_chooser_wifi_warning_description_phone" msgid="2555886884770958244">"もう一方のデバイスがこのスマートフォンと同じ Wi-Fi ネットワークに接続していることを確認してください"</string>
<string name="mr_chooser_wifi_warning_description_tablet" msgid="6038748488793588164">"他のデバイスがこのタブレットと同じ Wi-Fi ネットワークに接続していることを確認してください"</string>
<string name="mr_chooser_wifi_warning_description_tv" msgid="5845921667085074878">"他のデバイスがこのテレビと同じ Wi-Fi ネットワークに接続していることを確認してください"</string>
<string name="mr_chooser_wifi_warning_description_watch" msgid="5255021372884233706">"もう一方のデバイスがこのスマートウォッチと同じ Wi-Fi ネットワークに接続していることを確認してください"</string>
diff --git a/mediarouter/mediarouter/src/main/res/values-pl/strings.xml b/mediarouter/mediarouter/src/main/res/values-pl/strings.xml
index ced7b9e..4db44b8 100644
--- a/mediarouter/mediarouter/src/main/res/values-pl/strings.xml
+++ b/mediarouter/mediarouter/src/main/res/values-pl/strings.xml
@@ -43,7 +43,7 @@
<string name="mr_dialog_transferable_header" msgid="6068257520605505468">"Odtwórz w grupie"</string>
<string name="mr_cast_dialog_title_view_placeholder" msgid="2175930138959078155">"Brak informacji"</string>
<string name="mr_chooser_zero_routes_found_title" msgid="5213435473397442608">"Brak dostępnych urządzeń"</string>
- <string name="mr_chooser_wifi_warning_description_phone" msgid="2555886884770958244">"Sprawdź, czy drugie urządzenie jest połączone z tą samą siecią Wi-Fi co telefon"</string>
+ <string name="mr_chooser_wifi_warning_description_phone" msgid="2555886884770958244">"Upewnij się, że drugie urządzenie jest połączone z tą samą siecią Wi-Fi co ten telefon"</string>
<string name="mr_chooser_wifi_warning_description_tablet" msgid="6038748488793588164">"Sprawdź, czy drugie urządzenie jest połączone z tą samą siecią Wi-Fi co tablet"</string>
<string name="mr_chooser_wifi_warning_description_tv" msgid="5845921667085074878">"Sprawdź, czy drugie urządzenie jest połączone z tą samą siecią Wi-Fi co telewizor"</string>
<string name="mr_chooser_wifi_warning_description_watch" msgid="5255021372884233706">"Sprawdź, czy drugie urządzenie jest połączone z tą samą siecią Wi-Fi co zegarek"</string>
diff --git a/navigation/navigation-dynamic-features-fragment/src/main/res/values-it/strings.xml b/navigation/navigation-dynamic-features-fragment/src/main/res/values-it/strings.xml
index 62c3d78..b64b779 100644
--- a/navigation/navigation-dynamic-features-fragment/src/main/res/values-it/strings.xml
+++ b/navigation/navigation-dynamic-features-fragment/src/main/res/values-it/strings.xml
@@ -22,5 +22,5 @@
<string name="installing_module" msgid="5968445461040787716">"Modulo di installazione:"</string>
<string name="progress" msgid="8366783942222789124">"Avanzamento:"</string>
<string name="retry" msgid="1065327189183624288">"Riprova"</string>
- <string name="ok" msgid="4702104660890557116">"OK"</string>
+ <string name="ok" msgid="4702104660890557116">"Ok"</string>
</resources>
diff --git a/pdf/integration-tests/testapp/src/main/AndroidManifest.xml b/pdf/integration-tests/testapp/src/main/AndroidManifest.xml
index 04f1cba1..f155b14 100644
--- a/pdf/integration-tests/testapp/src/main/AndroidManifest.xml
+++ b/pdf/integration-tests/testapp/src/main/AndroidManifest.xml
@@ -27,6 +27,7 @@
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
+ android:configChanges="orientation|screenSize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
diff --git a/pdf/pdf-viewer/src/androidTest/kotlin/androidx/pdf/view/PdfViewStateChangeTest.kt b/pdf/pdf-viewer/src/androidTest/kotlin/androidx/pdf/view/PdfViewStateChangeTest.kt
index 2e62bae..142ea1b 100644
--- a/pdf/pdf-viewer/src/androidTest/kotlin/androidx/pdf/view/PdfViewStateChangeTest.kt
+++ b/pdf/pdf-viewer/src/androidTest/kotlin/androidx/pdf/view/PdfViewStateChangeTest.kt
@@ -143,6 +143,27 @@
}
@Test
+ fun recreate_withoutPdfDocument() = runTest {
+ withContext(Dispatchers.Main) { setupPdfView(500, 1000, fakePdfDocument = null) }
+ with(ActivityScenario.launch(PdfViewTestActivity::class.java)) {
+ // Recreate without ever setting a document on PdfView initially
+ recreate()
+
+ // Set PdfDocument on the new PdfView instance, and make sure we can interact with it
+ val pdfDocument = FakePdfDocument(List(10) { Point(100, 200) })
+ onActivity { activity ->
+ activity.findViewById<PdfView>(PDF_VIEW_ID)?.also { it.pdfDocument = pdfDocument }
+ }
+
+ pdfDocument.waitForLayout(untilPage = 4)
+ Espresso.onView(withId(PDF_VIEW_ID)).scrollToPage(3)
+ Espresso.onView(withId(PDF_VIEW_ID))
+ .checkPagesAreVisible(firstVisiblePage = 3, visiblePages = 1)
+ close()
+ }
+ }
+
+ @Test
fun resetDocument() = runTest {
val pdfDocument =
FakePdfDocument(
diff --git a/pdf/pdf-viewer/src/main/kotlin/androidx/pdf/view/PdfView.kt b/pdf/pdf-viewer/src/main/kotlin/androidx/pdf/view/PdfView.kt
index 407b2c6..d98efe1 100644
--- a/pdf/pdf-viewer/src/main/kotlin/androidx/pdf/view/PdfView.kt
+++ b/pdf/pdf-viewer/src/main/kotlin/androidx/pdf/view/PdfView.kt
@@ -314,19 +314,25 @@
super.onRestoreInstanceState(state.superState)
stateToRestore = state
if (pdfDocument != null) {
- restoreState()
+ maybeRestoreState()
}
}
- private fun restoreState() {
- val localStateToRestore = stateToRestore ?: return
- val localPdfDocument = pdfDocument ?: return
+ /**
+ * Returns true if we are able to restore a previous state from savedInstanceState
+ *
+ * We are not be able to restore our previous state if it pertains to a different document, or
+ * if it is missing critical data like page layout information.
+ */
+ private fun maybeRestoreState(): Boolean {
+ val localStateToRestore = stateToRestore ?: return false
+ val localPdfDocument = pdfDocument ?: return false
if (
localPdfDocument.uri != localStateToRestore.documentUri ||
!localStateToRestore.hasEnoughStateToRestore
) {
stateToRestore = null
- return
+ return false
}
pageLayoutManager =
PageLayoutManager(
@@ -346,6 +352,7 @@
}
stateToRestore = null
+ return true
}
private fun scrollToRestoredPosition(position: PointF, zoom: Float) {
@@ -401,9 +408,8 @@
private fun onDocumentSet() {
val localPdfDocument = pdfDocument ?: return
pageManager = PageManager(localPdfDocument, backgroundScope, DEFAULT_PAGE_PREFETCH_RADIUS)
- if (stateToRestore != null) {
- restoreState()
- } else {
+ // We'll either create our layout manager from restored state, or instantiate a new one
+ if (!maybeRestoreState()) {
pageLayoutManager =
PageLayoutManager(localPdfDocument, backgroundScope, DEFAULT_PAGE_PREFETCH_RADIUS)
.apply { onViewportChanged(scrollY, height, zoom) }
diff --git a/pdf/pdf-viewer/src/main/res/values-af/strings.xml b/pdf/pdf-viewer/src/main/res/values-af/strings.xml
index 9c529a2..0b88922 100644
--- a/pdf/pdf-viewer/src/main/res/values-af/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-af/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> van <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Geen passende resultate nie"</string>
<string name="action_edit" msgid="5882082700509010966">"Wysig lêer"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Deursoek lêer"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Rolbalk"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Voer wagwoord in om te ontsluit"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Probeer weer"</string>
<string name="pdf_error" msgid="3287950599604474450">"Kon nie die PDF-dokument verwerk nie!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-am/strings.xml b/pdf/pdf-viewer/src/main/res/values-am/strings.xml
index c7b82bc..596cd36 100644
--- a/pdf/pdf-viewer/src/main/res/values-am/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-am/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> ከ<xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"ምንም የሚመሳሰሉ ውጤቶች የሉም"</string>
<string name="action_edit" msgid="5882082700509010966">"ፋይል አርትዕ"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"ፋይል ፈልግ"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"መሸብለያ አሞሌ"</string>
<string name="password_not_entered" msgid="8875370870743585303">"ለመክፈት የይለፍ ቃል ያስገቡ"</string>
<string name="retry_button_text" msgid="3443862378337999137">"እንደገና ሞክር"</string>
<string name="pdf_error" msgid="3287950599604474450">"የPDF ሰነዱን ማሰናዳት አልተሳካም!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-ar/strings.xml b/pdf/pdf-viewer/src/main/res/values-ar/strings.xml
index 41bf466..63c38fa 100644
--- a/pdf/pdf-viewer/src/main/res/values-ar/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-ar/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> من إجمالي <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"ما مِن نتائج مطابقة"</string>
<string name="action_edit" msgid="5882082700509010966">"تعديل الملف"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"البحث في الملف"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"شريط التمرير"</string>
<string name="password_not_entered" msgid="8875370870743585303">"يجب إدخال كلمة المرور لفتح القفل"</string>
<string name="retry_button_text" msgid="3443862378337999137">"إعادة المحاولة"</string>
<string name="pdf_error" msgid="3287950599604474450">"تعذّرت معالجة مستند PDF."</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-as/strings.xml b/pdf/pdf-viewer/src/main/res/values-as/strings.xml
index 641ff3d..12fa623 100644
--- a/pdf/pdf-viewer/src/main/res/values-as/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-as/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="TOTAL">%2$d</xliff:g> খনৰ ভিতৰত <xliff:g id="POSITION">%1$d</xliff:g>তম"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"কোনো মিল থকা ফলাফল নাই"</string>
<string name="action_edit" msgid="5882082700509010966">"ফাইল সম্পাদনা কৰক"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"ফাইল সন্ধান কৰক"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"স্ক্ৰ’ল কৰা দণ্ড"</string>
<string name="password_not_entered" msgid="8875370870743585303">"আনলক কৰিবলৈ পাছৱৰ্ড দিয়ক"</string>
<string name="retry_button_text" msgid="3443862378337999137">"পুনৰ চেষ্টা কৰক"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF নথিখন প্ৰক্ৰিয়াকৰণ কৰিব পৰা নগ’ল!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-az/strings.xml b/pdf/pdf-viewer/src/main/res/values-az/strings.xml
index 6898e3f..88851a7 100644
--- a/pdf/pdf-viewer/src/main/res/values-az/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-az/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g>/<xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Uyğun gələn nəticə yoxdur"</string>
<string name="action_edit" msgid="5882082700509010966">"Faylı redaktə edin"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Fayl axtarın"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Sürüşdürmə paneli"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Kiliddən çıxarmaq üçün parol daxil edin"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Yenə cəhd edin"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF sənədi emal edilmədi!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-b+sr+Latn/strings.xml b/pdf/pdf-viewer/src/main/res/values-b+sr+Latn/strings.xml
index a2e554d..c12a6df 100644
--- a/pdf/pdf-viewer/src/main/res/values-b+sr+Latn/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-b+sr+Latn/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> od <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Nema podudarnih rezultata"</string>
<string name="action_edit" msgid="5882082700509010966">"Izmeni fajl"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Pretraži fajl"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Traka za skrolovanje"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Unesite lozinku za otključavanje"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Probaj ponovo"</string>
<string name="pdf_error" msgid="3287950599604474450">"Obrada PDF dokumenta nije uspela."</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-be/strings.xml b/pdf/pdf-viewer/src/main/res/values-be/strings.xml
index 67efe42..e2005e4ee 100644
--- a/pdf/pdf-viewer/src/main/res/values-be/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-be/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> з <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Супадзенняў няма"</string>
<string name="action_edit" msgid="5882082700509010966">"Рэдагаваць файл"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Шукаць файл"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Паласа прагорткі"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Увядзіце пароль для разблакіроўкі"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Паўтарыць"</string>
<string name="pdf_error" msgid="3287950599604474450">"Не ўдалося апрацаваць дакумент PDF."</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-bg/strings.xml b/pdf/pdf-viewer/src/main/res/values-bg/strings.xml
index 4faa5a4..a796d4ce 100644
--- a/pdf/pdf-viewer/src/main/res/values-bg/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-bg/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> от <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Няма съответстващи резултати"</string>
<string name="action_edit" msgid="5882082700509010966">"Редактиране на файла"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Търсене на файл"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Лента за превъртане"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Въведете паролата, за да отключите"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Нов опит"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF документът не бе обработен."</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-bn/strings.xml b/pdf/pdf-viewer/src/main/res/values-bn/strings.xml
index 14179f82..dba4b38 100644
--- a/pdf/pdf-viewer/src/main/res/values-bn/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-bn/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="TOTAL">%2$d</xliff:g>-এর মধ্যে <xliff:g id="POSITION">%1$d</xliff:g> নম্বর"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"কোনও ফলাফল মিলছে না"</string>
<string name="action_edit" msgid="5882082700509010966">"ফাইল এডিট করুন"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"ফাইলে খুঁজুন"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"স্ক্রলবার"</string>
<string name="password_not_entered" msgid="8875370870743585303">"আনলক করতে পাসওয়ার্ড লিখুন"</string>
<string name="retry_button_text" msgid="3443862378337999137">"আবার চেষ্টা করুন"</string>
<string name="pdf_error" msgid="3287950599604474450">"পিডিএফ ডকুমেন্ট প্রসেস করা যায়নি!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-bs/strings.xml b/pdf/pdf-viewer/src/main/res/values-bs/strings.xml
index 6806368..b1b25bf 100644
--- a/pdf/pdf-viewer/src/main/res/values-bs/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-bs/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> od <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Nema podudarnih rezultata"</string>
<string name="action_edit" msgid="5882082700509010966">"Uredite fajl"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Pretraživanje fajla"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Traka za pomicanje"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Unesite lozinku da otključate fajl"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Pokušajte ponovo"</string>
<string name="pdf_error" msgid="3287950599604474450">"Obrada PDF dokumenta nije uspjela!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-ca/strings.xml b/pdf/pdf-viewer/src/main/res/values-ca/strings.xml
index efd93eb..627423f 100644
--- a/pdf/pdf-viewer/src/main/res/values-ca/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-ca/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> de <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"No hi ha cap resultat coincident"</string>
<string name="action_edit" msgid="5882082700509010966">"Edita el fitxer"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Cerca un fitxer"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Barra de desplaçament"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Introdueix la contrasenya per desbloquejar-lo"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Torna-ho a provar"</string>
<string name="pdf_error" msgid="3287950599604474450">"No s\'ha pogut processar el document PDF."</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-cs/strings.xml b/pdf/pdf-viewer/src/main/res/values-cs/strings.xml
index 2879722..876efa9 100644
--- a/pdf/pdf-viewer/src/main/res/values-cs/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-cs/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> z <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Žádné výsledky neodpovídají"</string>
<string name="action_edit" msgid="5882082700509010966">"Upravit soubor"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Prohledat soubor"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Posuvník"</string>
<string name="password_not_entered" msgid="8875370870743585303">"K odemknutí zadejte heslo"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Zkusit znovu"</string>
<string name="pdf_error" msgid="3287950599604474450">"Dokument PDF se nepodařilo zpracovat"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-da/strings.xml b/pdf/pdf-viewer/src/main/res/values-da/strings.xml
index c518c091..ea0c1c3 100644
--- a/pdf/pdf-viewer/src/main/res/values-da/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-da/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> af <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Ingen matchende resultater"</string>
<string name="action_edit" msgid="5882082700509010966">"Rediger fil"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Søg i fil"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Rullepanel"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Angiv adgangskode for at låse op"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Prøv igen"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF-dokumentet kunne ikke behandles"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-de/strings.xml b/pdf/pdf-viewer/src/main/res/values-de/strings.xml
index 9b67e36..03afba8 100644
--- a/pdf/pdf-viewer/src/main/res/values-de/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-de/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> von <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Keine passenden Ergebnisse"</string>
<string name="action_edit" msgid="5882082700509010966">"Datei bearbeiten"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Datei suchen"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Bildlaufleiste"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Gib zum Entsperren ein Passwort ein"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Wiederholen"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF-Dokument konnte nicht verarbeitet werden."</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-el/strings.xml b/pdf/pdf-viewer/src/main/res/values-el/strings.xml
index 1990732..16c9fcf 100644
--- a/pdf/pdf-viewer/src/main/res/values-el/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-el/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> από <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Δεν υπάρχουν αντίστοιχα αποτελέσματα"</string>
<string name="action_edit" msgid="5882082700509010966">"Επεξεργασία αρχείου"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Αναζήτηση αρχείου"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Γραμμή κύλισης"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Εισαγάγετε τον κωδικό πρόσβασης για ξεκλείδωμα"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Επανάληψη"</string>
<string name="pdf_error" msgid="3287950599604474450">"Δεν ήταν δυνατή η επεξεργασία του εγγράφου PDF!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-en-rAU/strings.xml b/pdf/pdf-viewer/src/main/res/values-en-rAU/strings.xml
index de428f4..535c6f8 100644
--- a/pdf/pdf-viewer/src/main/res/values-en-rAU/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-en-rAU/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> of <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"No matching results"</string>
<string name="action_edit" msgid="5882082700509010966">"Edit file"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Search file"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Scroll bar"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Enter password to unlock"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Retry"</string>
<string name="pdf_error" msgid="3287950599604474450">"Failed to process the PDF document!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-en-rGB/strings.xml b/pdf/pdf-viewer/src/main/res/values-en-rGB/strings.xml
index de428f4..535c6f8 100644
--- a/pdf/pdf-viewer/src/main/res/values-en-rGB/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-en-rGB/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> of <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"No matching results"</string>
<string name="action_edit" msgid="5882082700509010966">"Edit file"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Search file"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Scroll bar"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Enter password to unlock"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Retry"</string>
<string name="pdf_error" msgid="3287950599604474450">"Failed to process the PDF document!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-en-rIN/strings.xml b/pdf/pdf-viewer/src/main/res/values-en-rIN/strings.xml
index de428f4..535c6f8 100644
--- a/pdf/pdf-viewer/src/main/res/values-en-rIN/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-en-rIN/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> of <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"No matching results"</string>
<string name="action_edit" msgid="5882082700509010966">"Edit file"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Search file"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Scroll bar"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Enter password to unlock"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Retry"</string>
<string name="pdf_error" msgid="3287950599604474450">"Failed to process the PDF document!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-es/strings.xml b/pdf/pdf-viewer/src/main/res/values-es/strings.xml
index 420f7af..6d0b1ee 100644
--- a/pdf/pdf-viewer/src/main/res/values-es/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-es/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> de <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"No hay coincidencias"</string>
<string name="action_edit" msgid="5882082700509010966">"Editar archivo"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Buscar archivo"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Barra de desplazamiento"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Introduce la contraseña para desbloquear"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Reintentar"</string>
<string name="pdf_error" msgid="3287950599604474450">"No se ha podido procesar el documento PDF"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-et/strings.xml b/pdf/pdf-viewer/src/main/res/values-et/strings.xml
index ad36fa9..68a9e65 100644
--- a/pdf/pdf-viewer/src/main/res/values-et/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-et/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g>/<xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Päringule vastavaid tulemusi pole"</string>
<string name="action_edit" msgid="5882082700509010966">"Faili muutmine"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Otsige failist"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Kerimisriba"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Avamiseks sisestage parool"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Proovi uuesti"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF-dokumendi töötlemine nurjus!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-eu/strings.xml b/pdf/pdf-viewer/src/main/res/values-eu/strings.xml
index 8224f3f..ca00340 100644
--- a/pdf/pdf-viewer/src/main/res/values-eu/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-eu/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="TOTAL">%2$d</xliff:g> bat-etortzetatik <xliff:g id="POSITION">%1$d</xliff:g>.a"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Ez dago bat datorren emaitzarik"</string>
<string name="action_edit" msgid="5882082700509010966">"Editatu fitxategia"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Bilatu fitxategian"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Korritze-barra"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Idatzi pasahitza desblokeatzeko"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Saiatu berriro"</string>
<string name="pdf_error" msgid="3287950599604474450">"Ezin izan da prozesatu PDF dokumentua!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-fa/strings.xml b/pdf/pdf-viewer/src/main/res/values-fa/strings.xml
index 0d718a96..6773303 100644
--- a/pdf/pdf-viewer/src/main/res/values-fa/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-fa/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> از <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"نتیجه منطبقی پیدا نشد"</string>
<string name="action_edit" msgid="5882082700509010966">"ویرایش فایل"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"جستجوی فایل"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"نوار پیمایش"</string>
<string name="password_not_entered" msgid="8875370870743585303">"گذرواژه را برای بازگشایی قفل وارد کنید"</string>
<string name="retry_button_text" msgid="3443862378337999137">"امتحان مجدد"</string>
<string name="pdf_error" msgid="3287950599604474450">"سند PDF پردازش نشد!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-fi/strings.xml b/pdf/pdf-viewer/src/main/res/values-fi/strings.xml
index ebbd3e5..728a103 100644
--- a/pdf/pdf-viewer/src/main/res/values-fi/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-fi/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g>/<xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Ei tuloksia"</string>
<string name="action_edit" msgid="5882082700509010966">"Muokkaa tiedostoa"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Hae tiedostoa"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Vierityspalkki"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Poista lukitus lisäämällä salasana"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Yritä uudelleen"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF-dokumentin käsittely epäonnistui."</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-fr-rCA/strings.xml b/pdf/pdf-viewer/src/main/res/values-fr-rCA/strings.xml
index f394aa6..a92cfb5 100644
--- a/pdf/pdf-viewer/src/main/res/values-fr-rCA/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-fr-rCA/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> de <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Aucun résultat correspondant"</string>
<string name="action_edit" msgid="5882082700509010966">"Modifier le fichier"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Rechercher un fichier"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Barre de défilement"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Entrez le mot de passe pour déverrouiller le fichier"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Réessayer"</string>
<string name="pdf_error" msgid="3287950599604474450">"Échec du traitement du document PDF!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-fr/strings.xml b/pdf/pdf-viewer/src/main/res/values-fr/strings.xml
index 0b21387..c5d1e23 100644
--- a/pdf/pdf-viewer/src/main/res/values-fr/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-fr/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> sur <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Aucun résultat"</string>
<string name="action_edit" msgid="5882082700509010966">"Modifier le fichier"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Rechercher un fichier"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Barre de défilement"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Saisissez le mot de passe pour procéder au déverrouillage"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Réessayer"</string>
<string name="pdf_error" msgid="3287950599604474450">"Échec du traitement du document PDF."</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-gl/strings.xml b/pdf/pdf-viewer/src/main/res/values-gl/strings.xml
index 69958ec..c817be5 100644
--- a/pdf/pdf-viewer/src/main/res/values-gl/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-gl/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> de <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Non hai ningún resultado que coincida"</string>
<string name="action_edit" msgid="5882082700509010966">"Editar o ficheiro"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Buscar un ficheiro"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Barra de desprazamento"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Introduce o contrasinal para desbloquear o ficheiro"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Tentar de novo"</string>
<string name="pdf_error" msgid="3287950599604474450">"Produciuse un erro ao procesar o documento PDF"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-gu/strings.xml b/pdf/pdf-viewer/src/main/res/values-gu/strings.xml
index b94915b..2d2982b 100644
--- a/pdf/pdf-viewer/src/main/res/values-gu/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-gu/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="TOTAL">%2$d</xliff:g>માંથી <xliff:g id="POSITION">%1$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"કોઈ મેળ ખાતું પરિણામ નથી"</string>
<string name="action_edit" msgid="5882082700509010966">"ફાઇલમાં ફેરફાર કરો"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"ફાઇલ શોધો"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"સ્ક્રોલ બાર"</string>
<string name="password_not_entered" msgid="8875370870743585303">"અનલૉક કરવા માટે પાસવર્ડ દાખલ કરો"</string>
<string name="retry_button_text" msgid="3443862378337999137">"ફરી પ્રયાસ કરો"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF દસ્તાવેજ પર પ્રક્રિયા કરવામાં નિષ્ફળ રહ્યાં!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-hi/strings.xml b/pdf/pdf-viewer/src/main/res/values-hi/strings.xml
index eabf6fe..a3d7265 100644
--- a/pdf/pdf-viewer/src/main/res/values-hi/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-hi/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="TOTAL">%2$d</xliff:g> में से <xliff:g id="POSITION">%1$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"कोई मिलता-जुलता नतीजा नहीं मिला"</string>
<string name="action_edit" msgid="5882082700509010966">"फ़ाइल में बदलाव करें"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"फ़ाइल खोजें"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"स्क्रोलबार"</string>
<string name="password_not_entered" msgid="8875370870743585303">"अनलॉक करने के लिए पासवर्ड डालें"</string>
<string name="retry_button_text" msgid="3443862378337999137">"फिर कोशिश करें"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF दस्तावेज़ को प्रोसेस नहीं किया जा सका!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-hr/strings.xml b/pdf/pdf-viewer/src/main/res/values-hr/strings.xml
index 390d30b..b76882b 100644
--- a/pdf/pdf-viewer/src/main/res/values-hr/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-hr/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> od <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Nema podudarnih rezultata"</string>
<string name="action_edit" msgid="5882082700509010966">"Uređivanje datoteke"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Pretraži datoteku"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Klizač"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Unesite zaporku za otključavanje"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Pokušaj ponovo"</string>
<string name="pdf_error" msgid="3287950599604474450">"Obrada PDF dokumenta nije uspjela!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-hu/strings.xml b/pdf/pdf-viewer/src/main/res/values-hu/strings.xml
index a6808f9..0bc634e 100644
--- a/pdf/pdf-viewer/src/main/res/values-hu/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-hu/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="TOTAL">%2$d</xliff:g>/<xliff:g id="POSITION">%1$d</xliff:g>."</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Nincs találat"</string>
<string name="action_edit" msgid="5882082700509010966">"Fájl szerkesztése"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Fájl keresése"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Görgetősáv"</string>
<string name="password_not_entered" msgid="8875370870743585303">"A feloldáshoz írja be a jelszót"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Újra"</string>
<string name="pdf_error" msgid="3287950599604474450">"Nem sikerült feldolgozni a PDF-dokumentumot!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-hy/strings.xml b/pdf/pdf-viewer/src/main/res/values-hy/strings.xml
index 74d5da8..46c6900 100644
--- a/pdf/pdf-viewer/src/main/res/values-hy/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-hy/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g>՝ <xliff:g id="TOTAL">%2$d</xliff:g>-ից"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Համապատասխանող արդյունքներ չկան"</string>
<string name="action_edit" msgid="5882082700509010966">"Փոփոխել ֆայլը"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Որոնել ֆայլ"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Ոլորագոտի"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Մուտքագրեք գաղտնաբառը՝ ապակողպելու համար"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Նորից փորձել"</string>
<string name="pdf_error" msgid="3287950599604474450">"Չհաջողվեց մշակել PDF փաստաթուղթը"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-in/strings.xml b/pdf/pdf-viewer/src/main/res/values-in/strings.xml
index 3ac1e7e..416db41 100644
--- a/pdf/pdf-viewer/src/main/res/values-in/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-in/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> dari <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Tidak ada hasil yang cocok"</string>
<string name="action_edit" msgid="5882082700509010966">"Edit file"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Telusuri file"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Scroll bar"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Masukkan sandi untuk membuka kunci"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Coba lagi"</string>
<string name="pdf_error" msgid="3287950599604474450">"Gagal memproses dokumen PDF"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-is/strings.xml b/pdf/pdf-viewer/src/main/res/values-is/strings.xml
index ec413bc..c2ec3ad 100644
--- a/pdf/pdf-viewer/src/main/res/values-is/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-is/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> af <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Engar samsvarandi niðurstöður fundust"</string>
<string name="action_edit" msgid="5882082700509010966">"Breyta skrá"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Leita í skrá"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Flettistika"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Sláðu inn aðgangsorð til að opna"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Reyna aftur"</string>
<string name="pdf_error" msgid="3287950599604474450">"Ekki tókst að vinna úr PDF-skjalinu!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-it/strings.xml b/pdf/pdf-viewer/src/main/res/values-it/strings.xml
index a8ecaae..4e15da5 100644
--- a/pdf/pdf-viewer/src/main/res/values-it/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-it/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> di <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Nessun risultato corrispondente"</string>
<string name="action_edit" msgid="5882082700509010966">"Modifica file"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Cerca file"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Barra di scorrimento"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Inserisci la password per sbloccare il file"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Riprova"</string>
<string name="pdf_error" msgid="3287950599604474450">"Impossibile elaborare il documento PDF"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-iw/strings.xml b/pdf/pdf-viewer/src/main/res/values-iw/strings.xml
index 8b52a43c..4fb87c6 100644
--- a/pdf/pdf-viewer/src/main/res/values-iw/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-iw/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> מתוך <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"לא נמצאו תוצאות תואמות"</string>
<string name="action_edit" msgid="5882082700509010966">"עריכת הקובץ"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"חיפוש קובץ"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"סרגל הגלילה"</string>
<string name="password_not_entered" msgid="8875370870743585303">"צריך להזין סיסמה לביטול הנעילה"</string>
<string name="retry_button_text" msgid="3443862378337999137">"ניסיון חוזר"</string>
<string name="pdf_error" msgid="3287950599604474450">"לא ניתן לעבד את מסמך ה-PDF"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-ja/strings.xml b/pdf/pdf-viewer/src/main/res/values-ja/strings.xml
index 0ffb53c..f425a9b 100644
--- a/pdf/pdf-viewer/src/main/res/values-ja/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-ja/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g>/<xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"一致する結果がありません"</string>
<string name="action_edit" msgid="5882082700509010966">"ファイルを編集"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"ファイルを検索"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"スクロールバー"</string>
<string name="password_not_entered" msgid="8875370870743585303">"ロックを解除するには、パスワードを入力してください"</string>
<string name="retry_button_text" msgid="3443862378337999137">"再試行"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF ドキュメントを処理できませんでした"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-ka/strings.xml b/pdf/pdf-viewer/src/main/res/values-ka/strings.xml
index 2e61dea..66633eb 100644
--- a/pdf/pdf-viewer/src/main/res/values-ka/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-ka/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="TOTAL">%2$d</xliff:g>-დან <xliff:g id="POSITION">%1$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"შედეგებში არ არის დამთხვევა"</string>
<string name="action_edit" msgid="5882082700509010966">"ფაილის რედაქტირება"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"ფაილის ძიება"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"გადაადგილების ზოლი"</string>
<string name="password_not_entered" msgid="8875370870743585303">"პაროლის შეყვანა განბლოკვისთვის"</string>
<string name="retry_button_text" msgid="3443862378337999137">"ხელახლა ცდა"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF დოკუმენტის დამუშავება ვერ მოხერხდა!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-kk/strings.xml b/pdf/pdf-viewer/src/main/res/values-kk/strings.xml
index 4fec50e..2806893 100644
--- a/pdf/pdf-viewer/src/main/res/values-kk/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-kk/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g>/<xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Сәйкес нәтижелер табылмады."</string>
<string name="action_edit" msgid="5882082700509010966">"Файлды өңдеу"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Файлды іздеу"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Жылжыту жолағы"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Құлыпты ашу үшін құпия сөзді енгізіңіз."</string>
<string name="retry_button_text" msgid="3443862378337999137">"Қайталау"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF құжаты өңделмеді."</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-km/strings.xml b/pdf/pdf-viewer/src/main/res/values-km/strings.xml
index 2a3fbf4..738de11 100644
--- a/pdf/pdf-viewer/src/main/res/values-km/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-km/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> នៃ <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"គ្មានលទ្ធផលត្រូវគ្នាទេ"</string>
<string name="action_edit" msgid="5882082700509010966">"កែឯកសារ"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"ស្វែងរកឯកសារ"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"របាររមូរ"</string>
<string name="password_not_entered" msgid="8875370870743585303">"បញ្ចូលពាក្យសម្ងាត់ ដើម្បីដោះសោ"</string>
<string name="retry_button_text" msgid="3443862378337999137">"ព្យាយាមម្ដងទៀត"</string>
<string name="pdf_error" msgid="3287950599604474450">"មិនអាចដំណើរការឯកសារ PDF បានទេ!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-kn/strings.xml b/pdf/pdf-viewer/src/main/res/values-kn/strings.xml
index 3ec09eb..d10e9b3 100644
--- a/pdf/pdf-viewer/src/main/res/values-kn/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-kn/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="TOTAL">%2$d</xliff:g> ರಲ್ಲಿ <xliff:g id="POSITION">%1$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"ಯಾವುದೇ ಹೊಂದಾಣಿಕೆಯ ಫಲಿತಾಂಶಗಳಿಲ್ಲ"</string>
<string name="action_edit" msgid="5882082700509010966">"ಫೈಲ್ ಎಡಿಟ್ ಮಾಡಿ"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"ಫೈಲ್ ಅನ್ನು ಹುಡುಕಿ"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"ಸ್ಕ್ರಾಲ್ಬಾರ್"</string>
<string name="password_not_entered" msgid="8875370870743585303">"ಅನ್ಲಾಕ್ ಮಾಡಲು ಪಾಸವರ್ಡ್ ಅನ್ನು ನಮೂದಿಸಿ"</string>
<string name="retry_button_text" msgid="3443862378337999137">"ಪುನಃ ಪ್ರಯತ್ನಿಸಿ"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF ಡಾಕ್ಯುಮೆಂಟ್ ಅನ್ನು ಪ್ರಕ್ರಿಯೆಗೊಳಿಸಲು ವಿಫಲವಾಗಿದೆ!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-ko/strings.xml b/pdf/pdf-viewer/src/main/res/values-ko/strings.xml
index a5d7657..2e8e44b 100644
--- a/pdf/pdf-viewer/src/main/res/values-ko/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-ko/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g>/<xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"일치하는 결과 없음"</string>
<string name="action_edit" msgid="5882082700509010966">"파일 수정"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"파일 검색"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"스크롤바"</string>
<string name="password_not_entered" msgid="8875370870743585303">"잠금 해제하려면 비밀번호 입력"</string>
<string name="retry_button_text" msgid="3443862378337999137">"재시도"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF 문서를 처리할 수 없습니다."</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-ky/strings.xml b/pdf/pdf-viewer/src/main/res/values-ky/strings.xml
index 27b2b2e..fe3fcfd 100644
--- a/pdf/pdf-viewer/src/main/res/values-ky/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-ky/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="TOTAL">%2$d</xliff:g> ичинен <xliff:g id="POSITION">%1$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Эч нерсе табылган жок"</string>
<string name="action_edit" msgid="5882082700509010966">"Файлды түзөтүү"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Файл издөө"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Сыдыруу тилкеси"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Кулпусун ачуу үчүн сырсөздү териңиз"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Кайталоо"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF документи иштетилген жок."</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-lo/strings.xml b/pdf/pdf-viewer/src/main/res/values-lo/strings.xml
index 8e87d25..3a3bee3 100644
--- a/pdf/pdf-viewer/src/main/res/values-lo/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-lo/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> ຈາກທັງໝົດ <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"ບໍ່ມີຜົນໄດ້ຮັບທີ່ກົງກັນ"</string>
<string name="action_edit" msgid="5882082700509010966">"ແກ້ໄຂໄຟລ໌"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"ຊອກຫາໄຟລ໌"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"ແຖບເລື່ອນ"</string>
<string name="password_not_entered" msgid="8875370870743585303">"ໃສ່ລະຫັດເພື່ອປົດລັອກ"</string>
<string name="retry_button_text" msgid="3443862378337999137">"ລອງໃໝ່"</string>
<string name="pdf_error" msgid="3287950599604474450">"ປະມວນຜົນເອກະສານ PDF ບໍ່ສຳເລັດ!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-lt/strings.xml b/pdf/pdf-viewer/src/main/res/values-lt/strings.xml
index bef118f..b8d14c1 100644
--- a/pdf/pdf-viewer/src/main/res/values-lt/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-lt/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> iš <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Atitikusių rezultatų nerasta"</string>
<string name="action_edit" msgid="5882082700509010966">"Redaguoti failą"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Ieškoti failo"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Slinkties juosta"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Įveskite slaptažodį, kad atrakintumėte"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Bandyti dar kartą"</string>
<string name="pdf_error" msgid="3287950599604474450">"Nepavyko apdoroti PDF dokumento!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-lv/strings.xml b/pdf/pdf-viewer/src/main/res/values-lv/strings.xml
index a505bb5..78627b9 100644
--- a/pdf/pdf-viewer/src/main/res/values-lv/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-lv/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"numur <xliff:g id="POSITION">%1$d</xliff:g>, kopējais skaits ir <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Nav atbilstošu rezultātu."</string>
<string name="action_edit" msgid="5882082700509010966">"Rediģēt failu"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Meklēt failu"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Ritjosla"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Lai atbloķētu, ievadiet paroli."</string>
<string name="retry_button_text" msgid="3443862378337999137">"Mēģināt vēlreiz"</string>
<string name="pdf_error" msgid="3287950599604474450">"Neizdevās apstrādāt PDF dokumentu."</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-mk/strings.xml b/pdf/pdf-viewer/src/main/res/values-mk/strings.xml
index 8beedf2..4dff3bb 100644
--- a/pdf/pdf-viewer/src/main/res/values-mk/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-mk/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> од <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Нема резултати што се совпаѓаат"</string>
<string name="action_edit" msgid="5882082700509010966">"Изменете ја датотеката"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Пребарувај датотеки"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Лента за лизгање"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Внесете лозинка за да отклучите"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Обидете се пoвторно"</string>
<string name="pdf_error" msgid="3287950599604474450">"Не можеше да се обработи PDF-документот!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-ml/strings.xml b/pdf/pdf-viewer/src/main/res/values-ml/strings.xml
index e7cedf6..b2236c3 100644
--- a/pdf/pdf-viewer/src/main/res/values-ml/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-ml/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="TOTAL">%2$d</xliff:g>-ൽ <xliff:g id="POSITION">%1$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"പൊരുത്തപ്പെടുന്ന ഫലങ്ങളൊന്നുമില്ല"</string>
<string name="action_edit" msgid="5882082700509010966">"ഫയൽ എഡിറ്റ് ചെയ്യുക"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"ഫയൽ തിരയുക"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"സ്ക്രോൾബാർ"</string>
<string name="password_not_entered" msgid="8875370870743585303">"അൺലോക്ക് ചെയ്യാൻ പാസ്വേഡ് നൽകുക"</string>
<string name="retry_button_text" msgid="3443862378337999137">"വീണ്ടും ശ്രമിക്കുക"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF ഡോക്യുമെന്റ് പ്രോസസ് ചെയ്യാനായില്ല!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-mn/strings.xml b/pdf/pdf-viewer/src/main/res/values-mn/strings.xml
index efdc55b..384ea73 100644
--- a/pdf/pdf-viewer/src/main/res/values-mn/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-mn/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="TOTAL">%2$d</xliff:g>-н <xliff:g id="POSITION">%1$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Ямар ч тохирох илэрц байхгүй"</string>
<string name="action_edit" msgid="5882082700509010966">"Файлыг засах"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Файлаас хайх"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Гүйлгэгч"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Түгжээг тайлахын тулд нууц үг оруулна уу"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Дахин оролдох"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF баримт бичгийг боловсруулж чадсангүй!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-mr/strings.xml b/pdf/pdf-viewer/src/main/res/values-mr/strings.xml
index 80fd8db..27e5a18 100644
--- a/pdf/pdf-viewer/src/main/res/values-mr/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-mr/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="TOTAL">%2$d</xliff:g> पैकी <xliff:g id="POSITION">%1$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"कोणतेही जुळणारे परिणाम नाहीत"</string>
<string name="action_edit" msgid="5882082700509010966">"फाइल संपादित करा"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"फाइल शोधा"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"स्क्रोलबार"</string>
<string name="password_not_entered" msgid="8875370870743585303">"अनलॉक करण्यासाठी पासवर्ड एंटर करा"</string>
<string name="retry_button_text" msgid="3443862378337999137">"पुन्हा प्रयत्न करा"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF दस्तऐवजावर प्रक्रिया करता आली नाही!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-ms/strings.xml b/pdf/pdf-viewer/src/main/res/values-ms/strings.xml
index 9b02c62..4b9c099 100644
--- a/pdf/pdf-viewer/src/main/res/values-ms/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-ms/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> daripada <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Tiada hasil carian yang sepadan"</string>
<string name="action_edit" msgid="5882082700509010966">"Edit fail"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Cari fail"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Bar tatal"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Masukkan kata laluan untuk membuka kunci"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Cuba lagi"</string>
<string name="pdf_error" msgid="3287950599604474450">"Gagal memproses dokumen PDF!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-my/strings.xml b/pdf/pdf-viewer/src/main/res/values-my/strings.xml
index 19f625c..e0f6586 100644
--- a/pdf/pdf-viewer/src/main/res/values-my/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-my/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="TOTAL">%2$d</xliff:g> အနက် <xliff:g id="POSITION">%1$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"ကိုက်ညီသောရလဒ် မရှိပါ"</string>
<string name="action_edit" msgid="5882082700509010966">"ဖိုင် တည်းဖြတ်ရန်"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"ဖိုင်ရှာရန်"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"လှိမ့်ဘား"</string>
<string name="password_not_entered" msgid="8875370870743585303">"ဖွင့်ရန် စကားဝှက်ထည့်ပါ"</string>
<string name="retry_button_text" msgid="3443862378337999137">"ထပ်စမ်းရန်"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF မှတ်တမ်း လုပ်ဆောင်၍မရလိုက်ပါ။"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-nb/strings.xml b/pdf/pdf-viewer/src/main/res/values-nb/strings.xml
index 2bac600..fe27e60 100644
--- a/pdf/pdf-viewer/src/main/res/values-nb/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-nb/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> av <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Ingen treff"</string>
<string name="action_edit" msgid="5882082700509010966">"Endre filen"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Søk i filen"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Rullefelt"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Skriv inn passordet for å låse opp"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Prøv på nytt"</string>
<string name="pdf_error" msgid="3287950599604474450">"Kunne ikke behandle PDF-dokumentet"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-ne/strings.xml b/pdf/pdf-viewer/src/main/res/values-ne/strings.xml
index 997e9a1..1ee8978 100644
--- a/pdf/pdf-viewer/src/main/res/values-ne/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-ne/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="TOTAL">%2$d</xliff:g> मध्ये <xliff:g id="POSITION">%1$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"कुनै पनि मिल्दोजुल्दो परिणाम भेटिएन"</string>
<string name="action_edit" msgid="5882082700509010966">"फाइल सम्पादन गर्नुहोस्"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"फाइल खोज्नुहोस्"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"स्क्रोल बार"</string>
<string name="password_not_entered" msgid="8875370870743585303">"अनलक गर्न पासवर्ड हाल्नुहोस्"</string>
<string name="retry_button_text" msgid="3443862378337999137">"फेरि प्रयास गर्नुहोस्"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF डकुमेन्ट प्रोसेस गर्न सकिएन!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-nl/strings.xml b/pdf/pdf-viewer/src/main/res/values-nl/strings.xml
index 841f887..454b2df 100644
--- a/pdf/pdf-viewer/src/main/res/values-nl/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-nl/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> van <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Geen overeenkomende resultaten"</string>
<string name="action_edit" msgid="5882082700509010966">"Bestand bewerken"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Bestand doorzoeken"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Scrollbar"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Voer het wachtwoord in om te ontgrendelen"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Opnieuw proberen"</string>
<string name="pdf_error" msgid="3287950599604474450">"Kan het pdf-document niet verwerken"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-or/strings.xml b/pdf/pdf-viewer/src/main/res/values-or/strings.xml
index 09c03ee..e88085f 100644
--- a/pdf/pdf-viewer/src/main/res/values-or/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-or/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="TOTAL">%2$d</xliff:g>ର <xliff:g id="POSITION">%1$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"ମେଳ ହେଉଥିବା କୌଣସି ଫଳାଫଳ ନାହିଁ"</string>
<string name="action_edit" msgid="5882082700509010966">"ଫାଇଲକୁ ଏଡିଟ କରନ୍ତୁ"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"ଫାଇଲ ସର୍ଚ୍ଚ କରନ୍ତୁ"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"ସ୍କ୍ରୋଲବାର"</string>
<string name="password_not_entered" msgid="8875370870743585303">"ଅନଲକ କରିବା ପାଇଁ ପାସୱାର୍ଡ ଲେଖନ୍ତୁ"</string>
<string name="retry_button_text" msgid="3443862378337999137">"ପୁଣି ଚେଷ୍ଟା କରନ୍ତୁ"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF ଡକ୍ୟୁମେଣ୍ଟକୁ ପ୍ରକ୍ୱିୟାନ୍ୱିତ କରିବାରେ ବିଫଳ ହୋଇଛି!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-pa/strings.xml b/pdf/pdf-viewer/src/main/res/values-pa/strings.xml
index 71b4098..6c4be6e 100644
--- a/pdf/pdf-viewer/src/main/res/values-pa/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-pa/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="TOTAL">%2$d</xliff:g> ਵਿੱਚੋਂ <xliff:g id="POSITION">%1$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"ਕੋਈ ਮੇਲ ਖਾਂਦਾ ਨਤੀਜਾ ਨਹੀਂ"</string>
<string name="action_edit" msgid="5882082700509010966">"ਫ਼ਾਈਲ ਦਾ ਸੰਪਾਦਨ ਕਰੋ"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"ਫ਼ਾਈਲ ਖੋਜੋ"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"ਸਕ੍ਰੋਲ ਬਾਰ"</string>
<string name="password_not_entered" msgid="8875370870743585303">"ਅਣਲਾਕ ਕਰਨ ਲਈ ਪਾਸਵਰਡ ਦਾਖਲ ਕਰੋ"</string>
<string name="retry_button_text" msgid="3443862378337999137">"ਮੁੜ-ਕੋਸ਼ਿਸ਼ ਕਰੋ"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF ਦਸਤਾਵੇਜ਼ \'ਤੇ ਪ੍ਰਕਿਰਿਆ ਨਹੀਂ ਕੀਤੀ ਜਾ ਸਕੀ!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-pl/strings.xml b/pdf/pdf-viewer/src/main/res/values-pl/strings.xml
index f9eff9a..4d4937f 100644
--- a/pdf/pdf-viewer/src/main/res/values-pl/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-pl/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> z <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Brak pasujących wyników"</string>
<string name="action_edit" msgid="5882082700509010966">"Edytuj plik"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Wyszukaj plik"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Pasek przewijania"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Podaj hasło, aby odblokować"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Spróbuj jeszcze raz"</string>
<string name="pdf_error" msgid="3287950599604474450">"Nie udało się przetworzyć dokumentu PDF."</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-pt-rBR/strings.xml b/pdf/pdf-viewer/src/main/res/values-pt-rBR/strings.xml
index 0e4c04d..4eda3cd 100644
--- a/pdf/pdf-viewer/src/main/res/values-pt-rBR/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-pt-rBR/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> de <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Nenhum resultado encontrado"</string>
<string name="action_edit" msgid="5882082700509010966">"Editar arquivo"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Pesquisar no arquivo"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Barra de rolagem"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Digite a senha para desbloquear"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Tentar de novo"</string>
<string name="pdf_error" msgid="3287950599604474450">"Falha no processamento do documento PDF"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-pt-rPT/strings.xml b/pdf/pdf-viewer/src/main/res/values-pt-rPT/strings.xml
index 18081de..7b5d664 100644
--- a/pdf/pdf-viewer/src/main/res/values-pt-rPT/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-pt-rPT/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> de <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Sem resultados correspondentes"</string>
<string name="action_edit" msgid="5882082700509010966">"Editar ficheiro"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Pesquisar ficheiro"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Barra de deslocamento"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Introduza a palavra-passe para desbloquear"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Tentar novamente"</string>
<string name="pdf_error" msgid="3287950599604474450">"Falha ao processar o documento PDF!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-pt/strings.xml b/pdf/pdf-viewer/src/main/res/values-pt/strings.xml
index 0e4c04d..4eda3cd 100644
--- a/pdf/pdf-viewer/src/main/res/values-pt/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-pt/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> de <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Nenhum resultado encontrado"</string>
<string name="action_edit" msgid="5882082700509010966">"Editar arquivo"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Pesquisar no arquivo"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Barra de rolagem"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Digite a senha para desbloquear"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Tentar de novo"</string>
<string name="pdf_error" msgid="3287950599604474450">"Falha no processamento do documento PDF"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-ro/strings.xml b/pdf/pdf-viewer/src/main/res/values-ro/strings.xml
index d3f7a36..7ed5c68 100644
--- a/pdf/pdf-viewer/src/main/res/values-ro/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-ro/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> din <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Niciun rezultat"</string>
<string name="action_edit" msgid="5882082700509010966">"Editează fișierul"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Caută fișierul"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Bară de derulare"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Introdu parola pentru a debloca"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Reîncearcă"</string>
<string name="pdf_error" msgid="3287950599604474450">"Nu s-a putut procesa documentul PDF!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-ru/strings.xml b/pdf/pdf-viewer/src/main/res/values-ru/strings.xml
index 6734347..0921947 100644
--- a/pdf/pdf-viewer/src/main/res/values-ru/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-ru/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> из <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Ничего не найдено."</string>
<string name="action_edit" msgid="5882082700509010966">"Редактировать файл"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Найти файл"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Полоса прокрутки"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Введите пароль для разблокировки."</string>
<string name="retry_button_text" msgid="3443862378337999137">"Повторить попытку"</string>
<string name="pdf_error" msgid="3287950599604474450">"Не удалось обработать документ PDF"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-si/strings.xml b/pdf/pdf-viewer/src/main/res/values-si/strings.xml
index bd4fdc7..d72aa11 100644
--- a/pdf/pdf-viewer/src/main/res/values-si/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-si/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="TOTAL">%2$d</xliff:g>න් <xliff:g id="POSITION">%1$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"ගැළපෙන ප්රතිඵල නැත"</string>
<string name="action_edit" msgid="5882082700509010966">"ගොනුව සංස්කරණ කරන්න"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"සෙවීම් ගොනුව"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"අනුචලන තීරුව"</string>
<string name="password_not_entered" msgid="8875370870743585303">"අගුලු හැරීමට මුරපදය ඇතුළත් කරන්න"</string>
<string name="retry_button_text" msgid="3443862378337999137">"යළි උත්සාහ කරන්න"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF ලේඛනය සැකසීමට අසමත් විය!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-sk/strings.xml b/pdf/pdf-viewer/src/main/res/values-sk/strings.xml
index 4458e20..7978936 100644
--- a/pdf/pdf-viewer/src/main/res/values-sk/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-sk/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> z <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Žiadne zodpovedajúce výsledky"</string>
<string name="action_edit" msgid="5882082700509010966">"Upraviť súbor"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Vyhľadať súbor"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Posúvač"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Zadajte heslo na odomknutie"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Skúsiť znova"</string>
<string name="pdf_error" msgid="3287950599604474450">"Dokument vo formáte PDF sa nepodarilo spracovať."</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-sl/strings.xml b/pdf/pdf-viewer/src/main/res/values-sl/strings.xml
index d23cae0..3723865 100644
--- a/pdf/pdf-viewer/src/main/res/values-sl/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-sl/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> od <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Ni ustreznih rezultatov"</string>
<string name="action_edit" msgid="5882082700509010966">"Urejanje datoteke"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Iskanje po datoteki"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Drsni trak"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Vnesite geslo za odklepanje"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Poskusi znova"</string>
<string name="pdf_error" msgid="3287950599604474450">"Obdelava dokumenta PDF ni uspela."</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-sq/strings.xml b/pdf/pdf-viewer/src/main/res/values-sq/strings.xml
index 5c02c72..ac85bd2 100644
--- a/pdf/pdf-viewer/src/main/res/values-sq/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-sq/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> nga <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Nuk përputhet asnjë rezultat"</string>
<string name="action_edit" msgid="5882082700509010966">"Modifiko skedarin"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Kërko në skedar"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Shiriti i lëvizjes"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Fut fjalëkalimin për ta shkyçur"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Riprovo"</string>
<string name="pdf_error" msgid="3287950599604474450">"Përpunimi i dokumentit PDF dështoi"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-sr/strings.xml b/pdf/pdf-viewer/src/main/res/values-sr/strings.xml
index 6669a2a..2dc9aee 100644
--- a/pdf/pdf-viewer/src/main/res/values-sr/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-sr/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> од <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Нема подударних резултата"</string>
<string name="action_edit" msgid="5882082700509010966">"Измени фајл"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Претражи фајл"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Трака за скроловање"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Унесите лозинку за откључавање"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Пробај поново"</string>
<string name="pdf_error" msgid="3287950599604474450">"Обрада PDF документа није успела."</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-sv/strings.xml b/pdf/pdf-viewer/src/main/res/values-sv/strings.xml
index 6d1b22a..9768715 100644
--- a/pdf/pdf-viewer/src/main/res/values-sv/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-sv/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> av <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Det finns inga matchande resultat"</string>
<string name="action_edit" msgid="5882082700509010966">"Redigera fil"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Sök i fil"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Scrollningslist"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Ange lösenord för att låsa upp"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Försök igen"</string>
<string name="pdf_error" msgid="3287950599604474450">"Det gick inte att bearbeta PDF-dokumentet"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-sw/strings.xml b/pdf/pdf-viewer/src/main/res/values-sw/strings.xml
index a667e4b..e3f5682 100644
--- a/pdf/pdf-viewer/src/main/res/values-sw/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-sw/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> kati ya <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Hakuna matokeo yanayolingana"</string>
<string name="action_edit" msgid="5882082700509010966">"Badilisha faili"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Tafuta faili"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Sehemu ya kusogeza"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Weka nenosiri ili ufungue"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Jaribu tena"</string>
<string name="pdf_error" msgid="3287950599604474450">"Imeshindwa kuchakata hati ya PDF!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-ta/strings.xml b/pdf/pdf-viewer/src/main/res/values-ta/strings.xml
index 4d8e030..4352dd7 100644
--- a/pdf/pdf-viewer/src/main/res/values-ta/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-ta/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g>/<xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"பொருந்தும் முடிவுகள் எதுவுமில்லை"</string>
<string name="action_edit" msgid="5882082700509010966">"ஃபைலைத் திருத்து"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"ஃபைலைத் தேடும்"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"ஸ்க்ரோல் பார்"</string>
<string name="password_not_entered" msgid="8875370870743585303">"அன்லாக் செய்ய கடவுச்சொல்லை டைப் செய்யவும்"</string>
<string name="retry_button_text" msgid="3443862378337999137">"மீண்டும் முயலுங்கள்"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF ஆவணத்தைச் செயலாக்க முடியவில்லை!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-te/strings.xml b/pdf/pdf-viewer/src/main/res/values-te/strings.xml
index 93a40f2..5e63dad 100644
--- a/pdf/pdf-viewer/src/main/res/values-te/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-te/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="TOTAL">%2$d</xliff:g>లో <xliff:g id="POSITION">%1$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"మ్యాచ్ అయ్యే ఫలితాలు ఏవీ లేవు"</string>
<string name="action_edit" msgid="5882082700509010966">"ఫైల్ను ఎడిట్ చేయండి"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"ఫైల్ను సెర్చ్ చేయండి"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"స్క్రోల్ బార్"</string>
<string name="password_not_entered" msgid="8875370870743585303">"అన్లాక్ చేయడానికి పాస్వర్డ్ను నమోదు చేయండి"</string>
<string name="retry_button_text" msgid="3443862378337999137">"మళ్లీ ట్రై చేయండి"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF డాక్యుమెంట్ను ప్రాసెస్ చేయడం విఫలమైంది!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-th/strings.xml b/pdf/pdf-viewer/src/main/res/values-th/strings.xml
index dc3da5a..521cd13 100644
--- a/pdf/pdf-viewer/src/main/res/values-th/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-th/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> จาก <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"ไม่มีผลลัพธ์ที่ตรงกัน"</string>
<string name="action_edit" msgid="5882082700509010966">"แก้ไขไฟล์"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"ค้นหาไฟล์"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"แถบเลื่อน"</string>
<string name="password_not_entered" msgid="8875370870743585303">"ป้อนรหัสผ่านเพื่อปลดล็อก"</string>
<string name="retry_button_text" msgid="3443862378337999137">"ลองอีกครั้ง"</string>
<string name="pdf_error" msgid="3287950599604474450">"ประมวลผลเอกสาร PDF ไม่สำเร็จ"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-tl/strings.xml b/pdf/pdf-viewer/src/main/res/values-tl/strings.xml
index 1a077e8..f10fa14 100644
--- a/pdf/pdf-viewer/src/main/res/values-tl/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-tl/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> sa <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Walang tumutugmang resulta"</string>
<string name="action_edit" msgid="5882082700509010966">"I-edit ang file"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Maghanap ng file"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Scrollbar"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Ilagay ang password para i-unlock"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Subukan ulit"</string>
<string name="pdf_error" msgid="3287950599604474450">"Hindi naproseso ang PDF na dokumento!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-tr/strings.xml b/pdf/pdf-viewer/src/main/res/values-tr/strings.xml
index 4ef25c3..60fed2c 100644
--- a/pdf/pdf-viewer/src/main/res/values-tr/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-tr/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g>/<xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Eşleşen sonuç yok"</string>
<string name="action_edit" msgid="5882082700509010966">"Dosyayı düzenle"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Dosya ara"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Kaydırma çubuğu"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Kilidi açmak için şifreyi girin"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Tekrar dene"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF dokümanı işlenemedi."</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-uk/strings.xml b/pdf/pdf-viewer/src/main/res/values-uk/strings.xml
index 8774d93..d8e7b7f 100644
--- a/pdf/pdf-viewer/src/main/res/values-uk/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-uk/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> з <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Немає результатів"</string>
<string name="action_edit" msgid="5882082700509010966">"Редагувати файл"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Пошук файлу"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Смуга прокручування"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Введіть пароль, щоб розблокувати"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Повторити"</string>
<string name="pdf_error" msgid="3287950599604474450">"Не вдалось обробити документ PDF."</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-ur/strings.xml b/pdf/pdf-viewer/src/main/res/values-ur/strings.xml
index 9e3b4be..fe78124 100644
--- a/pdf/pdf-viewer/src/main/res/values-ur/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-ur/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> از <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"کوئی مماثل نتائج نہیں ہیں"</string>
<string name="action_edit" msgid="5882082700509010966">"فائل میں ترمیم کریں"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"فائل تلاش کریں"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"اسکرول بار"</string>
<string name="password_not_entered" msgid="8875370870743585303">"غیر مقفل کرنے کیلئے پاس ورڈ درج کریں"</string>
<string name="retry_button_text" msgid="3443862378337999137">"پھر کوشش کریں"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF دستاویز پر کارروائی کرنے میں ناکام!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-uz/strings.xml b/pdf/pdf-viewer/src/main/res/values-uz/strings.xml
index 65f2fa9..4820c65 100644
--- a/pdf/pdf-viewer/src/main/res/values-uz/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-uz/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> / <xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Mos keladigani topilmadi"</string>
<string name="action_edit" msgid="5882082700509010966">"Faylni tahrirlash"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Faylni qidirish"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Aylantirish yoʻli"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Ochish uchun parolni kiriting"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Qayta urinish"</string>
<string name="pdf_error" msgid="3287950599604474450">"PDF hujjat qayta ishlanmadi!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-vi/strings.xml b/pdf/pdf-viewer/src/main/res/values-vi/strings.xml
index 03ff8c5..a9f802a 100644
--- a/pdf/pdf-viewer/src/main/res/values-vi/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-vi/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g>/<xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Không có kết quả phù hợp"</string>
<string name="action_edit" msgid="5882082700509010966">"Chỉnh sửa tệp"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Tìm tệp"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Thanh cuộn"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Nhập mật khẩu để mở khoá"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Thử lại"</string>
<string name="pdf_error" msgid="3287950599604474450">"Không xử lý được tài liệu PDF này!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-zh-rCN/strings.xml b/pdf/pdf-viewer/src/main/res/values-zh-rCN/strings.xml
index fdbce8b..17c14af 100644
--- a/pdf/pdf-viewer/src/main/res/values-zh-rCN/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-zh-rCN/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"第 <xliff:g id="POSITION">%1$d</xliff:g> 个(共 <xliff:g id="TOTAL">%2$d</xliff:g> 个)"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"没有符合条件的结果"</string>
<string name="action_edit" msgid="5882082700509010966">"编辑文件"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"搜索文件"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"滚动条"</string>
<string name="password_not_entered" msgid="8875370870743585303">"请输入密码进行解锁"</string>
<string name="retry_button_text" msgid="3443862378337999137">"重试"</string>
<string name="pdf_error" msgid="3287950599604474450">"无法处理 PDF 文档!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-zh-rHK/strings.xml b/pdf/pdf-viewer/src/main/res/values-zh-rHK/strings.xml
index e503236..b3c3658 100644
--- a/pdf/pdf-viewer/src/main/res/values-zh-rHK/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-zh-rHK/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"第 <xliff:g id="POSITION">%1$d</xliff:g> 個,共 <xliff:g id="TOTAL">%2$d</xliff:g> 個"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"找不到相符的結果"</string>
<string name="action_edit" msgid="5882082700509010966">"編輯檔案"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"搵檔案"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"捲軸"</string>
<string name="password_not_entered" msgid="8875370870743585303">"輸入密碼即可解鎖"</string>
<string name="retry_button_text" msgid="3443862378337999137">"重試"</string>
<string name="pdf_error" msgid="3287950599604474450">"無法處理 PDF 文件!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-zh-rTW/strings.xml b/pdf/pdf-viewer/src/main/res/values-zh-rTW/strings.xml
index b6561b8..1e16247 100644
--- a/pdf/pdf-viewer/src/main/res/values-zh-rTW/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-zh-rTW/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"第 <xliff:g id="POSITION">%1$d</xliff:g> 個,共 <xliff:g id="TOTAL">%2$d</xliff:g> 個"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"找不到相符的結果"</string>
<string name="action_edit" msgid="5882082700509010966">"編輯檔案"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"搜尋檔案"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"捲軸"</string>
<string name="password_not_entered" msgid="8875370870743585303">"輸入密碼即可解鎖"</string>
<string name="retry_button_text" msgid="3443862378337999137">"重試"</string>
<string name="pdf_error" msgid="3287950599604474450">"無法處理此 PDF 文件!"</string>
diff --git a/pdf/pdf-viewer/src/main/res/values-zu/strings.xml b/pdf/pdf-viewer/src/main/res/values-zu/strings.xml
index 64c11c5..4492469 100644
--- a/pdf/pdf-viewer/src/main/res/values-zu/strings.xml
+++ b/pdf/pdf-viewer/src/main/res/values-zu/strings.xml
@@ -50,10 +50,8 @@
<string name="match_status_description" msgid="4996847358326345288">"<xliff:g id="POSITION">%1$d</xliff:g> ku-<xliff:g id="TOTAL">%2$d</xliff:g>"</string>
<string name="message_no_match_status" msgid="5929387004361286433">"Ayikho imiphumela efanayo"</string>
<string name="action_edit" msgid="5882082700509010966">"Hlela ifayela"</string>
- <!-- no translation found for action_search (1044074359976464346) -->
- <skip />
- <!-- no translation found for scrollbar_description (5720892205323882483) -->
- <skip />
+ <string name="action_search" msgid="1044074359976464346">"Sesha ifayela"</string>
+ <string name="scrollbar_description" msgid="5720892205323882483">"Ibha yokuskrola"</string>
<string name="password_not_entered" msgid="8875370870743585303">"Faka iphasiwedi ukuvula"</string>
<string name="retry_button_text" msgid="3443862378337999137">"Zama futhi"</string>
<string name="pdf_error" msgid="3287950599604474450">"Yehlulekile ukucubungula idokhumenti ye-PDF!"</string>
diff --git a/privacysandbox/ui/integration-tests/testapp/src/main/res/layout/fragment_resize.xml b/privacysandbox/ui/integration-tests/testapp/src/main/res/layout/fragment_resize.xml
index 2c58ea6..5c86f79 100644
--- a/privacysandbox/ui/integration-tests/testapp/src/main/res/layout/fragment_resize.xml
+++ b/privacysandbox/ui/integration-tests/testapp/src/main/res/layout/fragment_resize.xml
@@ -30,7 +30,7 @@
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
- android:background="#FFFFFF" />
+ android:background="#D3D3D3" />
<LinearLayout
android:layout_width="wrap_content"
diff --git a/privacysandbox/ui/integration-tests/testapp/src/main/res/layout/fragment_scroll.xml b/privacysandbox/ui/integration-tests/testapp/src/main/res/layout/fragment_scroll.xml
index 1c64518..8487dd8 100644
--- a/privacysandbox/ui/integration-tests/testapp/src/main/res/layout/fragment_scroll.xml
+++ b/privacysandbox/ui/integration-tests/testapp/src/main/res/layout/fragment_scroll.xml
@@ -39,7 +39,7 @@
android:layout_width="wrap_content"
android:layout_weight="2"
android:layout_height="0dp"
- android:background="#FFFFFF" />
+ android:background="#D3D3D3" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/room/room-compiler-processing-testing/src/main/java/androidx/room/compiler/processing/util/compiler/steps/KaptCompilationStep.kt b/room/room-compiler-processing-testing/src/main/java/androidx/room/compiler/processing/util/compiler/steps/KaptCompilationStep.kt
index dc620b9..96a7404 100644
--- a/room/room-compiler-processing-testing/src/main/java/androidx/room/compiler/processing/util/compiler/steps/KaptCompilationStep.kt
+++ b/room/room-compiler-processing-testing/src/main/java/androidx/room/compiler/processing/util/compiler/steps/KaptCompilationStep.kt
@@ -38,9 +38,10 @@
override val name = "kapt"
init {
- check(annotationProcessors.size <= 10) {
- "Only 10 annotation processor can be loaded for test compilation for now, but " +
- "requested ${annotationProcessors.size}. Tell Dany to support more!"
+ check(annotationProcessors.size <= PROCESSOR_DELEGATES_SIZE) {
+ "Only $PROCESSOR_DELEGATES_SIZE annotation processor can be loaded for test " +
+ "compilation for now, but requested ${annotationProcessors.size}. " +
+ "Tell Dany to support more!"
}
}
@@ -126,7 +127,8 @@
// 'apclasspath' is not used since FQN are specified in 'processors', but if left unset
// KAPT does not try to load processors at all.
add(KaptCliOption.ANNOTATION_PROCESSOR_CLASSPATH_OPTION to "empty")
- List(annotationProcessors.size) { index ->
+
+ for (index in annotationProcessors.indices) {
add(
KaptCliOption.ANNOTATION_PROCESSORS_OPTION to
TestDelegateProcessor.KaptTestDelegateAP0::class.java.name.dropLast(1) + index
@@ -194,6 +196,9 @@
/** The list of processors to delegate to during the test compilation. */
private val delegateProcessors = ThreadLocal<List<Processor>>()
+/** The max amount of processors we support during test is based on the amount of delegates */
+private val PROCESSOR_DELEGATES_SIZE = TestDelegateProcessor::class.java.declaredClasses.size
+
/**
* These delegate classes may seem unused but will be instantiated by KAPT via reflection and
* through their no-arg constructor, and we use them to delegate to actual processors provided for
@@ -221,4 +226,24 @@
class KaptTestDelegateAP8 : TestDelegateProcessor(checkNotNull(delegateProcessors.get())[8])
class KaptTestDelegateAP9 : TestDelegateProcessor(checkNotNull(delegateProcessors.get())[9])
+
+ class KaptTestDelegateAP10 : TestDelegateProcessor(checkNotNull(delegateProcessors.get())[10])
+
+ class KaptTestDelegateAP11 : TestDelegateProcessor(checkNotNull(delegateProcessors.get())[11])
+
+ class KaptTestDelegateAP12 : TestDelegateProcessor(checkNotNull(delegateProcessors.get())[12])
+
+ class KaptTestDelegateAP13 : TestDelegateProcessor(checkNotNull(delegateProcessors.get())[13])
+
+ class KaptTestDelegateAP14 : TestDelegateProcessor(checkNotNull(delegateProcessors.get())[14])
+
+ class KaptTestDelegateAP15 : TestDelegateProcessor(checkNotNull(delegateProcessors.get())[15])
+
+ class KaptTestDelegateAP16 : TestDelegateProcessor(checkNotNull(delegateProcessors.get())[16])
+
+ class KaptTestDelegateAP17 : TestDelegateProcessor(checkNotNull(delegateProcessors.get())[17])
+
+ class KaptTestDelegateAP18 : TestDelegateProcessor(checkNotNull(delegateProcessors.get())[18])
+
+ class KaptTestDelegateAP19 : TestDelegateProcessor(checkNotNull(delegateProcessors.get())[19])
}
diff --git a/samples/MediaRoutingDemo/OWNERS b/samples/MediaRoutingDemo/OWNERS
index c39e4d9..74aa9f0 100644
--- a/samples/MediaRoutingDemo/OWNERS
+++ b/samples/MediaRoutingDemo/OWNERS
@@ -1,2 +1,2 @@
-# Bug component: 1611600
+# Bug component: 137631
file: ../../mediarouter/OWNERS
diff --git a/samples/MediaRoutingDemo/build.gradle b/samples/MediaRoutingDemo/build.gradle
index 617f702..7a56a07 100644
--- a/samples/MediaRoutingDemo/build.gradle
+++ b/samples/MediaRoutingDemo/build.gradle
@@ -11,8 +11,10 @@
}
dependencies {
+ api(libs.jspecify)
implementation(project(":appcompat:appcompat"))
implementation(project(":mediarouter:mediarouter"))
+ implementation(project(":preference:preference"))
implementation(project(":recyclerview:recyclerview"))
implementation(project(":concurrent:concurrent-futures"))
implementation(project(":swiperefreshlayout:swiperefreshlayout"))
diff --git a/samples/MediaRoutingDemo/src/main/AndroidManifest.xml b/samples/MediaRoutingDemo/src/main/AndroidManifest.xml
index aa26fb7..7aacb34 100644
--- a/samples/MediaRoutingDemo/src/main/AndroidManifest.xml
+++ b/samples/MediaRoutingDemo/src/main/AndroidManifest.xml
@@ -102,7 +102,7 @@
<service
android:name=".services.SampleDynamicGroupMediaRouteProviderService"
- android:label="@string/sample_media_route_provider_service"
+ android:label="@string/sample_dynamic_group_mrp_service"
android:exported="true">
<intent-filter>
@@ -112,6 +112,16 @@
</intent-filter>
</service>
+ <service
+ android:name=".services.WrapperMediaRouteProviderService"
+ android:label="@string/wrapper_media_route_provider_service"
+ android:exported="true">
+ <intent-filter>
+ <action android:name="android.media.MediaRouteProviderService" />
+ <action android:name="android.media.MediaRoute2ProviderService" />
+ </intent-filter>
+ </service>
+
</application>
<!-- The smallest screen this app works on is a phone. The app will
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/MyMediaRouteControllerDialog.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/MyMediaRouteControllerDialog.java
index 8051d4a7..0185867 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/MyMediaRouteControllerDialog.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/MyMediaRouteControllerDialog.java
@@ -22,9 +22,10 @@
import android.view.View;
import android.widget.TextView;
-import androidx.annotation.NonNull;
import androidx.mediarouter.app.MediaRouteControllerDialog;
+import org.jspecify.annotations.NonNull;
+
/**
* An example MediaRouteControllerDialog for demonstrating
* {@link androidx.mediarouter.app.MediaRouteControllerDialog#onCreateMediaControlView}.
@@ -34,9 +35,8 @@
super(context);
}
- @NonNull
@Override
- public View onCreateMediaControlView(@NonNull Bundle savedInstanceState) {
+ public @NonNull View onCreateMediaControlView(@NonNull Bundle savedInstanceState) {
TextView view = new TextView(getContext());
view.setText(R.string.my_media_control_text);
view.setBackgroundColor(Color.GRAY);
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/OverlayDisplayWindow.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/OverlayDisplayWindow.java
index 44d7985..f005665 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/OverlayDisplayWindow.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/OverlayDisplayWindow.java
@@ -37,8 +37,8 @@
import android.view.WindowManager;
import android.widget.TextView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* Manages an overlay display window, used for simulating remote playback.
@@ -57,8 +57,7 @@
protected final int mWidth;
protected final int mHeight;
protected final int mGravity;
- @Nullable
- protected OverlayWindowListener mListener;
+ protected @Nullable OverlayWindowListener mListener;
protected OverlayDisplayWindow(@NonNull Context context, @NonNull String name, int width,
int height, int gravity) {
@@ -74,9 +73,8 @@
*
* @return the created overlay window.
*/
- @NonNull
- public static OverlayDisplayWindow create(@NonNull Context context, @NonNull String name,
- int width, int height, int gravity) {
+ public static @NonNull OverlayDisplayWindow create(@NonNull Context context,
+ @NonNull String name, int width, int height, int gravity) {
return new JellybeanMr1Impl(context, name, width, height, gravity);
}
@@ -84,8 +82,7 @@
mListener = listener;
}
- @NonNull
- public Context getContext() {
+ public @NonNull Context getContext() {
return mContext;
}
@@ -109,8 +106,7 @@
*
* @return a bitmap representing the snapshot of the window.
*/
- @Nullable
- public abstract Bitmap getSnapshot();
+ public abstract @Nullable Bitmap getSnapshot();
/**
* Watches for significant changes in the overlay display window lifecycle.
@@ -214,9 +210,8 @@
relayout();
}
- @NonNull
@Override
- public Bitmap getSnapshot() {
+ public @NonNull Bitmap getSnapshot() {
return mTextureView.getBitmap();
}
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/RoutesManager.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/RoutesManager.java
index fff9c40..0cddd62 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/RoutesManager.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/RoutesManager.java
@@ -27,8 +27,6 @@
import android.content.Context;
import android.content.res.Resources;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.mediarouter.media.MediaRouter;
import androidx.mediarouter.media.MediaRouterParams;
import androidx.mediarouter.media.RouteListingPreference;
@@ -36,6 +34,9 @@
import com.example.androidx.mediarouting.activities.MainActivity;
import com.example.androidx.mediarouting.data.RouteItem;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -72,8 +73,7 @@
}
/** Singleton method. */
- @NonNull
- public static RoutesManager getInstance(@NonNull Context context) {
+ public static @NonNull RoutesManager getInstance(@NonNull Context context) {
synchronized (RoutesManager.class) {
if (sInstance == null) {
sInstance = new RoutesManager(context);
@@ -82,8 +82,7 @@
return sInstance;
}
- @NonNull
- public List<RouteItem> getRouteItems() {
+ public @NonNull List<RouteItem> getRouteItems() {
return new ArrayList<>(mRouteItems.values());
}
@@ -114,8 +113,7 @@
* @param id of the route to search for.
* @return the route with the passed id, or null if it does not exist.
*/
- @Nullable
- public RouteItem getRouteWithId(@Nullable String id) {
+ public @Nullable RouteItem getRouteWithId(@Nullable String id) {
return mRouteItems.get(id);
}
@@ -172,8 +170,7 @@
* The current list of route listing preference items, as set via {@link
* #setRouteListingPreferenceItems}.
*/
- @NonNull
- public List<RouteListingPreferenceItemHolder> getRouteListingPreferenceItems() {
+ public @NonNull List<RouteListingPreferenceItemHolder> getRouteListingPreferenceItems() {
return mRouteListingPreferenceItems;
}
@@ -338,19 +335,18 @@
*/
public static final class RouteListingPreferenceItemHolder {
- @NonNull public final RouteListingPreference.Item mItem;
- @NonNull public final String mRouteName;
+ public final RouteListingPreference.@NonNull Item mItem;
+ public final @NonNull String mRouteName;
public RouteListingPreferenceItemHolder(
- @NonNull RouteListingPreference.Item item, @NonNull String routeName) {
+ RouteListingPreference.@NonNull Item item, @NonNull String routeName) {
mItem = item;
mRouteName = routeName;
}
/** Returns the name of the corresponding route. */
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return mRouteName;
}
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/AddEditRouteActivity.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/AddEditRouteActivity.java
index cb1f13b..d01b97d 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/AddEditRouteActivity.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/AddEditRouteActivity.java
@@ -30,8 +30,6 @@
import android.widget.EditText;
import android.widget.Switch;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.util.Consumer;
@@ -40,11 +38,14 @@
import com.example.androidx.mediarouting.data.RouteItem;
import com.example.androidx.mediarouting.services.SampleDynamicGroupMediaRouteProviderService;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/** Allows the user to add and edit routes. */
public class AddEditRouteActivity extends AppCompatActivity {
private static final String EXTRA_ROUTE_ID_KEY = "routeId";
- @Nullable private SampleDynamicGroupMediaRouteProviderService mService;
+ private @Nullable SampleDynamicGroupMediaRouteProviderService mService;
private ServiceConnection mConnection;
private RoutesManager mRoutesManager;
private RouteItem mRouteItem;
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/MainActivity.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/MainActivity.java
index bb43e90..8786631 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/MainActivity.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/MainActivity.java
@@ -47,8 +47,6 @@
import android.widget.TextView;
import android.widget.Toast;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
@@ -76,13 +74,18 @@
import com.example.androidx.mediarouting.player.Player;
import com.example.androidx.mediarouting.player.RemotePlayer;
import com.example.androidx.mediarouting.providers.SampleMediaRouteProvider;
+import com.example.androidx.mediarouting.providers.WrapperMediaRouteProvider;
import com.example.androidx.mediarouting.session.SessionManager;
import com.example.androidx.mediarouting.ui.LibraryAdapter;
import com.example.androidx.mediarouting.ui.PlaylistAdapter;
+import com.example.androidx.mediarouting.util.Utils;
import com.google.common.base.Function;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.File;
import java.util.List;
@@ -111,6 +114,8 @@
createTransferListener();
private final MediaRouter.Callback mMediaRouterCB = new SampleMediaRouterCallback();
+ private boolean mSimpleRouteProviderEnabled;
+ private boolean mWrapperRouteProviderEnabled;
private MediaRouter mMediaRouter;
private MediaRouteSelector mSelector;
private PlaylistAdapter mPlayListItems;
@@ -130,6 +135,8 @@
requestRequiredPermissions();
+ initializeMediaRouteProviderService();
+
mMediaRouter = MediaRouter.getInstance(this);
mMediaRouter.setRouterParams(getRouterParams());
@@ -137,14 +144,19 @@
routesManager.reloadDialogType();
// Create a route selector for the type of routes that we care about.
- mSelector =
+ MediaRouteSelector.Builder selectorBuilder =
new MediaRouteSelector.Builder()
.addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)
.addControlCategory(MediaControlIntent.CATEGORY_REMOTE_AUDIO_PLAYBACK)
.addControlCategory(MediaControlIntent.CATEGORY_REMOTE_VIDEO_PLAYBACK)
- .addControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO)
- .addControlCategory(SampleMediaRouteProvider.CATEGORY_SAMPLE_ROUTE)
- .build();
+ .addControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO);
+ if (mSimpleRouteProviderEnabled) {
+ selectorBuilder.addControlCategory(SampleMediaRouteProvider.CATEGORY_SAMPLE_ROUTE);
+ }
+ if (mWrapperRouteProviderEnabled) {
+ selectorBuilder.addControlCategory(WrapperMediaRouteProvider.CATEGORY_WRAPPER_ROUTE);
+ }
+ mSelector = selectorBuilder.build();
mMediaRouter.setOnPrepareTransferListener(mOnPrepareTransferListener);
@@ -307,9 +319,9 @@
if (mediaRouteActionProvider != null) {
mediaRouteActionProvider.setRouteSelector(mSelector);
mediaRouteActionProvider.setDialogFactory(new MediaRouteDialogFactory() {
- @NonNull
@Override
- public MediaRouteControllerDialogFragment onCreateControllerDialogFragment() {
+ public @NonNull MediaRouteControllerDialogFragment
+ onCreateControllerDialogFragment() {
return new ControllerDialogFragment(MainActivity.this,
mUseDefaultControlCheckBox);
}
@@ -393,6 +405,16 @@
}
}
+ private void initializeMediaRouteProviderService() {
+ Context context = getApplicationContext();
+ mSimpleRouteProviderEnabled =
+ SettingsPreferenceFragment.isSimpleRouteProviderEnabled(context);
+ Utils.setSimpleRouteProviderServiceEnabled(context, mSimpleRouteProviderEnabled);
+ mWrapperRouteProviderEnabled =
+ SettingsPreferenceFragment.isWrapperRouteProviderEnabled(context);
+ Utils.setWrapperRouteProviderServiceEnabled(context, mWrapperRouteProviderEnabled);
+ }
+
private void createMediaSession() {
// Create the MediaSession
mMediaSession = new MediaSessionCompat(this, "SampleMediaRouter", mEventReceiver,
@@ -524,8 +546,7 @@
mSeekBar.setEnabled(item != null && item.getDuration() > 0);
}
- @Nullable
- private PlaylistItem getCheckedPlaylistItem() {
+ private @Nullable PlaylistItem getCheckedPlaylistItem() {
int count = mPlayListView.getCount();
int index = mPlayListView.getCheckedItemPosition();
if (count > 0) {
@@ -543,12 +564,13 @@
? 0 : (SystemClock.elapsedRealtime() - item.getTimestamp()));
}
- @NonNull
- private MediaRouterParams getRouterParams() {
- return new MediaRouterParams.Builder()
- .setDialogType(MediaRouterParams.DIALOG_TYPE_DEFAULT)
- .setTransferToLocalEnabled(true) // Phone speaker will be shown when casting.
- .build();
+ private @NonNull MediaRouterParams getRouterParams() {
+ MediaRouterParams.Builder routerParams =
+ new MediaRouterParams.Builder()
+ .setDialogType(MediaRouterParams.DIALOG_TYPE_DEFAULT)
+ .setTransferToLocalEnabled(
+ true); // Phone speaker will be shown when casting.
+ return routerParams.build();
}
/**
@@ -569,13 +591,12 @@
public static final class DiscoveryFragment extends MediaRouteDiscoveryFragment {
private MediaRouter.Callback mCallback;
- public void setCallback(@Nullable MediaRouter.Callback cb) {
+ public void setCallback(MediaRouter.@Nullable Callback cb) {
mCallback = cb;
}
- @Nullable
@Override
- public MediaRouter.Callback onCreateCallback() {
+ public MediaRouter.@Nullable Callback onCreateCallback() {
return mCallback;
}
@@ -738,9 +759,8 @@
mUseDefaultControlCheckBox = customControlViewCheckBox;
}
- @NonNull
@Override
- public MediaRouteControllerDialog onCreateControllerDialog(
+ public @NonNull MediaRouteControllerDialog onCreateControllerDialog(
@NonNull Context context, @Nullable Bundle savedInstanceState) {
mMainActivity.updateStatusFromSessionManager();
mControllerDialog =
@@ -795,9 +815,8 @@
@RequiresApi(30)
private class TransferListener implements MediaRouter.OnPrepareTransferListener {
- @Nullable
@Override
- public ListenableFuture<Void> onPrepareTransfer(@NonNull RouteInfo fromRoute,
+ public @Nullable ListenableFuture<Void> onPrepareTransfer(@NonNull RouteInfo fromRoute,
@NonNull RouteInfo toRoute) {
Log.d(TAG, "onPrepareTransfer: from=" + fromRoute.getId()
+ ", to=" + toRoute.getId());
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/RouteListingPreferenceActivity.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/RouteListingPreferenceActivity.java
index 94ac61d..56efb701 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/RouteListingPreferenceActivity.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/RouteListingPreferenceActivity.java
@@ -35,8 +35,6 @@
import android.widget.TextView;
import android.widget.Toast;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.MenuItemCompat;
@@ -57,6 +55,9 @@
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.common.collect.ImmutableList;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -280,8 +281,8 @@
mRoutesManager.setRouteListingPreferenceItems(newRouteListingPreference);
}
- @NonNull
- private ImmutableList<MediaRouter.RouteInfo> getRoutesWithNoAssociatedListingPreferenceItem() {
+ private @NonNull ImmutableList<MediaRouter.RouteInfo>
+ getRoutesWithNoAssociatedListingPreferenceItem() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
return ImmutableList.of();
}
@@ -319,8 +320,8 @@
@Override
public boolean onMove(
@NonNull RecyclerView recyclerView,
- @NonNull RecyclerView.ViewHolder origin,
- @NonNull RecyclerView.ViewHolder target) {
+ RecyclerView.@NonNull ViewHolder origin,
+ RecyclerView.@NonNull ViewHolder target) {
int fromPosition = origin.getBindingAdapterPosition();
int toPosition = target.getBindingAdapterPosition();
if (mDraggingFromPosition == INDEX_UNSET) {
@@ -334,7 +335,7 @@
}
@Override
- public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
+ public void onSwiped(RecyclerView.@NonNull ViewHolder viewHolder, int direction) {
ArrayList<RouteListingPreferenceItemHolder> newRouteListingPreference =
new ArrayList<>(mRoutesManager.getRouteListingPreferenceItems());
int itemPosition = viewHolder.getBindingAdapterPosition();
@@ -345,7 +346,7 @@
@Override
public void clearView(
- @NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
+ @NonNull RecyclerView recyclerView, RecyclerView.@NonNull ViewHolder viewHolder) {
super.clearView(recyclerView, viewHolder);
if (mDraggingFromPosition != INDEX_UNSET) {
ArrayList<RouteListingPreferenceItemHolder> newRouteListingPreference =
@@ -362,9 +363,8 @@
private class RouteListingPreferenceRecyclerViewAdapter
extends RecyclerView.Adapter<RecyclerViewItemViewHolder> {
- @NonNull
@Override
- public RecyclerViewItemViewHolder onCreateViewHolder(
+ public @NonNull RecyclerViewItemViewHolder onCreateViewHolder(
@NonNull ViewGroup parent, int viewType) {
TextView textView =
(TextView)
@@ -421,9 +421,8 @@
mHumanReadableString = humanReadableString;
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
return mHumanReadableString;
}
@@ -460,16 +459,15 @@
RouteListingPreference.Item.SUBTEXT_CUSTOM, "Custom text (placeholder value)");
public final int mConstant;
- @NonNull public final String mHumanReadableString;
+ public final @NonNull String mHumanReadableString;
RouteListingPreferenceItemSubtext(int constant, @NonNull String humanReadableString) {
mConstant = constant;
mHumanReadableString = humanReadableString;
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
return mHumanReadableString;
}
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/SettingsActivity.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/SettingsActivity.java
index 1285855..9ac8a2b 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/SettingsActivity.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/SettingsActivity.java
@@ -31,8 +31,6 @@
import android.widget.Spinner;
import android.widget.Switch;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatButton;
import androidx.mediarouter.media.MediaRouter;
@@ -44,10 +42,12 @@
import com.example.androidx.mediarouting.RoutesManager;
import com.example.androidx.mediarouting.activities.systemrouting.SystemRoutingActivity;
import com.example.androidx.mediarouting.services.SampleDynamicGroupMediaRouteProviderService;
-import com.example.androidx.mediarouting.services.SampleMediaRouteProviderService;
import com.example.androidx.mediarouting.ui.RoutesAdapter;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Allows the user to control dialog types, enabling or disabling Dynamic Groups, enabling or
* disabling transfer to local and customize the routes exposed by {@link
@@ -140,7 +140,6 @@
private void setUpViews() {
setUpDynamicGroupsEnabledSwitch();
setUpTransferToLocalSwitch();
- setUpSimpleProviderEnabledSwitch();
setUpDynamicProviderEnabledSwitch();
setUpDialogTypeDropDownList();
setUpNewRouteButton();
@@ -173,25 +172,6 @@
});
}
- private void setUpSimpleProviderEnabledSwitch() {
- Switch simpleProviderEnabledSwitch = findViewById(R.id.enable_simple_provider_switch);
- ComponentName simpleProviderComponentName =
- new ComponentName(/* context= */ this, SampleMediaRouteProviderService.class);
- simpleProviderEnabledSwitch.setChecked(
- mPackageManager.getComponentEnabledSetting(simpleProviderComponentName)
- != PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
- simpleProviderEnabledSwitch.setOnCheckedChangeListener(
- (compoundButton, enabled) -> {
- mPackageManager
- .setComponentEnabledSetting(
- simpleProviderComponentName,
- enabled
- ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
- : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
- /* flags= */ PackageManager.DONT_KILL_APP);
- });
- }
-
private void setUpDynamicProviderEnabledSwitch() {
Switch dynamicProviderEnabledSwitch = findViewById(R.id.enable_dynamic_provider_switch);
ComponentName dynamicProviderComponentName =
@@ -268,7 +248,7 @@
private static class ProviderServiceConnection implements ServiceConnection {
- @Nullable private SampleDynamicGroupMediaRouteProviderService mService;
+ private @Nullable SampleDynamicGroupMediaRouteProviderService mService;
@Override
public void onServiceConnected(ComponentName className, IBinder service) {
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/SettingsPreferenceFragment.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/SettingsPreferenceFragment.java
new file mode 100644
index 0000000..a42933c
--- /dev/null
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/SettingsPreferenceFragment.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.androidx.mediarouting.activities;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+
+import androidx.preference.PreferenceFragmentCompat;
+import androidx.preference.PreferenceManager;
+
+import com.example.androidx.mediarouting.R;
+import com.example.androidx.mediarouting.util.Utils;
+
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
+/** The preference fragment to show the switch settings. */
+public class SettingsPreferenceFragment extends PreferenceFragmentCompat
+ implements SharedPreferences.OnSharedPreferenceChangeListener {
+ private static final String TAG = "SettingsPreference";
+ private static final String PREF_KEY_SIMPLE_ROUTE_PROVIDER = "enable_simple_route_provider";
+ private static final boolean PREF_DEFAULT_VALUE_ENABLE_SIMPLE_ROUTE_PROVIDER = true;
+ private static final String PREF_KEY_WRAPPER_ROUTE_PROVIDER = "enable_wrapper_route_provider";
+ private static final boolean PREF_DEFAULT_VALUE_ENABLE_WRAPPER_ROUTE_PROVIDER = false;
+ private Context mContext;
+
+ @Override
+ public void onCreatePreferences(@Nullable Bundle savedInstanceState, @Nullable String rootKey) {
+ setPreferencesFromResource(R.xml.settings_preference, rootKey);
+ mContext = getPreferenceManager().getContext();
+
+ SharedPreferences sharedPreferences = getPreferenceScreen().getSharedPreferences();
+ if (sharedPreferences != null) {
+ sharedPreferences.registerOnSharedPreferenceChangeListener(this);
+ }
+ }
+
+ /** Returns {@code true} if the simple route provider is enables. */
+ public static boolean isSimpleRouteProviderEnabled(@NonNull Context context) {
+ SharedPreferences sharedPreferences =
+ PreferenceManager.getDefaultSharedPreferences(context);
+ return sharedPreferences.getBoolean(
+ PREF_KEY_SIMPLE_ROUTE_PROVIDER, PREF_DEFAULT_VALUE_ENABLE_SIMPLE_ROUTE_PROVIDER);
+ }
+
+ /** Returns {@code true} if the wrapper route provider is enables. */
+ public static boolean isWrapperRouteProviderEnabled(@NonNull Context context) {
+ SharedPreferences sharedPreferences =
+ PreferenceManager.getDefaultSharedPreferences(context);
+ return sharedPreferences.getBoolean(
+ PREF_KEY_WRAPPER_ROUTE_PROVIDER, PREF_DEFAULT_VALUE_ENABLE_WRAPPER_ROUTE_PROVIDER);
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(
+ @NonNull SharedPreferences sharedPreferences, @NonNull String key) {
+ switch (key) {
+ case PREF_KEY_SIMPLE_ROUTE_PROVIDER:
+ updateSimpleRouteProviderConfiguration(sharedPreferences);
+ break;
+ case PREF_KEY_WRAPPER_ROUTE_PROVIDER:
+ updateWrapperRouteProviderConfiguration(sharedPreferences);
+ break;
+ default:
+ // Ignored.
+ }
+ }
+
+ private void updateSimpleRouteProviderConfiguration(
+ @NonNull SharedPreferences sharedPreferences) {
+ boolean enabled =
+ sharedPreferences.getBoolean(
+ PREF_KEY_SIMPLE_ROUTE_PROVIDER,
+ PREF_DEFAULT_VALUE_ENABLE_SIMPLE_ROUTE_PROVIDER);
+ Utils.setSimpleRouteProviderServiceEnabled(mContext, enabled);
+ }
+
+ private void updateWrapperRouteProviderConfiguration(
+ @NonNull SharedPreferences sharedPreferences) {
+ boolean enabled =
+ sharedPreferences.getBoolean(
+ PREF_KEY_WRAPPER_ROUTE_PROVIDER,
+ PREF_DEFAULT_VALUE_ENABLE_WRAPPER_ROUTE_PROVIDER);
+ Utils.setWrapperRouteProviderServiceEnabled(mContext, enabled);
+ }
+}
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/SystemRouteItem.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/SystemRouteItem.java
index 0f331cd..bb7b8b8 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/SystemRouteItem.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/SystemRouteItem.java
@@ -18,11 +18,11 @@
import android.text.TextUtils;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
import com.example.androidx.mediarouting.activities.systemrouting.source.SystemRoutesSource;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Objects;
/** Holds information about a system route. */
@@ -50,24 +50,24 @@
}
/** The {@link SystemRoutesSource#getSourceId()} of the source that created this item. */
- @NonNull public final String mSourceId;
+ public final @NonNull String mSourceId;
/** An id that uniquely identifies this route item within the source. */
- @NonNull public final String mId;
+ public final @NonNull String mId;
- @NonNull public final String mName;
+ public final @NonNull String mName;
- @Nullable public final String mAddress;
+ public final @Nullable String mAddress;
- @Nullable public final String mDescription;
+ public final @Nullable String mDescription;
- @Nullable public final String mSuitabilityStatus;
+ public final @Nullable String mSuitabilityStatus;
- @Nullable public final Boolean mTransferInitiatedBySelf;
+ public final @Nullable Boolean mTransferInitiatedBySelf;
- @Nullable public final String mTransferReason;
+ public final @Nullable String mTransferReason;
- @NonNull public final SelectionSupportState mSelectionSupportState;
+ public final @NonNull SelectionSupportState mSelectionSupportState;
private SystemRouteItem(@NonNull Builder builder) {
mSourceId = Objects.requireNonNull(builder.mSourceId);
@@ -116,15 +116,15 @@
*/
public static final class Builder {
- @NonNull private String mSourceId;
- @NonNull private final String mId;
- @NonNull private String mName;
- @Nullable private String mAddress;
- @Nullable private String mDescription;
- @Nullable private String mSuitabilityStatus;
- @Nullable private Boolean mTransferInitiatedBySelf;
- @Nullable private String mTransferReason;
- @NonNull public SelectionSupportState mSelectionSupportState;
+ private @NonNull String mSourceId;
+ private final @NonNull String mId;
+ private @NonNull String mName;
+ private @Nullable String mAddress;
+ private @Nullable String mDescription;
+ private @Nullable String mSuitabilityStatus;
+ private @Nullable Boolean mTransferInitiatedBySelf;
+ private @Nullable String mTransferReason;
+ public @NonNull SelectionSupportState mSelectionSupportState;
/**
* Creates a builder with the mandatory properties.
@@ -141,8 +141,7 @@
/**
* Sets a route name.
*/
- @NonNull
- public Builder setName(@NonNull String name) {
+ public @NonNull Builder setName(@NonNull String name) {
mName = name;
return this;
}
@@ -150,8 +149,7 @@
/**
* Sets an address for the route.
*/
- @NonNull
- public Builder setAddress(@NonNull String address) {
+ public @NonNull Builder setAddress(@NonNull String address) {
if (!TextUtils.isEmpty(address)) {
mAddress = address;
}
@@ -161,8 +159,7 @@
/**
* Sets a description for the route.
*/
- @NonNull
- public Builder setDescription(@NonNull String description) {
+ public @NonNull Builder setDescription(@NonNull String description) {
if (!TextUtils.isEmpty(description)) {
mDescription = description;
}
@@ -173,8 +170,7 @@
* Sets a human-readable string describing the transfer suitability of the route, or null if
* not applicable.
*/
- @NonNull
- public Builder setSuitabilityStatus(@Nullable String suitabilityStatus) {
+ public @NonNull Builder setSuitabilityStatus(@Nullable String suitabilityStatus) {
mSuitabilityStatus = suitabilityStatus;
return this;
}
@@ -183,8 +179,8 @@
* Sets whether the corresponding route's selection is the result of an action of this app,
* or null if not applicable.
*/
- @NonNull
- public Builder setTransferInitiatedBySelf(@Nullable Boolean transferInitiatedBySelf) {
+ public @NonNull Builder setTransferInitiatedBySelf(
+ @Nullable Boolean transferInitiatedBySelf) {
mTransferInitiatedBySelf = transferInitiatedBySelf;
return this;
}
@@ -192,15 +188,13 @@
/**
* Sets a human-readable string describing the transfer reason, or null if not applicable.
*/
- @NonNull
- public Builder setTransferReason(@Nullable String transferReason) {
+ public @NonNull Builder setTransferReason(@Nullable String transferReason) {
mTransferReason = transferReason;
return this;
}
/** Sets the {@link SelectionSupportState} for the corresponding route. */
- @NonNull
- public Builder setSelectionSupportState(
+ public @NonNull Builder setSelectionSupportState(
@NonNull SelectionSupportState selectionSupportState) {
mSelectionSupportState = Objects.requireNonNull(selectionSupportState);
return this;
@@ -209,8 +203,7 @@
/**
* Builds {@link SystemRouteItem}.
*/
- @NonNull
- public SystemRouteItem build() {
+ public @NonNull SystemRouteItem build() {
return new SystemRouteItem(this);
}
}
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/SystemRoutesAdapter.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/SystemRoutesAdapter.java
index 764c050..22b6c57 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/SystemRoutesAdapter.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/SystemRoutesAdapter.java
@@ -26,8 +26,6 @@
import android.view.ViewGroup;
import android.widget.TextView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatButton;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.util.Consumer;
@@ -37,6 +35,9 @@
import com.example.androidx.mediarouting.R;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/** {@link RecyclerView.Adapter} for showing system route sources and their corresponding routes. */
@@ -57,14 +58,13 @@
mListDiffer.submitList(newItems);
}
- @NonNull
- public List<SystemRoutesAdapterItem> getItems() {
+ public @NonNull List<SystemRoutesAdapterItem> getItems() {
return mListDiffer.getCurrentList();
}
- @NonNull
@Override
- public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ public RecyclerView.@NonNull ViewHolder onCreateViewHolder(@NonNull ViewGroup parent,
+ int viewType) {
Context context = parent.getContext();
if (viewType == VIEW_TYPE_HEADER) {
View view = LayoutInflater.from(context).inflate(R.layout.item_system_route_header,
@@ -78,7 +78,7 @@
}
@Override
- public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
+ public void onBindViewHolder(RecyclerView.@NonNull ViewHolder holder, int position) {
SystemRoutesAdapterItem routeItem = getItems().get(position);
if (routeItem instanceof SystemRoutesSourceItem && holder instanceof HeaderViewHolder) {
((HeaderViewHolder) holder).bind((SystemRoutesSourceItem) routeItem);
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/SystemRoutesSourceItem.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/SystemRoutesSourceItem.java
index 9a5129e..9d97e01 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/SystemRoutesSourceItem.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/SystemRoutesSourceItem.java
@@ -18,7 +18,7 @@
import android.text.TextUtils;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
import java.util.Objects;
@@ -27,14 +27,13 @@
*/
public final class SystemRoutesSourceItem implements SystemRoutesAdapterItem {
- @NonNull private final String mName;
+ private final @NonNull String mName;
public SystemRoutesSourceItem(@NonNull String name) {
mName = name;
}
- @NonNull
- public String getSourceName() {
+ public @NonNull String getSourceName() {
return mName;
}
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/SystemRoutingActivity.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/SystemRoutingActivity.java
index 6f18b57..efde5a5 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/SystemRoutingActivity.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/SystemRoutingActivity.java
@@ -26,8 +26,6 @@
import android.os.Bundle;
import android.widget.Toast;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
@@ -43,6 +41,9 @@
import com.example.androidx.mediarouting.activities.systemrouting.source.MediaRouterSystemRoutesSource;
import com.example.androidx.mediarouting.activities.systemrouting.source.SystemRoutesSource;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -55,12 +56,11 @@
private static final int REQUEST_CODE_BLUETOOTH_CONNECT = 4199;
- @NonNull
- private final SystemRoutesAdapter mSystemRoutesAdapter =
+ private final @NonNull SystemRoutesAdapter mSystemRoutesAdapter =
new SystemRoutesAdapter(this::onRouteItemClicked);
- @NonNull private final Map<String, SystemRoutesSource> mSystemRoutesSources = new HashMap<>();
- @NonNull private SwipeRefreshLayout mSwipeRefreshLayout;
+ private final @NonNull Map<String, SystemRoutesSource> mSystemRoutesSources = new HashMap<>();
+ private @NonNull SwipeRefreshLayout mSwipeRefreshLayout;
/**
* Creates and launches an intent to start current activity.
@@ -101,8 +101,8 @@
}
@Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
- @NonNull int[] grantResults) {
+ public void onRequestPermissionsResult(int requestCode, String @NonNull [] permissions,
+ int @NonNull [] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQUEST_CODE_BLUETOOTH_CONNECT
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/AndroidXMediaRouterSystemRoutesSource.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/AndroidXMediaRouterSystemRoutesSource.java
index d7763d0..ee3896b 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/AndroidXMediaRouterSystemRoutesSource.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/AndroidXMediaRouterSystemRoutesSource.java
@@ -18,7 +18,6 @@
import android.content.Context;
-import androidx.annotation.NonNull;
import androidx.mediarouter.media.MediaControlIntent;
import androidx.mediarouter.media.MediaRouteSelector;
import androidx.mediarouter.media.MediaRouter;
@@ -26,57 +25,56 @@
import com.example.androidx.mediarouting.activities.systemrouting.SystemRouteItem;
import com.example.androidx.mediarouting.activities.systemrouting.SystemRoutesSourceItem;
+import org.jspecify.annotations.NonNull;
+
import java.util.ArrayList;
import java.util.List;
/** Implements {@link SystemRoutesSource} using {@link MediaRouter}. */
public final class AndroidXMediaRouterSystemRoutesSource extends SystemRoutesSource {
- @NonNull
- private final MediaRouter mMediaRouter;
+ private final @NonNull MediaRouter mMediaRouter;
- @NonNull
- private final MediaRouter.Callback mMediaRouterCallback =
+ private final MediaRouter.@NonNull Callback mMediaRouterCallback =
new MediaRouter.Callback() {
@Override
public void onRouteAdded(
- @NonNull MediaRouter router, @NonNull MediaRouter.RouteInfo route) {
+ @NonNull MediaRouter router, MediaRouter.@NonNull RouteInfo route) {
mOnRoutesChangedListener.run();
}
@Override
public void onRouteRemoved(
- @NonNull MediaRouter router, @NonNull MediaRouter.RouteInfo route) {
+ @NonNull MediaRouter router, MediaRouter.@NonNull RouteInfo route) {
mOnRoutesChangedListener.run();
}
@Override
public void onRouteSelected(
@NonNull MediaRouter router,
- @NonNull MediaRouter.RouteInfo selectedRoute,
+ MediaRouter.@NonNull RouteInfo selectedRoute,
int reason,
- @NonNull MediaRouter.RouteInfo requestedRoute) {
+ MediaRouter.@NonNull RouteInfo requestedRoute) {
mOnRoutesChangedListener.run();
}
@Override
public void onRouteUnselected(
@NonNull MediaRouter router,
- @NonNull MediaRouter.RouteInfo route,
+ MediaRouter.@NonNull RouteInfo route,
int reason) {
mOnRoutesChangedListener.run();
}
@Override
public void onRouteChanged(
- @NonNull MediaRouter router, @NonNull MediaRouter.RouteInfo route) {
+ @NonNull MediaRouter router, MediaRouter.@NonNull RouteInfo route) {
mOnRoutesChangedListener.run();
}
};
/** Returns a new instance. */
- @NonNull
- public static AndroidXMediaRouterSystemRoutesSource create(@NonNull Context context) {
+ public static @NonNull AndroidXMediaRouterSystemRoutesSource create(@NonNull Context context) {
MediaRouter mediaRouter = MediaRouter.getInstance(context);
return new AndroidXMediaRouterSystemRoutesSource(mediaRouter);
}
@@ -100,15 +98,13 @@
mMediaRouter.removeCallback(mMediaRouterCallback);
}
- @NonNull
@Override
- public SystemRoutesSourceItem getSourceItem() {
+ public @NonNull SystemRoutesSourceItem getSourceItem() {
return new SystemRoutesSourceItem(/* name= */ "AndroidX MediaRouter");
}
- @NonNull
@Override
- public List<SystemRouteItem> fetchSourceRouteItems() {
+ public @NonNull List<SystemRouteItem> fetchSourceRouteItems() {
List<SystemRouteItem> out = new ArrayList<>();
for (MediaRouter.RouteInfo routeInfo : mMediaRouter.getRoutes()) {
@@ -133,8 +129,7 @@
return false;
}
- @NonNull
- private SystemRouteItem createRouteItemFor(@NonNull MediaRouter.RouteInfo routeInfo) {
+ private @NonNull SystemRouteItem createRouteItemFor(MediaRouter.@NonNull RouteInfo routeInfo) {
SystemRouteItem.Builder builder =
new SystemRouteItem.Builder(getSourceId(), routeInfo.getId())
.setName(routeInfo.getName());
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/AudioManagerSystemRoutesSource.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/AudioManagerSystemRoutesSource.java
index 9e7b67a..e3d708a 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/AudioManagerSystemRoutesSource.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/AudioManagerSystemRoutesSource.java
@@ -22,12 +22,13 @@
import android.media.AudioManager;
import android.os.Build;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import com.example.androidx.mediarouting.activities.systemrouting.SystemRouteItem;
import com.example.androidx.mediarouting.activities.systemrouting.SystemRoutesSourceItem;
+import org.jspecify.annotations.NonNull;
+
import java.util.ArrayList;
import java.util.List;
@@ -35,11 +36,9 @@
@RequiresApi(Build.VERSION_CODES.M)
public final class AudioManagerSystemRoutesSource extends SystemRoutesSource {
- @NonNull
- private final AudioManager mAudioManager;
+ private final @NonNull AudioManager mAudioManager;
- @NonNull
- private final AudioDeviceCallback mAudioDeviceCallback =
+ private final @NonNull AudioDeviceCallback mAudioDeviceCallback =
new AudioDeviceCallback() {
@Override
public void onAudioDevicesAdded(AudioDeviceInfo[] addedDevices) {
@@ -53,8 +52,7 @@
};
/** Returns a new instance. */
- @NonNull
- public static AudioManagerSystemRoutesSource create(@NonNull Context context) {
+ public static @NonNull AudioManagerSystemRoutesSource create(@NonNull Context context) {
AudioManager audioManager = context.getSystemService(AudioManager.class);
return new AudioManagerSystemRoutesSource(audioManager);
}
@@ -73,15 +71,13 @@
mAudioManager.unregisterAudioDeviceCallback(mAudioDeviceCallback);
}
- @NonNull
@Override
- public SystemRoutesSourceItem getSourceItem() {
+ public @NonNull SystemRoutesSourceItem getSourceItem() {
return new SystemRoutesSourceItem(/* name= */ "AudioManager");
}
- @NonNull
@Override
- public List<SystemRouteItem> fetchSourceRouteItems() {
+ public @NonNull List<SystemRouteItem> fetchSourceRouteItems() {
List<SystemRouteItem> out = new ArrayList<>();
AudioDeviceInfo[] deviceInfos = mAudioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS);
@@ -97,8 +93,7 @@
throw new UnsupportedOperationException();
}
- @NonNull
- private SystemRouteItem createRouteItemFor(@NonNull AudioDeviceInfo audioDeviceInfo) {
+ private @NonNull SystemRouteItem createRouteItemFor(@NonNull AudioDeviceInfo audioDeviceInfo) {
SystemRouteItem.Builder builder =
new SystemRouteItem.Builder(getSourceId(), String.valueOf(audioDeviceInfo.getId()))
.setName(audioDeviceInfo.getProductName().toString());
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/BluetoothManagerSystemRoutesSource.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/BluetoothManagerSystemRoutesSource.java
index 7bc34d7..c024e65 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/BluetoothManagerSystemRoutesSource.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/BluetoothManagerSystemRoutesSource.java
@@ -28,31 +28,27 @@
import android.content.Intent;
import android.content.IntentFilter;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresPermission;
import com.example.androidx.mediarouting.activities.systemrouting.SystemRouteItem;
import com.example.androidx.mediarouting.activities.systemrouting.SystemRoutesSourceItem;
+import org.jspecify.annotations.NonNull;
+
import java.util.ArrayList;
import java.util.List;
/** Implements {@link SystemRoutesSource} using {@link BluetoothManager}. */
public final class BluetoothManagerSystemRoutesSource extends SystemRoutesSource {
- @NonNull
- private final Context mContext;
- @NonNull
- private final BluetoothManager mBluetoothManager;
- @NonNull
- private final BluetoothAdapter mBluetoothAdapter;
- @NonNull
- private final DeviceStateChangedReceiver mDeviceStateChangedReceiver =
+ private final @NonNull Context mContext;
+ private final @NonNull BluetoothManager mBluetoothManager;
+ private final @NonNull BluetoothAdapter mBluetoothAdapter;
+ private final @NonNull DeviceStateChangedReceiver mDeviceStateChangedReceiver =
new DeviceStateChangedReceiver();
/** Returns a new instance. */
- @NonNull
- public static BluetoothManagerSystemRoutesSource create(@NonNull Context context) {
+ public static @NonNull BluetoothManagerSystemRoutesSource create(@NonNull Context context) {
BluetoothManager bluetoothManager =
(BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
return new BluetoothManagerSystemRoutesSource(context, bluetoothManager);
@@ -83,16 +79,14 @@
mContext.unregisterReceiver(mDeviceStateChangedReceiver);
}
- @NonNull
@Override
- public SystemRoutesSourceItem getSourceItem() {
+ public @NonNull SystemRoutesSourceItem getSourceItem() {
return new SystemRoutesSourceItem(/* name= */ "BluetoothManager");
}
- @NonNull
@RequiresPermission(Manifest.permission.BLUETOOTH_CONNECT)
@Override
- public List<SystemRouteItem> fetchSourceRouteItems() {
+ public @NonNull List<SystemRouteItem> fetchSourceRouteItems() {
List<SystemRouteItem> out = new ArrayList<>();
for (BluetoothDevice device : mBluetoothAdapter.getBondedDevices()) {
@@ -107,9 +101,8 @@
throw new UnsupportedOperationException();
}
- @NonNull
@RequiresPermission(Manifest.permission.BLUETOOTH_CONNECT)
- private SystemRouteItem createRouteItemFor(@NonNull BluetoothDevice device) {
+ private @NonNull SystemRouteItem createRouteItemFor(@NonNull BluetoothDevice device) {
return new SystemRouteItem.Builder(getSourceId(), /* id= */ device.getAddress())
.setName(device.getName())
.setAddress(device.getAddress())
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/MediaRouter2SystemRoutesSource.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/MediaRouter2SystemRoutesSource.java
index 1c85f85..828eef4 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/MediaRouter2SystemRoutesSource.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/MediaRouter2SystemRoutesSource.java
@@ -25,13 +25,14 @@
import android.os.Build;
import androidx.annotation.DoNotInline;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.example.androidx.mediarouting.activities.systemrouting.SystemRouteItem;
import com.example.androidx.mediarouting.activities.systemrouting.SystemRoutesSourceItem;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -46,15 +47,14 @@
@RequiresApi(Build.VERSION_CODES.R)
public final class MediaRouter2SystemRoutesSource extends SystemRoutesSource {
- @NonNull private final Context mContext;
- @NonNull private final MediaRouter2 mMediaRouter2;
- @Nullable private final Method mSuitabilityStatusMethod;
- @Nullable private final Method mWasTransferInitiatedBySelfMethod;
- @Nullable private final Method mTransferReasonMethod;
- @NonNull private final ArrayList<SystemRouteItem> mRouteItems = new ArrayList<>();
+ private final @NonNull Context mContext;
+ private final @NonNull MediaRouter2 mMediaRouter2;
+ private final @Nullable Method mSuitabilityStatusMethod;
+ private final @Nullable Method mWasTransferInitiatedBySelfMethod;
+ private final @Nullable Method mTransferReasonMethod;
+ private final @NonNull ArrayList<SystemRouteItem> mRouteItems = new ArrayList<>();
- @NonNull
- private final MediaRouter2.RouteCallback mRouteCallback =
+ private final MediaRouter2.@NonNull RouteCallback mRouteCallback =
new MediaRouter2.RouteCallback() {
@Override
public void onRoutesUpdated(@NonNull List<MediaRoute2Info> routes) {
@@ -62,19 +62,17 @@
}
};
- @NonNull
- private final MediaRouter2.ControllerCallback mControllerCallback =
+ private final MediaRouter2.@NonNull ControllerCallback mControllerCallback =
new MediaRouter2.ControllerCallback() {
@Override
public void onControllerUpdated(
- @NonNull MediaRouter2.RoutingController unusedController) {
+ MediaRouter2.@NonNull RoutingController unusedController) {
populateRouteItems(mMediaRouter2.getRoutes());
}
};
/** Returns a new instance. */
- @NonNull
- public static MediaRouter2SystemRoutesSource create(@NonNull Context context) {
+ public static @NonNull MediaRouter2SystemRoutesSource create(@NonNull Context context) {
MediaRouter2 mediaRouter2 = MediaRouter2.getInstance(context);
return new MediaRouter2SystemRoutesSource(context, mediaRouter2);
}
@@ -125,15 +123,13 @@
mMediaRouter2.unregisterRouteCallback(mRouteCallback);
}
- @NonNull
@Override
- public SystemRoutesSourceItem getSourceItem() {
+ public @NonNull SystemRoutesSourceItem getSourceItem() {
return new SystemRoutesSourceItem(/* name= */ "MediaRouter2");
}
- @NonNull
@Override
- public List<SystemRouteItem> fetchSourceRouteItems() {
+ public @NonNull List<SystemRouteItem> fetchSourceRouteItems() {
return mRouteItems;
}
@@ -193,8 +189,7 @@
mOnRoutesChangedListener.run();
}
- @NonNull
- private SystemRouteItem createRouteItemFor(
+ private @NonNull SystemRouteItem createRouteItemFor(
@NonNull MediaRoute2Info routeInfo,
boolean isSelectedRoute,
@Nullable Boolean wasTransferredBySelf,
@@ -224,8 +219,7 @@
return builder.build();
}
- @NonNull
- private String getHumanReadableSuitabilityStatus(@Nullable Integer status) {
+ private @NonNull String getHumanReadableSuitabilityStatus(@Nullable Integer status) {
if (status == null) {
// The route is not selected, or this Android version doesn't support suitability
// status.
@@ -243,8 +237,7 @@
}
}
- @NonNull
- private String getHumanReadableTransferReason(@Nullable Integer transferReason) {
+ private @NonNull String getHumanReadableTransferReason(@Nullable Integer transferReason) {
if (transferReason == null) {
// The route is not selected, or this Android version doesn't support transfer reason.
return null;
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/MediaRouterSystemRoutesSource.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/MediaRouterSystemRoutesSource.java
index 21d112f..bbcf097 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/MediaRouterSystemRoutesSource.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/MediaRouterSystemRoutesSource.java
@@ -20,22 +20,20 @@
import android.media.MediaRouter;
import android.text.TextUtils;
-import androidx.annotation.NonNull;
-
import com.example.androidx.mediarouting.activities.systemrouting.SystemRouteItem;
import com.example.androidx.mediarouting.activities.systemrouting.SystemRoutesSourceItem;
+import org.jspecify.annotations.NonNull;
+
import java.util.ArrayList;
import java.util.List;
/** Implements {@link SystemRoutesSource} using {@link MediaRouter}. */
public final class MediaRouterSystemRoutesSource extends SystemRoutesSource {
- @NonNull
- private final MediaRouter mMediaRouter;
+ private final @NonNull MediaRouter mMediaRouter;
- @NonNull
- private final MediaRouter.Callback mCallback =
+ private final MediaRouter.@NonNull Callback mCallback =
new MediaRouter.SimpleCallback() {
@Override
public void onRouteAdded(MediaRouter router, MediaRouter.RouteInfo info) {
@@ -66,8 +64,7 @@
};
/** Returns a new instance. */
- @NonNull
- public static MediaRouterSystemRoutesSource create(@NonNull Context context) {
+ public static @NonNull MediaRouterSystemRoutesSource create(@NonNull Context context) {
MediaRouter mediaRouter =
(MediaRouter) context.getSystemService(Context.MEDIA_ROUTER_SERVICE);
return new MediaRouterSystemRoutesSource(mediaRouter);
@@ -87,15 +84,13 @@
mMediaRouter.removeCallback(mCallback);
}
- @NonNull
@Override
- public SystemRoutesSourceItem getSourceItem() {
+ public @NonNull SystemRoutesSourceItem getSourceItem() {
return new SystemRoutesSourceItem(/* name= */ "Legacy MediaRouter");
}
- @NonNull
@Override
- public List<SystemRouteItem> fetchSourceRouteItems() {
+ public @NonNull List<SystemRouteItem> fetchSourceRouteItems() {
int count = mMediaRouter.getRouteCount();
List<SystemRouteItem> out = new ArrayList<>();
@@ -126,9 +121,8 @@
return false;
}
- @NonNull
- private SystemRouteItem createRouteItemFor(
- @NonNull MediaRouter.RouteInfo routeInfo, boolean isSelected) {
+ private @NonNull SystemRouteItem createRouteItemFor(
+ MediaRouter.@NonNull RouteInfo routeInfo, boolean isSelected) {
SystemRouteItem.Builder builder =
new SystemRouteItem.Builder(getSourceId(), /* id= */ routeInfo.getName().toString())
.setName(routeInfo.getName().toString());
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/SystemRoutesSource.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/SystemRoutesSource.java
index bad6317..d6fe390 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/SystemRoutesSource.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/activities/systemrouting/source/SystemRoutesSource.java
@@ -16,11 +16,11 @@
package com.example.androidx.mediarouting.activities.systemrouting.source;
-import androidx.annotation.NonNull;
-
import com.example.androidx.mediarouting.activities.systemrouting.SystemRouteItem;
import com.example.androidx.mediarouting.activities.systemrouting.SystemRoutesSourceItem;
+import org.jspecify.annotations.NonNull;
+
import java.util.List;
/**
@@ -28,7 +28,7 @@
*/
public abstract class SystemRoutesSource {
- @NonNull protected Runnable mOnRoutesChangedListener = () -> {};
+ protected @NonNull Runnable mOnRoutesChangedListener = () -> {};
/** Sets a {@link Runnable} to invoke whenever routes change. */
public void setOnRoutesChangedListener(@NonNull Runnable onRoutesChangedListener) {
@@ -51,22 +51,19 @@
}
/** Returns a string that uniquely identifies this source. */
- @NonNull
- public final String getSourceId() {
+ public final @NonNull String getSourceId() {
return getClass().getSimpleName();
}
/**
* Gets a source item containing source type.
*/
- @NonNull
- public abstract SystemRoutesSourceItem getSourceItem();
+ public abstract @NonNull SystemRoutesSourceItem getSourceItem();
/**
* Fetches a list of {@link SystemRouteItem} discovered by this source.
*/
- @NonNull
- public abstract List<SystemRouteItem> fetchSourceRouteItems();
+ public abstract @NonNull List<SystemRouteItem> fetchSourceRouteItems();
/**
* Selects the route that corresponds to the given item.
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/data/MediaItem.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/data/MediaItem.java
index 40f1172..506c114 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/data/MediaItem.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/data/MediaItem.java
@@ -18,7 +18,7 @@
import android.net.Uri;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* MediaItem helps keep track of the media items before adding to playlist.
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/data/PlaylistItem.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/data/PlaylistItem.java
index c111b2f..a7cb608 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/data/PlaylistItem.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/data/PlaylistItem.java
@@ -20,9 +20,10 @@
import android.net.Uri;
import android.os.SystemClock;
-import androidx.annotation.NonNull;
import androidx.mediarouter.media.MediaItemStatus;
+import org.jspecify.annotations.NonNull;
+
/**
* PlaylistItem helps keep track of the current status of an media item.
*/
@@ -87,38 +88,31 @@
mContentDuration = duration;
}
- @NonNull
- public String getSessionId() {
+ public @NonNull String getSessionId() {
return mSessionId;
}
- @NonNull
- public String getItemId() {
+ public @NonNull String getItemId() {
return mItemId;
}
- @NonNull
- public String getRemoteItemId() {
+ public @NonNull String getRemoteItemId() {
return mRemoteItemId;
}
- @NonNull
- public String getTitle() {
+ public @NonNull String getTitle() {
return mTitle;
}
- @NonNull
- public Uri getUri() {
+ public @NonNull Uri getUri() {
return mUri;
}
- @NonNull
- public String getMime() {
+ public @NonNull String getMime() {
return mMime;
}
- @NonNull
- public PendingIntent getUpdateReceiver() {
+ public @NonNull PendingIntent getUpdateReceiver() {
return mUpdateReceiver;
}
@@ -138,8 +132,7 @@
return mTimestamp;
}
- @NonNull
- public MediaItemStatus getStatus() {
+ public @NonNull MediaItemStatus getStatus() {
return new MediaItemStatus.Builder(mPlaybackState)
.setContentPosition(mContentPosition)
.setContentDuration(mContentDuration)
@@ -147,9 +140,8 @@
.build();
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
String[] state = {
"PENDING",
"PLAYING",
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/data/RouteItem.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/data/RouteItem.java
index b093db9..6dc9c48 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/data/RouteItem.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/data/RouteItem.java
@@ -18,9 +18,10 @@
import android.media.AudioManager;
-import androidx.annotation.NonNull;
import androidx.mediarouter.media.MediaRouter;
+import org.jspecify.annotations.NonNull;
+
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@@ -88,8 +89,7 @@
}
/** Returns a deep copy of an existing {@link RouteItem}. */
- @NonNull
- public static RouteItem copyOf(@NonNull RouteItem routeItem) {
+ public static @NonNull RouteItem copyOf(@NonNull RouteItem routeItem) {
return new RouteItem(
routeItem.getId(),
routeItem.getName(),
@@ -173,8 +173,7 @@
}
}
- @NonNull
- public String getId() {
+ public @NonNull String getId() {
return mId;
}
@@ -182,8 +181,7 @@
mId = id;
}
- @NonNull
- public String getName() {
+ public @NonNull String getName() {
return mName;
}
@@ -191,8 +189,7 @@
mName = name;
}
- @NonNull
- public String getDescription() {
+ public @NonNull String getDescription() {
return mDescription;
}
@@ -200,8 +197,7 @@
mDescription = description;
}
- @NonNull
- public ControlFilter getControlFilter() {
+ public @NonNull ControlFilter getControlFilter() {
return mControlFilter;
}
@@ -209,8 +205,7 @@
mControlFilter = controlFilter;
}
- @NonNull
- public PlaybackStream getPlaybackStream() {
+ public @NonNull PlaybackStream getPlaybackStream() {
return mPlaybackStream;
}
@@ -218,8 +213,7 @@
mPlaybackStream = playbackStream;
}
- @NonNull
- public PlaybackType getPlaybackType() {
+ public @NonNull PlaybackType getPlaybackType() {
return mPlaybackType;
}
@@ -235,8 +229,7 @@
mCanDisconnect = canDisconnect;
}
- @NonNull
- public VolumeHandling getVolumeHandling() {
+ public @NonNull VolumeHandling getVolumeHandling() {
return mVolumeHandling;
}
@@ -260,8 +253,7 @@
mVolumeMax = volumeMax;
}
- @NonNull
- public DeviceType getDeviceType() {
+ public @NonNull DeviceType getDeviceType() {
return mDeviceType;
}
@@ -269,8 +261,7 @@
mDeviceType = deviceType;
}
- @NonNull
- public List<String> getGroupMemberIds() {
+ public @NonNull List<String> getGroupMemberIds() {
return mGroupMemberIds;
}
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/player/LocalPlayer.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/player/LocalPlayer.java
index 89456df..d65d346 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/player/LocalPlayer.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/player/LocalPlayer.java
@@ -36,8 +36,6 @@
import android.view.WindowManager;
import android.widget.FrameLayout;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.mediarouter.media.MediaItemStatus;
import androidx.mediarouter.media.MediaRouter.RouteInfo;
@@ -45,6 +43,9 @@
import com.example.androidx.mediarouting.R;
import com.example.androidx.mediarouting.data.PlaylistItem;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.IOException;
/**
@@ -107,7 +108,7 @@
// Player
@Override
- public void play(@NonNull final PlaylistItem item) {
+ public void play(final @NonNull PlaylistItem item) {
if (DEBUG) {
Log.d(TAG, "play: item=" + item);
}
@@ -133,7 +134,7 @@
}
@Override
- public void seek(@NonNull final PlaylistItem item) {
+ public void seek(final @NonNull PlaylistItem item) {
if (DEBUG) {
Log.d(TAG, "seek: item=" + item);
}
@@ -151,7 +152,7 @@
@Override
public void getPlaylistItemStatus(
- @NonNull final PlaylistItem item, final boolean shouldUpdate) {
+ final @NonNull PlaylistItem item, final boolean shouldUpdate) {
if (mState == STATE_PLAYING || mState == STATE_PAUSED) {
item.setDuration(mMediaPlayer.getDuration());
item.setPosition(getCurrentPosition());
@@ -205,13 +206,12 @@
}
@Override
- public void enqueue(@NonNull final PlaylistItem item) {
+ public void enqueue(final @NonNull PlaylistItem item) {
throw new UnsupportedOperationException("LocalPlayer doesn't support enqueue!");
}
- @NonNull
@Override
- public PlaylistItem remove(@NonNull String iid) {
+ public @NonNull PlaylistItem remove(@NonNull String iid) {
throw new UnsupportedOperationException("LocalPlayer doesn't support remove!");
}
@@ -297,13 +297,11 @@
});
}
- @NonNull
- protected Context getContext() {
+ protected @NonNull Context getContext() {
return mContext;
}
- @NonNull
- protected MediaPlayer getMediaPlayer() {
+ protected @NonNull MediaPlayer getMediaPlayer() {
return mMediaPlayer;
}
@@ -657,9 +655,8 @@
setSurface((SurfaceHolder) null);
}
- @Nullable
@Override
- public Bitmap getSnapshot() {
+ public @Nullable Bitmap getSnapshot() {
if (getState() == STATE_PLAYING || getState() == STATE_PAUSED) {
return mOverlay.getSnapshot();
}
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/player/Player.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/player/Player.java
index 8701350..033684d 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/player/Player.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/player/Player.java
@@ -39,8 +39,6 @@
import android.widget.Toast;
import androidx.annotation.CallSuper;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.core.app.NotificationCompat;
@@ -51,6 +49,9 @@
import com.example.androidx.mediarouting.R;
import com.example.androidx.mediarouting.data.PlaylistItem;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Abstraction of common playback operations of media items, such as play,
* seek, etc. Used by PlaybackManager as a backend to handle actual playback
@@ -77,15 +78,11 @@
private static final PlaybackStateCompat INIT_PLAYBACK_STATE = new PlaybackStateCompat.Builder()
.setState(PlaybackStateCompat.STATE_NONE, 0, .0f).build();
- @NonNull
- protected Context mContext;
- @NonNull
- protected Callback mCallback;
- @NonNull
- protected MediaSessionCompat mMediaSession;
+ protected @NonNull Context mContext;
+ protected @NonNull Callback mCallback;
+ protected @NonNull MediaSessionCompat mMediaSession;
- @NonNull
- protected String mNotificationChannelId;
+ protected @NonNull String mNotificationChannelId;
private NotificationCompat.Action mPlayAction;
private NotificationCompat.Action mPauseAction;
@@ -167,8 +164,7 @@
* @param iid
* @return
*/
- @NonNull
- public abstract PlaylistItem remove(@NonNull String iid);
+ public abstract @NonNull PlaylistItem remove(@NonNull String iid);
/**
* Takes player snapshot.
@@ -176,8 +172,7 @@
public void takeSnapshot() {
}
- @Nullable
- public Bitmap getSnapshot() {
+ public @Nullable Bitmap getSnapshot() {
return null;
}
@@ -195,8 +190,7 @@
* Creates a {@link Player} for the given {@code route}, whose UI is hosted by the given {@code
* activity}.
*/
- @NonNull
- public static Player createPlayerForActivity(
+ public static @NonNull Player createPlayerForActivity(
@NonNull Activity activity,
@NonNull RouteInfo route,
@NonNull MediaSessionCompat session) {
@@ -214,8 +208,7 @@
}
/** Creates a {@link Player} for playback on an overlay. */
- @NonNull
- public static Player createPlayerForOverlay(@NonNull Context context) {
+ public static @NonNull Player createPlayerForOverlay(@NonNull Context context) {
Player player = new LocalPlayer.OverlayPlayer(context);
player.setPlayPauseNotificationAction();
return player;
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/player/RemotePlayer.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/player/RemotePlayer.java
index 019ad8f..a7988b1 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/player/RemotePlayer.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/player/RemotePlayer.java
@@ -25,8 +25,6 @@
import android.view.View;
import android.widget.FrameLayout;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.concurrent.futures.CallbackToFutureAdapter;
import androidx.mediarouter.media.MediaItemStatus;
import androidx.mediarouter.media.MediaRouter.ControlRequestCallback;
@@ -44,6 +42,9 @@
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.List;
@@ -328,9 +329,8 @@
}
}
- @NonNull
@Override
- public PlaylistItem remove(@NonNull String itemId) {
+ public @NonNull PlaylistItem remove(@NonNull String itemId) {
throwIfNoSession();
throwIfQueuingUnsupported();
@@ -383,9 +383,8 @@
}
}
- @NonNull
@Override
- public Bitmap getSnapshot() {
+ public @NonNull Bitmap getSnapshot() {
return mSnapshot;
}
@@ -393,8 +392,7 @@
* Caches the remote state of the given playlist item and returns an updated copy through a
* {@link ListenableFuture}.
*/
- @NonNull
- public ListenableFuture<PlaylistItem> cacheRemoteState(@NonNull PlaylistItem item) {
+ public @NonNull ListenableFuture<PlaylistItem> cacheRemoteState(@NonNull PlaylistItem item) {
ListenableFuture<MediaItemStatus> remoteStatus = getRemoteItemStatus(item);
return Futures.transform(
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/providers/SampleDynamicGroupMediaRouteProvider.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/providers/SampleDynamicGroupMediaRouteProvider.java
index a597796..758c965 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/providers/SampleDynamicGroupMediaRouteProvider.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/providers/SampleDynamicGroupMediaRouteProvider.java
@@ -24,8 +24,6 @@
import android.media.MediaRouter;
import android.util.Log;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.collection.ArrayMap;
import androidx.mediarouter.media.MediaRouteDescriptor;
import androidx.mediarouter.media.MediaRouteProvider;
@@ -38,6 +36,9 @@
import com.example.androidx.mediarouting.data.RouteItem;
import com.example.androidx.mediarouting.services.SampleDynamicGroupMediaRouteProviderService;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
@@ -63,9 +64,8 @@
super(context);
}
- @Nullable
@Override
- public RouteController onCreateRouteController(@NonNull String routeId) {
+ public @Nullable RouteController onCreateRouteController(@NonNull String routeId) {
if (!checkDrawOverlay()) return null;
MediaRouteDescriptor routeDescriptor = mRouteDescriptors.get(routeId);
@@ -77,9 +77,8 @@
return new SampleRouteController(routeId);
}
- @Nullable
@Override
- public RouteController onCreateRouteController(@NonNull String routeId,
+ public @Nullable RouteController onCreateRouteController(@NonNull String routeId,
@NonNull String groupId) {
// Handle a static group exceptionally
if (groupId.equals(STATIC_GROUP_ROUTE_ID)) {
@@ -100,9 +99,8 @@
return controller;
}
- @Nullable
@Override
- public DynamicGroupRouteController onCreateDynamicGroupRouteController(
+ public @Nullable DynamicGroupRouteController onCreateDynamicGroupRouteController(
@NonNull String initialMemberRouteId) {
if (!checkDrawOverlay()) return null;
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/providers/SampleMediaRouteProvider.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/providers/SampleMediaRouteProvider.java
index 7721f91..4be09b3 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/providers/SampleMediaRouteProvider.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/providers/SampleMediaRouteProvider.java
@@ -31,8 +31,6 @@
import android.provider.Settings;
import android.util.Log;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.collection.ArrayMap;
import androidx.mediarouter.media.MediaControlIntent;
@@ -50,6 +48,9 @@
import com.example.androidx.mediarouting.services.SampleMediaRouteProviderService;
import com.example.androidx.mediarouting.session.SessionManager;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -160,10 +161,8 @@
}
}
- @NonNull
- protected Map<String, Integer> mVolumes = new ArrayMap<>();
- @NonNull
- protected Map<String, MediaRouteDescriptor> mRouteDescriptors = new HashMap<>();
+ protected @NonNull Map<String, Integer> mVolumes = new ArrayMap<>();
+ protected @NonNull Map<String, MediaRouteDescriptor> mRouteDescriptors = new HashMap<>();
public SampleMediaRouteProvider(@NonNull Context context) {
super(context);
@@ -171,9 +170,8 @@
publishRoutes();
}
- @Nullable
@Override
- public RouteController onCreateRouteController(@NonNull String routeId) {
+ public @Nullable RouteController onCreateRouteController(@NonNull String routeId) {
if (!checkDrawOverlay()) return null;
return new SampleRouteController(routeId);
}
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/providers/WrapperMediaRouteProvider.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/providers/WrapperMediaRouteProvider.java
new file mode 100644
index 0000000..f02c38e
--- /dev/null
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/providers/WrapperMediaRouteProvider.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.androidx.mediarouting.providers;
+
+import android.content.Context;
+
+import androidx.mediarouter.media.MediaRouteProvider;
+
+import org.jspecify.annotations.NonNull;
+
+public class WrapperMediaRouteProvider extends MediaRouteProvider {
+ private static final String TAG = "WrapperMrp";
+
+ /**
+ * A custom media control intent category for special requests that are supported by this
+ * provider's routes.
+ */
+ public static final String CATEGORY_WRAPPER_ROUTE =
+ "com.example.androidx.media.CATEGORY_WRAPPER_ROUTE";
+
+ /**
+ * Creates a media route provider to provide wrapper routes.
+ *
+ * @param context the context
+ */
+ public WrapperMediaRouteProvider(@NonNull Context context) {
+ super(context);
+ }
+}
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/services/SampleDynamicGroupMediaRouteProviderService.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/services/SampleDynamicGroupMediaRouteProviderService.java
index abbfbf2..62c3852 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/services/SampleDynamicGroupMediaRouteProviderService.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/services/SampleDynamicGroupMediaRouteProviderService.java
@@ -20,13 +20,14 @@
import android.os.Binder;
import android.os.IBinder;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.mediarouter.media.MediaRouteProvider;
import androidx.mediarouter.media.MediaRouteProviderService;
import com.example.androidx.mediarouting.providers.SampleDynamicGroupMediaRouteProvider;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Demonstrates how to register a custom media route provider service
* using the support library.
@@ -39,16 +40,14 @@
private SampleDynamicGroupMediaRouteProvider mDynamicGroupMediaRouteProvider;
- @NonNull
@Override
- public MediaRouteProvider onCreateMediaRouteProvider() {
+ public @NonNull MediaRouteProvider onCreateMediaRouteProvider() {
mDynamicGroupMediaRouteProvider = new SampleDynamicGroupMediaRouteProvider(this);
return mDynamicGroupMediaRouteProvider;
}
- @Nullable
@Override
- public IBinder onBind(@NonNull Intent intent) {
+ public @Nullable IBinder onBind(@NonNull Intent intent) {
if (intent != null && ACTION_BIND_LOCAL.equals(intent.getAction())) {
return new LocalBinder();
} else {
@@ -75,8 +74,7 @@
* bindings within the same process.
*/
public class LocalBinder extends Binder {
- @NonNull
- public SampleDynamicGroupMediaRouteProviderService getService() {
+ public @NonNull SampleDynamicGroupMediaRouteProviderService getService() {
return SampleDynamicGroupMediaRouteProviderService.this;
}
}
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/services/SampleMediaRouteProviderService.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/services/SampleMediaRouteProviderService.java
index 21c3e54..32acee4 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/services/SampleMediaRouteProviderService.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/services/SampleMediaRouteProviderService.java
@@ -16,12 +16,13 @@
package com.example.androidx.mediarouting.services;
-import androidx.annotation.NonNull;
import androidx.mediarouter.media.MediaRouteProvider;
import androidx.mediarouter.media.MediaRouteProviderService;
import com.example.androidx.mediarouting.providers.SampleMediaRouteProvider;
+import org.jspecify.annotations.NonNull;
+
/**
* Demonstrates how to register a custom media route provider service
* using the support library.
@@ -29,9 +30,8 @@
* @see SampleMediaRouteProvider
*/
public class SampleMediaRouteProviderService extends MediaRouteProviderService {
- @NonNull
@Override
- public MediaRouteProvider onCreateMediaRouteProvider() {
+ public @NonNull MediaRouteProvider onCreateMediaRouteProvider() {
return new SampleMediaRouteProvider(this);
}
}
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/services/WrapperMediaRouteProviderService.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/services/WrapperMediaRouteProviderService.java
new file mode 100644
index 0000000..7da91bc
--- /dev/null
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/services/WrapperMediaRouteProviderService.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.androidx.mediarouting.services;
+
+import androidx.mediarouter.media.MediaRouteProvider;
+import androidx.mediarouter.media.MediaRouteProviderService;
+
+import com.example.androidx.mediarouting.providers.WrapperMediaRouteProvider;
+
+import org.jspecify.annotations.NonNull;
+
+public class WrapperMediaRouteProviderService extends MediaRouteProviderService {
+
+ private WrapperMediaRouteProvider mWrapperMediaRouteProvider;
+
+ @Override
+ public @NonNull MediaRouteProvider onCreateMediaRouteProvider() {
+ if (mWrapperMediaRouteProvider == null) {
+ mWrapperMediaRouteProvider = new WrapperMediaRouteProvider(/* context= */ this);
+ }
+ return mWrapperMediaRouteProvider;
+ }
+}
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/session/SessionManager.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/session/SessionManager.java
index 4b68110..bca2bb36 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/session/SessionManager.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/session/SessionManager.java
@@ -20,14 +20,15 @@
import android.net.Uri;
import android.util.Log;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.mediarouter.media.MediaItemStatus;
import androidx.mediarouter.media.MediaSessionStatus;
import com.example.androidx.mediarouting.data.PlaylistItem;
import com.example.androidx.mediarouting.player.Player;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.List;
@@ -67,19 +68,16 @@
return mSessionValid;
}
- @Nullable
- public String getSessionId() {
+ public @Nullable String getSessionId() {
return mSessionValid ? Integer.toString(mSessionId) : null;
}
- @Nullable
- public PlaylistItem getCurrentItem() {
+ public @Nullable PlaylistItem getCurrentItem() {
return mPlaylist.isEmpty() ? null : mPlaylist.get(0);
}
// Returns the cached playlist (note this is not responsible for updating it)
- @Nullable
- public List<PlaylistItem> getPlaylist() {
+ public @Nullable List<PlaylistItem> getPlaylist() {
return mPlaylist;
}
@@ -118,16 +116,15 @@
/**
* Adds an item to the playlist.
*/
- @NonNull
- public PlaylistItem add(@NonNull String title, @NonNull Uri uri, @NonNull String mime) {
+ public @NonNull PlaylistItem add(@NonNull String title, @NonNull Uri uri,
+ @NonNull String mime) {
return add(title, uri, mime, 0, null);
}
/**
* Adds an item to the playlist.
*/
- @NonNull
- public PlaylistItem add(@NonNull String title, @NonNull Uri uri, @NonNull String mime,
+ public @NonNull PlaylistItem add(@NonNull String title, @NonNull Uri uri, @NonNull String mime,
long startPosition, @Nullable PendingIntent receiver) {
if (DEBUG) {
log("add: title=" + title + ", uri=" + uri + ", receiver=" + receiver);
@@ -154,8 +151,7 @@
/**
* Removes an item from the playlist.
*/
- @NonNull
- public PlaylistItem remove(@NonNull String iid) {
+ public @NonNull PlaylistItem remove(@NonNull String iid) {
if (DEBUG) {
log("remove: iid=" + iid);
}
@@ -166,8 +162,7 @@
/**
* Seeks a specific position for the current item.
*/
- @NonNull
- public PlaylistItem seek(@NonNull String iid, long pos) {
+ public @NonNull PlaylistItem seek(@NonNull String iid, long pos) {
if (DEBUG) {
log("seek: iid=" + iid + ", pos=" + pos);
}
@@ -189,8 +184,7 @@
/**
* Returns the status for the current item.
*/
- @NonNull
- public PlaylistItem getStatus(@NonNull String iid) {
+ public @NonNull PlaylistItem getStatus(@NonNull String iid) {
checkPlayerAndSession();
// This should only be called for local player. Remote player is
@@ -261,8 +255,7 @@
/**
* Starts the current session.
*/
- @Nullable
- public String startSession() {
+ public @Nullable String startSession() {
if (!mSessionValid) {
mSessionId++;
mItemId = 0;
@@ -307,8 +300,7 @@
/**
* Returns the current session status.
*/
- @NonNull
- public MediaSessionStatus getSessionStatus(@NonNull String sid) {
+ public @NonNull MediaSessionStatus getSessionStatus(@NonNull String sid) {
int sessionState = (sid != null && sid.equals(Integer.toString(mSessionId)))
? MediaSessionStatus.SESSION_STATE_ACTIVE
: MediaSessionStatus.SESSION_STATE_INVALIDATED;
@@ -493,9 +485,8 @@
mCallback = callback;
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
String result = "Media Queue: ";
if (!mPlaylist.isEmpty()) {
for (PlaylistItem item : mPlaylist) {
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/ui/LibraryAdapter.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/ui/LibraryAdapter.java
index 33481f5..6be0261 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/ui/LibraryAdapter.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/ui/LibraryAdapter.java
@@ -24,13 +24,13 @@
import android.widget.ListView;
import android.widget.TextView;
-import androidx.annotation.NonNull;
-
import com.example.androidx.mediarouting.R;
import com.example.androidx.mediarouting.activities.MainActivity;
import com.example.androidx.mediarouting.data.MediaItem;
import com.example.androidx.mediarouting.session.SessionManager;
+import org.jspecify.annotations.NonNull;
+
/**
* {@link ListView} {@link Adapter} for showing items before adding to the playlist.
*/
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/ui/PlaylistAdapter.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/ui/PlaylistAdapter.java
index b017bac..1ace89c 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/ui/PlaylistAdapter.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/ui/PlaylistAdapter.java
@@ -24,13 +24,13 @@
import android.widget.ListView;
import android.widget.TextView;
-import androidx.annotation.NonNull;
-
import com.example.androidx.mediarouting.R;
import com.example.androidx.mediarouting.activities.MainActivity;
import com.example.androidx.mediarouting.data.PlaylistItem;
import com.example.androidx.mediarouting.session.SessionManager;
+import org.jspecify.annotations.NonNull;
+
/**
* {@link ListView} {@link Adapter} for showing items in the playlist listview.
*/
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/ui/RoutesAdapter.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/ui/RoutesAdapter.java
index bec91d6..9bf137f 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/ui/RoutesAdapter.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/ui/RoutesAdapter.java
@@ -22,12 +22,13 @@
import android.widget.ImageButton;
import android.widget.TextView;
-import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.androidx.mediarouting.R;
import com.example.androidx.mediarouting.data.RouteItem;
+import org.jspecify.annotations.NonNull;
+
import java.util.List;
/** {@link RecyclerView.Adapter} for showing routes in the settings screen */
@@ -42,9 +43,8 @@
this.mRouteItemListener = routeItemListener;
}
- @NonNull
@Override
- public RouteViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ public @NonNull RouteViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view =
LayoutInflater.from(parent.getContext())
.inflate(R.layout.route_item, parent, false);
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/ui/UiUtils.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/ui/UiUtils.java
index 7d3ff97..dc293fb 100644
--- a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/ui/UiUtils.java
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/ui/UiUtils.java
@@ -21,9 +21,10 @@
import android.widget.ArrayAdapter;
import android.widget.Spinner;
-import androidx.annotation.NonNull;
import androidx.core.util.Consumer;
+import org.jspecify.annotations.NonNull;
+
/** Contains utility methods related to UI management. */
public final class UiUtils {
diff --git a/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/util/Utils.java b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/util/Utils.java
new file mode 100644
index 0000000..ee258f9
--- /dev/null
+++ b/samples/MediaRoutingDemo/src/main/java/com/example/androidx/mediarouting/util/Utils.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.androidx.mediarouting.util;
+
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.util.Log;
+
+import com.example.androidx.mediarouting.services.SampleMediaRouteProviderService;
+import com.example.androidx.mediarouting.services.WrapperMediaRouteProviderService;
+
+import org.jspecify.annotations.NonNull;
+
+public class Utils {
+ private static final String TAG = "Utils";
+
+ private Utils() {}
+
+ /** Sets the simple media router provider service to be enabled or disabled. */
+ public static void setSimpleRouteProviderServiceEnabled(
+ @NonNull Context context, boolean enabled) {
+ ComponentName componentName =
+ new ComponentName(context, SampleMediaRouteProviderService.class);
+ Log.i(TAG, "enable_simple_route_provider is changed to " + enabled);
+ setMediaRouteProviderServiceEnabled(context, componentName, enabled);
+ }
+
+ /** Sets the wrapper media router provider service to be enabled or disabled. */
+ public static void setWrapperRouteProviderServiceEnabled(
+ @NonNull Context context, boolean enabled) {
+ ComponentName componentName =
+ new ComponentName(context, WrapperMediaRouteProviderService.class);
+ Log.i(TAG, "enable_wrapper_route_provider is changed to " + enabled);
+ setMediaRouteProviderServiceEnabled(context, componentName, enabled);
+ }
+
+ private static void setMediaRouteProviderServiceEnabled(
+ @NonNull Context context, ComponentName componentName, boolean enabled) {
+ PackageManager packageManager = context.getPackageManager();
+ packageManager.setComponentEnabledSetting(
+ componentName,
+ enabled
+ ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
+ : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
+ /* flags= */ PackageManager.DONT_KILL_APP);
+ }
+}
diff --git a/samples/MediaRoutingDemo/src/main/res/layout/activity_settings.xml b/samples/MediaRoutingDemo/src/main/res/layout/activity_settings.xml
index 50418cb..97191d0 100644
--- a/samples/MediaRoutingDemo/src/main/res/layout/activity_settings.xml
+++ b/samples/MediaRoutingDemo/src/main/res/layout/activity_settings.xml
@@ -35,6 +35,15 @@
android:layout_height="wrap_content"
android:text="Route listing preference"/>
+ <fragment
+ android:id="@+id/preference_settings"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentStart="true"
+ android:layout_alignParentLeft="true"
+ android:layout_centerVertical="true"
+ class="com.example.androidx.mediarouting.activities.SettingsPreferenceFragment"/>
+
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
@@ -92,31 +101,6 @@
android:padding="4dp">
<Switch
- android:id="@+id/enable_simple_provider_switch"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_alignParentEnd="true"
- android:layout_alignParentRight="true"
- android:layout_centerVertical="true" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true"
- android:layout_centerVertical="true"
- android:gravity="center"
- android:text="Enable simple route provider" />
-
- </RelativeLayout>
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="50dp"
- android:layout_margin="12dp"
- android:padding="4dp">
-
- <Switch
android:id="@+id/enable_dynamic_provider_switch"
android:layout_width="wrap_content"
android:layout_height="match_parent"
diff --git a/samples/MediaRoutingDemo/src/main/res/values/strings.xml b/samples/MediaRoutingDemo/src/main/res/values/strings.xml
index f46edb8..38d0565 100644
--- a/samples/MediaRoutingDemo/src/main/res/values/strings.xml
+++ b/samples/MediaRoutingDemo/src/main/res/values/strings.xml
@@ -41,6 +41,8 @@
<string name="mixed_volume_route_group_name">Mixed Volume Route Group</string>
<string name="sample_route_description">Sample route from AndroidXDemos</string>
+ <string name="wrapper_media_route_provider_service">Media Route Provider Service provides wrapper routes</string>
+
<string name="sample_dynamic_group_mrp_service">Media Route Provider Service Support Library Sample (supporting dynamic group)</string>
<string name="dg_tv_route_name1">Dynamic Route 1 - TV</string>
<string name="dg_tv_route_name2">Dynamic Route 2 - TV</string>
@@ -49,6 +51,11 @@
<string name="dg_not_unselectable_route_name5"> Dynamic Route 5 - Not unselectable</string>
<string name="dg_static_group_route_name6"> Dynamic Route 6 - Static Group</string>
+ <!-- Preference settings -->
+ <string name="prefs_header_media_route_provider_configuration">Media Route Provider Configurations</string>
+ <string name="prefs_enable_simple_route_provider_title">Enable simple route provider</string>
+ <string name="prefs_enable_wrapper_route_provider_title">Enable wrapper route provider</string>
+
<string name="sender_driven_route_name1">Sender Driven TV 1</string>
<string name="sender_driven_route_name2">Sender Driven TV 2</string>
diff --git a/samples/MediaRoutingDemo/src/main/res/xml/settings_preference.xml b/samples/MediaRoutingDemo/src/main/res/xml/settings_preference.xml
new file mode 100644
index 0000000..4ceaa91
--- /dev/null
+++ b/samples/MediaRoutingDemo/src/main/res/xml/settings_preference.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ Copyright 2024 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+
+<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
+ <androidx.preference.PreferenceCategory
+ android:title="@string/prefs_header_media_route_provider_configuration">
+ <SwitchPreference
+ android:defaultValue="true"
+ android:key="enable_simple_route_provider"
+ android:title="@string/prefs_enable_simple_route_provider_title"/>
+ <SwitchPreference
+ android:defaultValue="false"
+ android:key="enable_wrapper_route_provider"
+ android:title="@string/prefs_enable_wrapper_route_provider_title"/>
+ </androidx.preference.PreferenceCategory>
+</androidx.preference.PreferenceScreen>
\ No newline at end of file
diff --git a/security/security-app-authenticator-testing/build.gradle b/security/security-app-authenticator-testing/build.gradle
index 43cc85f..3599ad9 100644
--- a/security/security-app-authenticator-testing/build.gradle
+++ b/security/security-app-authenticator-testing/build.gradle
@@ -29,6 +29,7 @@
}
dependencies {
+ api(libs.jspecify)
implementation (project(":security:security-app-authenticator"))
implementation("androidx.collection:collection:1.4.2")
diff --git a/security/security-app-authenticator-testing/src/main/java/androidx/security/app/authenticator/TestAppAuthenticatorBuilder.java b/security/security-app-authenticator-testing/src/main/java/androidx/security/app/authenticator/TestAppAuthenticatorBuilder.java
index 372a166..f8585aa 100644
--- a/security/security-app-authenticator-testing/src/main/java/androidx/security/app/authenticator/TestAppAuthenticatorBuilder.java
+++ b/security/security-app-authenticator-testing/src/main/java/androidx/security/app/authenticator/TestAppAuthenticatorBuilder.java
@@ -22,9 +22,9 @@
import android.os.Binder;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
import androidx.annotation.XmlRes;
+import org.jspecify.annotations.NonNull;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
@@ -161,8 +161,7 @@
// This is not a setter for the builder but instead a static factory method to obtain a new
// builder.
@SuppressLint("BuilderSetStyle")
- @NonNull
- public static TestAppAuthenticatorBuilder createFromResource(@NonNull Context context,
+ public static @NonNull TestAppAuthenticatorBuilder createFromResource(@NonNull Context context,
@XmlRes int xmlResource) {
Resources resources = context.getResources();
XmlPullParser parser = resources.getXml(xmlResource);
@@ -182,8 +181,7 @@
// This is not a setter for the builder but instead a static factory method to obtain a new
// builder.
@SuppressLint("BuilderSetStyle")
- @NonNull
- public static TestAppAuthenticatorBuilder createFromInputStream(
+ public static @NonNull TestAppAuthenticatorBuilder createFromInputStream(
@NonNull Context context,
@NonNull InputStream xmlInputStream)
throws AppAuthenticatorXmlException {
@@ -231,8 +229,7 @@
// The builder allows configuring other options that are not directly controlled by the
// AppAuthenticator.
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public TestAppAuthenticatorBuilder setSignatureAcceptedForPackage(
+ public @NonNull TestAppAuthenticatorBuilder setSignatureAcceptedForPackage(
@NonNull String packageName) {
mTestPolicy = POLICY_CUSTOM;
mAppSignatureVerifierBuilder.setSignatureAcceptedForPackage(packageName);
@@ -250,8 +247,7 @@
// The builder allows configuring other options that are not directly controlled by the
// AppAuthenticator.
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public TestAppAuthenticatorBuilder setSigningIdentityForPackage(
+ public @NonNull TestAppAuthenticatorBuilder setSigningIdentityForPackage(
@NonNull String packageName,
@NonNull String certDigest) {
mTestPolicy = POLICY_CUSTOM;
@@ -274,8 +270,7 @@
// The builder allows configuring other options that are not directly controlled by the
// AppAuthenticator.
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public TestAppAuthenticatorBuilder setUidForPackage(@NonNull String packageName,
+ public @NonNull TestAppAuthenticatorBuilder setUidForPackage(@NonNull String packageName,
int uid) {
mAppAuthenticatorUtilsBuilder.setUidForPackage(packageName, uid);
return this;
@@ -291,8 +286,7 @@
// The builder allows configuring other options that are not directly controlled by the
// AppAuthenticator.
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public TestAppAuthenticatorBuilder setPackageNotInstalled(
+ public @NonNull TestAppAuthenticatorBuilder setPackageNotInstalled(
@NonNull String packageName) {
mTestPolicy = POLICY_CUSTOM;
mAppAuthenticatorUtilsBuilder.setPackageNotInstalled(packageName);
@@ -313,8 +307,7 @@
// This class is provided so that apps can inject a configurable AppAuthenticator for their
// tests, so it needs access to the restricted test APIs.
@SuppressLint("RestrictedApi")
- @NonNull
- public AppAuthenticator build() throws AppAuthenticatorXmlException, IOException {
+ public @NonNull AppAuthenticator build() throws AppAuthenticatorXmlException, IOException {
// Obtain the config from the AppAuthenticator class to ensure that the provided XML is
// properly configured.
AppAuthenticator.AppAuthenticatorConfig config =
diff --git a/security/security-app-authenticator/build.gradle b/security/security-app-authenticator/build.gradle
index f73e3d1..3b36b65 100644
--- a/security/security-app-authenticator/build.gradle
+++ b/security/security-app-authenticator/build.gradle
@@ -29,6 +29,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.annotation:annotation:1.8.1")
implementation(libs.autoValueAnnotations)
annotationProcessor(libs.autoValue)
diff --git a/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppAuthenticator.java b/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppAuthenticator.java
index b926493..af080ca 100644
--- a/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppAuthenticator.java
+++ b/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppAuthenticator.java
@@ -29,8 +29,6 @@
import android.util.Log;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.annotation.XmlRes;
@@ -39,6 +37,8 @@
import com.google.auto.value.AutoValue;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
@@ -828,8 +828,7 @@
* Returns the result message for the query; if the query successfully verified an app's
* signature matches the expected signing identity this value will be {@code null}.
*/
- @Nullable
- abstract String getResultMessage();
+ abstract @Nullable String getResultMessage();
/**
* Creates a new instance with the provided {@code resultCode} and {@code resultMessage}.
diff --git a/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppAuthenticatorUtils.java b/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppAuthenticatorUtils.java
index cdeae4f..6c828d0 100644
--- a/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppAuthenticatorUtils.java
+++ b/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppAuthenticatorUtils.java
@@ -22,7 +22,7 @@
import android.os.Binder;
import android.os.Build;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -90,7 +90,7 @@
* <p>The specified {@code digestAlgorithm} must be one supported from API level 1; use of
* MD5 and SHA-1 are strongly discouraged.
*/
- static String computeDigest(@NonNull String digestAlgorithm, @NonNull byte[] data) {
+ static String computeDigest(@NonNull String digestAlgorithm, byte @NonNull [] data) {
MessageDigest messageDigest;
try {
messageDigest = MessageDigest.getInstance(digestAlgorithm);
@@ -106,7 +106,7 @@
/**
* Returns a {@code String} representing the hex encoding of the provided {@code data}.
*/
- static String toHexString(@NonNull byte[] data) {
+ static String toHexString(byte @NonNull [] data) {
char[] result = new char[data.length * 2];
for (int i = 0; i < data.length; i++) {
int resultIndex = i * 2;
diff --git a/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppAuthenticatorXmlException.java b/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppAuthenticatorXmlException.java
index 6ce4ce6..b185842 100644
--- a/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppAuthenticatorXmlException.java
+++ b/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppAuthenticatorXmlException.java
@@ -16,7 +16,7 @@
package androidx.security.app.authenticator;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* This {@code Exception} is thrown when the XML configuration file is not in the proper format
diff --git a/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppSignatureVerifier.java b/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppSignatureVerifier.java
index 29321cc..e620f06 100644
--- a/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppSignatureVerifier.java
+++ b/security/security-app-authenticator/src/main/java/androidx/security/app/authenticator/AppSignatureVerifier.java
@@ -24,14 +24,15 @@
import android.os.Build;
import android.util.Log;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.collection.ArrayMap;
import androidx.collection.LruCache;
import com.google.auto.value.AutoValue;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -434,8 +435,7 @@
abstract static class AppSigningInfo {
abstract String getPackageName();
abstract List<Signature> getCurrentSignatures();
- @Nullable
- abstract List<Signature> getSigningLineage();
+ abstract @Nullable List<Signature> getSigningLineage();
abstract long getLastUpdateTime();
/**
@@ -446,7 +446,7 @@
* level 28, but a non-null value must be specified for the {@code currentSignatures}.
*/
static AppSigningInfo create(@NonNull String packageName,
- @NonNull Signature[] currentSignatures, Signature[] signingLineage,
+ Signature @NonNull [] currentSignatures, Signature[] signingLineage,
long lastUpdateTime) {
return new AutoValue_AppSignatureVerifier_AppSigningInfo(packageName,
Arrays.asList(currentSignatures),
diff --git a/security/security-crypto/build.gradle b/security/security-crypto/build.gradle
index b4e0bf02..6114d86 100644
--- a/security/security-crypto/build.gradle
+++ b/security/security-crypto/build.gradle
@@ -30,6 +30,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.annotation:annotation:1.8.1")
implementation("com.google.crypto.tink:tink-android:1.8.0")
diff --git a/security/security-crypto/src/androidTest/java/androidx/security/crypto/EncryptedFileTest.java b/security/security-crypto/src/androidTest/java/androidx/security/crypto/EncryptedFileTest.java
index 844eef4..c918bfb 100644
--- a/security/security-crypto/src/androidTest/java/androidx/security/crypto/EncryptedFileTest.java
+++ b/security/security-crypto/src/androidTest/java/androidx/security/crypto/EncryptedFileTest.java
@@ -23,7 +23,6 @@
import android.content.Context;
import android.content.SharedPreferences;
-import androidx.annotation.NonNull;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
@@ -34,6 +33,7 @@
import com.google.crypto.tink.streamingaead.AesGcmHkdfStreamingKeyManager;
import com.google.crypto.tink.streamingaead.StreamingAeadConfig;
+import org.jspecify.annotations.NonNull;
import org.junit.Assert;
import org.junit.AssumptionViolatedException;
import org.junit.Before;
@@ -79,9 +79,8 @@
mText = text;
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
return mText;
}
}
diff --git a/security/security-crypto/src/main/java/androidx/security/crypto/EncryptedFile.java b/security/security-crypto/src/main/java/androidx/security/crypto/EncryptedFile.java
index 41c8b7b..d8793bc 100644
--- a/security/security-crypto/src/main/java/androidx/security/crypto/EncryptedFile.java
+++ b/security/security-crypto/src/main/java/androidx/security/crypto/EncryptedFile.java
@@ -21,8 +21,6 @@
import android.annotation.SuppressLint;
import android.content.Context;
-import androidx.annotation.NonNull;
-
import com.google.crypto.tink.KeyTemplate;
import com.google.crypto.tink.KeyTemplates;
import com.google.crypto.tink.KeysetHandle;
@@ -30,6 +28,8 @@
import com.google.crypto.tink.integration.android.AndroidKeysetManager;
import com.google.crypto.tink.streamingaead.StreamingAeadConfig;
+import org.jspecify.annotations.NonNull;
+
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
@@ -202,8 +202,7 @@
* @param keysetPrefName The SharedPreferences file to store the keyset.
* @return This Builder
*/
- @NonNull
- public Builder setKeysetPrefName(@NonNull String keysetPrefName) {
+ public @NonNull Builder setKeysetPrefName(@NonNull String keysetPrefName) {
mKeysetPrefName = keysetPrefName;
return this;
}
@@ -212,8 +211,7 @@
* @param keysetAlias The alias in the SharedPreferences file to store the keyset.
* @return This Builder
*/
- @NonNull
- public Builder setKeysetAlias(@NonNull String keysetAlias) {
+ public @NonNull Builder setKeysetAlias(@NonNull String keysetAlias) {
mKeysetAlias = keysetAlias;
return this;
}
@@ -221,8 +219,7 @@
/**
* @return An EncryptedFile with the specified parameters.
*/
- @NonNull
- public EncryptedFile build() throws GeneralSecurityException, IOException {
+ public @NonNull EncryptedFile build() throws GeneralSecurityException, IOException {
StreamingAeadConfig.register();
AndroidKeysetManager.Builder keysetManagerBuilder = new AndroidKeysetManager.Builder()
@@ -257,8 +254,7 @@
* @throws GeneralSecurityException when a bad master key or keyset has been used
* @throws IOException when the file already exists or is not available for writing
*/
- @NonNull
- public FileOutputStream openFileOutput()
+ public @NonNull FileOutputStream openFileOutput()
throws GeneralSecurityException, IOException {
if (mFile.exists()) {
throw new IOException("output file already exists, please use a new file: "
@@ -281,8 +277,7 @@
* @throws FileNotFoundException when the file was not found
* @throws IOException when other I/O errors occur
*/
- @NonNull
- public FileInputStream openFileInput()
+ public @NonNull FileInputStream openFileInput()
throws GeneralSecurityException, IOException, FileNotFoundException {
if (!mFile.exists()) {
throw new FileNotFoundException("file doesn't exist: " + mFile.getName());
@@ -306,7 +301,7 @@
}
@Override
- public void write(@NonNull byte[] b) throws IOException {
+ public void write(byte @NonNull [] b) throws IOException {
mEncryptedOutputStream.write(b);
}
@@ -316,7 +311,7 @@
}
@Override
- public void write(@NonNull byte[] b, int off, int len) throws IOException {
+ public void write(byte @NonNull [] b, int off, int len) throws IOException {
mEncryptedOutputStream.write(b, off, len);
}
@@ -325,9 +320,8 @@
mEncryptedOutputStream.close();
}
- @NonNull
@Override
- public FileChannel getChannel() {
+ public @NonNull FileChannel getChannel() {
throw new UnsupportedOperationException("For encrypted files, please open the "
+ "relevant FileInput/FileOutputStream.");
}
@@ -360,12 +354,12 @@
}
@Override
- public int read(@NonNull byte[] b) throws IOException {
+ public int read(byte @NonNull [] b) throws IOException {
return mEncryptedInputStream.read(b);
}
@Override
- public int read(@NonNull byte[] b, int off, int len) throws IOException {
+ public int read(byte @NonNull [] b, int off, int len) throws IOException {
return mEncryptedInputStream.read(b, off, len);
}
diff --git a/security/security-crypto/src/main/java/androidx/security/crypto/EncryptedSharedPreferences.java b/security/security-crypto/src/main/java/androidx/security/crypto/EncryptedSharedPreferences.java
index b5f72f03..e5b66fe 100644
--- a/security/security-crypto/src/main/java/androidx/security/crypto/EncryptedSharedPreferences.java
+++ b/security/security-crypto/src/main/java/androidx/security/crypto/EncryptedSharedPreferences.java
@@ -22,8 +22,6 @@
import android.content.SharedPreferences;
import android.util.Pair;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.collection.ArraySet;
import com.google.crypto.tink.Aead;
@@ -36,6 +34,9 @@
import com.google.crypto.tink.integration.android.AndroidKeysetManager;
import com.google.crypto.tink.subtle.Base64;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.IOException;
import java.nio.ByteBuffer;
import java.security.GeneralSecurityException;
@@ -121,8 +122,7 @@
* @throws GeneralSecurityException when a bad master key or keyset has been attempted
* @throws IOException when fileName can not be used
*/
- @NonNull
- public static SharedPreferences create(@NonNull Context context,
+ public static @NonNull SharedPreferences create(@NonNull Context context,
@NonNull String fileName,
@NonNull MasterKey masterKey,
@NonNull PrefKeyEncryptionScheme prefKeyEncryptionScheme,
@@ -152,8 +152,7 @@
* @throws IOException when fileName can not be used
*/
@Deprecated
- @NonNull
- public static SharedPreferences create(@NonNull String fileName,
+ public static @NonNull SharedPreferences create(@NonNull String fileName,
@NonNull String masterKeyAlias,
@NonNull Context context,
@NonNull PrefKeyEncryptionScheme prefKeyEncryptionScheme,
@@ -248,8 +247,8 @@
}
@Override
- @NonNull
- public SharedPreferences.Editor putString(@Nullable String key, @Nullable String value) {
+ public SharedPreferences.@NonNull Editor putString(@Nullable String key,
+ @Nullable String value) {
if (value == null) {
value = NULL_VALUE;
}
@@ -265,8 +264,7 @@
}
@Override
- @NonNull
- public SharedPreferences.Editor putStringSet(@Nullable String key,
+ public SharedPreferences.@NonNull Editor putStringSet(@Nullable String key,
@Nullable Set<String> values) {
if (values == null) {
values = new ArraySet<>();
@@ -291,8 +289,7 @@
}
@Override
- @NonNull
- public SharedPreferences.Editor putInt(@Nullable String key, int value) {
+ public SharedPreferences.@NonNull Editor putInt(@Nullable String key, int value) {
ByteBuffer buffer = ByteBuffer.allocate(Integer.BYTES + Integer.BYTES);
buffer.putInt(EncryptedType.INT.getId());
buffer.putInt(value);
@@ -301,8 +298,7 @@
}
@Override
- @NonNull
- public SharedPreferences.Editor putLong(@Nullable String key, long value) {
+ public SharedPreferences.@NonNull Editor putLong(@Nullable String key, long value) {
ByteBuffer buffer = ByteBuffer.allocate(Integer.BYTES + Long.BYTES);
buffer.putInt(EncryptedType.LONG.getId());
buffer.putLong(value);
@@ -311,8 +307,7 @@
}
@Override
- @NonNull
- public SharedPreferences.Editor putFloat(@Nullable String key, float value) {
+ public SharedPreferences.@NonNull Editor putFloat(@Nullable String key, float value) {
ByteBuffer buffer = ByteBuffer.allocate(Integer.BYTES + Float.BYTES);
buffer.putInt(EncryptedType.FLOAT.getId());
buffer.putFloat(value);
@@ -321,8 +316,7 @@
}
@Override
- @NonNull
- public SharedPreferences.Editor putBoolean(@Nullable String key, boolean value) {
+ public SharedPreferences.@NonNull Editor putBoolean(@Nullable String key, boolean value) {
ByteBuffer buffer = ByteBuffer.allocate(Integer.BYTES + Byte.BYTES);
buffer.putInt(EncryptedType.BOOLEAN.getId());
buffer.put(value ? (byte) 1 : (byte) 0);
@@ -331,8 +325,7 @@
}
@Override
- @NonNull
- public SharedPreferences.Editor remove(@Nullable String key) {
+ public SharedPreferences.@NonNull Editor remove(@Nullable String key) {
if (mEncryptedSharedPreferences.isReservedKey(key)) {
throw new SecurityException(key + " is a reserved key for the encryption keyset.");
}
@@ -342,8 +335,7 @@
}
@Override
- @NonNull
- public SharedPreferences.Editor clear() {
+ public SharedPreferences.@NonNull Editor clear() {
// Set the flag to clear on commit, this operation happens first on commit.
// Cannot use underlying clear operation, it will remove the keysets and
// break the editor.
@@ -413,8 +405,7 @@
// SharedPreferences methods
@Override
- @NonNull
- public Map<String, ?> getAll() {
+ public @NonNull Map<String, ?> getAll() {
Map<String, ? super Object> allEntries = new HashMap<>();
for (Map.Entry<String, ?> entry : mSharedPreferences.getAll().entrySet()) {
if (!isReservedKey(entry.getKey())) {
@@ -426,17 +417,16 @@
return allEntries;
}
- @Nullable
@Override
- public String getString(@Nullable String key, @Nullable String defValue) {
+ public @Nullable String getString(@Nullable String key, @Nullable String defValue) {
Object value = getDecryptedObject(key);
return (value instanceof String ? (String) value : defValue);
}
@SuppressWarnings("unchecked")
- @Nullable
@Override
- public Set<String> getStringSet(@Nullable String key, @Nullable Set<String> defValues) {
+ public @Nullable Set<String> getStringSet(@Nullable String key,
+ @Nullable Set<String> defValues) {
Set<String> returnValues;
Object value = getDecryptedObject(key);
if (value instanceof Set) {
@@ -481,8 +471,7 @@
}
@Override
- @NonNull
- public SharedPreferences.Editor edit() {
+ public SharedPreferences.@NonNull Editor edit() {
return new Editor(this, mSharedPreferences.edit());
}
@@ -519,8 +508,7 @@
return mId;
}
- @Nullable
- public static EncryptedType fromId(int id) {
+ public static @Nullable EncryptedType fromId(int id) {
switch (id) {
case 0:
return STRING;
diff --git a/security/security-crypto/src/main/java/androidx/security/crypto/MasterKey.java b/security/security-crypto/src/main/java/androidx/security/crypto/MasterKey.java
index 0ac7512..9f305e6 100644
--- a/security/security-crypto/src/main/java/androidx/security/crypto/MasterKey.java
+++ b/security/security-crypto/src/main/java/androidx/security/crypto/MasterKey.java
@@ -27,10 +27,11 @@
import android.security.keystore.KeyProperties;
import androidx.annotation.IntRange;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
@@ -65,10 +66,8 @@
private static final int DEFAULT_AUTHENTICATION_VALIDITY_DURATION_SECONDS = 5 * 60;
- @NonNull
- private final String mKeyAlias;
- @Nullable
- private final KeyGenParameterSpec mKeyGenParameterSpec;
+ private final @NonNull String mKeyAlias;
+ private final @Nullable KeyGenParameterSpec mKeyGenParameterSpec;
/**
* Algorithm/Cipher choices used for the master key.
@@ -158,16 +157,14 @@
return Api28Impl.isStrongBoxBacked(mKeyGenParameterSpec);
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
return "MasterKey{keyAlias=" + mKeyAlias
+ ", isKeyStoreBacked=" + isKeyStoreBacked()
+ "}";
}
- @NonNull
- /* package */ String getKeyAlias() {
+ /* package */ @NonNull String getKeyAlias() {
return mKeyAlias;
}
@@ -177,13 +174,10 @@
*/
@Deprecated
public static final class Builder {
- @NonNull
- final String mKeyAlias;
+ final @NonNull String mKeyAlias;
- @Nullable
- KeyGenParameterSpec mKeyGenParameterSpec;
- @Nullable
- KeyScheme mKeyScheme;
+ @Nullable KeyGenParameterSpec mKeyGenParameterSpec;
+ @Nullable KeyScheme mKeyScheme;
boolean mAuthenticationRequired;
int mUserAuthenticationValidityDurationSeconds;
@@ -222,8 +216,7 @@
* @param keyScheme The KeyScheme to use.
* @return This builder.
*/
- @NonNull
- public Builder setKeyScheme(@NonNull KeyScheme keyScheme) {
+ public @NonNull Builder setKeyScheme(@NonNull KeyScheme keyScheme) {
switch (keyScheme) {
case AES256_GCM:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
@@ -252,8 +245,7 @@
* the key.
* @return This builder.
*/
- @NonNull
- public Builder setUserAuthenticationRequired(boolean authenticationRequired) {
+ public @NonNull Builder setUserAuthenticationRequired(boolean authenticationRequired) {
return setUserAuthenticationRequired(authenticationRequired,
getDefaultAuthenticationValidityDurationSeconds());
}
@@ -271,8 +263,7 @@
* authentication.
* @return This builder.
*/
- @NonNull
- public Builder setUserAuthenticationRequired(boolean authenticationRequired,
+ public @NonNull Builder setUserAuthenticationRequired(boolean authenticationRequired,
@IntRange(from = 1) int userAuthenticationValidityDurationSeconds) {
mAuthenticationRequired = authenticationRequired;
mUserAuthenticationValidityDurationSeconds = userAuthenticationValidityDurationSeconds;
@@ -287,8 +278,7 @@
* @param requestStrongBoxBacked Whether to request to use strongbox
* @return This builder.
*/
- @NonNull
- public Builder setRequestStrongBoxBacked(boolean requestStrongBoxBacked) {
+ public @NonNull Builder setRequestStrongBoxBacked(boolean requestStrongBoxBacked) {
mRequestStrongBoxBacked = requestStrongBoxBacked;
return this;
}
@@ -302,9 +292,9 @@
* @param keyGenParameterSpec The key spec to use.
* @return This builder.
*/
- @NonNull
@RequiresApi(Build.VERSION_CODES.M)
- public Builder setKeyGenParameterSpec(@NonNull KeyGenParameterSpec keyGenParameterSpec) {
+ public @NonNull Builder setKeyGenParameterSpec(
+ @NonNull KeyGenParameterSpec keyGenParameterSpec) {
if (mKeyScheme != null) {
throw new IllegalArgumentException("KeyGenParamSpec set after setting a "
+ "KeyScheme");
@@ -323,8 +313,7 @@
*
* @return The master key.
*/
- @NonNull
- public MasterKey build() throws GeneralSecurityException, IOException {
+ public @NonNull MasterKey build() throws GeneralSecurityException, IOException {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return Api23Impl.build(this);
} else {
diff --git a/security/security-crypto/src/main/java/androidx/security/crypto/MasterKeys.java b/security/security-crypto/src/main/java/androidx/security/crypto/MasterKeys.java
index bd7edf2..75aea95 100644
--- a/security/security-crypto/src/main/java/androidx/security/crypto/MasterKeys.java
+++ b/security/security-crypto/src/main/java/androidx/security/crypto/MasterKeys.java
@@ -20,10 +20,11 @@
import android.security.keystore.KeyGenParameterSpec;
import android.security.keystore.KeyProperties;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting;
+import org.jspecify.annotations.NonNull;
+
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
@@ -53,9 +54,8 @@
/**
* @deprecated Use {@link android.security.keystore.KeyGenParameterSpec.Builder} instead.
*/
- @NonNull
@Deprecated
- public static final KeyGenParameterSpec AES256_GCM_SPEC =
+ public static final @NonNull KeyGenParameterSpec AES256_GCM_SPEC =
createAES256GCMKeyGenParameterSpec(MASTER_KEY_ALIAS);
private static final Object sLock = new Object();
@@ -70,9 +70,8 @@
* @param keyAlias The alias for the master key
* @return The spec for the master key with the specified keyAlias
*/
- @NonNull
@SuppressWarnings("SameParameterValue")
- private static KeyGenParameterSpec createAES256GCMKeyGenParameterSpec(
+ private static @NonNull KeyGenParameterSpec createAES256GCMKeyGenParameterSpec(
@NonNull String keyAlias) {
KeyGenParameterSpec.Builder builder = new KeyGenParameterSpec.Builder(
keyAlias,
@@ -92,8 +91,7 @@
* @param keyGenParameterSpec The key encryption scheme
* @return The key alias for the master key
*/
- @NonNull
- public static String getOrCreate(
+ public static @NonNull String getOrCreate(
@NonNull KeyGenParameterSpec keyGenParameterSpec)
throws GeneralSecurityException, IOException {
validate(keyGenParameterSpec);
diff --git a/security/security-identity-credential/build.gradle b/security/security-identity-credential/build.gradle
index 180b1cf..9857044 100644
--- a/security/security-identity-credential/build.gradle
+++ b/security/security-identity-credential/build.gradle
@@ -31,6 +31,7 @@
}
dependencies {
+ api(libs.jspecify)
implementation("androidx.annotation:annotation:1.8.1")
implementation("androidx.biometric:biometric:1.1.0")
implementation("co.nstant.in:cbor:0.8")
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/AccessControlProfile.java b/security/security-identity-credential/src/main/java/androidx/security/identity/AccessControlProfile.java
index b2be22a..cf03728 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/AccessControlProfile.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/AccessControlProfile.java
@@ -16,8 +16,8 @@
package androidx.security.identity;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.security.cert.X509Certificate;
@@ -33,8 +33,7 @@
AccessControlProfile() {
}
- @NonNull
- AccessControlProfileId getAccessControlProfileId() {
+ @NonNull AccessControlProfileId getAccessControlProfileId() {
return mAccessControlProfileId;
}
@@ -46,8 +45,7 @@
return mUserAuthenticationRequired;
}
- @Nullable
- X509Certificate getReaderCertificate() {
+ @Nullable X509Certificate getReaderCertificate() {
return mReaderCertificate;
}
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/AlreadyPersonalizedException.java b/security/security-identity-credential/src/main/java/androidx/security/identity/AlreadyPersonalizedException.java
index d77c01c..4cbecdb 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/AlreadyPersonalizedException.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/AlreadyPersonalizedException.java
@@ -16,7 +16,7 @@
package androidx.security.identity;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* Thrown if trying to create a credential which already exists.
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/CipherSuiteNotSupportedException.java b/security/security-identity-credential/src/main/java/androidx/security/identity/CipherSuiteNotSupportedException.java
index 4fdc8d8..5b48822 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/CipherSuiteNotSupportedException.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/CipherSuiteNotSupportedException.java
@@ -16,7 +16,7 @@
package androidx.security.identity;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* Thrown if trying to use a cipher suite which isn't supported.
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/CredentialData.java b/security/security-identity-credential/src/main/java/androidx/security/identity/CredentialData.java
index 7ddaf24..a53f4c3 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/CredentialData.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/CredentialData.java
@@ -24,7 +24,7 @@
import android.util.Log;
import android.util.Pair;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -356,7 +356,7 @@
}
// Returns COSE_Sign1 with payload set to ProofOfOwnership
- @NonNull byte[] proveOwnership(@NonNull byte[] challenge) {
+ byte @NonNull [] proveOwnership(byte @NonNull [] challenge) {
PrivateKey key = getCredentialKeyPrivate();
CborBuilder signedDataBuilder = new CborBuilder();
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/DocTypeNotSupportedException.java b/security/security-identity-credential/src/main/java/androidx/security/identity/DocTypeNotSupportedException.java
index 90433a6..322a22b 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/DocTypeNotSupportedException.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/DocTypeNotSupportedException.java
@@ -16,7 +16,7 @@
package androidx.security.identity;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* Thrown if trying to create a credential with an unsupported document type.
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/EphemeralPublicKeyNotFoundException.java b/security/security-identity-credential/src/main/java/androidx/security/identity/EphemeralPublicKeyNotFoundException.java
index 0f671eb..1b7a10f 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/EphemeralPublicKeyNotFoundException.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/EphemeralPublicKeyNotFoundException.java
@@ -16,7 +16,7 @@
package androidx.security.identity;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
import java.util.Map;
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/HardwareIdentityCredential.java b/security/security-identity-credential/src/main/java/androidx/security/identity/HardwareIdentityCredential.java
index 76c8677..775bec1 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/HardwareIdentityCredential.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/HardwareIdentityCredential.java
@@ -19,11 +19,12 @@
import android.icu.util.Calendar;
import android.os.Build;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.biometric.BiometricPrompt;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.nio.ByteBuffer;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
@@ -83,7 +84,7 @@
}
@Override
- public void setSessionTranscript(@NonNull byte[] sessionTranscript) {
+ public void setSessionTranscript(byte @NonNull [] sessionTranscript) {
if (mSessionTranscript != null) {
throw new RuntimeException("SessionTranscript already set");
}
@@ -128,8 +129,7 @@
}
@Override
- public @NonNull
- byte[] encryptMessageToReader(@NonNull byte[] messagePlaintext) {
+ public byte @NonNull [] encryptMessageToReader(byte @NonNull [] messagePlaintext) {
ensureSessionEncryptionKey();
byte[] messageCiphertextAndAuthTag = null;
try {
@@ -154,8 +154,7 @@
}
@Override
- public @NonNull
- byte[] decryptMessageFromReader(@NonNull byte[] messageCiphertext)
+ public byte @NonNull [] decryptMessageFromReader(byte @NonNull [] messageCiphertext)
throws MessageDecryptionException {
ensureSessionEncryptionKey();
ByteBuffer iv = ByteBuffer.allocate(12);
@@ -181,8 +180,7 @@
}
@Override
- public @NonNull
- Collection<X509Certificate> getCredentialKeyCertificateChain() {
+ public @NonNull Collection<X509Certificate> getCredentialKeyCertificateChain() {
return mCredential.getCredentialKeyCertificateChain();
}
@@ -193,19 +191,17 @@
}
@Override
- @Nullable
- public BiometricPrompt.CryptoObject getCryptoObject() {
+ public BiometricPrompt.@Nullable CryptoObject getCryptoObject() {
BiometricPrompt.CryptoObject cryptoObject = new BiometricPrompt.CryptoObject(mCredential);
return cryptoObject;
}
@SuppressWarnings("deprecation")
@Override
- @NonNull
- public ResultData getEntries(
- @Nullable byte[] requestMessage,
- @NonNull java.util.Map<String, Collection<String>> entriesToRequest,
- @Nullable byte[] readerSignature)
+ public @NonNull ResultData getEntries(
+ byte @Nullable [] requestMessage,
+ java.util.@NonNull Map<String, Collection<String>> entriesToRequest,
+ byte @Nullable [] readerSignature)
throws NoAuthenticationKeyAvailableException,
InvalidReaderSignatureException, InvalidRequestMessageException,
EphemeralPublicKeyNotFoundException {
@@ -255,15 +251,14 @@
}
@Override
- public @NonNull
- Collection<X509Certificate> getAuthKeysNeedingCertification() {
+ public @NonNull Collection<X509Certificate> getAuthKeysNeedingCertification() {
return mCredential.getAuthKeysNeedingCertification();
}
@SuppressWarnings("deprecation")
@Override
public void storeStaticAuthenticationData(@NonNull X509Certificate authenticationKey,
- @NonNull byte[] staticAuthData) throws UnknownAuthenticationKeyException {
+ byte @NonNull [] staticAuthData) throws UnknownAuthenticationKeyException {
try {
mCredential.storeStaticAuthenticationData(authenticationKey, staticAuthData);
} catch (android.security.identity.UnknownAuthenticationKeyException e) {
@@ -273,8 +268,7 @@
@SuppressWarnings("deprecation")
@Override
- public @NonNull
- int[] getAuthenticationDataUsageCount() {
+ public int @NonNull [] getAuthenticationDataUsageCount() {
return mCredential.getAuthenticationDataUsageCount();
}
@@ -282,37 +276,37 @@
private static class ApiImplS {
@SuppressWarnings("deprecation")
static void callSetAllowUsingExpiredKeys(
- @NonNull android.security.identity.IdentityCredential credential,
+ android.security.identity.@NonNull IdentityCredential credential,
boolean allowUsingExpiredKeys) {
credential.setAllowUsingExpiredKeys(allowUsingExpiredKeys);
}
static void callStoreStaticAuthenticationData(
- @NonNull android.security.identity.IdentityCredential credential,
+ android.security.identity.@NonNull IdentityCredential credential,
@NonNull X509Certificate authenticationKey,
@NonNull Instant expirationDate,
- @NonNull byte[] staticAuthData)
+ byte @NonNull [] staticAuthData)
throws android.security.identity.UnknownAuthenticationKeyException {
credential.storeStaticAuthenticationData(authenticationKey,
expirationDate,
staticAuthData);
}
- static @NonNull byte[] callProveOwnership(
- @NonNull android.security.identity.IdentityCredential credential,
- @NonNull byte[] challenge) {
+ static byte @NonNull [] callProveOwnership(
+ android.security.identity.@NonNull IdentityCredential credential,
+ byte @NonNull [] challenge) {
return credential.proveOwnership(challenge);
}
- static @NonNull byte[] callDelete(
- @NonNull android.security.identity.IdentityCredential credential,
- @NonNull byte[] challenge) {
+ static byte @NonNull [] callDelete(
+ android.security.identity.@NonNull IdentityCredential credential,
+ byte @NonNull [] challenge) {
return credential.delete(challenge);
}
- static @NonNull byte[] callUpdate(
- @NonNull android.security.identity.IdentityCredential credential,
- @NonNull android.security.identity.PersonalizationData personalizationData) {
+ static byte @NonNull [] callUpdate(
+ android.security.identity.@NonNull IdentityCredential credential,
+ android.security.identity.@NonNull PersonalizationData personalizationData) {
return credential.update(personalizationData);
}
}
@@ -330,7 +324,7 @@
public void storeStaticAuthenticationData(
@NonNull X509Certificate authenticationKey,
@NonNull Calendar expirationDate,
- @NonNull byte[] staticAuthData)
+ byte @NonNull [] staticAuthData)
throws UnknownAuthenticationKeyException {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
try {
@@ -349,7 +343,7 @@
}
@Override
- public @NonNull byte[] proveOwnership(@NonNull byte[] challenge) {
+ public byte @NonNull [] proveOwnership(byte @NonNull [] challenge) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
return ApiImplS.callProveOwnership(mCredential, challenge);
} else {
@@ -358,7 +352,7 @@
}
@Override
- public @NonNull byte[] delete(@NonNull byte[] challenge) {
+ public byte @NonNull [] delete(byte @NonNull [] challenge) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
return ApiImplS.callDelete(mCredential, challenge);
} else {
@@ -367,7 +361,7 @@
}
@Override
- public @NonNull byte[] update(@NonNull PersonalizationData personalizationData) {
+ public byte @NonNull [] update(@NonNull PersonalizationData personalizationData) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
return ApiImplS.callUpdate(mCredential,
HardwareWritableIdentityCredential.convertPDFromJetpack(personalizationData));
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/HardwareIdentityCredentialStore.java b/security/security-identity-credential/src/main/java/androidx/security/identity/HardwareIdentityCredentialStore.java
index 4446489..09f0a3e7 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/HardwareIdentityCredentialStore.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/HardwareIdentityCredentialStore.java
@@ -20,10 +20,11 @@
import android.content.pm.PackageManager;
import android.os.Build;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -38,7 +39,7 @@
private boolean mIsDirectAccess = false;
private HardwareIdentityCredentialStore(
- @NonNull android.security.identity.IdentityCredentialStore store,
+ android.security.identity.@NonNull IdentityCredentialStore store,
@NonNull Context context,
boolean isDirectAccess) {
mStore = store;
@@ -94,7 +95,7 @@
@SuppressWarnings("deprecation")
@Override
- public @NonNull String[] getSupportedDocTypes() {
+ public String @NonNull [] getSupportedDocTypes() {
Set<String> docTypeSet = getCapabilities().getSupportedDocTypes();
String[] docTypes = new String[docTypeSet.size()];
int n = 0;
@@ -138,15 +139,14 @@
@SuppressWarnings("deprecation")
@Override
- public @Nullable byte[] deleteCredentialByName(@NonNull String credentialName) {
+ public byte @Nullable [] deleteCredentialByName(@NonNull String credentialName) {
return mStore.deleteCredentialByName(credentialName);
}
SimpleIdentityCredentialStoreCapabilities mCapabilities = null;
@Override
- public @NonNull
- IdentityCredentialStoreCapabilities getCapabilities() {
+ public @NonNull IdentityCredentialStoreCapabilities getCapabilities() {
LinkedHashSet<String> supportedDocTypesSet =
new LinkedHashSet<>(Arrays.asList(mStore.getSupportedDocTypes()));
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/HardwareWritableIdentityCredential.java b/security/security-identity-credential/src/main/java/androidx/security/identity/HardwareWritableIdentityCredential.java
index 686c500..8da9547 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/HardwareWritableIdentityCredential.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/HardwareWritableIdentityCredential.java
@@ -18,9 +18,10 @@
import android.os.Build;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
+import org.jspecify.annotations.NonNull;
+
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collection;
@@ -39,11 +40,11 @@
@Override
public @NonNull Collection<X509Certificate> getCredentialKeyCertificateChain(
- @NonNull byte[] challenge) {
+ byte @NonNull [] challenge) {
return mWritableCredential.getCredentialKeyCertificateChain(challenge);
}
- static @NonNull android.security.identity.PersonalizationData convertPDFromJetpack(
+ static android.security.identity.@NonNull PersonalizationData convertPDFromJetpack(
@NonNull PersonalizationData personalizationData) {
android.security.identity.PersonalizationData.Builder builder =
@@ -78,8 +79,7 @@
}
@Override
- @NonNull
- public byte[] personalize(@NonNull PersonalizationData personalizationData) {
+ public byte @NonNull [] personalize(@NonNull PersonalizationData personalizationData) {
return mWritableCredential.personalize(convertPDFromJetpack(personalizationData));
}
}
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/IdentityCredential.java b/security/security-identity-credential/src/main/java/androidx/security/identity/IdentityCredential.java
index 4e4a17a..f12db719 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/IdentityCredential.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/IdentityCredential.java
@@ -18,11 +18,12 @@
import android.icu.util.Calendar;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.biometric.BiometricPrompt;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.security.InvalidKeyException;
import java.security.KeyPair;
import java.security.PublicKey;
@@ -51,7 +52,7 @@
*
* @return ephemeral key pair to use to establish a secure channel with a reader.
*/
- public @NonNull abstract KeyPair createEphemeralKeyPair();
+ public abstract @NonNull KeyPair createEphemeralKeyPair();
/**
* Set the ephemeral public key provided by the reader. This must be called before
@@ -72,7 +73,7 @@
*
* @param sessionTranscript the session transcript.
*/
- public abstract void setSessionTranscript(@NonNull byte[] sessionTranscript);
+ public abstract void setSessionTranscript(byte @NonNull [] sessionTranscript);
/**
* Encrypt a message for transmission to the reader.
@@ -84,7 +85,7 @@
* @param messagePlaintext unencrypted message to encrypt.
* @return encrypted message.
*/
- public @NonNull abstract byte[] encryptMessageToReader(@NonNull byte[] messagePlaintext);
+ public abstract byte @NonNull [] encryptMessageToReader(byte @NonNull [] messagePlaintext);
/**
* Decrypt a message received from the reader.
@@ -97,7 +98,7 @@
* @return decrypted message.
* @throws MessageDecryptionException if the ciphertext couldn't be decrypted.
*/
- public @NonNull abstract byte[] decryptMessageFromReader(@NonNull byte[] messageCiphertext)
+ public abstract byte @NonNull [] decryptMessageFromReader(byte @NonNull [] messageCiphertext)
throws MessageDecryptionException;
/**
@@ -110,7 +111,7 @@
*
* @return the certificate chain for this credential's CredentialKey.
*/
- public @NonNull abstract Collection<X509Certificate> getCredentialKeyCertificateChain();
+ public abstract @NonNull Collection<X509Certificate> getCredentialKeyCertificateChain();
/**
* Sets whether to allow using an authentication key which use count has been exceeded if no
@@ -163,8 +164,7 @@
* @return A {@link BiometricPrompt.CryptoObject} which can be used with
* {@link BiometricPrompt} or {@code null}.
*/
- @Nullable
- public abstract BiometricPrompt.CryptoObject getCryptoObject();
+ public abstract BiometricPrompt.@Nullable CryptoObject getCryptoObject();
/**
* Retrieve data entries and associated data from this {@code IdentityCredential}.
@@ -287,9 +287,9 @@
* the session transcript.
*/
public abstract @NonNull ResultData getEntries(
- @Nullable byte[] requestMessage,
+ byte @Nullable [] requestMessage,
@NonNull Map<String, Collection<String>> entriesToRequest,
- @Nullable byte[] readerSignature)
+ byte @Nullable [] readerSignature)
throws NoAuthenticationKeyAvailableException,
InvalidReaderSignatureException, EphemeralPublicKeyNotFoundException,
InvalidRequestMessageException;
@@ -353,7 +353,7 @@
* @return A collection of X.509 certificates for dynamic authentication keys that need issuer
* certification.
*/
- public @NonNull abstract Collection<X509Certificate> getAuthKeysNeedingCertification();
+ public abstract @NonNull Collection<X509Certificate> getAuthKeysNeedingCertification();
/**
* Store authentication data associated with a dynamic authentication key.
@@ -373,7 +373,7 @@
@Deprecated
public abstract void storeStaticAuthenticationData(
@NonNull X509Certificate authenticationKey,
- @NonNull byte[] staticAuthData)
+ byte @NonNull [] staticAuthData)
throws UnknownAuthenticationKeyException;
/**
@@ -397,7 +397,7 @@
public void storeStaticAuthenticationData(
@NonNull X509Certificate authenticationKey,
@NonNull Calendar expirationDate,
- @NonNull byte[] staticAuthData)
+ byte @NonNull [] staticAuthData)
throws UnknownAuthenticationKeyException {
throw new UnsupportedOperationException();
}
@@ -407,7 +407,7 @@
*
* @return int array of dynamic authentication key usage counts.
*/
- public @NonNull abstract int[] getAuthenticationDataUsageCount();
+ public abstract int @NonNull [] getAuthenticationDataUsageCount();
/**
@@ -435,7 +435,7 @@
* returned proof is fresh.
* @return the COSE_Sign1 data structure above
*/
- public @NonNull byte[] proveOwnership(@NonNull byte[] challenge) {
+ public byte @NonNull [] proveOwnership(byte @NonNull [] challenge) {
throw new UnsupportedOperationException();
}
@@ -464,7 +464,7 @@
* returned proof is fresh.
* @return the COSE_Sign1 data structure above
*/
- public @NonNull byte[] delete(@NonNull byte[] challenge) {
+ public byte @NonNull [] delete(byte @NonNull [] challenge) {
throw new UnsupportedOperationException();
}
@@ -489,7 +489,7 @@
* and data elements and their values, grouped into namespaces.
* @return A COSE_Sign1 data structure, see above.
*/
- public @NonNull byte[] update(@NonNull PersonalizationData personalizationData) {
+ public byte @NonNull [] update(@NonNull PersonalizationData personalizationData) {
throw new UnsupportedOperationException();
}
}
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/IdentityCredentialException.java b/security/security-identity-credential/src/main/java/androidx/security/identity/IdentityCredentialException.java
index 7f89d8d..26a6211 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/IdentityCredentialException.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/IdentityCredentialException.java
@@ -16,7 +16,7 @@
package androidx.security.identity;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* Base class for all Identity Credential exceptions.
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/IdentityCredentialStore.java b/security/security-identity-credential/src/main/java/androidx/security/identity/IdentityCredentialStore.java
index cf2d8d2..4504e8e 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/IdentityCredentialStore.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/IdentityCredentialStore.java
@@ -20,10 +20,11 @@
import android.os.Build;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.security.cert.X509Certificate;
@@ -156,8 +157,8 @@
* @return the {@link IdentityCredentialStore} or {@code null} if direct access is not
* supported on this device.
*/
- public static @NonNull IdentityCredentialStore getDirectAccessInstance(@NonNull
- Context context) {
+ public static @NonNull IdentityCredentialStore getDirectAccessInstance(
+ @NonNull Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Context appContext = context.getApplicationContext();
IdentityCredentialStore store = HardwareIdentityCredentialStore.getDirectAccessInstance(
@@ -206,7 +207,7 @@
* @deprecated Use {@link IdentityCredentialStoreCapabilities#getSupportedDocTypes()} instead.
*/
@Deprecated
- public abstract @NonNull String[] getSupportedDocTypes();
+ public abstract String @NonNull [] getSupportedDocTypes();
/**
* Creates a new credential.
@@ -257,7 +258,7 @@
* @deprecated Use {@link IdentityCredential#delete(byte[])} instead.
*/
@Deprecated
- public abstract @Nullable byte[] deleteCredentialByName(@NonNull String credentialName);
+ public abstract byte @Nullable [] deleteCredentialByName(@NonNull String credentialName);
@Retention(RetentionPolicy.SOURCE)
@RestrictTo(RestrictTo.Scope.LIBRARY)
@@ -270,8 +271,7 @@
*
* @return the capabilities of the store
*/
- @NonNull
- public IdentityCredentialStoreCapabilities getCapabilities() {
+ public @NonNull IdentityCredentialStoreCapabilities getCapabilities() {
throw new UnsupportedOperationException();
}
@@ -283,8 +283,7 @@
* of Android Keystore.
*/
@SuppressWarnings("deprecation")
- public static @NonNull IdentityCredentialStore getSoftwareInstance(@NonNull
- Context context) {
+ public static @NonNull IdentityCredentialStore getSoftwareInstance(@NonNull Context context) {
return SoftwareIdentityCredentialStore.getInstance(context);
}
@@ -301,8 +300,7 @@
* Credential HAL.
*/
@SuppressWarnings("deprecation")
- public static @Nullable IdentityCredentialStore getHardwareInstance(@NonNull
- Context context) {
+ public static @Nullable IdentityCredentialStore getHardwareInstance(@NonNull Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
return HardwareIdentityCredentialStore.getInstance(context);
}
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/IdentityCredentialStoreCapabilities.java b/security/security-identity-credential/src/main/java/androidx/security/identity/IdentityCredentialStoreCapabilities.java
index 3fb35d6..81b54189 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/IdentityCredentialStoreCapabilities.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/IdentityCredentialStoreCapabilities.java
@@ -18,7 +18,7 @@
import android.icu.util.Calendar;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
import java.security.cert.X509Certificate;
import java.util.Set;
@@ -107,8 +107,7 @@
*
* @return The supported document types or the empty set if any document type is supported.
*/
- public @NonNull
- Set<String> getSupportedDocTypes() {
+ public @NonNull Set<String> getSupportedDocTypes() {
throw new UnsupportedOperationException();
}
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/InvalidReaderSignatureException.java b/security/security-identity-credential/src/main/java/androidx/security/identity/InvalidReaderSignatureException.java
index e551b1a..4294c37 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/InvalidReaderSignatureException.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/InvalidReaderSignatureException.java
@@ -16,7 +16,7 @@
package androidx.security.identity;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* Thrown if the reader signature is invalid, or it doesn't contain a certificate chain, or if the
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/InvalidRequestMessageException.java b/security/security-identity-credential/src/main/java/androidx/security/identity/InvalidRequestMessageException.java
index ab3dd61..601ede3 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/InvalidRequestMessageException.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/InvalidRequestMessageException.java
@@ -16,7 +16,7 @@
package androidx.security.identity;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
import java.util.Map;
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/MessageDecryptionException.java b/security/security-identity-credential/src/main/java/androidx/security/identity/MessageDecryptionException.java
index eaff383..9e73c66 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/MessageDecryptionException.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/MessageDecryptionException.java
@@ -16,7 +16,7 @@
package androidx.security.identity;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* Thrown when failing to decrypt a message from the reader device.
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/NoAuthenticationKeyAvailableException.java b/security/security-identity-credential/src/main/java/androidx/security/identity/NoAuthenticationKeyAvailableException.java
index 4b74f26..fd9b077 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/NoAuthenticationKeyAvailableException.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/NoAuthenticationKeyAvailableException.java
@@ -16,7 +16,7 @@
package androidx.security.identity;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* Thrown if no dynamic authentication keys are available.
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/PersonalizationData.java b/security/security-identity-credential/src/main/java/androidx/security/identity/PersonalizationData.java
index 657d67d..e7669bd 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/PersonalizationData.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/PersonalizationData.java
@@ -19,7 +19,7 @@
import android.annotation.SuppressLint;
import android.icu.util.Calendar;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
import java.util.ArrayList;
import java.util.Collection;
@@ -63,8 +63,8 @@
static class NamespaceData {
- @NonNull protected String mNamespace;
- @NonNull protected LinkedHashMap<String, EntryData> mEntries = new LinkedHashMap<>();
+ protected @NonNull String mNamespace;
+ protected @NonNull LinkedHashMap<String, EntryData> mEntries = new LinkedHashMap<>();
protected NamespaceData(@NonNull String namespace) {
this.mNamespace = namespace;
@@ -137,7 +137,7 @@
@SuppressLint("BuilderSetStyle")
public @NonNull Builder putEntry(@NonNull String namespace, @NonNull String name,
@NonNull Collection<AccessControlProfileId> accessControlProfileIds,
- @NonNull byte[] value) {
+ byte @NonNull [] value) {
NamespaceData namespaceData = mData.mNamespaces.get(namespace);
if (namespaceData == null) {
namespaceData = new NamespaceData(namespace);
@@ -184,7 +184,7 @@
@SuppressLint("BuilderSetStyle")
public @NonNull Builder putEntryBytestring(@NonNull String namespace, @NonNull String name,
@NonNull Collection<AccessControlProfileId> accessControlProfileIds,
- @NonNull byte[] value) {
+ byte @NonNull [] value) {
return putEntry(namespace, name, accessControlProfileIds,
Util.cborEncodeBytestring(value));
}
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/ResultData.java b/security/security-identity-credential/src/main/java/androidx/security/identity/ResultData.java
index b794d97..71aebf2 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/ResultData.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/ResultData.java
@@ -21,10 +21,11 @@
import android.icu.util.Calendar;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.security.PublicKey;
import java.util.Collection;
@@ -109,7 +110,7 @@
*
* @return The bytes of the {@code DeviceNameSpaces} CBOR structure.
*/
- public abstract @NonNull byte[] getAuthenticatedData();
+ public abstract byte @NonNull [] getAuthenticatedData();
/**
* Returns a message authentication code over the {@code DeviceAuthenticationBytes} CBOR
@@ -135,7 +136,7 @@
* @return A COSE_Mac0 structure with the message authentication code as described above
* or {@code null} if the conditions specified above are not met.
*/
- public abstract @Nullable byte[] getMessageAuthenticationCode();
+ public abstract byte @Nullable [] getMessageAuthenticationCode();
/**
* Returns a digital signature over the {@code DeviceAuthenticationBytes} CBOR
@@ -149,7 +150,7 @@
* @return {@code null} if not implemented, otherwise a COSE_Sign1 structure with the payload
* set to the data returned by {@link #getAuthenticatedData()}.
*/
- public abstract @Nullable byte[] getEcdsaSignature();
+ public abstract byte @Nullable [] getEcdsaSignature();
/**
* Returns the static authentication data associated with the dynamic authentication
@@ -158,7 +159,7 @@
* @return The static authentication data associated with dynamic authentication key used to
* MAC the data.
*/
- public abstract @NonNull byte[] getStaticAuthenticationData();
+ public abstract byte @NonNull [] getStaticAuthenticationData();
/**
* Gets the names of namespaces with retrieved entries.
@@ -222,7 +223,7 @@
* @param name the name of the entry to get the value for.
* @return the raw CBOR data or {@code null} if no entry with the given name exists.
*/
- public abstract @Nullable byte[] getEntry(@NonNull String namespaceName, @NonNull String name);
+ public abstract byte @Nullable [] getEntry(@NonNull String namespaceName, @NonNull String name);
/**
* Gets the value of an entry.
@@ -252,7 +253,7 @@
* @param name the name of the entry to get the value for.
* @return a {@code byte[]} or {@code null} if no entry with the given name exists.
*/
- public @Nullable byte[] getEntryBytestring(@NonNull String namespaceName,
+ public byte @Nullable [] getEntryBytestring(@NonNull String namespaceName,
@NonNull String name) {
byte[] value = getEntry(namespaceName, name);
if (value == null) {
@@ -307,8 +308,7 @@
* @param name the name of the entry to get the value for.
* @return a {@code Calendar} or {@code null} if no entry with the given name exists.
*/
- public @Nullable
- Calendar getEntryCalendar(@NonNull String namespaceName,
+ public @Nullable Calendar getEntryCalendar(@NonNull String namespaceName,
@NonNull String name) {
byte[] value = getEntry(namespaceName, name);
if (value == null) {
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/SimpleIdentityCredentialStoreCapabilities.java b/security/security-identity-credential/src/main/java/androidx/security/identity/SimpleIdentityCredentialStoreCapabilities.java
index 3c35587..238567f 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/SimpleIdentityCredentialStoreCapabilities.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/SimpleIdentityCredentialStoreCapabilities.java
@@ -16,7 +16,7 @@
package androidx.security.identity;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
import java.util.Set;
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/SimpleResultData.java b/security/security-identity-credential/src/main/java/androidx/security/identity/SimpleResultData.java
index f21314c..30f931e 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/SimpleResultData.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/SimpleResultData.java
@@ -16,8 +16,8 @@
package androidx.security.identity;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collection;
@@ -51,22 +51,22 @@
SimpleResultData() {}
@Override
- public @NonNull byte[] getAuthenticatedData() {
+ public byte @NonNull [] getAuthenticatedData() {
return mAuthenticatedData;
}
@Override
- public @Nullable byte[] getMessageAuthenticationCode() {
+ public byte @Nullable [] getMessageAuthenticationCode() {
return mMessageAuthenticationCode;
}
@Override
- public @Nullable byte[] getEcdsaSignature() {
+ public byte @Nullable [] getEcdsaSignature() {
return mEcdsaSignature;
}
@Override
- public @NonNull byte[] getStaticAuthenticationData() {
+ public byte @NonNull [] getStaticAuthenticationData() {
return mStaticAuthenticationData;
}
@@ -118,7 +118,7 @@
}
@Override
- public @Nullable byte[] getEntry(@NonNull String namespaceName, @NonNull String name) {
+ public byte @Nullable [] getEntry(@NonNull String namespaceName, @NonNull String name) {
EntryData value = getEntryData(namespaceName, name);
if (value == null) {
return null;
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/SoftwareIdentityCredential.java b/security/security-identity-credential/src/main/java/androidx/security/identity/SoftwareIdentityCredential.java
index c8f6c05..2209646 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/SoftwareIdentityCredential.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/SoftwareIdentityCredential.java
@@ -21,10 +21,11 @@
import android.security.keystore.KeyProperties;
import android.util.Pair;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.biometric.BiometricPrompt;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -118,12 +119,12 @@
}
@Override
- public @NonNull byte[] delete(@NonNull byte[] challenge) {
+ public byte @NonNull [] delete(byte @NonNull [] challenge) {
return CredentialData.delete(mContext, mCredentialName, challenge);
}
@Override
- public @NonNull byte[] proveOwnership(@NonNull byte[] challenge) {
+ public byte @NonNull [] proveOwnership(byte @NonNull [] challenge) {
return mData.proveOwnership(challenge);
}
@@ -132,7 +133,7 @@
// This only extracts the requested namespaces, not DocType or RequestInfo. We
// can do this later if it's needed.
private static HashMap<String, Collection<String>> parseRequestMessage(
- @Nullable byte[] requestMessage) {
+ byte @Nullable [] requestMessage) {
HashMap<String, Collection<String>> result = new HashMap<>();
if (requestMessage == null) {
@@ -208,7 +209,7 @@
}
@Override
- public void setSessionTranscript(@NonNull byte[] sessionTranscript) {
+ public void setSessionTranscript(byte @NonNull [] sessionTranscript) {
if (mSessionTranscript != null) {
throw new RuntimeException("SessionTranscript already set");
}
@@ -253,8 +254,7 @@
}
@Override
- public @NonNull
- byte[] encryptMessageToReader(@NonNull byte[] messagePlaintext) {
+ public byte @NonNull [] encryptMessageToReader(byte @NonNull [] messagePlaintext) {
ensureSessionEncryptionKey();
byte[] messageCiphertextAndAuthTag = null;
try {
@@ -279,8 +279,7 @@
}
@Override
- public @NonNull
- byte[] decryptMessageFromReader(@NonNull byte[] messageCiphertext)
+ public byte @NonNull [] decryptMessageFromReader(byte @NonNull [] messageCiphertext)
throws MessageDecryptionException {
ensureSessionEncryptionKey();
ByteBuffer iv = ByteBuffer.allocate(12);
@@ -306,8 +305,7 @@
}
@Override
- public @NonNull
- Collection<X509Certificate> getCredentialKeyCertificateChain() {
+ public @NonNull Collection<X509Certificate> getCredentialKeyCertificateChain() {
return mData.getCredentialKeyCertificateChain();
}
@@ -366,13 +364,12 @@
}
@Override
- @Nullable
- public BiometricPrompt.CryptoObject getCryptoObject() {
+ public BiometricPrompt.@Nullable CryptoObject getCryptoObject() {
ensureCryptoObject();
return mCryptoObject;
}
- private boolean hasEphemeralKeyInSessionTranscript(@NonNull byte[] sessionTranscript) {
+ private boolean hasEphemeralKeyInSessionTranscript(byte @NonNull [] sessionTranscript) {
if (mEphemeralKeyPair == null) {
return false;
}
@@ -428,12 +425,11 @@
}
- @NonNull
@Override
- public ResultData getEntries(
- @Nullable byte[] requestMessage,
- @NonNull java.util.Map<String, Collection<String>> entriesToRequest,
- @Nullable byte[] readerSignature)
+ public @NonNull ResultData getEntries(
+ byte @Nullable [] requestMessage,
+ java.util.@NonNull Map<String, Collection<String>> entriesToRequest,
+ byte @Nullable [] readerSignature)
throws NoAuthenticationKeyAvailableException,
InvalidReaderSignatureException, InvalidRequestMessageException,
EphemeralPublicKeyNotFoundException {
@@ -694,15 +690,14 @@
}
@Override
- public @NonNull
- Collection<X509Certificate> getAuthKeysNeedingCertification() {
+ public @NonNull Collection<X509Certificate> getAuthKeysNeedingCertification() {
return mData.getAuthKeysNeedingCertification();
}
@SuppressWarnings("deprecation")
@Override
public void storeStaticAuthenticationData(@NonNull X509Certificate authenticationKey,
- @NonNull byte[] staticAuthData) throws UnknownAuthenticationKeyException {
+ byte @NonNull [] staticAuthData) throws UnknownAuthenticationKeyException {
mData.storeStaticAuthenticationData(authenticationKey, null, staticAuthData);
}
@@ -710,20 +705,19 @@
public void storeStaticAuthenticationData(
@NonNull X509Certificate authenticationKey,
@NonNull Calendar expirationDate,
- @NonNull byte[] staticAuthData)
+ byte @NonNull [] staticAuthData)
throws UnknownAuthenticationKeyException {
mData.storeStaticAuthenticationData(authenticationKey, expirationDate, staticAuthData);
}
@Override
- public @NonNull
- int[] getAuthenticationDataUsageCount() {
+ public int @NonNull [] getAuthenticationDataUsageCount() {
return mData.getAuthKeyUseCounts();
}
@Override
- public @NonNull byte[] update(@NonNull PersonalizationData personalizationData) {
+ public byte @NonNull [] update(@NonNull PersonalizationData personalizationData) {
try {
String docType = mData.getDocType();
Collection<X509Certificate> certificates = mData.getCredentialKeyCertificateChain();
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/SoftwareIdentityCredentialStore.java b/security/security-identity-credential/src/main/java/androidx/security/identity/SoftwareIdentityCredentialStore.java
index d5bac8d..2dc6377 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/SoftwareIdentityCredentialStore.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/SoftwareIdentityCredentialStore.java
@@ -19,8 +19,8 @@
import android.content.Context;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -41,8 +41,8 @@
}
@SuppressWarnings("deprecation")
- public static @NonNull IdentityCredentialStore getDirectAccessInstance(@NonNull
- Context context) {
+ public static @NonNull IdentityCredentialStore getDirectAccessInstance(
+ @NonNull Context context) {
throw new RuntimeException("Direct-access IdentityCredential is not supported");
}
@@ -53,7 +53,7 @@
@SuppressWarnings("deprecation")
@Override
- public @NonNull String[] getSupportedDocTypes() {
+ public String @NonNull [] getSupportedDocTypes() {
Set<String> docTypeSet = getCapabilities().getSupportedDocTypes();
String[] docTypes = new String[docTypeSet.size()];
int n = 0;
@@ -66,8 +66,7 @@
SimpleIdentityCredentialStoreCapabilities mCapabilities = null;
@Override
- public @NonNull
- IdentityCredentialStoreCapabilities getCapabilities() {
+ public @NonNull IdentityCredentialStoreCapabilities getCapabilities() {
if (mCapabilities == null) {
LinkedHashSet<String> supportedDocTypesSet = new LinkedHashSet<>();
mCapabilities = SimpleIdentityCredentialStoreCapabilities.getFeatureVersion202101(
@@ -100,7 +99,7 @@
@SuppressWarnings("deprecation")
@Override
- public @Nullable byte[] deleteCredentialByName(@NonNull String credentialName) {
+ public byte @Nullable [] deleteCredentialByName(@NonNull String credentialName) {
return SoftwareIdentityCredential.delete(mContext, credentialName);
}
}
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/SoftwareWritableIdentityCredential.java b/security/security-identity-credential/src/main/java/androidx/security/identity/SoftwareWritableIdentityCredential.java
index 29493b5..c1c3d03 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/SoftwareWritableIdentityCredential.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/SoftwareWritableIdentityCredential.java
@@ -20,7 +20,7 @@
import android.security.keystore.KeyGenParameterSpec;
import android.security.keystore.KeyProperties;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -136,7 +136,7 @@
@Override
public @NonNull Collection<X509Certificate> getCredentialKeyCertificateChain(
- @NonNull byte[] challenge) {
+ byte @NonNull [] challenge) {
Collection<X509Certificate> certificates = ensureCredentialKey(challenge);
if (certificates == null) {
throw new RuntimeException(
@@ -193,9 +193,8 @@
return signature;
}
- @NonNull
@Override
- public byte[] personalize(@NonNull PersonalizationData personalizationData) {
+ public byte @NonNull [] personalize(@NonNull PersonalizationData personalizationData) {
try {
ensureCredentialKey(null);
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/UnknownAuthenticationKeyException.java b/security/security-identity-credential/src/main/java/androidx/security/identity/UnknownAuthenticationKeyException.java
index 618dc89..a825f40 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/UnknownAuthenticationKeyException.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/UnknownAuthenticationKeyException.java
@@ -16,7 +16,7 @@
package androidx.security.identity;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* Thrown if trying to certify an unknown dynamic authentication key.
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/Util.java b/security/security-identity-credential/src/main/java/androidx/security/identity/Util.java
index a730041..427a6be41 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/Util.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/Util.java
@@ -25,9 +25,6 @@
import android.security.keystore.KeyProperties;
import android.util.Log;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1OctetString;
@@ -35,6 +32,8 @@
import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder;
import org.bouncycastle.operator.ContentSigner;
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -173,7 +172,7 @@
return cborEncode(new CborBuilder().add(value).build().get(0));
}
- static byte[] cborEncodeBytestring(@NonNull byte[] value) {
+ static byte[] cborEncodeBytestring(byte @NonNull [] value) {
return cborEncode(new CborBuilder().add(value).build().get(0));
}
@@ -212,24 +211,24 @@
return dataItems.get(0);
}
- static boolean cborDecodeBoolean(@NonNull byte[] data) {
+ static boolean cborDecodeBoolean(byte @NonNull [] data) {
SimpleValue simple = (SimpleValue) cborDecode(data);
return simple.getSimpleValueType() == SimpleValueType.TRUE;
}
- static String cborDecodeString(@NonNull byte[] data) {
+ static String cborDecodeString(byte @NonNull [] data) {
return ((co.nstant.in.cbor.model.UnicodeString) cborDecode(data)).getString();
}
- static long cborDecodeLong(@NonNull byte[] data) {
+ static long cborDecodeLong(byte @NonNull [] data) {
return ((co.nstant.in.cbor.model.Number) cborDecode(data)).getValue().longValue();
}
- static byte[] cborDecodeByteString(@NonNull byte[] data) {
+ static byte[] cborDecodeByteString(byte @NonNull [] data) {
return ((co.nstant.in.cbor.model.ByteString) cborDecode(data)).getBytes();
}
- static Calendar cborDecodeDateTime(@NonNull byte[] data) {
+ static Calendar cborDecodeDateTime(byte @NonNull [] data) {
DataItem di = cborDecode(data);
if (!(di instanceof co.nstant.in.cbor.model.UnicodeString)) {
throw new IllegalArgumentException("Passed in data is not a Unicode-string");
@@ -670,7 +669,7 @@
}
public static DataItem coseSign1Sign(Signature s,
- @Nullable byte[] data,
+ byte @Nullable [] data,
byte[] detachedContent,
@Nullable Collection<X509Certificate> certificateChain)
throws CertificateEncodingException {
@@ -724,7 +723,7 @@
}
public static DataItem coseSign1Sign(PrivateKey key,
- @Nullable byte[] data,
+ byte @Nullable [] data,
byte[] additionalData,
@Nullable Collection<X509Certificate> certificateChain)
throws NoSuchAlgorithmException, InvalidKeyException, CertificateEncodingException {
@@ -818,7 +817,7 @@
}
public static DataItem coseMac0(SecretKey key,
- @Nullable byte[] data,
+ byte @Nullable [] data,
byte[] detachedContent) {
int dataLen = (data != null ? data.length : 0);
@@ -911,7 +910,7 @@
// Returns #6.24(bstr) of the given already encoded CBOR
//
- public static @NonNull DataItem cborBuildTaggedByteString(@NonNull byte[] encodedCbor) {
+ public static @NonNull DataItem cborBuildTaggedByteString(byte @NonNull [] encodedCbor) {
DataItem item = new ByteString(encodedCbor);
item.setTag(CBOR_SEMANTIC_TAG_ENCODED_CBOR);
return item;
@@ -1493,8 +1492,8 @@
* type.
* @return CBOR data conforming to the CDDL mentioned above.
*/
- static @NonNull byte[] createItemsRequest(
- @NonNull java.util.Map<String, Collection<String>> entriesToRequest,
+ static byte @NonNull [] createItemsRequest(
+ java.util.@NonNull Map<String, Collection<String>> entriesToRequest,
@Nullable String docType) {
CborBuilder builder = new CborBuilder();
MapBuilder<CborBuilder> mapBuilder = builder.addMap();
diff --git a/security/security-identity-credential/src/main/java/androidx/security/identity/WritableIdentityCredential.java b/security/security-identity-credential/src/main/java/androidx/security/identity/WritableIdentityCredential.java
index 53dafdc..d7da98c 100644
--- a/security/security-identity-credential/src/main/java/androidx/security/identity/WritableIdentityCredential.java
+++ b/security/security-identity-credential/src/main/java/androidx/security/identity/WritableIdentityCredential.java
@@ -16,9 +16,10 @@
package androidx.security.identity;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
import java.security.cert.X509Certificate;
import java.util.Collection;
@@ -72,7 +73,7 @@
* @return the X.509 certificate for this credential's CredentialKey.
*/
public abstract @NonNull Collection<X509Certificate> getCredentialKeyCertificateChain(
- @NonNull byte[] challenge);
+ byte @NonNull [] challenge);
/**
* Stores all of the data in the credential, with the specified access control profiles.
@@ -123,6 +124,6 @@
* and data elements and their values, grouped into namespaces.
* @return A COSE_Sign1 data structure, see above.
*/
- public abstract @NonNull byte[] personalize(
+ public abstract byte @NonNull [] personalize(
@NonNull PersonalizationData personalizationData);
}
diff --git a/settings.gradle b/settings.gradle
index ec91b3e..6edbd68 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -447,6 +447,7 @@
includeProject(":camera:integration-tests:camera-testapp-uiwidgets", "camera/integration-tests/uiwidgetstestapp", [BuildType.CAMERA])
includeProject(":camera:integration-tests:camera-testapp-viewfinder", "camera/integration-tests/viewfindertestapp", [BuildType.CAMERA])
includeProject(":camera:integration-tests:camera-testapp-view", "camera/integration-tests/viewtestapp", [BuildType.CAMERA])
+includeProject(":camera:media3:media3-effect", [BuildType.MAIN])
includeProject(":camera:viewfinder:viewfinder-compose", [BuildType.CAMERA])
includeProject(":camera:viewfinder:viewfinder-core", [BuildType.CAMERA])
includeProject(":camera:viewfinder:viewfinder-core:viewfinder-core-samples", "camera/viewfinder/viewfinder-core/samples", [BuildType.CAMERA])
diff --git a/swiperefreshlayout/swiperefreshlayout/build.gradle b/swiperefreshlayout/swiperefreshlayout/build.gradle
index da01a47..e5c567e 100644
--- a/swiperefreshlayout/swiperefreshlayout/build.gradle
+++ b/swiperefreshlayout/swiperefreshlayout/build.gradle
@@ -13,6 +13,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.annotation:annotation:1.8.1")
api("androidx.core:core:1.1.0")
api("androidx.interpolator:interpolator:1.0.0")
diff --git a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/RequestDisallowInterceptRecordingRecyclerView.java b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/RequestDisallowInterceptRecordingRecyclerView.java
index e199353..44f7c77 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/RequestDisallowInterceptRecordingRecyclerView.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/RequestDisallowInterceptRecordingRecyclerView.java
@@ -18,9 +18,10 @@
import android.content.Context;
-import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
+import org.jspecify.annotations.NonNull;
+
public class RequestDisallowInterceptRecordingRecyclerView extends RecyclerView {
public boolean mRequestDisallowInterceptTrueCalled;
diff --git a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutActions.java b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutActions.java
index 61e927c..c61e8d6 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutActions.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutActions.java
@@ -25,7 +25,6 @@
import org.hamcrest.Matcher;
-
public class SwipeRefreshLayoutActions {
public static ViewAction setRefreshing() {
return new ViewAction() {
diff --git a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInRecyclerViewBaseActivity.java b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInRecyclerViewBaseActivity.java
index e820f36..849a142 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInRecyclerViewBaseActivity.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInRecyclerViewBaseActivity.java
@@ -24,12 +24,13 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
public abstract class SwipeRefreshLayoutInRecyclerViewBaseActivity extends FragmentActivity {
RequestDisallowInterceptRecordingRecyclerView mRecyclerView;
@@ -71,9 +72,8 @@
return position == 1 ? SRL_ITEM : OTHER_ITEM;
}
- @NonNull
@Override
- public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ public @NonNull ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return viewType == SRL_ITEM ? createSrlItem(parent) : createOtherItem(parent);
}
diff --git a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInRecyclerViewWithRecyclerViewChildActivity.java b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInRecyclerViewWithRecyclerViewChildActivity.java
index 05a7d58..9b8b45d 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInRecyclerViewWithRecyclerViewChildActivity.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInRecyclerViewWithRecyclerViewChildActivity.java
@@ -27,11 +27,12 @@
import android.widget.LinearLayout;
import android.widget.TextView;
-import androidx.annotation.NonNull;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
+import org.jspecify.annotations.NonNull;
+
public class SwipeRefreshLayoutInRecyclerViewWithRecyclerViewChildActivity extends
SwipeRefreshLayoutInRecyclerViewBaseActivity {
@Override
@@ -63,9 +64,8 @@
return 100;
}
- @NonNull
@Override
- public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ public @NonNull MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
TextView textView = new TextView(parent.getContext());
textView.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
textView.setGravity(Gravity.CENTER);
diff --git a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInRecyclerViewWithSimpleChildActivity.java b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInRecyclerViewWithSimpleChildActivity.java
index c7998e99..e9e46865 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInRecyclerViewWithSimpleChildActivity.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInRecyclerViewWithSimpleChildActivity.java
@@ -18,7 +18,7 @@
import android.view.View;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
public class SwipeRefreshLayoutInRecyclerViewWithSimpleChildActivity extends
SwipeRefreshLayoutInRecyclerViewBaseActivity {
diff --git a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInScrollingParentBaseTest.java b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInScrollingParentBaseTest.java
index 6486134..9a77a95 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInScrollingParentBaseTest.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutInScrollingParentBaseTest.java
@@ -27,13 +27,13 @@
import android.view.View;
import android.view.ViewConfiguration;
-import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.testutils.PollingCheck;
import androidx.testutils.SwipeInjector;
+import org.jspecify.annotations.Nullable;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -59,8 +59,7 @@
protected abstract
Class<? extends SwipeRefreshLayoutInRecyclerViewBaseActivity> getActivityClass();
- @Nullable
- private SwipeRefreshLayout getSwipeRefreshLayout() {
+ private @Nullable SwipeRefreshLayout getSwipeRefreshLayout() {
return mActivityTestRule.getActivity().mSwipeRefreshLayout;
}
diff --git a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutNestedScrollingChild2Test.java b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutNestedScrollingChild2Test.java
index 1717df6..dd018ae 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutNestedScrollingChild2Test.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutNestedScrollingChild2Test.java
@@ -32,13 +32,13 @@
import android.view.ViewGroup;
import android.widget.FrameLayout;
-import androidx.annotation.NonNull;
import androidx.core.view.NestedScrollingParent2;
import androidx.core.view.ViewCompat;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
+import org.jspecify.annotations.NonNull;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -347,8 +347,8 @@
}
@Override
- public void onNestedPreScroll(@NonNull View target, int dx, int dy, @NonNull int[] consumed,
- int type) {
+ public void onNestedPreScroll(@NonNull View target, int dx, int dy,
+ int @NonNull [] consumed, int type) {
}
diff --git a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutNestedScrollingChild3Test.java b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutNestedScrollingChild3Test.java
index 1020a1b..bb097d1 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutNestedScrollingChild3Test.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutNestedScrollingChild3Test.java
@@ -30,13 +30,13 @@
import android.view.ViewGroup;
import android.widget.FrameLayout;
-import androidx.annotation.NonNull;
import androidx.core.view.NestedScrollingParent3;
import androidx.core.view.ViewCompat;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
+import org.jspecify.annotations.NonNull;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -159,8 +159,8 @@
}
@Override
- public void onNestedPreScroll(@NonNull View target, int dx, int dy, @NonNull int[] consumed,
- int type) {
+ public void onNestedPreScroll(@NonNull View target, int dx, int dy,
+ int @NonNull [] consumed, int type) {
}
diff --git a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutNestedScrollingParent2Test.java b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutNestedScrollingParent2Test.java
index fa6c36a..43c4275 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutNestedScrollingParent2Test.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutNestedScrollingParent2Test.java
@@ -33,13 +33,13 @@
import android.view.ViewGroup;
import android.widget.FrameLayout;
-import androidx.annotation.NonNull;
import androidx.core.view.NestedScrollingParent2;
import androidx.core.view.ViewCompat;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
+import org.jspecify.annotations.NonNull;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -406,8 +406,8 @@
}
@Override
- public void onNestedPreScroll(@NonNull View target, int dx, int dy, @NonNull int[] consumed,
- int type) {
+ public void onNestedPreScroll(@NonNull View target, int dx, int dy,
+ int @NonNull [] consumed, int type) {
}
diff --git a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutNestedScrollingParent3Test.java b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutNestedScrollingParent3Test.java
index ece591a..56e8fb4 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutNestedScrollingParent3Test.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutNestedScrollingParent3Test.java
@@ -32,13 +32,13 @@
import android.view.ViewGroup;
import android.widget.FrameLayout;
-import androidx.annotation.NonNull;
import androidx.core.view.NestedScrollingParent3;
import androidx.core.view.ViewCompat;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
+import org.jspecify.annotations.NonNull;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -267,8 +267,8 @@
}
@Override
- public void onNestedPreScroll(@NonNull View target, int dx, int dy, @NonNull int[] consumed,
- int type) {
+ public void onNestedPreScroll(@NonNull View target, int dx, int dy,
+ int @NonNull [] consumed, int type) {
}
diff --git a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutWithHorizontallyScrollingChildTest.java b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutWithHorizontallyScrollingChildTest.java
index 0b88a46..990610b 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutWithHorizontallyScrollingChildTest.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/androidTest/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayoutWithHorizontallyScrollingChildTest.java
@@ -37,13 +37,13 @@
import android.widget.TextView;
import androidx.activity.ComponentActivity;
-import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.test.filters.FlakyTest;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.testutils.SwipeInjector;
+import org.jspecify.annotations.NonNull;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -190,9 +190,8 @@
return 3;
}
- @NonNull
@Override
- public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ public @NonNull ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
TextView textView = new TextView(parent.getContext());
textView.setLayoutParams(matchParent());
textView.setTextSize(40);
diff --git a/swiperefreshlayout/swiperefreshlayout/src/main/java/androidx/swiperefreshlayout/widget/CircleImageView.java b/swiperefreshlayout/swiperefreshlayout/src/main/java/androidx/swiperefreshlayout/widget/CircleImageView.java
index c33fd2a3..f768edb 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/main/java/androidx/swiperefreshlayout/widget/CircleImageView.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/main/java/androidx/swiperefreshlayout/widget/CircleImageView.java
@@ -30,10 +30,11 @@
import android.view.animation.Animation;
import android.widget.ImageView;
-import androidx.annotation.NonNull;
import androidx.core.view.ViewCompat;
import androidx.swiperefreshlayout.R;
+import org.jspecify.annotations.NonNull;
+
/**
* Private class created to work around issues with AnimationListeners being
* called before the animation is actually complete and support shadows on older
diff --git a/swiperefreshlayout/swiperefreshlayout/src/main/java/androidx/swiperefreshlayout/widget/CircularProgressDrawable.java b/swiperefreshlayout/swiperefreshlayout/src/main/java/androidx/swiperefreshlayout/widget/CircularProgressDrawable.java
index cb39f75..1afed0a 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/main/java/androidx/swiperefreshlayout/widget/CircularProgressDrawable.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/main/java/androidx/swiperefreshlayout/widget/CircularProgressDrawable.java
@@ -38,11 +38,12 @@
import android.view.animation.LinearInterpolator;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.core.util.Preconditions;
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
+import org.jspecify.annotations.NonNull;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -217,7 +218,7 @@
*
* @param strokeCap stroke cap
*/
- public void setStrokeCap(@NonNull Paint.Cap strokeCap) {
+ public void setStrokeCap(Paint.@NonNull Cap strokeCap) {
mRing.setStrokeCap(strokeCap);
invalidateSelf();
}
@@ -227,8 +228,7 @@
*
* @return stroke cap
*/
- @NonNull
- public Paint.Cap getStrokeCap() {
+ public Paint.@NonNull Cap getStrokeCap() {
return mRing.getStrokeCap();
}
@@ -376,8 +376,7 @@
*
* @return list of ARGB colors
*/
- @NonNull
- public int[] getColorSchemeColors() {
+ public int @NonNull [] getColorSchemeColors() {
return mRing.getColors();
}
@@ -387,7 +386,7 @@
*
* @param colors list of ARGB colors to be used in the spinner
*/
- public void setColorSchemeColors(@NonNull int... colors) {
+ public void setColorSchemeColors(int @NonNull ... colors) {
mRing.setColors(colors);
mRing.setColorIndex(0);
invalidateSelf();
@@ -759,7 +758,7 @@
*
* @param colors array of ARGB colors. Must be non-{@code null}.
*/
- void setColors(@NonNull int[] colors) {
+ void setColors(int @NonNull [] colors) {
mColors = colors;
// if colors are reset, make sure to reset the color index as well
setColorIndex(0);
diff --git a/swiperefreshlayout/swiperefreshlayout/src/main/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayout.java b/swiperefreshlayout/swiperefreshlayout/src/main/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayout.java
index 1daa440..fb15e0e 100644
--- a/swiperefreshlayout/swiperefreshlayout/src/main/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayout.java
+++ b/swiperefreshlayout/swiperefreshlayout/src/main/java/androidx/swiperefreshlayout/widget/SwipeRefreshLayout.java
@@ -37,8 +37,6 @@
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.Px;
import androidx.annotation.VisibleForTesting;
import androidx.core.content.ContextCompat;
@@ -52,6 +50,9 @@
import androidx.core.view.NestedScrollingParentHelper;
import androidx.core.view.ViewCompat;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* The SwipeRefreshLayout should be used whenever the user can refresh the
* contents of a view via a vertical swipe gesture. The activity that
@@ -630,7 +631,7 @@
*
* @param colorResIds
*/
- public void setColorSchemeResources(@NonNull @ColorRes int... colorResIds) {
+ public void setColorSchemeResources(@ColorRes int @NonNull ... colorResIds) {
final Context context = getContext();
int[] colorRes = new int[colorResIds.length];
for (int i = 0; i < colorResIds.length; i++) {
@@ -646,7 +647,7 @@
*
* @param colors
*/
- public void setColorSchemeColors(@NonNull @ColorInt int... colors) {
+ public void setColorSchemeColors(@ColorInt int @NonNull ... colors) {
ensureTarget();
mProgress.setColorSchemeColors(colors);
}
@@ -867,7 +868,7 @@
@Override
public void onNestedScroll(@NonNull View target, int dxConsumed, int dyConsumed,
int dxUnconsumed, int dyUnconsumed, @ViewCompat.NestedScrollType int type,
- @NonNull int[] consumed) {
+ int @NonNull [] consumed) {
if (type != ViewCompat.TYPE_TOUCH) {
return;
}
@@ -950,7 +951,7 @@
}
@Override
- public void onNestedPreScroll(@NonNull View target, int dx, int dy, @NonNull int[] consumed,
+ public void onNestedPreScroll(@NonNull View target, int dx, int dy, int @NonNull [] consumed,
int type) {
// Should always be true because onStartNestedScroll returns false for all type !=
// ViewCompat.TYPE_TOUCH, but check just in case.
@@ -1056,8 +1057,8 @@
@Override
public void dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed,
- int dyUnconsumed, @Nullable int[] offsetInWindow, @ViewCompat.NestedScrollType int type,
- @NonNull int[] consumed) {
+ int dyUnconsumed, int @Nullable [] offsetInWindow,
+ @ViewCompat.NestedScrollType int type, int @NonNull [] consumed) {
if (type == ViewCompat.TYPE_TOUCH) {
mNestedScrollingChildHelper.dispatchNestedScroll(dxConsumed, dyConsumed, dxUnconsumed,
dyUnconsumed, offsetInWindow, type, consumed);
@@ -1085,14 +1086,14 @@
@Override
public boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed,
- int dyUnconsumed, @Nullable int[] offsetInWindow, int type) {
+ int dyUnconsumed, int @Nullable [] offsetInWindow, int type) {
return type == ViewCompat.TYPE_TOUCH && mNestedScrollingChildHelper.dispatchNestedScroll(
dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, offsetInWindow, type);
}
@Override
- public boolean dispatchNestedPreScroll(int dx, int dy, @Nullable int[] consumed,
- @Nullable int[] offsetInWindow, int type) {
+ public boolean dispatchNestedPreScroll(int dx, int dy, int @Nullable [] consumed,
+ int @Nullable [] offsetInWindow, int type) {
return type == ViewCompat.TYPE_TOUCH && dispatchNestedPreScroll(dx, dy, consumed,
offsetInWindow);
}
@@ -1126,14 +1127,14 @@
@Override
public boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed,
- int dyUnconsumed, @Nullable int[] offsetInWindow) {
+ int dyUnconsumed, int @Nullable [] offsetInWindow) {
return mNestedScrollingChildHelper.dispatchNestedScroll(dxConsumed, dyConsumed,
dxUnconsumed, dyUnconsumed, offsetInWindow);
}
@Override
- public boolean dispatchNestedPreScroll(int dx, int dy, @Nullable int[] consumed,
- @Nullable int[] offsetInWindow) {
+ public boolean dispatchNestedPreScroll(int dx, int dy, int @Nullable [] consumed,
+ int @Nullable [] offsetInWindow) {
return mNestedScrollingChildHelper.dispatchNestedPreScroll(
dx, dy, consumed, offsetInWindow);
}
diff --git a/testutils/testutils-macrobenchmark/src/main/java/androidx/testutils/MacrobenchUtils.kt b/testutils/testutils-macrobenchmark/src/main/java/androidx/testutils/MacrobenchUtils.kt
index 76b4dd2..ad84d20 100644
--- a/testutils/testutils-macrobenchmark/src/main/java/androidx/testutils/MacrobenchUtils.kt
+++ b/testutils/testutils-macrobenchmark/src/main/java/androidx/testutils/MacrobenchUtils.kt
@@ -112,15 +112,21 @@
}
}
+private val STARTUP_COMPILATION_MODES =
+ COMPILATION_MODES.filter {
+ // Skip full for startup specifically, as it's not representative
+ Build.VERSION.SDK_INT < 24 || it !is CompilationMode.Full
+ }
+
fun createStartupCompilationParams(
startupModes: List<StartupMode> = STARTUP_MODES,
- compilationModes: List<CompilationMode> = COMPILATION_MODES
+ compilationModes: List<CompilationMode> = STARTUP_COMPILATION_MODES
): List<Array<Any>> =
mutableListOf<Array<Any>>().apply {
// To save CI resources, avoid measuring startup combinations which have non-primary
// compilation or startup mode (BP, cold respectively) in the default case
val minimalIntersection =
- startupModes == STARTUP_MODES && compilationModes == COMPILATION_MODES
+ startupModes == STARTUP_MODES && compilationModes == STARTUP_COMPILATION_MODES
for (startupMode in startupModes) {
for (compilationMode in compilationModes) {
diff --git a/transition/transition/build.gradle b/transition/transition/build.gradle
index ebdf43b..769d2b6 100644
--- a/transition/transition/build.gradle
+++ b/transition/transition/build.gradle
@@ -14,6 +14,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.annotation:annotation:1.8.1")
api(project(":core:core"))
implementation("androidx.collection:collection:1.4.2")
diff --git a/transition/transition/src/androidTest/java/androidx/transition/BaseTransitionTest.java b/transition/transition/src/androidTest/java/androidx/transition/BaseTransitionTest.java
index e2ed58e..27303b5 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/BaseTransitionTest.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/BaseTransitionTest.java
@@ -27,11 +27,11 @@
import android.view.ViewGroup;
import android.widget.LinearLayout;
-import androidx.annotation.NonNull;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.testutils.AnimationDurationScaleRule;
import androidx.transition.test.R;
+import org.jspecify.annotations.NonNull;
import org.junit.Before;
import org.junit.Rule;
diff --git a/transition/transition/src/androidTest/java/androidx/transition/ChangeBoundsTest.java b/transition/transition/src/androidTest/java/androidx/transition/ChangeBoundsTest.java
index 92b0821..b494151 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/ChangeBoundsTest.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/ChangeBoundsTest.java
@@ -31,7 +31,6 @@
import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
-import androidx.annotation.NonNull;
import androidx.test.annotation.UiThreadTest;
import androidx.test.filters.LargeTest;
import androidx.test.filters.SdkSuppress;
@@ -39,6 +38,7 @@
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
+import org.jspecify.annotations.NonNull;
import org.junit.Test;
import java.util.concurrent.CountDownLatch;
diff --git a/transition/transition/src/androidTest/java/androidx/transition/ChangeImageTransformTest.java b/transition/transition/src/androidTest/java/androidx/transition/ChangeImageTransformTest.java
index fb08845..b830dd3 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/ChangeImageTransformTest.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/ChangeImageTransformTest.java
@@ -35,13 +35,13 @@
import android.view.ViewGroup;
import android.widget.ImageView;
-import androidx.annotation.NonNull;
import androidx.core.app.ActivityCompat;
import androidx.test.filters.LargeTest;
import androidx.test.filters.SdkSuppress;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.transition.test.R;
+import org.jspecify.annotations.NonNull;
import org.junit.Test;
import javax.annotation.Nullable;
diff --git a/transition/transition/src/androidTest/java/androidx/transition/FadeTest.java b/transition/transition/src/androidTest/java/androidx/transition/FadeTest.java
index 1667459..25530fb 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/FadeTest.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/FadeTest.java
@@ -40,8 +40,6 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.annotation.UiThreadTest;
import androidx.test.filters.LargeTest;
import androidx.test.filters.SdkSuppress;
@@ -49,11 +47,12 @@
import androidx.testutils.AnimationDurationScaleRule;
import androidx.transition.test.R;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-
@LargeTest
public class FadeTest extends BaseTest {
@@ -519,11 +518,10 @@
mAlphaValues = alphaValues;
}
- @Nullable
@Override
- public Animator createAnimator(@NonNull ViewGroup sceneRoot,
- @Nullable final TransitionValues startValues,
- @Nullable final TransitionValues endValues) {
+ public @Nullable Animator createAnimator(@NonNull ViewGroup sceneRoot,
+ final @Nullable TransitionValues startValues,
+ final @Nullable TransitionValues endValues) {
final Animator animator = super.createAnimator(sceneRoot, startValues, endValues);
if (animator instanceof ObjectAnimator) {
((ObjectAnimator) animator).addUpdateListener(
diff --git a/transition/transition/src/androidTest/java/androidx/transition/FragmentTransitionSupportTest.java b/transition/transition/src/androidTest/java/androidx/transition/FragmentTransitionSupportTest.java
index 91efb1c..e153a5a5 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/FragmentTransitionSupportTest.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/FragmentTransitionSupportTest.java
@@ -30,7 +30,6 @@
import android.view.ViewGroup;
import androidx.annotation.LayoutRes;
-import androidx.annotation.Nullable;
import androidx.collection.SparseArrayCompat;
import androidx.core.util.Pair;
import androidx.core.view.ViewCompat;
@@ -41,11 +40,11 @@
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.transition.test.R;
+import org.jspecify.annotations.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
-
@MediumTest
@RunWith(Parameterized.class)
public class FragmentTransitionSupportTest extends BaseTest {
@@ -189,9 +188,8 @@
setSharedElementReturnTransition(createTransition(TRANSITION_SHARED_RETURN));
}
- @Nullable
@Override
- public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
+ public @Nullable View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
return inflater.inflate(getArguments().getInt(ARG_LAYOUT_ID), container, false);
}
diff --git a/transition/transition/src/androidTest/java/androidx/transition/MultipleRootsTest.java b/transition/transition/src/androidTest/java/androidx/transition/MultipleRootsTest.java
index 57ea293..da0f160 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/MultipleRootsTest.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/MultipleRootsTest.java
@@ -28,13 +28,13 @@
import android.view.ViewGroup;
import android.widget.LinearLayout;
-import androidx.annotation.NonNull;
import androidx.test.core.app.ActivityScenario;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
import androidx.transition.test.R;
import org.jetbrains.annotations.NotNull;
+import org.jspecify.annotations.NonNull;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -244,7 +244,7 @@
row1FirstTransition.setDuration(150);
final Transition.TransitionListener row2FirstListener = new TransitionListenerAdapter() {
@Override
- public void onTransitionEnd(@NonNull @NotNull Transition transition) {
+ public void onTransitionEnd(@NotNull @NonNull Transition transition) {
TransitionManager.beginDelayedTransition(views.mRow1, row1SecondTransition);
views.mRed.setVisibility(View.VISIBLE);
}
diff --git a/transition/transition/src/androidTest/java/androidx/transition/PrevTransitionStoppedTest.java b/transition/transition/src/androidTest/java/androidx/transition/PrevTransitionStoppedTest.java
index f26fbe9..e5736c8 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/PrevTransitionStoppedTest.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/PrevTransitionStoppedTest.java
@@ -27,10 +27,10 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
import androidx.test.filters.MediumTest;
import androidx.transition.test.R;
+import org.jspecify.annotations.NonNull;
import org.junit.Test;
@MediumTest
diff --git a/transition/transition/src/androidTest/java/androidx/transition/PropagationTest.java b/transition/transition/src/androidTest/java/androidx/transition/PropagationTest.java
index 9263255..64ef5f0 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/PropagationTest.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/PropagationTest.java
@@ -32,12 +32,12 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.filters.MediumTest;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.transition.test.R;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Test;
import java.util.concurrent.CountDownLatch;
diff --git a/transition/transition/src/androidTest/java/androidx/transition/SyncTransitionListener.java b/transition/transition/src/androidTest/java/androidx/transition/SyncTransitionListener.java
index 204c05f..172cd30 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/SyncTransitionListener.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/SyncTransitionListener.java
@@ -15,7 +15,7 @@
*/
package androidx.transition;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
diff --git a/transition/transition/src/androidTest/java/androidx/transition/TrackingVisibility.java b/transition/transition/src/androidTest/java/androidx/transition/TrackingVisibility.java
index 5ea2d2e..88a6bc5e 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/TrackingVisibility.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/TrackingVisibility.java
@@ -22,9 +22,10 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
import androidx.fragment.app.TargetTracking;
+import org.jspecify.annotations.NonNull;
+
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
@@ -116,15 +117,13 @@
return null;
}
- @NonNull
@Override
- public List<View> getEnteringTargets() {
+ public @NonNull List<View> getEnteringTargets() {
return mEnteringTargets;
}
- @NonNull
@Override
- public List<View> getExitingTargets() {
+ public @NonNull List<View> getExitingTargets() {
return mExitingTargets;
}
diff --git a/transition/transition/src/androidTest/java/androidx/transition/TransitionInflaterTest.java b/transition/transition/src/androidTest/java/androidx/transition/TransitionInflaterTest.java
index 494f45d..9df9996 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/TransitionInflaterTest.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/TransitionInflaterTest.java
@@ -30,10 +30,10 @@
import android.widget.ImageView;
import android.widget.TextView;
-import androidx.annotation.NonNull;
import androidx.test.filters.MediumTest;
import androidx.transition.test.R;
+import org.jspecify.annotations.NonNull;
import org.junit.Test;
import java.util.List;
@@ -220,9 +220,8 @@
super(context, attrs);
}
- @NonNull
@Override
- public Path getPath(float startX, float startY, float endX, float endY) {
+ public @NonNull Path getPath(float startX, float startY, float endX, float endY) {
return null;
}
}
diff --git a/transition/transition/src/androidTest/java/androidx/transition/TransitionManagerTest.java b/transition/transition/src/androidTest/java/androidx/transition/TransitionManagerTest.java
index a4b47e8..30980f9 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/TransitionManagerTest.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/TransitionManagerTest.java
@@ -31,13 +31,13 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
import androidx.test.annotation.UiThreadTest;
import androidx.test.filters.MediumTest;
import androidx.test.filters.SdkSuppress;
import androidx.testutils.AnimationDurationScaleRule;
import androidx.transition.test.R;
+import org.jspecify.annotations.NonNull;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
diff --git a/transition/transition/src/androidTest/java/androidx/transition/TransitionSetTest.java b/transition/transition/src/androidTest/java/androidx/transition/TransitionSetTest.java
index a8f7d26..4c3cccc3 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/TransitionSetTest.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/TransitionSetTest.java
@@ -33,11 +33,11 @@
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.filters.SmallTest;
import androidx.transition.test.R;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Before;
import org.junit.Test;
@@ -270,9 +270,8 @@
public void captureValues(@NonNull TransitionValues transitionValues) {
}
- @Nullable
@Override
- public String[] getPropagationProperties() {
+ public String @Nullable [] getPropagationProperties() {
return new String[] { };
}
}
diff --git a/transition/transition/src/androidTest/java/androidx/transition/TransitionTest.java b/transition/transition/src/androidTest/java/androidx/transition/TransitionTest.java
index 628464e..7d20b3d 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/TransitionTest.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/TransitionTest.java
@@ -47,14 +47,14 @@
import android.widget.FrameLayout;
import android.widget.ImageView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import androidx.test.annotation.UiThreadTest;
import androidx.test.filters.MediumTest;
import androidx.testutils.AnimationDurationScaleRule;
import androidx.transition.test.R;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -260,9 +260,8 @@
public void testMatchOrder() throws Throwable {
showInitialScene();
final Transition transition = new ChangeBounds() {
- @Nullable
@Override
- public Animator createAnimator(@NonNull ViewGroup sceneRoot,
+ public @Nullable Animator createAnimator(@NonNull ViewGroup sceneRoot,
@Nullable TransitionValues startValues, @Nullable TransitionValues endValues) {
if (startValues != null && endValues != null) {
fail("Match by View ID should be prevented");
@@ -410,16 +409,14 @@
return ValueAnimator.ofFloat(0f, 100f);
}
- @Nullable
@Override
- public Animator onDisappear(@NonNull ViewGroup sceneRoot, @NonNull View view,
+ public @Nullable Animator onDisappear(@NonNull ViewGroup sceneRoot, @NonNull View view,
@Nullable TransitionValues startValues, @Nullable TransitionValues endValues) {
return createAnimator();
}
- @Nullable
@Override
- public Animator onAppear(@NonNull ViewGroup sceneRoot, @NonNull View view,
+ public @Nullable Animator onAppear(@NonNull ViewGroup sceneRoot, @NonNull View view,
@Nullable TransitionValues startValues, @Nullable TransitionValues endValues) {
return createAnimator();
}
@@ -531,9 +528,8 @@
final CountDownLatch startLatch = new CountDownLatch(3);
class CancelingAnimator extends Slide {
- @Nullable
@Override
- public Animator createAnimator(@NonNull ViewGroup sceneRoot,
+ public @Nullable Animator createAnimator(@NonNull ViewGroup sceneRoot,
@Nullable TransitionValues startValues, @Nullable TransitionValues endValues) {
Animator anim = super.createAnimator(sceneRoot, startValues, endValues);
if (anim != null) {
@@ -708,9 +704,8 @@
public void captureValues(@NonNull TransitionValues transitionValues) {
}
- @Nullable
@Override
- public String[] getPropagationProperties() {
+ public String @Nullable [] getPropagationProperties() {
return new String[0];
}
}
diff --git a/transition/transition/src/androidTest/java/androidx/transition/VisibilityTest.java b/transition/transition/src/androidTest/java/androidx/transition/VisibilityTest.java
index 73ce42f..f2879c2 100644
--- a/transition/transition/src/androidTest/java/androidx/transition/VisibilityTest.java
+++ b/transition/transition/src/androidTest/java/androidx/transition/VisibilityTest.java
@@ -33,13 +33,13 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.annotation.UiThreadTest;
import androidx.test.filters.FlakyTest;
import androidx.test.filters.MediumTest;
import androidx.testutils.AnimationDurationScaleRule;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -221,9 +221,8 @@
private static String[] sTransitionProperties;
- @Nullable
@Override
- public String[] getTransitionProperties() {
+ public String @Nullable [] getTransitionProperties() {
if (sTransitionProperties == null) {
String[] properties = super.getTransitionProperties();
if (properties != null) {
diff --git a/transition/transition/src/main/java/androidx/transition/ArcMotion.java b/transition/transition/src/main/java/androidx/transition/ArcMotion.java
index bd297ef..f188f0e 100644
--- a/transition/transition/src/main/java/androidx/transition/ArcMotion.java
+++ b/transition/transition/src/main/java/androidx/transition/ArcMotion.java
@@ -21,9 +21,9 @@
import android.graphics.Path;
import android.util.AttributeSet;
-import androidx.annotation.NonNull;
import androidx.core.content.res.TypedArrayUtils;
+import org.jspecify.annotations.NonNull;
import org.xmlpull.v1.XmlPullParser;
/**
@@ -178,9 +178,8 @@
return (float) Math.tan(Math.toRadians(arcInDegrees / 2));
}
- @NonNull
@Override
- public Path getPath(float startX, float startY, float endX, float endY) {
+ public @NonNull Path getPath(float startX, float startY, float endX, float endY) {
// Here's a little ascii art to show how this is calculated:
// c---------- b
// \ / |
diff --git a/transition/transition/src/main/java/androidx/transition/AutoTransition.java b/transition/transition/src/main/java/androidx/transition/AutoTransition.java
index a6d8536..9857a32 100644
--- a/transition/transition/src/main/java/androidx/transition/AutoTransition.java
+++ b/transition/transition/src/main/java/androidx/transition/AutoTransition.java
@@ -19,7 +19,7 @@
import android.content.Context;
import android.util.AttributeSet;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* Utility class for creating a default transition that automatically fades,
diff --git a/transition/transition/src/main/java/androidx/transition/CanvasUtils.java b/transition/transition/src/main/java/androidx/transition/CanvasUtils.java
index 6c058c5..8f0b0d9 100644
--- a/transition/transition/src/main/java/androidx/transition/CanvasUtils.java
+++ b/transition/transition/src/main/java/androidx/transition/CanvasUtils.java
@@ -20,9 +20,10 @@
import android.graphics.Canvas;
import android.os.Build;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
+import org.jspecify.annotations.NonNull;
+
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
diff --git a/transition/transition/src/main/java/androidx/transition/ChangeBounds.java b/transition/transition/src/main/java/androidx/transition/ChangeBounds.java
index e8cf7d6..57e0d28 100644
--- a/transition/transition/src/main/java/androidx/transition/ChangeBounds.java
+++ b/transition/transition/src/main/java/androidx/transition/ChangeBounds.java
@@ -31,10 +31,11 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.core.content.res.TypedArrayUtils;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Map;
/**
@@ -158,9 +159,8 @@
return true;
}
- @NonNull
@Override
- public String[] getTransitionProperties() {
+ public String @NonNull [] getTransitionProperties() {
return sTransitionProperties;
}
@@ -223,8 +223,7 @@
}
@Override
- @Nullable
- public Animator createAnimator(@NonNull final ViewGroup sceneRoot,
+ public @Nullable Animator createAnimator(final @NonNull ViewGroup sceneRoot,
@Nullable TransitionValues startValues, @Nullable TransitionValues endValues) {
if (startValues == null || endValues == null) {
return null;
diff --git a/transition/transition/src/main/java/androidx/transition/ChangeClipBounds.java b/transition/transition/src/main/java/androidx/transition/ChangeClipBounds.java
index 0d1d14e..78161fb 100644
--- a/transition/transition/src/main/java/androidx/transition/ChangeClipBounds.java
+++ b/transition/transition/src/main/java/androidx/transition/ChangeClipBounds.java
@@ -25,8 +25,8 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* ChangeClipBounds captures the {@link android.view.View#getClipBounds()} before and after the
@@ -48,8 +48,7 @@
static final Rect NULL_SENTINEL = new Rect();
@Override
- @NonNull
- public String[] getTransitionProperties() {
+ public String @NonNull [] getTransitionProperties() {
return sTransitionProperties;
}
@@ -99,9 +98,8 @@
captureValues(transitionValues, false);
}
- @Nullable
@Override
- public Animator createAnimator(@NonNull final ViewGroup sceneRoot,
+ public @Nullable Animator createAnimator(final @NonNull ViewGroup sceneRoot,
@Nullable TransitionValues startValues,
@Nullable TransitionValues endValues) {
if (startValues == null || endValues == null
diff --git a/transition/transition/src/main/java/androidx/transition/ChangeImageTransform.java b/transition/transition/src/main/java/androidx/transition/ChangeImageTransform.java
index a9cc6ba..7f2afbb 100644
--- a/transition/transition/src/main/java/androidx/transition/ChangeImageTransform.java
+++ b/transition/transition/src/main/java/androidx/transition/ChangeImageTransform.java
@@ -30,8 +30,8 @@
import android.view.ViewGroup;
import android.widget.ImageView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.util.Map;
@@ -125,8 +125,7 @@
}
@Override
- @NonNull
- public String[] getTransitionProperties() {
+ public String @NonNull [] getTransitionProperties() {
return sTransitionProperties;
}
@@ -140,9 +139,8 @@
* @return An Animator to move an ImageView or null if the View is not an ImageView,
* the Drawable changed, the View is not VISIBLE, or there was no change.
*/
- @Nullable
@Override
- public Animator createAnimator(@NonNull ViewGroup sceneRoot,
+ public @Nullable Animator createAnimator(@NonNull ViewGroup sceneRoot,
@Nullable TransitionValues startValues,
final @Nullable TransitionValues endValues) {
if (startValues == null || endValues == null) {
@@ -190,8 +188,7 @@
return animator;
}
- @NonNull
- private ObjectAnimator createNullAnimator(@NonNull ImageView imageView) {
+ private @NonNull ObjectAnimator createNullAnimator(@NonNull ImageView imageView) {
return ObjectAnimator.ofObject(imageView, ANIMATED_TRANSFORM_PROPERTY,
NULL_MATRIX_EVALUATOR, MatrixUtils.IDENTITY_MATRIX, MatrixUtils.IDENTITY_MATRIX);
}
@@ -202,8 +199,7 @@
new TransitionUtils.MatrixEvaluator(), startMatrix, endMatrix);
}
- @NonNull
- private static Matrix copyImageMatrix(@NonNull ImageView view) {
+ private static @NonNull Matrix copyImageMatrix(@NonNull ImageView view) {
final Drawable image = view.getDrawable();
if (image.getIntrinsicWidth() > 0 && image.getIntrinsicHeight() > 0) {
switch (view.getScaleType()) {
diff --git a/transition/transition/src/main/java/androidx/transition/ChangeScroll.java b/transition/transition/src/main/java/androidx/transition/ChangeScroll.java
index 03fa492..d684120 100644
--- a/transition/transition/src/main/java/androidx/transition/ChangeScroll.java
+++ b/transition/transition/src/main/java/androidx/transition/ChangeScroll.java
@@ -23,9 +23,8 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* This transition captures the scroll properties of targets before and after
@@ -62,9 +61,8 @@
return true;
}
- @Nullable
@Override
- public String[] getTransitionProperties() {
+ public String @Nullable [] getTransitionProperties() {
return PROPERTIES;
}
@@ -73,9 +71,8 @@
transitionValues.values.put(PROPNAME_SCROLL_Y, transitionValues.view.getScrollY());
}
- @Nullable
@Override
- public Animator createAnimator(@NonNull ViewGroup sceneRoot,
+ public @Nullable Animator createAnimator(@NonNull ViewGroup sceneRoot,
@Nullable TransitionValues startValues, @Nullable TransitionValues endValues) {
if (startValues == null || endValues == null) {
return null;
diff --git a/transition/transition/src/main/java/androidx/transition/ChangeTransform.java b/transition/transition/src/main/java/androidx/transition/ChangeTransform.java
index f0bd400..61313f9 100644
--- a/transition/transition/src/main/java/androidx/transition/ChangeTransform.java
+++ b/transition/transition/src/main/java/androidx/transition/ChangeTransform.java
@@ -31,11 +31,11 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.core.content.res.TypedArrayUtils;
import androidx.core.view.ViewCompat;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.xmlpull.v1.XmlPullParser;
/**
@@ -187,8 +187,7 @@
}
@Override
- @NonNull
- public String[] getTransitionProperties() {
+ public String @NonNull [] getTransitionProperties() {
return sTransitionProperties;
}
@@ -237,9 +236,8 @@
captureValues(transitionValues);
}
- @Nullable
@Override
- public Animator createAnimator(@NonNull ViewGroup sceneRoot,
+ public @Nullable Animator createAnimator(@NonNull ViewGroup sceneRoot,
@Nullable TransitionValues startValues,
@Nullable TransitionValues endValues) {
if (startValues == null || endValues == null
diff --git a/transition/transition/src/main/java/androidx/transition/CircularPropagation.java b/transition/transition/src/main/java/androidx/transition/CircularPropagation.java
index 710c615..c93dd5f 100644
--- a/transition/transition/src/main/java/androidx/transition/CircularPropagation.java
+++ b/transition/transition/src/main/java/androidx/transition/CircularPropagation.java
@@ -20,8 +20,8 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* A propagation that varies with the distance to the epicenter of the Transition
diff --git a/transition/transition/src/main/java/androidx/transition/Explode.java b/transition/transition/src/main/java/androidx/transition/Explode.java
index a671288..9d5e8a3 100644
--- a/transition/transition/src/main/java/androidx/transition/Explode.java
+++ b/transition/transition/src/main/java/androidx/transition/Explode.java
@@ -26,8 +26,8 @@
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* This transition tracks changes to the visibility of target views in the
@@ -84,9 +84,8 @@
return true;
}
- @Nullable
@Override
- public Animator onAppear(@NonNull ViewGroup sceneRoot, @NonNull View view,
+ public @Nullable Animator onAppear(@NonNull ViewGroup sceneRoot, @NonNull View view,
@Nullable TransitionValues startValues, @Nullable TransitionValues endValues) {
if (endValues == null) {
return null;
@@ -102,9 +101,8 @@
startX, startY, endX, endY, sDecelerate, this);
}
- @Nullable
@Override
- public Animator onDisappear(@NonNull ViewGroup sceneRoot, @NonNull View view,
+ public @Nullable Animator onDisappear(@NonNull ViewGroup sceneRoot, @NonNull View view,
@Nullable TransitionValues startValues, @Nullable TransitionValues endValues) {
if (startValues == null) {
return null;
diff --git a/transition/transition/src/main/java/androidx/transition/Fade.java b/transition/transition/src/main/java/androidx/transition/Fade.java
index edd1722..af232dd 100644
--- a/transition/transition/src/main/java/androidx/transition/Fade.java
+++ b/transition/transition/src/main/java/androidx/transition/Fade.java
@@ -27,10 +27,11 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.core.content.res.TypedArrayUtils;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* This transition tracks changes to the visibility of target views in the
* start and end scenes and fades views in or out when they become visible
@@ -145,9 +146,8 @@
return anim;
}
- @Nullable
@Override
- public Animator onAppear(@NonNull ViewGroup sceneRoot, @NonNull View view,
+ public @Nullable Animator onAppear(@NonNull ViewGroup sceneRoot, @NonNull View view,
@Nullable TransitionValues startValues, @Nullable TransitionValues endValues) {
if (DBG) {
View startView = (startValues != null) ? startValues.view : null;
@@ -159,9 +159,8 @@
return createAnimation(view, startAlpha, 1);
}
- @Nullable
@Override
- public Animator onDisappear(@NonNull ViewGroup sceneRoot, @NonNull final View view,
+ public @Nullable Animator onDisappear(@NonNull ViewGroup sceneRoot, final @NonNull View view,
@Nullable TransitionValues startValues, @Nullable TransitionValues endValues) {
ViewUtils.saveNonTransitionAlpha(view);
float startAlpha = getStartAlpha(startValues, 1);
diff --git a/transition/transition/src/main/java/androidx/transition/FragmentTransitionSupport.java b/transition/transition/src/main/java/androidx/transition/FragmentTransitionSupport.java
index 2d66ce9..3db829d 100644
--- a/transition/transition/src/main/java/androidx/transition/FragmentTransitionSupport.java
+++ b/transition/transition/src/main/java/androidx/transition/FragmentTransitionSupport.java
@@ -24,16 +24,16 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransitionImpl;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.List;
-
/**
*/
// This is instantiated in androidx.fragment.app.FragmentTransition
@@ -46,9 +46,8 @@
return transition instanceof Transition;
}
- @Nullable
@Override
- public Object cloneTransition(@Nullable Object transition) {
+ public @Nullable Object cloneTransition(@Nullable Object transition) {
Transition copy = null;
if (transition != null) {
copy = ((Transition) transition).clone();
@@ -56,9 +55,8 @@
return copy;
}
- @Nullable
@Override
- public Object wrapTransitionInSet(@Nullable Object transition) {
+ public @Nullable Object wrapTransitionInSet(@Nullable Object transition) {
if (transition == null) {
return null;
}
@@ -130,9 +128,8 @@
|| !isNullOrEmpty(transition.getTargetTypes());
}
- @NonNull
@Override
- public Object mergeTransitionsTogether(@Nullable Object transition1,
+ public @NonNull Object mergeTransitionsTogether(@Nullable Object transition1,
@Nullable Object transition2, @Nullable Object transition3) {
TransitionSet transitionSet = new TransitionSet();
if (transition1 != null) {
@@ -188,9 +185,8 @@
});
}
- @Nullable
@Override
- public Object mergeTransitionsInSequence(@Nullable Object exitTransitionObj,
+ public @Nullable Object mergeTransitionsInSequence(@Nullable Object exitTransitionObj,
@Nullable Object enterTransitionObj, @Nullable Object sharedElementTransitionObj) {
// First do exit, then enter, but allow shared element transition to happen
// during both.
@@ -243,8 +239,7 @@
}
@Override
- @Nullable
- public Object controlDelayedTransition(@NonNull ViewGroup sceneRoot,
+ public @Nullable Object controlDelayedTransition(@NonNull ViewGroup sceneRoot,
@NonNull Object transition) {
return TransitionManager.controlDelayedTransition(sceneRoot, (Transition) transition);
}
@@ -320,10 +315,10 @@
*/
@SuppressWarnings("deprecation")
@Override
- public void setListenerForTransitionEnd(@NonNull final Fragment outFragment,
- @NonNull final Object transition,
- @NonNull final androidx.core.os.CancellationSignal signal,
- @NonNull final Runnable transitionCompleteRunnable) {
+ public void setListenerForTransitionEnd(final @NonNull Fragment outFragment,
+ final @NonNull Object transition,
+ final androidx.core.os.@NonNull CancellationSignal signal,
+ final @NonNull Runnable transitionCompleteRunnable) {
setListenerForTransitionEnd(outFragment, transition, signal,
null, transitionCompleteRunnable);
}
@@ -331,7 +326,7 @@
@SuppressWarnings("deprecation")
@Override
public void setListenerForTransitionEnd(@NonNull Fragment outFragment,
- @NonNull Object transition, @NonNull androidx.core.os.CancellationSignal signal,
+ @NonNull Object transition, androidx.core.os.@NonNull CancellationSignal signal,
@Nullable Runnable cancelRunnable, @NonNull Runnable transitionCompleteRunnable) {
final Transition realTransition = ((Transition) transition);
signal.setOnCancelListener(() -> {
diff --git a/transition/transition/src/main/java/androidx/transition/GhostViewHolder.java b/transition/transition/src/main/java/androidx/transition/GhostViewHolder.java
index bd9137b..40bfbe7 100644
--- a/transition/transition/src/main/java/androidx/transition/GhostViewHolder.java
+++ b/transition/transition/src/main/java/androidx/transition/GhostViewHolder.java
@@ -23,17 +23,17 @@
import android.view.ViewParent;
import android.widget.FrameLayout;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.view.ViewCompat;
+import org.jspecify.annotations.NonNull;
+
import java.util.ArrayList;
@SuppressLint("ViewConstructor")
class GhostViewHolder extends FrameLayout {
- @NonNull
- private ViewGroup mParent;
+ private @NonNull ViewGroup mParent;
private boolean mAttached;
GhostViewHolder(ViewGroup parent) {
diff --git a/transition/transition/src/main/java/androidx/transition/GhostViewPlatform.java b/transition/transition/src/main/java/androidx/transition/GhostViewPlatform.java
index 0ee32d4..0ade460 100644
--- a/transition/transition/src/main/java/androidx/transition/GhostViewPlatform.java
+++ b/transition/transition/src/main/java/androidx/transition/GhostViewPlatform.java
@@ -22,9 +22,10 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
+import org.jspecify.annotations.NonNull;
+
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
diff --git a/transition/transition/src/main/java/androidx/transition/GhostViewPort.java b/transition/transition/src/main/java/androidx/transition/GhostViewPort.java
index 7e4a8e9..e6f9bea 100644
--- a/transition/transition/src/main/java/androidx/transition/GhostViewPort.java
+++ b/transition/transition/src/main/java/androidx/transition/GhostViewPort.java
@@ -23,8 +23,8 @@
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* Backport of android.view.GhostView introduced in API level 21.
@@ -44,8 +44,7 @@
/** The number of references to this ghost view */
int mReferences;
- @Nullable
- private Matrix mMatrix;
+ private @Nullable Matrix mMatrix;
private final ViewTreeObserver.OnPreDrawListener mOnPreDrawListener =
new ViewTreeObserver.OnPreDrawListener() {
diff --git a/transition/transition/src/main/java/androidx/transition/GhostViewUtils.java b/transition/transition/src/main/java/androidx/transition/GhostViewUtils.java
index f572740..1278293 100644
--- a/transition/transition/src/main/java/androidx/transition/GhostViewUtils.java
+++ b/transition/transition/src/main/java/androidx/transition/GhostViewUtils.java
@@ -21,13 +21,12 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
class GhostViewUtils {
- @Nullable
- static GhostView addGhost(@NonNull View view, @NonNull ViewGroup viewGroup,
+ static @Nullable GhostView addGhost(@NonNull View view, @NonNull ViewGroup viewGroup,
@Nullable Matrix matrix) {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.P) {
// Use the platform implementation on P as we can't backport the shadows drawing.
diff --git a/transition/transition/src/main/java/androidx/transition/ImageViewUtils.java b/transition/transition/src/main/java/androidx/transition/ImageViewUtils.java
index 58c435a..c9f6e46 100644
--- a/transition/transition/src/main/java/androidx/transition/ImageViewUtils.java
+++ b/transition/transition/src/main/java/androidx/transition/ImageViewUtils.java
@@ -22,10 +22,11 @@
import android.os.Build;
import android.widget.ImageView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.reflect.Field;
class ImageViewUtils {
diff --git a/transition/transition/src/main/java/androidx/transition/PathMotion.java b/transition/transition/src/main/java/androidx/transition/PathMotion.java
index 3640283..e314b7e 100644
--- a/transition/transition/src/main/java/androidx/transition/PathMotion.java
+++ b/transition/transition/src/main/java/androidx/transition/PathMotion.java
@@ -20,7 +20,7 @@
import android.graphics.Path;
import android.util.AttributeSet;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* This base class can be extended to provide motion along a Path to Transitions.
@@ -60,6 +60,5 @@
* must start at point <code>(startX, startY)</code>, typically using
* {@link android.graphics.Path#moveTo(float, float)} and end at <code>(endX, endY)</code>.
*/
- @NonNull
- public abstract Path getPath(float startX, float startY, float endX, float endY);
+ public abstract @NonNull Path getPath(float startX, float startY, float endX, float endY);
}
diff --git a/transition/transition/src/main/java/androidx/transition/PatternPathMotion.java b/transition/transition/src/main/java/androidx/transition/PatternPathMotion.java
index 2d440bb..5705eee 100644
--- a/transition/transition/src/main/java/androidx/transition/PatternPathMotion.java
+++ b/transition/transition/src/main/java/androidx/transition/PatternPathMotion.java
@@ -23,10 +23,10 @@
import android.graphics.PathMeasure;
import android.util.AttributeSet;
-import androidx.annotation.NonNull;
import androidx.core.content.res.TypedArrayUtils;
import androidx.core.graphics.PathParser;
+import org.jspecify.annotations.NonNull;
import org.xmlpull.v1.XmlPullParser;
/**
@@ -90,8 +90,7 @@
*
* @return the Path defining a pattern of motion between two coordinates.
*/
- @NonNull
- public Path getPatternPath() {
+ public @NonNull Path getPatternPath() {
return mOriginalPatternPath;
}
@@ -129,9 +128,8 @@
mOriginalPatternPath = patternPath;
}
- @NonNull
@Override
- public Path getPath(float startX, float startY, float endX, float endY) {
+ public @NonNull Path getPath(float startX, float startY, float endX, float endY) {
float dx = endX - startX;
float dy = endY - startY;
float length = distance(dx, dy);
diff --git a/transition/transition/src/main/java/androidx/transition/Scene.java b/transition/transition/src/main/java/androidx/transition/Scene.java
index d979a72..dd37df6 100644
--- a/transition/transition/src/main/java/androidx/transition/Scene.java
+++ b/transition/transition/src/main/java/androidx/transition/Scene.java
@@ -23,8 +23,9 @@
import android.view.ViewGroup;
import androidx.annotation.LayoutRes;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* A scene represents the collection of values that various properties in the
@@ -56,9 +57,8 @@
* the layout resource.
* @return The scene for the given root and layout id
*/
- @NonNull
- public static Scene getSceneForLayout(@NonNull ViewGroup sceneRoot, @LayoutRes int layoutId,
- @NonNull Context context) {
+ public static @NonNull Scene getSceneForLayout(@NonNull ViewGroup sceneRoot,
+ @LayoutRes int layoutId, @NonNull Context context) {
@SuppressWarnings("unchecked")
SparseArray<Scene> scenes =
(SparseArray<Scene>) sceneRoot.getTag(R.id.transition_scene_layoutid_cache);
@@ -133,8 +133,7 @@
*
* @return The root of the view hierarchy affected by this scene.
*/
- @NonNull
- public ViewGroup getSceneRoot() {
+ public @NonNull ViewGroup getSceneRoot() {
return mSceneRoot;
}
@@ -204,8 +203,7 @@
* @return The current Scene set on this ViewGroup. A value of null indicates that
* no Scene is currently set.
*/
- @Nullable
- public static Scene getCurrentScene(@NonNull ViewGroup sceneRoot) {
+ public static @Nullable Scene getCurrentScene(@NonNull ViewGroup sceneRoot) {
return (Scene) sceneRoot.getTag(R.id.transition_current_scene);
}
diff --git a/transition/transition/src/main/java/androidx/transition/SidePropagation.java b/transition/transition/src/main/java/androidx/transition/SidePropagation.java
index e7198e1..6956744 100644
--- a/transition/transition/src/main/java/androidx/transition/SidePropagation.java
+++ b/transition/transition/src/main/java/androidx/transition/SidePropagation.java
@@ -21,8 +21,8 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* A <code>TransitionPropagation</code> that propagates based on the distance to the side
diff --git a/transition/transition/src/main/java/androidx/transition/Slide.java b/transition/transition/src/main/java/androidx/transition/Slide.java
index 03e3d51..7e6a5d1 100644
--- a/transition/transition/src/main/java/androidx/transition/Slide.java
+++ b/transition/transition/src/main/java/androidx/transition/Slide.java
@@ -30,11 +30,11 @@
import android.view.animation.DecelerateInterpolator;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.core.content.res.TypedArrayUtils;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.xmlpull.v1.XmlPullParser;
import java.lang.annotation.Retention;
@@ -245,9 +245,8 @@
return mSlideEdge;
}
- @Nullable
@Override
- public Animator onAppear(@NonNull ViewGroup sceneRoot, @NonNull View view,
+ public @Nullable Animator onAppear(@NonNull ViewGroup sceneRoot, @NonNull View view,
@Nullable TransitionValues startValues, @Nullable TransitionValues endValues) {
if (endValues == null) {
return null;
@@ -262,9 +261,8 @@
startX, startY, endX, endY, sDecelerate, this);
}
- @Nullable
@Override
- public Animator onDisappear(@NonNull ViewGroup sceneRoot, @NonNull View view,
+ public @Nullable Animator onDisappear(@NonNull ViewGroup sceneRoot, @NonNull View view,
@Nullable TransitionValues startValues, @Nullable TransitionValues endValues) {
if (startValues == null) {
return null;
diff --git a/transition/transition/src/main/java/androidx/transition/Transition.java b/transition/transition/src/main/java/androidx/transition/Transition.java
index a4b20ea..6b1f33b 100644
--- a/transition/transition/src/main/java/androidx/transition/Transition.java
+++ b/transition/transition/src/main/java/androidx/transition/Transition.java
@@ -44,8 +44,6 @@
import androidx.annotation.IdRes;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.collection.ArrayMap;
@@ -58,6 +56,9 @@
import androidx.dynamicanimation.animation.SpringAnimation;
import androidx.dynamicanimation.animation.SpringForce;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
@@ -178,9 +179,8 @@
};
private static final PathMotion STRAIGHT_PATH_MOTION = new PathMotion() {
- @NonNull
@Override
- public Path getPath(float startX, float startY, float endX, float endY) {
+ public @NonNull Path getPath(float startX, float startY, float endX, float endY) {
Path path = new Path();
path.moveTo(startX, startY);
path.lineTo(endX, endY);
@@ -358,8 +358,7 @@
* of a TransitionSet, the parent TransitionSets are walked until a TransitionSet is found
* that isn't contained in another TransitionSet.
*/
- @NonNull
- public final Transition getRootTransition() {
+ public final @NonNull Transition getRootTransition() {
if (mParent != null) {
return mParent.getRootTransition();
}
@@ -375,8 +374,7 @@
* @param duration The length of the animation, in milliseconds.
* @return This transition object.
*/
- @NonNull
- public Transition setDuration(long duration) {
+ public @NonNull Transition setDuration(long duration) {
mDuration = duration;
return this;
}
@@ -402,8 +400,7 @@
* @param startDelay The length of the delay, in milliseconds.
* @return This transition object.
*/
- @NonNull
- public Transition setStartDelay(long startDelay) {
+ public @NonNull Transition setStartDelay(long startDelay) {
mStartDelay = startDelay;
return this;
}
@@ -429,8 +426,7 @@
* @param interpolator The time interpolator used by the transition
* @return This transition object.
*/
- @NonNull
- public Transition setInterpolator(@Nullable TimeInterpolator interpolator) {
+ public @NonNull Transition setInterpolator(@Nullable TimeInterpolator interpolator) {
mInterpolator = interpolator;
return this;
}
@@ -443,8 +439,7 @@
* @return The interpolator set on this transition, if one has been set, otherwise
* returns null.
*/
- @Nullable
- public TimeInterpolator getInterpolator() {
+ public @Nullable TimeInterpolator getInterpolator() {
return mInterpolator;
}
@@ -469,8 +464,7 @@
* @return An array of property names as described in the class documentation for
* {@link TransitionValues}. The default implementation returns <code>null</code>.
*/
- @Nullable
- public String[] getTransitionProperties() {
+ public String @Nullable [] getTransitionProperties() {
return null;
}
@@ -519,8 +513,7 @@
* overall transition for this scene change. A null value means no animation
* should be run.
*/
- @Nullable
- public Animator createAnimator(@NonNull ViewGroup sceneRoot,
+ public @Nullable Animator createAnimator(@NonNull ViewGroup sceneRoot,
@Nullable TransitionValues startValues, @Nullable TransitionValues endValues) {
return null;
}
@@ -532,8 +525,7 @@
* animations.
*/
@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
- @NonNull
- TransitionSeekController createSeekController() {
+ @NonNull TransitionSeekController createSeekController() {
mSeekController = new SeekController();
addListener(mSeekController);
return mSeekController;
@@ -556,7 +548,7 @@
* {@link #MATCH_NAME}, {@link #MATCH_ITEM_ID}, and {@link #MATCH_ID}.
* If none are provided, then the default match order will be set.
*/
- public void setMatchOrder(@MatchOrder @Nullable int... matches) {
+ public void setMatchOrder(@MatchOrder int @Nullable ... matches) {
if (matches == null || matches.length == 0) {
mMatchOrder = DEFAULT_MATCH_ORDER;
} else {
@@ -1087,8 +1079,7 @@
* <code>transitionSet.addTransitions(new Fade()).addTarget(someView);</code>
* @see #addTarget(int)
*/
- @NonNull
- public Transition addTarget(@NonNull View target) {
+ public @NonNull Transition addTarget(@NonNull View target) {
mTargets.add(target);
return this;
}
@@ -1111,8 +1102,7 @@
* <code>transitionSet.addTransitions(new Fade()).addTarget(someId);</code>
* @see View#getId()
*/
- @NonNull
- public Transition addTarget(@IdRes int targetId) {
+ public @NonNull Transition addTarget(@IdRes int targetId) {
if (targetId != 0) {
mTargetIds.add(targetId);
}
@@ -1136,8 +1126,7 @@
* <code>transitionSet.addTransitions(new Fade()).addTarget(someName);</code>
* @see ViewCompat#getTransitionName(View)
*/
- @NonNull
- public Transition addTarget(@NonNull String targetName) {
+ public @NonNull Transition addTarget(@NonNull String targetName) {
if (mTargetNames == null) {
mTargetNames = new ArrayList<>();
}
@@ -1166,8 +1155,7 @@
* @see #excludeTarget(Class, boolean)
* @see #excludeChildren(Class, boolean)
*/
- @NonNull
- public Transition addTarget(@NonNull Class<?> targetType) {
+ public @NonNull Transition addTarget(@NonNull Class<?> targetType) {
if (mTargetTypes == null) {
mTargetTypes = new ArrayList<>();
}
@@ -1185,8 +1173,7 @@
* construction, such as
* <code>transitionSet.addTransitions(new Fade()).removeTarget(someView);</code>
*/
- @NonNull
- public Transition removeTarget(@NonNull View target) {
+ public @NonNull Transition removeTarget(@NonNull View target) {
mTargets.remove(target);
return this;
}
@@ -1201,8 +1188,7 @@
* construction, such as
* <code>transitionSet.addTransitions(new Fade()).removeTargetId(someId);</code>
*/
- @NonNull
- public Transition removeTarget(@IdRes int targetId) {
+ public @NonNull Transition removeTarget(@IdRes int targetId) {
if (targetId != 0) {
mTargetIds.remove((Integer) targetId);
}
@@ -1219,8 +1205,7 @@
* construction, such as
* <code>transitionSet.addTransitions(new Fade()).removeTargetName(someName);</code>
*/
- @NonNull
- public Transition removeTarget(@NonNull String targetName) {
+ public @NonNull Transition removeTarget(@NonNull String targetName) {
if (mTargetNames != null) {
mTargetNames.remove(targetName);
}
@@ -1237,8 +1222,7 @@
* construction, such as
* <code>transitionSet.addTransitions(new Fade()).removeTarget(someType);</code>
*/
- @NonNull
- public Transition removeTarget(@NonNull Class<?> target) {
+ public @NonNull Transition removeTarget(@NonNull Class<?> target) {
if (mTargetTypes != null) {
mTargetTypes.remove(target);
}
@@ -1280,8 +1264,7 @@
* @see #excludeTarget(int, boolean)
* @see #excludeTarget(Class, boolean)
*/
- @NonNull
- public Transition excludeTarget(@NonNull View target, boolean exclude) {
+ public @NonNull Transition excludeTarget(@NonNull View target, boolean exclude) {
mTargetExcludes = excludeView(mTargetExcludes, target, exclude);
return this;
}
@@ -1306,8 +1289,7 @@
* @see #excludeTarget(View, boolean)
* @see #excludeTarget(Class, boolean)
*/
- @NonNull
- public Transition excludeTarget(@IdRes int targetId, boolean exclude) {
+ public @NonNull Transition excludeTarget(@IdRes int targetId, boolean exclude) {
mTargetIdExcludes = excludeId(mTargetIdExcludes, targetId, exclude);
return this;
}
@@ -1332,8 +1314,7 @@
* @see #excludeTarget(int, boolean)
* @see #excludeTarget(Class, boolean)
*/
- @NonNull
- public Transition excludeTarget(@NonNull String targetName, boolean exclude) {
+ public @NonNull Transition excludeTarget(@NonNull String targetName, boolean exclude) {
mTargetNameExcludes = excludeObject(mTargetNameExcludes, targetName, exclude);
return this;
}
@@ -1358,8 +1339,7 @@
* @see #excludeChildren(int, boolean)
* @see #excludeChildren(Class, boolean)
*/
- @NonNull
- public Transition excludeChildren(@NonNull View target, boolean exclude) {
+ public @NonNull Transition excludeChildren(@NonNull View target, boolean exclude) {
mTargetChildExcludes = excludeView(mTargetChildExcludes, target, exclude);
return this;
}
@@ -1388,8 +1368,7 @@
* @see #excludeChildren(View, boolean)
* @see #excludeChildren(Class, boolean)
*/
- @NonNull
- public Transition excludeChildren(@IdRes int targetId, boolean exclude) {
+ public @NonNull Transition excludeChildren(@IdRes int targetId, boolean exclude) {
mTargetIdChildExcludes = excludeId(mTargetIdChildExcludes, targetId, exclude);
return this;
}
@@ -1444,8 +1423,7 @@
* @see #excludeTarget(int, boolean)
* @see #excludeTarget(View, boolean)
*/
- @NonNull
- public Transition excludeTarget(@NonNull Class<?> type, boolean exclude) {
+ public @NonNull Transition excludeTarget(@NonNull Class<?> type, boolean exclude) {
mTargetTypeExcludes = excludeType(mTargetTypeExcludes, type, exclude);
return this;
}
@@ -1471,8 +1449,7 @@
* @see #excludeChildren(int, boolean)
* @see #excludeChildren(View, boolean)
*/
- @NonNull
- public Transition excludeChildren(@NonNull Class<?> type, boolean exclude) {
+ public @NonNull Transition excludeChildren(@NonNull Class<?> type, boolean exclude) {
mTargetTypeChildExcludes = excludeType(mTargetTypeChildExcludes, type, exclude);
return this;
}
@@ -1502,8 +1479,7 @@
*
* @return the list of target IDs
*/
- @NonNull
- public List<Integer> getTargetIds() {
+ public @NonNull List<Integer> getTargetIds() {
return mTargetIds;
}
@@ -1516,8 +1492,7 @@
*
* @return the list of target views
*/
- @NonNull
- public List<View> getTargets() {
+ public @NonNull List<View> getTargets() {
return mTargets;
}
@@ -1531,8 +1506,7 @@
*
* @return the list of target transitionNames
*/
- @Nullable
- public List<String> getTargetNames() {
+ public @Nullable List<String> getTargetNames() {
return mTargetNames;
}
@@ -1546,8 +1520,7 @@
*
* @return the list of target Types
*/
- @Nullable
- public List<Class<?>> getTargetTypes() {
+ public @Nullable List<Class<?>> getTargetTypes() {
return mTargetTypes;
}
@@ -1764,8 +1737,7 @@
* necessary, for example, to query the before/after state of related views
* for a given transition.
*/
- @Nullable
- public TransitionValues getTransitionValues(@NonNull View view, boolean start) {
+ public @Nullable TransitionValues getTransitionValues(@NonNull View view, boolean start) {
if (mParent != null) {
return mParent.getTransitionValues(view, start);
}
@@ -2140,8 +2112,7 @@
* for this animation.
* @return This transition object.
*/
- @NonNull
- public Transition addListener(@NonNull TransitionListener listener) {
+ public @NonNull Transition addListener(@NonNull TransitionListener listener) {
if (mListeners == null) {
mListeners = new ArrayList<>();
}
@@ -2156,8 +2127,7 @@
* listeners for this transition.
* @return This transition object.
*/
- @NonNull
- public Transition removeListener(@NonNull TransitionListener listener) {
+ public @NonNull Transition removeListener(@NonNull TransitionListener listener) {
if (mListeners == null) {
return this;
}
@@ -2203,8 +2173,7 @@
* @see PatternPathMotion
* @see android.transition.PathMotion
*/
- @NonNull
- public PathMotion getPathMotion() {
+ public @NonNull PathMotion getPathMotion() {
return mPathMotion;
}
@@ -2233,8 +2202,7 @@
*
* @return the callback used to find the epicenter of the Transition.
*/
- @Nullable
- public EpicenterCallback getEpicenterCallback() {
+ public @Nullable EpicenterCallback getEpicenterCallback() {
return mEpicenterCallback;
}
@@ -2246,8 +2214,7 @@
* {@link android.transition.Transition.EpicenterCallback} or null if no callback exists.
* @see #setEpicenterCallback(EpicenterCallback)
*/
- @Nullable
- public Rect getEpicenter() {
+ public @Nullable Rect getEpicenter() {
if (mEpicenterCallback == null) {
return null;
}
@@ -2281,8 +2248,7 @@
* @return the {@link android.transition.TransitionPropagation} used to calculate Animator start
* delays. This is null by default.
*/
- @Nullable
- public TransitionPropagation getPropagation() {
+ public @Nullable TransitionPropagation getPropagation() {
return mPropagation;
}
@@ -2314,15 +2280,13 @@
mCanRemoveViews = canRemoveViews;
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
return toString("");
}
- @NonNull
@Override
- public Transition clone() {
+ public @NonNull Transition clone() {
try {
Transition clone = (Transition) super.clone();
clone.mAnimators = new ArrayList<>();
@@ -2351,8 +2315,7 @@
*
* @return The name of this transition.
*/
- @NonNull
- public String getName() {
+ public @NonNull String getName() {
return mName;
}
@@ -2667,8 +2630,7 @@
* @return The Rect region of the epicenter of <code>transition</code> or null if
* there is no epicenter.
*/
- @Nullable
- public abstract Rect onGetEpicenter(@NonNull Transition transition);
+ public abstract @Nullable Rect onGetEpicenter(@NonNull Transition transition);
}
/**
diff --git a/transition/transition/src/main/java/androidx/transition/TransitionInflater.java b/transition/transition/src/main/java/androidx/transition/TransitionInflater.java
index a5f612a..5018d28 100644
--- a/transition/transition/src/main/java/androidx/transition/TransitionInflater.java
+++ b/transition/transition/src/main/java/androidx/transition/TransitionInflater.java
@@ -25,11 +25,11 @@
import android.view.InflateException;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.collection.ArrayMap;
import androidx.core.content.res.TypedArrayUtils;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -54,8 +54,7 @@
/**
* Obtains the TransitionInflater from the given context.
*/
- @NonNull
- public static TransitionInflater from(@NonNull Context context) {
+ public static @NonNull TransitionInflater from(@NonNull Context context) {
return new TransitionInflater(context);
}
@@ -67,8 +66,7 @@
* @throws android.content.res.Resources.NotFoundException when the
* transition cannot be loaded
*/
- @Nullable
- public Transition inflateTransition(int resource) {
+ public @Nullable Transition inflateTransition(int resource) {
XmlResourceParser parser = mContext.getResources().getXml(resource);
try {
return createTransitionFromXml(parser, Xml.asAttributeSet(parser), null);
@@ -90,8 +88,8 @@
* @throws android.content.res.Resources.NotFoundException when the
* transition manager cannot be loaded
*/
- @Nullable
- public TransitionManager inflateTransitionManager(int resource, @NonNull ViewGroup sceneRoot) {
+ public @Nullable TransitionManager inflateTransitionManager(int resource,
+ @NonNull ViewGroup sceneRoot) {
XmlResourceParser parser = mContext.getResources().getXml(resource);
try {
return createTransitionManagerFromXml(parser, Xml.asAttributeSet(parser), sceneRoot);
diff --git a/transition/transition/src/main/java/androidx/transition/TransitionListenerAdapter.java b/transition/transition/src/main/java/androidx/transition/TransitionListenerAdapter.java
index 6f93260..2b9a030 100644
--- a/transition/transition/src/main/java/androidx/transition/TransitionListenerAdapter.java
+++ b/transition/transition/src/main/java/androidx/transition/TransitionListenerAdapter.java
@@ -16,7 +16,7 @@
package androidx.transition;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* This adapter class provides empty implementations of the methods from {@link
diff --git a/transition/transition/src/main/java/androidx/transition/TransitionManager.java b/transition/transition/src/main/java/androidx/transition/TransitionManager.java
index 78aa1a0..6d3a1cf 100644
--- a/transition/transition/src/main/java/androidx/transition/TransitionManager.java
+++ b/transition/transition/src/main/java/androidx/transition/TransitionManager.java
@@ -23,11 +23,12 @@
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.collection.ArrayMap;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -363,8 +364,7 @@
* @throws IllegalArgumentException if {@code transition} returns {@code false} from
* {@link Transition#isSeekingSupported()}.
*/
- @Nullable
- public static TransitionSeekController createSeekController(
+ public static @Nullable TransitionSeekController createSeekController(
@NonNull Scene scene,
@NonNull Transition transition
) {
@@ -428,7 +428,7 @@
*
* @param sceneRoot The root of the View hierarchy to run the transition on.
*/
- public static void beginDelayedTransition(@NonNull final ViewGroup sceneRoot) {
+ public static void beginDelayedTransition(final @NonNull ViewGroup sceneRoot) {
beginDelayedTransition(sceneRoot, null);
}
@@ -455,7 +455,7 @@
* @param transition The transition to use for this change. A
* value of null causes the TransitionManager to use the default transition.
*/
- public static void beginDelayedTransition(@NonNull final ViewGroup sceneRoot,
+ public static void beginDelayedTransition(final @NonNull ViewGroup sceneRoot,
@Nullable Transition transition) {
if (!sPendingTransitions.contains(sceneRoot) && sceneRoot.isLaidOut()) {
if (Transition.DBG) {
@@ -499,9 +499,8 @@
* @throws IllegalArgumentException if {@code transition} returns {@code false} from
* {@link Transition#isSeekingSupported()}.
*/
- @Nullable
- public static TransitionSeekController controlDelayedTransition(
- @NonNull final ViewGroup sceneRoot,
+ public static @Nullable TransitionSeekController controlDelayedTransition(
+ final @NonNull ViewGroup sceneRoot,
@NonNull Transition transition
) {
if (sPendingTransitions.contains(sceneRoot) || !sceneRoot.isLaidOut()
diff --git a/transition/transition/src/main/java/androidx/transition/TransitionPropagation.java b/transition/transition/src/main/java/androidx/transition/TransitionPropagation.java
index f0bee2f..e068159 100644
--- a/transition/transition/src/main/java/androidx/transition/TransitionPropagation.java
+++ b/transition/transition/src/main/java/androidx/transition/TransitionPropagation.java
@@ -19,8 +19,8 @@
import android.annotation.SuppressLint;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* Extend <code>TransitionPropagation</code> to customize start delays for Animators created
@@ -90,7 +90,6 @@
* {@link TransitionValues}.
*/
@SuppressLint("NullableCollection")
- @Nullable
- public abstract String[] getPropagationProperties();
+ public abstract String @Nullable [] getPropagationProperties();
}
diff --git a/transition/transition/src/main/java/androidx/transition/TransitionSeekController.java b/transition/transition/src/main/java/androidx/transition/TransitionSeekController.java
index 93b83f2..67872f5 100644
--- a/transition/transition/src/main/java/androidx/transition/TransitionSeekController.java
+++ b/transition/transition/src/main/java/androidx/transition/TransitionSeekController.java
@@ -20,9 +20,10 @@
import androidx.annotation.FloatRange;
import androidx.annotation.IntRange;
-import androidx.annotation.NonNull;
import androidx.core.util.Consumer;
+import org.jspecify.annotations.NonNull;
+
/**
* Returned from {@link TransitionManager#controlDelayedTransition(ViewGroup, Transition)}
* to allow manually controlling the animations within a Transition using
diff --git a/transition/transition/src/main/java/androidx/transition/TransitionSet.java b/transition/transition/src/main/java/androidx/transition/TransitionSet.java
index adf966e..c91dbc3 100644
--- a/transition/transition/src/main/java/androidx/transition/TransitionSet.java
+++ b/transition/transition/src/main/java/androidx/transition/TransitionSet.java
@@ -29,12 +29,13 @@
import android.view.ViewGroup;
import androidx.annotation.IdRes;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.core.content.res.TypedArrayUtils;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.Arrays;
@@ -131,8 +132,7 @@
* transitions in sequence.
* @return This transitionSet object.
*/
- @NonNull
- public TransitionSet setOrdering(int ordering) {
+ public @NonNull TransitionSet setOrdering(int ordering) {
switch (ordering) {
case ORDERING_SEQUENTIAL:
mPlayTogether = false;
@@ -175,8 +175,7 @@
* @param transition A non-null child transition to be added to this set.
* @return This transitionSet object.
*/
- @NonNull
- public TransitionSet addTransition(@NonNull Transition transition) {
+ public @NonNull TransitionSet addTransition(@NonNull Transition transition) {
addTransitionInternal(transition);
if (mDuration >= 0) {
transition.setDuration(mDuration);
@@ -219,8 +218,7 @@
* @see #addTransition(Transition)
* @see #getTransitionCount()
*/
- @Nullable
- public Transition getTransitionAt(int index) {
+ public @Nullable Transition getTransitionAt(int index) {
if (index < 0 || index >= mTransitions.size()) {
return null;
}
@@ -234,9 +232,8 @@
* @param duration The length of the animation, in milliseconds.
* @return This transitionSet object.
*/
- @NonNull
@Override
- public TransitionSet setDuration(long duration) {
+ public @NonNull TransitionSet setDuration(long duration) {
super.setDuration(duration);
if (mDuration >= 0 && mTransitions != null) {
int numTransitions = mTransitions.size();
@@ -247,15 +244,13 @@
return this;
}
- @NonNull
@Override
- public TransitionSet setStartDelay(long startDelay) {
+ public @NonNull TransitionSet setStartDelay(long startDelay) {
return (TransitionSet) super.setStartDelay(startDelay);
}
- @NonNull
@Override
- public TransitionSet setInterpolator(@Nullable TimeInterpolator interpolator) {
+ public @NonNull TransitionSet setInterpolator(@Nullable TimeInterpolator interpolator) {
mChangeFlags |= FLAG_CHANGE_INTERPOLATOR;
if (mTransitions != null) {
int numTransitions = mTransitions.size();
@@ -266,123 +261,109 @@
return (TransitionSet) super.setInterpolator(interpolator);
}
- @NonNull
@Override
- public TransitionSet addTarget(@NonNull View target) {
+ public @NonNull TransitionSet addTarget(@NonNull View target) {
for (int i = 0; i < mTransitions.size(); i++) {
mTransitions.get(i).addTarget(target);
}
return (TransitionSet) super.addTarget(target);
}
- @NonNull
@Override
- public TransitionSet addTarget(@IdRes int targetId) {
+ public @NonNull TransitionSet addTarget(@IdRes int targetId) {
for (int i = 0; i < mTransitions.size(); i++) {
mTransitions.get(i).addTarget(targetId);
}
return (TransitionSet) super.addTarget(targetId);
}
- @NonNull
@Override
- public TransitionSet addTarget(@NonNull String targetName) {
+ public @NonNull TransitionSet addTarget(@NonNull String targetName) {
for (int i = 0; i < mTransitions.size(); i++) {
mTransitions.get(i).addTarget(targetName);
}
return (TransitionSet) super.addTarget(targetName);
}
- @NonNull
@Override
- public TransitionSet addTarget(@NonNull Class<?> targetType) {
+ public @NonNull TransitionSet addTarget(@NonNull Class<?> targetType) {
for (int i = 0; i < mTransitions.size(); i++) {
mTransitions.get(i).addTarget(targetType);
}
return (TransitionSet) super.addTarget(targetType);
}
- @NonNull
@Override
- public TransitionSet addListener(@NonNull TransitionListener listener) {
+ public @NonNull TransitionSet addListener(@NonNull TransitionListener listener) {
return (TransitionSet) super.addListener(listener);
}
- @NonNull
@Override
- public TransitionSet removeTarget(@IdRes int targetId) {
+ public @NonNull TransitionSet removeTarget(@IdRes int targetId) {
for (int i = 0; i < mTransitions.size(); i++) {
mTransitions.get(i).removeTarget(targetId);
}
return (TransitionSet) super.removeTarget(targetId);
}
- @NonNull
@Override
- public TransitionSet removeTarget(@NonNull View target) {
+ public @NonNull TransitionSet removeTarget(@NonNull View target) {
for (int i = 0; i < mTransitions.size(); i++) {
mTransitions.get(i).removeTarget(target);
}
return (TransitionSet) super.removeTarget(target);
}
- @NonNull
@Override
- public TransitionSet removeTarget(@NonNull Class<?> target) {
+ public @NonNull TransitionSet removeTarget(@NonNull Class<?> target) {
for (int i = 0; i < mTransitions.size(); i++) {
mTransitions.get(i).removeTarget(target);
}
return (TransitionSet) super.removeTarget(target);
}
- @NonNull
@Override
- public TransitionSet removeTarget(@NonNull String targetName) {
+ public @NonNull TransitionSet removeTarget(@NonNull String targetName) {
for (int i = 0; i < mTransitions.size(); i++) {
mTransitions.get(i).removeTarget(targetName);
}
return (TransitionSet) super.removeTarget(targetName);
}
- @NonNull
@Override
- public Transition excludeTarget(@NonNull View target, boolean exclude) {
+ public @NonNull Transition excludeTarget(@NonNull View target, boolean exclude) {
for (int i = 0; i < mTransitions.size(); i++) {
mTransitions.get(i).excludeTarget(target, exclude);
}
return super.excludeTarget(target, exclude);
}
- @NonNull
@Override
- public Transition excludeTarget(@NonNull String targetName, boolean exclude) {
+ public @NonNull Transition excludeTarget(@NonNull String targetName, boolean exclude) {
for (int i = 0; i < mTransitions.size(); i++) {
mTransitions.get(i).excludeTarget(targetName, exclude);
}
return super.excludeTarget(targetName, exclude);
}
- @NonNull
@Override
- public Transition excludeTarget(int targetId, boolean exclude) {
+ public @NonNull Transition excludeTarget(int targetId, boolean exclude) {
for (int i = 0; i < mTransitions.size(); i++) {
mTransitions.get(i).excludeTarget(targetId, exclude);
}
return super.excludeTarget(targetId, exclude);
}
- @NonNull
@Override
- public Transition excludeTarget(@NonNull Class<?> type, boolean exclude) {
+ public @NonNull Transition excludeTarget(@NonNull Class<?> type, boolean exclude) {
for (int i = 0; i < mTransitions.size(); i++) {
mTransitions.get(i).excludeTarget(type, exclude);
}
return super.excludeTarget(type, exclude);
}
- @NonNull
@Override
- public TransitionSet removeListener(@NonNull TransitionListener listener) {
+ public @NonNull TransitionSet removeListener(@NonNull TransitionListener listener) {
return (TransitionSet) super.removeListener(listener);
}
@@ -403,8 +384,7 @@
* @param transition The transition to be removed.
* @return This transitionSet object.
*/
- @NonNull
- public TransitionSet removeTransition(@NonNull Transition transition) {
+ public @NonNull TransitionSet removeTransition(@NonNull Transition transition) {
mTransitions.remove(transition);
transition.mParent = null;
return this;
@@ -794,9 +774,8 @@
return result;
}
- @NonNull
@Override
- public Transition clone() {
+ public @NonNull Transition clone() {
TransitionSet clone = (TransitionSet) super.clone();
clone.mTransitions = new ArrayList<>();
int numTransitions = mTransitions.size();
diff --git a/transition/transition/src/main/java/androidx/transition/TransitionValues.java b/transition/transition/src/main/java/androidx/transition/TransitionValues.java
index 8765f3218..bb678de 100644
--- a/transition/transition/src/main/java/androidx/transition/TransitionValues.java
+++ b/transition/transition/src/main/java/androidx/transition/TransitionValues.java
@@ -19,7 +19,7 @@
import android.annotation.SuppressLint;
import android.view.View;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
import java.util.ArrayList;
import java.util.HashMap;
@@ -88,9 +88,8 @@
return 31 * view.hashCode() + values.hashCode();
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
String returnValue = "TransitionValues@" + Integer.toHexString(hashCode()) + ":\n";
returnValue += " view = " + view + "\n";
returnValue += " values:";
diff --git a/transition/transition/src/main/java/androidx/transition/TranslationAnimationCreator.java b/transition/transition/src/main/java/androidx/transition/TranslationAnimationCreator.java
index 2b79de9..aa1f2c8 100644
--- a/transition/transition/src/main/java/androidx/transition/TranslationAnimationCreator.java
+++ b/transition/transition/src/main/java/androidx/transition/TranslationAnimationCreator.java
@@ -23,8 +23,8 @@
import android.animation.TimeInterpolator;
import android.view.View;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* This class is used by Slide and Explode to create an animator that goes from the start
@@ -49,8 +49,7 @@
* @return An animator that moves from (startX, startY) to (endX, endY) unless there was
* a previous interruption, in which case it moves from the current position to (endX, endY).
*/
- @Nullable
- static Animator createAnimation(@NonNull View view, @NonNull TransitionValues values,
+ static @Nullable Animator createAnimation(@NonNull View view, @NonNull TransitionValues values,
int viewPosX, int viewPosY, float startX, float startY, float endX, float endY,
@Nullable TimeInterpolator interpolator, @NonNull Transition transition) {
float terminalX = view.getTranslationX();
diff --git a/transition/transition/src/main/java/androidx/transition/ViewGroupUtils.java b/transition/transition/src/main/java/androidx/transition/ViewGroupUtils.java
index 20b4000..5734919 100644
--- a/transition/transition/src/main/java/androidx/transition/ViewGroupUtils.java
+++ b/transition/transition/src/main/java/androidx/transition/ViewGroupUtils.java
@@ -20,9 +20,10 @@
import android.os.Build;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
+import org.jspecify.annotations.NonNull;
+
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
diff --git a/transition/transition/src/main/java/androidx/transition/ViewUtils.java b/transition/transition/src/main/java/androidx/transition/ViewUtils.java
index 16de6e6..a4500b4 100644
--- a/transition/transition/src/main/java/androidx/transition/ViewUtils.java
+++ b/transition/transition/src/main/java/androidx/transition/ViewUtils.java
@@ -22,8 +22,8 @@
import android.util.Property;
import android.view.View;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* Compatibility utilities for platform features of {@link View}.
diff --git a/transition/transition/src/main/java/androidx/transition/ViewUtilsApi19.java b/transition/transition/src/main/java/androidx/transition/ViewUtilsApi19.java
index f7c5b7d..a5f8bb5 100644
--- a/transition/transition/src/main/java/androidx/transition/ViewUtilsApi19.java
+++ b/transition/transition/src/main/java/androidx/transition/ViewUtilsApi19.java
@@ -22,10 +22,11 @@
import android.view.View;
import android.view.ViewParent;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
diff --git a/transition/transition/src/main/java/androidx/transition/ViewUtilsApi21.java b/transition/transition/src/main/java/androidx/transition/ViewUtilsApi21.java
index 3a4adeb..68bccc2 100644
--- a/transition/transition/src/main/java/androidx/transition/ViewUtilsApi21.java
+++ b/transition/transition/src/main/java/androidx/transition/ViewUtilsApi21.java
@@ -20,10 +20,11 @@
import android.graphics.Matrix;
import android.view.View;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
@RequiresApi(21)
class ViewUtilsApi21 extends ViewUtilsApi19 {
diff --git a/transition/transition/src/main/java/androidx/transition/ViewUtilsApi22.java b/transition/transition/src/main/java/androidx/transition/ViewUtilsApi22.java
index e0330a7..c7454f6 100644
--- a/transition/transition/src/main/java/androidx/transition/ViewUtilsApi22.java
+++ b/transition/transition/src/main/java/androidx/transition/ViewUtilsApi22.java
@@ -19,9 +19,10 @@
import android.annotation.SuppressLint;
import android.view.View;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
+import org.jspecify.annotations.NonNull;
+
@RequiresApi(22)
class ViewUtilsApi22 extends ViewUtilsApi21 {
diff --git a/transition/transition/src/main/java/androidx/transition/ViewUtilsApi23.java b/transition/transition/src/main/java/androidx/transition/ViewUtilsApi23.java
index fc1d27b..5b975ee 100644
--- a/transition/transition/src/main/java/androidx/transition/ViewUtilsApi23.java
+++ b/transition/transition/src/main/java/androidx/transition/ViewUtilsApi23.java
@@ -20,9 +20,10 @@
import android.os.Build;
import android.view.View;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
+import org.jspecify.annotations.NonNull;
+
@RequiresApi(23)
class ViewUtilsApi23 extends ViewUtilsApi22 {
diff --git a/transition/transition/src/main/java/androidx/transition/ViewUtilsApi29.java b/transition/transition/src/main/java/androidx/transition/ViewUtilsApi29.java
index be835de5..45250b5 100644
--- a/transition/transition/src/main/java/androidx/transition/ViewUtilsApi29.java
+++ b/transition/transition/src/main/java/androidx/transition/ViewUtilsApi29.java
@@ -19,10 +19,11 @@
import android.graphics.Matrix;
import android.view.View;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
@RequiresApi(29)
class ViewUtilsApi29 extends ViewUtilsApi23 {
diff --git a/transition/transition/src/main/java/androidx/transition/Visibility.java b/transition/transition/src/main/java/androidx/transition/Visibility.java
index 9d87ee2..f4a1306 100644
--- a/transition/transition/src/main/java/androidx/transition/Visibility.java
+++ b/transition/transition/src/main/java/androidx/transition/Visibility.java
@@ -29,12 +29,13 @@
import android.view.ViewGroup;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.core.content.res.TypedArrayUtils;
import androidx.core.view.ViewCompat;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -138,9 +139,8 @@
return mMode;
}
- @Nullable
@Override
- public String[] getTransitionProperties() {
+ public String @Nullable [] getTransitionProperties() {
return sTransitionProperties;
}
@@ -241,9 +241,8 @@
return visInfo;
}
- @Nullable
@Override
- public Animator createAnimator(@NonNull ViewGroup sceneRoot,
+ public @Nullable Animator createAnimator(@NonNull ViewGroup sceneRoot,
@Nullable TransitionValues startValues, @Nullable TransitionValues endValues) {
VisibilityInfo visInfo = getVisibilityChangeInfo(startValues, endValues);
if (visInfo.mVisibilityChange
@@ -275,10 +274,10 @@
* overall transition for this scene change. A null value means no animation
* should be run.
*/
- @Nullable
@SuppressWarnings("UnusedParameters")
- public Animator onAppear(@NonNull ViewGroup sceneRoot, @Nullable TransitionValues startValues,
- int startVisibility, @Nullable TransitionValues endValues, int endVisibility) {
+ public @Nullable Animator onAppear(@NonNull ViewGroup sceneRoot,
+ @Nullable TransitionValues startValues, int startVisibility,
+ @Nullable TransitionValues endValues, int endVisibility) {
if ((mMode & MODE_IN) != MODE_IN || endValues == null) {
return null;
}
@@ -313,8 +312,7 @@
* overall transition for this scene change. A null value means no animation
* should be run.
*/
- @Nullable
- public Animator onAppear(@NonNull ViewGroup sceneRoot, @NonNull View view,
+ public @Nullable Animator onAppear(@NonNull ViewGroup sceneRoot, @NonNull View view,
@Nullable TransitionValues startValues, @Nullable TransitionValues endValues) {
return null;
}
@@ -334,9 +332,8 @@
* overall transition for this scene change. A null value means no animation
* should be run.
*/
- @Nullable
@SuppressWarnings("UnusedParameters")
- public Animator onDisappear(@NonNull ViewGroup sceneRoot,
+ public @Nullable Animator onDisappear(@NonNull ViewGroup sceneRoot,
@Nullable TransitionValues startValues, int startVisibility,
@Nullable TransitionValues endValues, int endVisibility) {
if ((mMode & MODE_OUT) != MODE_OUT) {
@@ -480,8 +477,7 @@
* overall transition for this scene change. A null value means no animation
* should be run.
*/
- @Nullable
- public Animator onDisappear(@NonNull ViewGroup sceneRoot, @NonNull View view,
+ public @Nullable Animator onDisappear(@NonNull ViewGroup sceneRoot, @NonNull View view,
@Nullable TransitionValues startValues, @Nullable TransitionValues endValues) {
return null;
}
diff --git a/transition/transition/src/main/java/androidx/transition/VisibilityPropagation.java b/transition/transition/src/main/java/androidx/transition/VisibilityPropagation.java
index c9c1e30..eda55b5 100644
--- a/transition/transition/src/main/java/androidx/transition/VisibilityPropagation.java
+++ b/transition/transition/src/main/java/androidx/transition/VisibilityPropagation.java
@@ -18,8 +18,8 @@
import android.view.View;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* Base class for <code>TransitionPropagation</code>s that care about
@@ -60,9 +60,8 @@
transitionValues.values.put(PROPNAME_VIEW_CENTER, loc);
}
- @Nullable
@Override
- public String[] getPropagationProperties() {
+ public String @Nullable [] getPropagationProperties() {
return VISIBILITY_PROPAGATION_VALUES;
}
diff --git a/vectordrawable/integration-tests/testapp/build.gradle b/vectordrawable/integration-tests/testapp/build.gradle
index 9dccbed..d124c31 100644
--- a/vectordrawable/integration-tests/testapp/build.gradle
+++ b/vectordrawable/integration-tests/testapp/build.gradle
@@ -20,6 +20,7 @@
}
dependencies {
+ api(libs.jspecify)
implementation(project(":vectordrawable:vectordrawable"))
implementation(project(":vectordrawable:vectordrawable-animated"))
implementation(project(":vectordrawable:vectordrawable-seekable"))
diff --git a/vectordrawable/integration-tests/testapp/src/main/java/com/example/android/support/vectordrawable/app/AVDCListenerDemo.java b/vectordrawable/integration-tests/testapp/src/main/java/com/example/android/support/vectordrawable/app/AVDCListenerDemo.java
index 1b6cba4..b77c2ed 100644
--- a/vectordrawable/integration-tests/testapp/src/main/java/com/example/android/support/vectordrawable/app/AVDCListenerDemo.java
+++ b/vectordrawable/integration-tests/testapp/src/main/java/com/example/android/support/vectordrawable/app/AVDCListenerDemo.java
@@ -23,7 +23,6 @@
import android.view.View;
import android.widget.TextView;
-import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
@@ -31,6 +30,8 @@
import com.example.android.support.vectordrawable.R;
+import org.jspecify.annotations.NonNull;
+
/**
* A demo for AnimatedVectorDrawableCompat's listener support.
*/
diff --git a/vectordrawable/integration-tests/testapp/src/main/java/com/example/android/support/vectordrawable/app/SeekableDemo.java b/vectordrawable/integration-tests/testapp/src/main/java/com/example/android/support/vectordrawable/app/SeekableDemo.java
index c36bbd7..c8966a9 100644
--- a/vectordrawable/integration-tests/testapp/src/main/java/com/example/android/support/vectordrawable/app/SeekableDemo.java
+++ b/vectordrawable/integration-tests/testapp/src/main/java/com/example/android/support/vectordrawable/app/SeekableDemo.java
@@ -21,13 +21,14 @@
import android.widget.ImageView;
import android.widget.SeekBar;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.vectordrawable.graphics.drawable.SeekableAnimatedVectorDrawable;
import com.example.android.support.vectordrawable.R;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Demonstrates usage of {@link SeekableAnimatedVectorDrawable}.
*/
diff --git a/vectordrawable/vectordrawable-animated/build.gradle b/vectordrawable/vectordrawable-animated/build.gradle
index 1b0b716..4c3cfa9 100644
--- a/vectordrawable/vectordrawable-animated/build.gradle
+++ b/vectordrawable/vectordrawable-animated/build.gradle
@@ -13,6 +13,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.annotation:annotation:1.8.1")
api(project(":vectordrawable:vectordrawable"))
implementation("androidx.core:core:1.12.0")
diff --git a/vectordrawable/vectordrawable-animated/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/AnimatedVectorDrawableParameterizedTest.java b/vectordrawable/vectordrawable-animated/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/AnimatedVectorDrawableParameterizedTest.java
index 5015314..03ee29b 100644
--- a/vectordrawable/vectordrawable-animated/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/AnimatedVectorDrawableParameterizedTest.java
+++ b/vectordrawable/vectordrawable-animated/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/AnimatedVectorDrawableParameterizedTest.java
@@ -26,7 +26,6 @@
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
-import androidx.annotation.NonNull;
import androidx.test.filters.SmallTest;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.rule.ActivityTestRule;
@@ -34,6 +33,7 @@
import androidx.vectordrawable.graphics.drawable.Animatable2Compat.AnimationCallback;
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat;
+import org.jspecify.annotations.NonNull;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
diff --git a/vectordrawable/vectordrawable-animated/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/AnimatedVectorDrawableTest.java b/vectordrawable/vectordrawable-animated/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/AnimatedVectorDrawableTest.java
index 711c05c..928f6c0 100644
--- a/vectordrawable/vectordrawable-animated/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/AnimatedVectorDrawableTest.java
+++ b/vectordrawable/vectordrawable-animated/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/AnimatedVectorDrawableTest.java
@@ -39,7 +39,6 @@
import android.widget.ImageButton;
import androidx.annotation.DrawableRes;
-import androidx.annotation.NonNull;
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.FlakyTest;
@@ -50,6 +49,7 @@
import androidx.vectordrawable.graphics.drawable.Animatable2Compat.AnimationCallback;
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat;
+import org.jspecify.annotations.NonNull;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
diff --git a/vectordrawable/vectordrawable-animated/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/DrawableUtils.java b/vectordrawable/vectordrawable-animated/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/DrawableUtils.java
index 690d9cc..c12a24d 100644
--- a/vectordrawable/vectordrawable-animated/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/DrawableUtils.java
+++ b/vectordrawable/vectordrawable-animated/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/DrawableUtils.java
@@ -24,7 +24,6 @@
import java.io.FileOutputStream;
import java.io.IOException;
-
public class DrawableUtils {
private static final String LOGTAG = DrawableUtils.class.getSimpleName();
diff --git a/vectordrawable/vectordrawable-animated/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/PathInterpolatorParameterizedTest.java b/vectordrawable/vectordrawable-animated/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/PathInterpolatorParameterizedTest.java
index c33a254..9a8ab0e 100644
--- a/vectordrawable/vectordrawable-animated/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/PathInterpolatorParameterizedTest.java
+++ b/vectordrawable/vectordrawable-animated/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/PathInterpolatorParameterizedTest.java
@@ -23,7 +23,6 @@
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
-import androidx.annotation.NonNull;
import androidx.test.filters.MediumTest;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.rule.ActivityTestRule;
@@ -31,6 +30,7 @@
import androidx.vectordrawable.graphics.drawable.Animatable2Compat;
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat;
+import org.jspecify.annotations.NonNull;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
diff --git a/vectordrawable/vectordrawable-animated/src/main/java/androidx/vectordrawable/graphics/drawable/Animatable2Compat.java b/vectordrawable/vectordrawable-animated/src/main/java/androidx/vectordrawable/graphics/drawable/Animatable2Compat.java
index f5f900c..f3716d1 100644
--- a/vectordrawable/vectordrawable-animated/src/main/java/androidx/vectordrawable/graphics/drawable/Animatable2Compat.java
+++ b/vectordrawable/vectordrawable-animated/src/main/java/androidx/vectordrawable/graphics/drawable/Animatable2Compat.java
@@ -22,9 +22,10 @@
import android.graphics.drawable.Animatable2;
import android.graphics.drawable.Drawable;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
+import org.jspecify.annotations.NonNull;
+
/**
* Interface that drawables supporting animations and callbacks should extend in support lib.
*/
diff --git a/vectordrawable/vectordrawable-animated/src/main/java/androidx/vectordrawable/graphics/drawable/AnimatedVectorDrawableCompat.java b/vectordrawable/vectordrawable-animated/src/main/java/androidx/vectordrawable/graphics/drawable/AnimatedVectorDrawableCompat.java
index 4a6e255..40bbcc3 100644
--- a/vectordrawable/vectordrawable-animated/src/main/java/androidx/vectordrawable/graphics/drawable/AnimatedVectorDrawableCompat.java
+++ b/vectordrawable/vectordrawable-animated/src/main/java/androidx/vectordrawable/graphics/drawable/AnimatedVectorDrawableCompat.java
@@ -41,8 +41,6 @@
import android.util.Xml;
import androidx.annotation.DrawableRes;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.collection.ArrayMap;
import androidx.core.content.res.ResourcesCompat;
@@ -50,6 +48,8 @@
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.util.ObjectsCompat;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -154,8 +154,7 @@
private static final boolean DBG_ANIMATION_VECTOR_DRAWABLE = false;
- @NonNull
- private final AnimatedVectorDrawableCompatState mAnimatedVectorState;
+ private final @NonNull AnimatedVectorDrawableCompatState mAnimatedVectorState;
private final Context mContext;
@@ -194,9 +193,8 @@
* mutate() will be effective only if the getConstantState() is returning non-null.
* Otherwise, it just return the current object without modification.
*/
- @NonNull
@Override
- public Drawable mutate() {
+ public @NonNull Drawable mutate() {
if (mDelegateDrawable != null) {
mDelegateDrawable.mutate();
}
@@ -213,8 +211,7 @@
* @param resId the resource ID for AnimatedVectorDrawableCompat object.
* @return a new AnimatedVectorDrawableCompat or null if parsing error is found.
*/
- @Nullable
- public static AnimatedVectorDrawableCompat create(@NonNull Context context,
+ public static @Nullable AnimatedVectorDrawableCompat create(@NonNull Context context,
@DrawableRes int resId) {
if (Build.VERSION.SDK_INT >= 24) {
final AnimatedVectorDrawableCompat drawable = new AnimatedVectorDrawableCompat(context);
@@ -258,8 +255,7 @@
* document, tries to create a Drawable from that tag. Returns {@code null}
* if the tag is not a valid drawable.
*/
- @NonNull
- public static AnimatedVectorDrawableCompat createFromXmlInner(@NonNull Context context,
+ public static @NonNull AnimatedVectorDrawableCompat createFromXmlInner(@NonNull Context context,
@NonNull Resources r, @NonNull XmlPullParser parser, @NonNull AttributeSet attrs,
@Nullable Theme theme) throws XmlPullParserException, IOException {
final AnimatedVectorDrawableCompat drawable = new AnimatedVectorDrawableCompat(context);
@@ -272,9 +268,8 @@
* <strong>Note</strong> that we don't support constant state when SDK < 24.
* Make sure you check the return value before using it.
*/
- @Nullable
@Override
- public ConstantState getConstantState() {
+ public @Nullable ConstantState getConstantState() {
if (mDelegateDrawable != null && Build.VERSION.SDK_INT >= 24) {
return new AnimatedVectorDrawableDelegateState(mDelegateDrawable.getConstantState());
}
@@ -355,9 +350,8 @@
mAnimatedVectorState.mVectorDrawable.setColorFilter(colorFilter);
}
- @Nullable
@Override
- public ColorFilter getColorFilter() {
+ public @Nullable ColorFilter getColorFilter() {
if (mDelegateDrawable != null) {
return DrawableCompat.getColorFilter(mDelegateDrawable);
}
@@ -385,7 +379,7 @@
}
@Override
- public void setTintMode(@Nullable PorterDuff.Mode tintMode) {
+ public void setTintMode(PorterDuff.@Nullable Mode tintMode) {
if (mDelegateDrawable != null) {
DrawableCompat.setTintMode(mDelegateDrawable, tintMode);
return;
@@ -827,7 +821,7 @@
*/
@RequiresApi(23)
private static void registerPlatformCallback(@NonNull AnimatedVectorDrawable avd,
- @NonNull final AnimationCallback callback) {
+ final @NonNull AnimationCallback callback) {
Api23Impl.registerAnimationCallback(avd, callback.getPlatformCallback());
}
diff --git a/vectordrawable/vectordrawable-animated/src/main/java/androidx/vectordrawable/graphics/drawable/AnimationUtilsCompat.java b/vectordrawable/vectordrawable-animated/src/main/java/androidx/vectordrawable/graphics/drawable/AnimationUtilsCompat.java
index acaa9f8..789c166 100644
--- a/vectordrawable/vectordrawable-animated/src/main/java/androidx/vectordrawable/graphics/drawable/AnimationUtilsCompat.java
+++ b/vectordrawable/vectordrawable-animated/src/main/java/androidx/vectordrawable/graphics/drawable/AnimationUtilsCompat.java
@@ -37,13 +37,13 @@
import android.view.animation.OvershootInterpolator;
import androidx.annotation.AnimRes;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.core.util.ObjectsCompat;
import androidx.interpolator.view.animation.FastOutLinearInInterpolator;
import androidx.interpolator.view.animation.FastOutSlowInInterpolator;
import androidx.interpolator.view.animation.LinearOutSlowInInterpolator;
+import org.jspecify.annotations.NonNull;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -62,8 +62,7 @@
* @return The animation object reference by the specified id
*/
@SuppressWarnings("UnnecessaryInitCause") // requires API 24+
- @NonNull
- public static Interpolator loadInterpolator(@NonNull Context context, @AnimRes int id)
+ public static @NonNull Interpolator loadInterpolator(@NonNull Context context, @AnimRes int id)
throws NotFoundException {
// From API 21, we added path Interpolator .
if (Build.VERSION.SDK_INT >= 21) {
@@ -101,8 +100,7 @@
}
- @NonNull
- private static Interpolator createInterpolatorFromXml(@NonNull Context context,
+ private static @NonNull Interpolator createInterpolatorFromXml(@NonNull Context context,
@NonNull XmlPullParser parser) throws XmlPullParserException, IOException {
Interpolator interpolator = null;
diff --git a/vectordrawable/vectordrawable-animated/src/main/java/androidx/vectordrawable/graphics/drawable/ArgbEvaluator.java b/vectordrawable/vectordrawable-animated/src/main/java/androidx/vectordrawable/graphics/drawable/ArgbEvaluator.java
index bba021e..412061c 100644
--- a/vectordrawable/vectordrawable-animated/src/main/java/androidx/vectordrawable/graphics/drawable/ArgbEvaluator.java
+++ b/vectordrawable/vectordrawable-animated/src/main/java/androidx/vectordrawable/graphics/drawable/ArgbEvaluator.java
@@ -21,9 +21,10 @@
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* This evaluator can be used to perform type interpolation between integer
* values that represent ARGB colors.
@@ -39,8 +40,7 @@
*
* @return An instance of <code>ArgbEvalutor</code>.
*/
- @NonNull
- public static ArgbEvaluator getInstance() {
+ public static @NonNull ArgbEvaluator getInstance() {
return sInstance;
}
diff --git a/vectordrawable/vectordrawable-seekable/build.gradle b/vectordrawable/vectordrawable-seekable/build.gradle
index 17cbd45..5001fa7 100644
--- a/vectordrawable/vectordrawable-seekable/build.gradle
+++ b/vectordrawable/vectordrawable-seekable/build.gradle
@@ -13,6 +13,7 @@
}
dependencies {
+ api(libs.jspecify)
api(project(":vectordrawable:vectordrawable"))
api("androidx.core:core-animation:1.0.0")
implementation("androidx.collection:collection:1.4.2")
diff --git a/vectordrawable/vectordrawable-seekable/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/DrawableUtils.java b/vectordrawable/vectordrawable-seekable/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/DrawableUtils.java
index 8e728a5..2c542cf 100644
--- a/vectordrawable/vectordrawable-seekable/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/DrawableUtils.java
+++ b/vectordrawable/vectordrawable-seekable/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/DrawableUtils.java
@@ -24,7 +24,6 @@
import java.io.FileOutputStream;
import java.io.IOException;
-
public class DrawableUtils {
private static final String LOGTAG = DrawableUtils.class.getSimpleName();
diff --git a/vectordrawable/vectordrawable-seekable/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/PathInterpolatorParameterizedTest.java b/vectordrawable/vectordrawable-seekable/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/PathInterpolatorParameterizedTest.java
index 73e3bd7..5e19231 100644
--- a/vectordrawable/vectordrawable-seekable/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/PathInterpolatorParameterizedTest.java
+++ b/vectordrawable/vectordrawable-seekable/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/PathInterpolatorParameterizedTest.java
@@ -24,7 +24,6 @@
import android.graphics.Bitmap;
import android.graphics.Canvas;
-import androidx.annotation.NonNull;
import androidx.core.animation.AnimatorTestRule;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.filters.MediumTest;
@@ -32,6 +31,7 @@
import androidx.vectordrawable.graphics.drawable.SeekableAnimatedVectorDrawable;
import androidx.vectordrawable.seekable.test.R;
+import org.jspecify.annotations.NonNull;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/vectordrawable/vectordrawable-seekable/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/SeekableAnimatedVectorDrawableTest.java b/vectordrawable/vectordrawable-seekable/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/SeekableAnimatedVectorDrawableTest.java
index fb173e3..455f68c 100644
--- a/vectordrawable/vectordrawable-seekable/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/SeekableAnimatedVectorDrawableTest.java
+++ b/vectordrawable/vectordrawable-seekable/src/androidTest/java/androidx/vectordrawable/graphics/drawable/tests/SeekableAnimatedVectorDrawableTest.java
@@ -32,7 +32,6 @@
import android.view.InflateException;
import androidx.annotation.DrawableRes;
-import androidx.annotation.NonNull;
import androidx.core.animation.AnimatorTestRule;
import androidx.test.annotation.UiThreadTest;
import androidx.test.core.app.ApplicationProvider;
@@ -41,6 +40,7 @@
import androidx.vectordrawable.graphics.drawable.SeekableAnimatedVectorDrawable;
import androidx.vectordrawable.seekable.test.R;
+import org.jspecify.annotations.NonNull;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/vectordrawable/vectordrawable-seekable/src/main/java/androidx/vectordrawable/graphics/drawable/SeekableAnimatedVectorDrawable.java b/vectordrawable/vectordrawable-seekable/src/main/java/androidx/vectordrawable/graphics/drawable/SeekableAnimatedVectorDrawable.java
index e2f77c1..b2eb21b 100644
--- a/vectordrawable/vectordrawable-seekable/src/main/java/androidx/vectordrawable/graphics/drawable/SeekableAnimatedVectorDrawable.java
+++ b/vectordrawable/vectordrawable-seekable/src/main/java/androidx/vectordrawable/graphics/drawable/SeekableAnimatedVectorDrawable.java
@@ -34,8 +34,6 @@
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
import androidx.annotation.IntRange;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.collection.SimpleArrayMap;
import androidx.core.animation.Animator;
import androidx.core.animation.AnimatorInflater;
@@ -44,6 +42,8 @@
import androidx.core.animation.ObjectAnimator;
import androidx.core.content.res.TypedArrayUtils;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -240,9 +240,8 @@
/**
* mutate() is not supported. This method simply returns {@code this}.
*/
- @NonNull
@Override
- public Drawable mutate() {
+ public @NonNull Drawable mutate() {
return this;
}
@@ -253,8 +252,7 @@
* @param resId the resource ID for SeekableAnimatedVectorDrawable object.
* @return a new SeekableAnimatedVectorDrawable or null if parsing error is found.
*/
- @Nullable
- public static SeekableAnimatedVectorDrawable create(
+ public static @Nullable SeekableAnimatedVectorDrawable create(
@NonNull Context context,
@DrawableRes int resId
) {
@@ -285,8 +283,7 @@
* document, tries to create a Drawable from that tag. Returns {@code null}
* if the tag is not a valid drawable.
*/
- @NonNull
- public static SeekableAnimatedVectorDrawable createFromXmlInner(
+ public static @NonNull SeekableAnimatedVectorDrawable createFromXmlInner(
@NonNull Resources r,
@NonNull XmlPullParser parser,
@NonNull AttributeSet attrs,
@@ -297,9 +294,8 @@
return drawable;
}
- @Nullable
@Override
- public ConstantState getConstantState() {
+ public @Nullable ConstantState getConstantState() {
// We can't support constant state in older platform.
// We need Context to create the animator, and we can't save the context in the constant
// state.
@@ -325,7 +321,7 @@
}
@Override
- protected boolean onStateChange(@NonNull int[] state) {
+ protected boolean onStateChange(int @NonNull [] state) {
return mAnimatedVectorState.mVectorDrawable.setState(state);
}
@@ -350,9 +346,8 @@
mAnimatedVectorState.mVectorDrawable.setColorFilter(colorFilter);
}
- @Nullable
@Override
- public ColorFilter getColorFilter() {
+ public @Nullable ColorFilter getColorFilter() {
return mAnimatedVectorState.mVectorDrawable.getColorFilter();
}
@@ -367,7 +362,7 @@
}
@Override
- public void setTintMode(@Nullable PorterDuff.Mode tintMode) {
+ public void setTintMode(PorterDuff.@Nullable Mode tintMode) {
mAnimatedVectorState.mVectorDrawable.setTintMode(tintMode);
}
@@ -542,15 +537,13 @@
}
}
- @NonNull
@Override
- public Drawable newDrawable() {
+ public @NonNull Drawable newDrawable() {
throw new IllegalStateException("No constant state support for SDK < 24.");
}
- @NonNull
@Override
- public Drawable newDrawable(Resources res) {
+ public @NonNull Drawable newDrawable(Resources res) {
throw new IllegalStateException("No constant state support for SDK < 24.");
}
diff --git a/vectordrawable/vectordrawable/build.gradle b/vectordrawable/vectordrawable/build.gradle
index 3193b19..75b1aa2 100644
--- a/vectordrawable/vectordrawable/build.gradle
+++ b/vectordrawable/vectordrawable/build.gradle
@@ -13,6 +13,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.annotation:annotation:1.8.1")
api("androidx.core:core:1.13.0")
implementation("androidx.collection:collection:1.4.2")
diff --git a/vectordrawable/vectordrawable/src/main/java/androidx/vectordrawable/graphics/drawable/VectorDrawableCommon.java b/vectordrawable/vectordrawable/src/main/java/androidx/vectordrawable/graphics/drawable/VectorDrawableCommon.java
index d6b87af..7f56765 100644
--- a/vectordrawable/vectordrawable/src/main/java/androidx/vectordrawable/graphics/drawable/VectorDrawableCommon.java
+++ b/vectordrawable/vectordrawable/src/main/java/androidx/vectordrawable/graphics/drawable/VectorDrawableCommon.java
@@ -22,10 +22,11 @@
import android.graphics.Region;
import android.graphics.drawable.Drawable;
-import androidx.annotation.NonNull;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.graphics.drawable.TintAwareDrawable;
+import org.jspecify.annotations.NonNull;
+
/**
* Internal common delegation shared by VectorDrawableCompat and AnimatedVectorDrawableCompat
*/
@@ -90,7 +91,7 @@
}
@Override
- public void applyTheme(@NonNull Resources.Theme t) {
+ public void applyTheme(Resources.@NonNull Theme t) {
// API >= 21 only.
if (mDelegateDrawable != null) {
DrawableCompat.applyTheme(mDelegateDrawable, t);
diff --git a/vectordrawable/vectordrawable/src/main/java/androidx/vectordrawable/graphics/drawable/VectorDrawableCompat.java b/vectordrawable/vectordrawable/src/main/java/androidx/vectordrawable/graphics/drawable/VectorDrawableCompat.java
index 187b211f..00f079f 100644
--- a/vectordrawable/vectordrawable/src/main/java/androidx/vectordrawable/graphics/drawable/VectorDrawableCompat.java
+++ b/vectordrawable/vectordrawable/src/main/java/androidx/vectordrawable/graphics/drawable/VectorDrawableCompat.java
@@ -54,8 +54,6 @@
import androidx.annotation.ColorInt;
import androidx.annotation.DrawableRes;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.collection.ArrayMap;
@@ -65,6 +63,8 @@
import androidx.core.graphics.PathParser;
import androidx.core.graphics.drawable.DrawableCompat;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -325,9 +325,8 @@
mTintFilter = updateTintFilter(mTintFilter, state.mTint, state.mTintMode);
}
- @NonNull
@Override
- public Drawable mutate() {
+ public @NonNull Drawable mutate() {
if (mDelegateDrawable != null) {
mDelegateDrawable.mutate();
return this;
@@ -344,9 +343,8 @@
return mVectorState.mVPathRenderer.mVGTargetsMap.get(name);
}
- @NonNull
@Override
- public ConstantState getConstantState() {
+ public @NonNull ConstantState getConstantState() {
if (mDelegateDrawable != null && Build.VERSION.SDK_INT >= 24) {
// Such that the configuration can be refreshed.
return new VectorDrawableDelegateState(mDelegateDrawable.getConstantState());
@@ -460,9 +458,8 @@
invalidateSelf();
}
- @Nullable
@Override
- public ColorFilter getColorFilter() {
+ public @Nullable ColorFilter getColorFilter() {
if (mDelegateDrawable != null) {
return DrawableCompat.getColorFilter(mDelegateDrawable);
}
@@ -641,9 +638,8 @@
* @param theme the theme of this vector drawable, it can be null.
* @return a new VectorDrawableCompat or null if parsing error is found.
*/
- @Nullable
- public static VectorDrawableCompat create(@NonNull Resources res, @DrawableRes int resId,
- @Nullable Theme theme) {
+ public static @Nullable VectorDrawableCompat create(@NonNull Resources res,
+ @DrawableRes int resId, @Nullable Theme theme) {
if (Build.VERSION.SDK_INT >= 24) {
final VectorDrawableCompat drawable = new VectorDrawableCompat();
drawable.mDelegateDrawable = ResourcesCompat.getDrawable(res, resId, theme);
@@ -684,8 +680,7 @@
* document, tries to create a Drawable from that tag. Returns {@code null}
* if the tag is not a valid drawable.
*/
- @NonNull
- public static VectorDrawableCompat createFromXmlInner(@NonNull Resources r,
+ public static @NonNull VectorDrawableCompat createFromXmlInner(@NonNull Resources r,
@NonNull XmlPullParser parser, @NonNull AttributeSet attrs, @Nullable Theme theme)
throws XmlPullParserException, IOException {
final VectorDrawableCompat drawable = new VectorDrawableCompat();
@@ -1129,15 +1124,13 @@
mVPathRenderer = new VPathRenderer();
}
- @NonNull
@Override
- public Drawable newDrawable() {
+ public @NonNull Drawable newDrawable() {
return new VectorDrawableCompat(this);
}
- @NonNull
@Override
- public Drawable newDrawable(Resources res) {
+ public @NonNull Drawable newDrawable(Resources res) {
return new VectorDrawableCompat(this);
}
diff --git a/versionedparcelable/versionedparcelable/build.gradle b/versionedparcelable/versionedparcelable/build.gradle
index abf8f79..a639726 100644
--- a/versionedparcelable/versionedparcelable/build.gradle
+++ b/versionedparcelable/versionedparcelable/build.gradle
@@ -30,6 +30,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.annotation:annotation:1.8.1")
implementation("androidx.collection:collection:1.4.2")
diff --git a/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/ParcelField.java b/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/ParcelField.java
index 0732df3..00510ad 100644
--- a/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/ParcelField.java
+++ b/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/ParcelField.java
@@ -16,9 +16,10 @@
package androidx.versionedparcelable;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -36,6 +37,5 @@
/**
* Specifies the default value of this field.
*/
- @NonNull
- String defaultValue() default "";
+ @NonNull String defaultValue() default "";
}
diff --git a/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/ParcelImpl.java b/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/ParcelImpl.java
index 7bec846..28eb96f 100644
--- a/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/ParcelImpl.java
+++ b/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/ParcelImpl.java
@@ -20,18 +20,18 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
@SuppressLint("BanParcelableUsage")
public class ParcelImpl implements Parcelable {
- @Nullable
- private final VersionedParcelable mParcel;
+ private final @Nullable VersionedParcelable mParcel;
public ParcelImpl(@Nullable VersionedParcelable parcel) {
mParcel = parcel;
@@ -44,8 +44,7 @@
/**
*/
@SuppressWarnings({"TypeParameterUnusedInFormals", "unchecked"})
- @Nullable
- public <T extends VersionedParcelable> T getVersionedParcel() {
+ public <T extends VersionedParcelable> @Nullable T getVersionedParcel() {
return (T) mParcel;
}
@@ -62,14 +61,12 @@
public static final Creator<ParcelImpl> CREATOR = new Creator<ParcelImpl>() {
@Override
- @NonNull
- public ParcelImpl createFromParcel(@NonNull Parcel in) {
+ public @NonNull ParcelImpl createFromParcel(@NonNull Parcel in) {
return new ParcelImpl(in);
}
@Override
- @NonNull
- public ParcelImpl[] newArray(int size) {
+ public ParcelImpl @NonNull [] newArray(int size) {
return new ParcelImpl[size];
}
};
diff --git a/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/ParcelUtils.java b/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/ParcelUtils.java
index 59acea2..e5b1640 100644
--- a/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/ParcelUtils.java
+++ b/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/ParcelUtils.java
@@ -21,10 +21,11 @@
import android.os.Bundle;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
@@ -35,8 +36,7 @@
*/
public class ParcelUtils {
- @NonNull
- private static final String INNER_BUNDLE_KEY = "a";
+ private static final @NonNull String INNER_BUNDLE_KEY = "a";
private ParcelUtils() { }
@@ -44,8 +44,7 @@
* Turn a VersionedParcelable into a Parcelable
*/
@RestrictTo(LIBRARY_GROUP_PREFIX)
- @NonNull
- public static Parcelable toParcelable(@Nullable VersionedParcelable obj) {
+ public static @NonNull Parcelable toParcelable(@Nullable VersionedParcelable obj) {
return new ParcelImpl(obj);
}
@@ -54,8 +53,7 @@
*/
@RestrictTo(LIBRARY_GROUP_PREFIX)
@SuppressWarnings("TypeParameterUnusedInFormals")
- @Nullable
- public static <T extends VersionedParcelable> T fromParcelable(
+ public static <T extends VersionedParcelable> @Nullable T fromParcelable(
@NonNull Parcelable p
) {
if (!(p instanceof ParcelImpl)) {
@@ -82,8 +80,8 @@
*/
@SuppressWarnings("TypeParameterUnusedInFormals")
@RestrictTo(LIBRARY_GROUP_PREFIX)
- @Nullable
- public static <T extends VersionedParcelable> T fromInputStream(@NonNull InputStream input) {
+ public static <T extends VersionedParcelable> @Nullable T fromInputStream(
+ @NonNull InputStream input) {
VersionedParcelStream stream = new VersionedParcelStream(input, null);
return stream.readVersionedParcelable();
}
@@ -107,9 +105,8 @@
*
* Returns null if the bundle isn't present or ClassLoader issues occur.
*/
- @Nullable
@SuppressWarnings({"TypeParameterUnusedInFormals", "deprecation"})
- public static <T extends VersionedParcelable> T getVersionedParcelable(
+ public static <T extends VersionedParcelable> @Nullable T getVersionedParcelable(
@NonNull Bundle bundle, @NonNull String key) {
try {
Bundle innerBundle = bundle.getParcelable(key);
@@ -144,8 +141,7 @@
* Returns an empty list if the bundle isn't present or ClassLoader issues occur.
*/
@SuppressWarnings({"TypeParameterUnusedInFormals", "unchecked", "deprecation"})
- @NonNull
- public static <T extends VersionedParcelable> List<T> getVersionedParcelableList(
+ public static <T extends VersionedParcelable> @NonNull List<T> getVersionedParcelableList(
@NonNull Bundle bundle,
@Nullable String key
) {
diff --git a/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/VersionedParcel.java b/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/VersionedParcel.java
index b796da3..809c0ab 100644
--- a/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/VersionedParcel.java
+++ b/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/VersionedParcel.java
@@ -29,14 +29,15 @@
import android.util.SizeF;
import android.util.SparseBooleanArray;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.collection.ArrayMap;
import androidx.collection.ArraySet;
import androidx.collection.SimpleArrayMap;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -57,8 +58,7 @@
@RestrictTo(LIBRARY_GROUP_PREFIX)
public abstract class VersionedParcel {
- @NonNull
- private static final String TAG = "VersionedParcel";
+ private static final @NonNull String TAG = "VersionedParcel";
// These constants cannot change once shipped.
private static final int EX_SECURITY = -1;
@@ -78,12 +78,9 @@
private static final int TYPE_INTEGER = 7;
private static final int TYPE_FLOAT = 8;
- @NonNull
- final SimpleArrayMap<String, Method> mReadCache;
- @NonNull
- final SimpleArrayMap<String, Method> mWriteCache;
- @NonNull
- final SimpleArrayMap<String, Class<?>> mParcelizerCache;
+ final @NonNull SimpleArrayMap<String, Method> mReadCache;
+ final @NonNull SimpleArrayMap<String, Method> mWriteCache;
+ final @NonNull SimpleArrayMap<String, Class<?>> mParcelizerCache;
VersionedParcel(
@NonNull SimpleArrayMap<String, Method> readCache,
@@ -110,15 +107,14 @@
/**
* Create a sub-parcel to be used for a child VersionedParcelable
*/
- @NonNull
- protected abstract VersionedParcel createSubParcel();
+ protected abstract @NonNull VersionedParcel createSubParcel();
/**
* Write a byte array into the parcel.
*
* @param b Bytes to place into the parcel.
*/
- protected abstract void writeByteArray(@Nullable byte[] b);
+ protected abstract void writeByteArray(byte @Nullable [] b);
/**
* Write a byte array into the parcel.
@@ -127,7 +123,7 @@
* @param offset Index of first byte to be written.
* @param len Number of bytes to write.
*/
- protected abstract void writeByteArray(@Nullable byte[] b, int offset, int len);
+ protected abstract void writeByteArray(byte @Nullable [] b, int offset, int len);
/**
* Write a CharSequence into the parcel.
@@ -222,40 +218,34 @@
/**
* Read a string value from the parcel at the current dataPosition().
*/
- @Nullable
- protected abstract String readString();
+ protected abstract @Nullable String readString();
/**
* Read an object from the parcel at the current dataPosition().
*/
- @Nullable
- protected abstract IBinder readStrongBinder();
+ protected abstract @Nullable IBinder readStrongBinder();
/**
* Read a byte[] object from the parcel.
*/
- @Nullable
- protected abstract byte[] readByteArray();
+ protected abstract byte @Nullable [] readByteArray();
/**
* Read a CharSequence from the parcel
*/
- @Nullable
- protected abstract CharSequence readCharSequence();
+ protected abstract @Nullable CharSequence readCharSequence();
/**
*/
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
- @Nullable
- protected abstract <T extends Parcelable> T readParcelable();
+ protected abstract <T extends Parcelable> @Nullable T readParcelable();
/**
* Read and return a new Bundle object from the parcel at the current
* dataPosition(). Returns null if the previously written Bundle object was
* null.
*/
- @Nullable
- protected abstract Bundle readBundle();
+ protected abstract @Nullable Bundle readBundle();
/**
* Read a boolean value from the parcel at the current dataPosition().
@@ -313,7 +303,7 @@
*
* @param b Bytes to place into the parcel.
*/
- public void writeByteArray(@Nullable byte[] b, int fieldId) {
+ public void writeByteArray(byte @Nullable [] b, int fieldId) {
setOutputField(fieldId);
writeByteArray(b);
}
@@ -325,7 +315,7 @@
* @param offset Index of first byte to be written.
* @param len Number of bytes to write.
*/
- public void writeByteArray(@Nullable byte[] b, int offset, int len, int fieldId) {
+ public void writeByteArray(byte @Nullable [] b, int offset, int len, int fieldId) {
setOutputField(fieldId);
writeByteArray(b, offset, len);
}
@@ -460,8 +450,7 @@
/**
* Read a string value from the parcel at the current dataPosition().
*/
- @Nullable
- public String readString(@Nullable String def, int fieldId) {
+ public @Nullable String readString(@Nullable String def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -471,8 +460,7 @@
/**
* Read an object from the parcel at the current dataPosition().
*/
- @Nullable
- public IBinder readStrongBinder(@Nullable IBinder def, int fieldId) {
+ public @Nullable IBinder readStrongBinder(@Nullable IBinder def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -483,8 +471,7 @@
* Read a byte[] object from the parcel and copy it into the
* given byte array.
*/
- @Nullable
- public byte[] readByteArray(@Nullable byte[] def, int fieldId) {
+ public byte @Nullable [] readByteArray(byte @Nullable [] def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -493,8 +480,7 @@
/**
*/
- @Nullable
- public <T extends Parcelable> T readParcelable(@Nullable T def, int fieldId) {
+ public <T extends Parcelable> @Nullable T readParcelable(@Nullable T def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -506,8 +492,7 @@
* dataPosition(). Returns null if the previously written Bundle object was
* null.
*/
- @Nullable
- public Bundle readBundle(@Nullable Bundle def, int fieldId) {
+ public @Nullable Bundle readBundle(@Nullable Bundle def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -563,14 +548,14 @@
/**
*/
- public void writeBooleanArray(@Nullable boolean[] val, int fieldId) {
+ public void writeBooleanArray(boolean @Nullable [] val, int fieldId) {
setOutputField(fieldId);
writeBooleanArray(val);
}
/**
*/
- protected void writeBooleanArray(@Nullable boolean[] val) {
+ protected void writeBooleanArray(boolean @Nullable [] val) {
if (val != null) {
int n = val.length;
writeInt(n);
@@ -584,8 +569,7 @@
/**
*/
- @Nullable
- public boolean[] readBooleanArray(@Nullable boolean[] def, int fieldId) {
+ public boolean @Nullable [] readBooleanArray(boolean @Nullable [] def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -594,8 +578,7 @@
/**
*/
- @Nullable
- protected boolean[] readBooleanArray() {
+ protected boolean @Nullable [] readBooleanArray() {
int n = readInt();
if (n < 0) {
return null;
@@ -609,7 +592,7 @@
/**
*/
- public void writeCharArray(@Nullable char[] val, int fieldId) {
+ public void writeCharArray(char @Nullable [] val, int fieldId) {
setOutputField(fieldId);
if (val != null) {
int n = val.length;
@@ -624,8 +607,7 @@
/**
*/
- @Nullable
- public CharSequence readCharSequence(@Nullable CharSequence def, int fieldId) {
+ public @Nullable CharSequence readCharSequence(@Nullable CharSequence def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -634,8 +616,7 @@
/**
*/
- @Nullable
- public char[] readCharArray(@Nullable char[] def, int fieldId) {
+ public char @Nullable [] readCharArray(char @Nullable [] def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -652,14 +633,14 @@
/**
*/
- public void writeIntArray(@Nullable int[] val, int fieldId) {
+ public void writeIntArray(int @Nullable [] val, int fieldId) {
setOutputField(fieldId);
writeIntArray(val);
}
/**
*/
- protected void writeIntArray(@Nullable int[] val) {
+ protected void writeIntArray(int @Nullable [] val) {
if (val != null) {
int n = val.length;
writeInt(n);
@@ -673,8 +654,7 @@
/**
*/
- @Nullable
- public int[] readIntArray(@Nullable int[] def, int fieldId) {
+ public int @Nullable [] readIntArray(int @Nullable [] def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -683,8 +663,7 @@
/**
*/
- @Nullable
- protected int[] readIntArray() {
+ protected int @Nullable [] readIntArray() {
int n = readInt();
if (n < 0) {
return null;
@@ -698,14 +677,14 @@
/**
*/
- public void writeLongArray(@Nullable long[] val, int fieldId) {
+ public void writeLongArray(long @Nullable [] val, int fieldId) {
setOutputField(fieldId);
writeLongArray(val);
}
/**
*/
- protected void writeLongArray(@Nullable long[] val) {
+ protected void writeLongArray(long @Nullable [] val) {
if (val != null) {
int n = val.length;
writeInt(n);
@@ -719,8 +698,7 @@
/**
*/
- @Nullable
- public long[] readLongArray(@Nullable long[] def, int fieldId) {
+ public long @Nullable [] readLongArray(long @Nullable [] def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -729,8 +707,7 @@
/**
*/
- @Nullable
- protected long[] readLongArray() {
+ protected long @Nullable [] readLongArray() {
int n = readInt();
if (n < 0) {
return null;
@@ -744,14 +721,14 @@
/**
*/
- public void writeFloatArray(@Nullable float[] val, int fieldId) {
+ public void writeFloatArray(float @Nullable [] val, int fieldId) {
setOutputField(fieldId);
writeFloatArray(val);
}
/**
*/
- protected void writeFloatArray(@Nullable float[] val) {
+ protected void writeFloatArray(float @Nullable [] val) {
if (val != null) {
int n = val.length;
writeInt(n);
@@ -765,8 +742,7 @@
/**
*/
- @Nullable
- public float[] readFloatArray(@Nullable float[] def, int fieldId) {
+ public float @Nullable [] readFloatArray(float @Nullable [] def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -775,8 +751,7 @@
/**
*/
- @Nullable
- protected float[] readFloatArray() {
+ protected float @Nullable [] readFloatArray() {
int n = readInt();
if (n < 0) {
return null;
@@ -790,14 +765,14 @@
/**
*/
- public void writeDoubleArray(@Nullable double[] val, int fieldId) {
+ public void writeDoubleArray(double @Nullable [] val, int fieldId) {
setOutputField(fieldId);
writeDoubleArray(val);
}
/**
*/
- protected void writeDoubleArray(@Nullable double[] val) {
+ protected void writeDoubleArray(double @Nullable [] val) {
if (val != null) {
int n = val.length;
writeInt(n);
@@ -811,8 +786,7 @@
/**
*/
- @Nullable
- public double[] readDoubleArray(@Nullable double[] def, int fieldId) {
+ public double @Nullable [] readDoubleArray(double @Nullable [] def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -821,8 +795,7 @@
/**
*/
- @Nullable
- protected double[] readDoubleArray() {
+ protected double @Nullable [] readDoubleArray() {
int n = readInt();
if (n < 0) {
return null;
@@ -959,14 +932,14 @@
* @see #readList
* @see VersionedParcelable
*/
- public <T> void writeArray(@Nullable T[] val, int fieldId) {
+ public <T> void writeArray(T @Nullable [] val, int fieldId) {
setOutputField(fieldId);
writeArray(val);
}
/**
*/
- protected <T> void writeArray(@Nullable T[] val) {
+ protected <T> void writeArray(T @Nullable [] val) {
if (val == null) {
writeInt(-1);
return;
@@ -1188,8 +1161,7 @@
* @see #writeException
* @see #writeNoException
*/
- @Nullable
- public Exception readException(@Nullable Exception def, int fieldId) {
+ public @Nullable Exception readException(@Nullable Exception def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -1220,8 +1192,7 @@
/**
* Gets the root {@link Throwable#getCause() cause} of {@code t}
*/
- @NonNull
- protected static Throwable getRootCause(@NonNull Throwable t) {
+ protected static @NonNull Throwable getRootCause(@NonNull Throwable t) {
while (t.getCause() != null) t = t.getCause();
return t;
}
@@ -1232,8 +1203,7 @@
* @param code Used to determine which exception class to throw.
* @param msg The exception message.
*/
- @NonNull
- private Exception createException(int code, String msg) {
+ private @NonNull Exception createException(int code, String msg) {
switch (code) {
case EX_PARCELABLE:
return (Exception) readParcelable();
@@ -1270,8 +1240,7 @@
* Read a Size from the parcel at the current dataPosition().
*/
@RequiresApi(21)
- @Nullable
- public Size readSize(@Nullable Size def, int fieldId) {
+ public @Nullable Size readSize(@Nullable Size def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -1282,8 +1251,7 @@
* Read a SizeF from the parcel at the current dataPosition().
*/
@RequiresApi(21)
- @Nullable
- public SizeF readSizeF(@Nullable SizeF def, int fieldId) {
+ public @Nullable SizeF readSizeF(@Nullable SizeF def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -1295,8 +1263,7 @@
* dataPosition(). Returns null if the previously written list object was
* null.
*/
- @Nullable
- public SparseBooleanArray readSparseBooleanArray(
+ public @Nullable SparseBooleanArray readSparseBooleanArray(
@Nullable SparseBooleanArray def,
int fieldId
) {
@@ -1328,8 +1295,7 @@
* as those that were previously written.
* @see #writeSet
*/
- @Nullable
- public <T> Set<T> readSet(@Nullable Set<T> def, int fieldId) {
+ public <T> @Nullable Set<T> readSet(@Nullable Set<T> def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -1348,8 +1314,7 @@
* as those that were previously written.
* @see #writeList
*/
- @Nullable
- public <T> List<T> readList(@Nullable List<T> def, int fieldId) {
+ public <T> @Nullable List<T> readList(@Nullable List<T> def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -1357,8 +1322,7 @@
}
@SuppressWarnings("unchecked")
- @Nullable
- private <T, S extends Collection<T>> S readCollection(@NonNull S list) {
+ private <T, S extends Collection<T>> @Nullable S readCollection(@NonNull S list) {
int n = readInt();
if (n < 0) {
return null;
@@ -1415,8 +1379,7 @@
* as those that were previously written.
* @see #writeMap
*/
- @Nullable
- public <K, V> Map<K, V> readMap(@Nullable Map<K, V> def, int fieldId) {
+ public <K, V> @Nullable Map<K, V> readMap(@Nullable Map<K, V> def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -1450,8 +1413,7 @@
* as those that were previously written.
* @see #writeArray
*/
- @Nullable
- public <T> T[] readArray(@Nullable T[] def, int fieldId) {
+ public <T> T @Nullable [] readArray(T @Nullable [] def, int fieldId) {
if (!readField(fieldId)) {
return def;
}
@@ -1461,8 +1423,7 @@
/**
*/
@SuppressWarnings("unchecked")
- @Nullable
- protected <T> T[] readArray(@Nullable T[] def) {
+ protected <T> T @Nullable [] readArray(T @Nullable [] def) {
int n = readInt();
if (n < 0) {
return null;
@@ -1511,8 +1472,7 @@
/**
*/
- @Nullable
- public <T extends VersionedParcelable> T readVersionedParcelable(
+ public <T extends VersionedParcelable> @Nullable T readVersionedParcelable(
@Nullable T def,
int fieldId
) {
@@ -1531,8 +1491,7 @@
* was an error trying to instantiate the VersionedParcelable.
*/
@SuppressWarnings("TypeParameterUnusedInFormals")
- @Nullable
- protected <T extends VersionedParcelable> T readVersionedParcelable() {
+ protected <T extends VersionedParcelable> @Nullable T readVersionedParcelable() {
String name = readString();
if (name == null) {
return null;
@@ -1546,8 +1505,7 @@
* @return the Serializable object, or null if the Serializable name
* wasn't found in the parcel.
*/
- @Nullable
- protected Serializable readSerializable() {
+ protected @Nullable Serializable readSerializable() {
String name = readString();
if (name == null) {
// For some reason we were unable to read the name of the Serializable (either there
@@ -1585,8 +1543,7 @@
/**
*/
@SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"})
- @NonNull
- protected <T extends VersionedParcelable> T readFromParcel(
+ protected <T extends VersionedParcelable> @NonNull T readFromParcel(
@NonNull String parcelCls,
@NonNull VersionedParcel versionedParcel
) {
@@ -1638,8 +1595,7 @@
}
}
- @NonNull
- private Method getReadMethod(@NonNull String parcelCls) throws IllegalAccessException,
+ private @NonNull Method getReadMethod(@NonNull String parcelCls) throws IllegalAccessException,
NoSuchMethodException, ClassNotFoundException {
Method m = mReadCache.get(parcelCls);
if (m == null) {
@@ -1650,8 +1606,7 @@
return m;
}
- @NonNull
- private Method getWriteMethod(@NonNull Class<?> baseCls) throws IllegalAccessException,
+ private @NonNull Method getWriteMethod(@NonNull Class<?> baseCls) throws IllegalAccessException,
NoSuchMethodException, ClassNotFoundException {
Method m = mWriteCache.get(baseCls.getName());
if (m == null) {
@@ -1662,8 +1617,7 @@
return m;
}
- @NonNull
- private Class<?> findParcelClass(@NonNull Class<?> cls)
+ private @NonNull Class<?> findParcelClass(@NonNull Class<?> cls)
throws ClassNotFoundException {
Class<?> ret = mParcelizerCache.get(cls.getName());
if (ret == null) {
@@ -1701,8 +1655,7 @@
}
}
- @Nullable
- static Size readSize(@NonNull VersionedParcel self) {
+ static @Nullable Size readSize(@NonNull VersionedParcel self) {
if (self.readBoolean()) {
int width = self.readInt();
int height = self.readInt();
@@ -1711,8 +1664,7 @@
return null;
}
- @Nullable
- static SizeF readSizeF(@NonNull VersionedParcel self) {
+ static @Nullable SizeF readSizeF(@NonNull VersionedParcel self) {
if (self.readBoolean()) {
float width = self.readFloat();
float height = self.readFloat();
diff --git a/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/VersionedParcelParcel.java b/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/VersionedParcelParcel.java
index 5b40c60..a7f9b13 100644
--- a/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/VersionedParcelParcel.java
+++ b/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/VersionedParcelParcel.java
@@ -25,11 +25,12 @@
import android.util.Log;
import android.util.SparseIntArray;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.collection.SimpleArrayMap;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.reflect.Method;
/**
@@ -37,17 +38,13 @@
@RestrictTo(RestrictTo.Scope.LIBRARY)
class VersionedParcelParcel extends VersionedParcel {
private static final boolean DEBUG = false;
- @NonNull
- private static final String TAG = "VersionedParcelParcel";
+ private static final @NonNull String TAG = "VersionedParcelParcel";
- @NonNull
- private final SparseIntArray mPositionLookup = new SparseIntArray();
- @NonNull
- private final Parcel mParcel;
+ private final @NonNull SparseIntArray mPositionLookup = new SparseIntArray();
+ private final @NonNull Parcel mParcel;
private final int mOffset;
private final int mEnd;
- @NonNull
- private final String mPrefix;
+ private final @NonNull String mPrefix;
private int mCurrentField = -1;
private int mNextRead = 0;
private int mFieldId = -1;
@@ -206,8 +203,7 @@
}
@Override
- @Nullable
- protected CharSequence readCharSequence() {
+ protected @Nullable CharSequence readCharSequence() {
return TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(mParcel);
}
@@ -232,20 +228,17 @@
}
@Override
- @Nullable
- public String readString() {
+ public @Nullable String readString() {
return mParcel.readString();
}
@Override
- @Nullable
- public IBinder readStrongBinder() {
+ public @Nullable IBinder readStrongBinder() {
return mParcel.readStrongBinder();
}
@Override
- @Nullable
- public byte[] readByteArray() {
+ public byte @Nullable [] readByteArray() {
int len = mParcel.readInt();
if (len < 0) {
return null;
@@ -257,14 +250,12 @@
@Override
@SuppressWarnings({"TypeParameterUnusedInFormals", "deprecation"})
- @Nullable
- public <T extends Parcelable> T readParcelable() {
+ public <T extends Parcelable> @Nullable T readParcelable() {
return mParcel.readParcelable(getClass().getClassLoader());
}
@Override
- @Nullable
- public Bundle readBundle() {
+ public @Nullable Bundle readBundle() {
return mParcel.readBundle(getClass().getClassLoader());
}
diff --git a/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/VersionedParcelStream.java b/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/VersionedParcelStream.java
index 4b0a20c..5c1edaf 100644
--- a/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/VersionedParcelStream.java
+++ b/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/VersionedParcelStream.java
@@ -21,11 +21,12 @@
import android.os.IInterface;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.collection.SimpleArrayMap;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -42,8 +43,7 @@
@RestrictTo(RestrictTo.Scope.LIBRARY)
class VersionedParcelStream extends VersionedParcel {
- @NonNull
- private static final Charset UTF_16 = Charset.forName("UTF-16");
+ private static final @NonNull Charset UTF_16 = Charset.forName("UTF-16");
// Supported types held inside a bundle. These cannot be added to or changed once shipped.
private static final int TYPE_NULL = 0;
@@ -62,17 +62,12 @@
private static final int TYPE_FLOAT = 13;
private static final int TYPE_FLOAT_ARRAY = 14;
- @Nullable
- private final DataInputStream mMasterInput;
- @Nullable
- private final DataOutputStream mMasterOutput;
+ private final @Nullable DataInputStream mMasterInput;
+ private final @Nullable DataOutputStream mMasterOutput;
- @Nullable
- private DataInputStream mCurrentInput;
- @Nullable
- private DataOutputStream mCurrentOutput;
- @Nullable
- private FieldBuffer mFieldBuffer;
+ private @Nullable DataInputStream mCurrentInput;
+ private @Nullable DataOutputStream mCurrentOutput;
+ private @Nullable FieldBuffer mFieldBuffer;
private boolean mIgnoreParcelables;
int mCount = 0;
@@ -204,7 +199,7 @@
}
@Override
- public void writeByteArray(@Nullable byte[] b) {
+ public void writeByteArray(byte @Nullable [] b) {
try {
if (b != null) {
mCurrentOutput.writeInt(b.length);
@@ -218,7 +213,7 @@
}
@Override
- public void writeByteArray(@Nullable byte[] b, int offset, int len) {
+ public void writeByteArray(byte @Nullable [] b, int offset, int len) {
try {
if (b != null) {
mCurrentOutput.writeInt(len);
@@ -323,15 +318,13 @@
}
@Override
- @Nullable
- public IBinder readStrongBinder() {
+ public @Nullable IBinder readStrongBinder() {
return null;
}
@Override
@SuppressWarnings("TypeParameterUnusedInFormals")
- @Nullable
- public <T extends Parcelable> T readParcelable() {
+ public <T extends Parcelable> @Nullable T readParcelable() {
return null;
}
@@ -372,8 +365,7 @@
}
@Override
- @Nullable
- public String readString() {
+ public @Nullable String readString() {
try {
int len = mCurrentInput.readInt();
if (len > 0) {
@@ -389,8 +381,7 @@
}
@Override
- @Nullable
- public byte[] readByteArray() {
+ public byte @Nullable [] readByteArray() {
try {
int len = mCurrentInput.readInt();
if (len > 0) {
@@ -406,8 +397,7 @@
}
@Override
- @Nullable
- protected CharSequence readCharSequence() {
+ protected @Nullable CharSequence readCharSequence() {
return null;
}
@@ -441,8 +431,7 @@
}
@Override
- @Nullable
- public Bundle readBundle() {
+ public @Nullable Bundle readBundle() {
int size = readInt();
if (size < 0) {
return null;
@@ -558,13 +547,10 @@
// TODO: Use less buffers
private static class FieldBuffer {
- @NonNull
- final ByteArrayOutputStream mOutput = new ByteArrayOutputStream();
- @NonNull
- final DataOutputStream mDataStream = new DataOutputStream(mOutput);
+ final @NonNull ByteArrayOutputStream mOutput = new ByteArrayOutputStream();
+ final @NonNull DataOutputStream mDataStream = new DataOutputStream(mOutput);
private final int mFieldId;
- @NonNull
- private final DataOutputStream mTarget;
+ private final @NonNull DataOutputStream mTarget;
FieldBuffer(int fieldId, @NonNull DataOutputStream target) {
mFieldId = fieldId;
diff --git a/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/VersionedParcelize.java b/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/VersionedParcelize.java
index c0edf43..e0427ce 100644
--- a/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/VersionedParcelize.java
+++ b/versionedparcelable/versionedparcelable/src/main/java/androidx/versionedparcelable/VersionedParcelize.java
@@ -22,9 +22,10 @@
import android.os.IInterface;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.annotation.ElementType;
@@ -74,21 +75,18 @@
* This can be filled with any ids that used to be contained within this VersionedParcelable,
* but are no longer present. Ids listed here cannot be used by any fields within this class.
*/
- @NonNull
- int[] deprecatedIds() default {};
+ int @NonNull [] deprecatedIds() default {};
/**
* An alternate classname to also generate serialization for to support jetifier androidx
* migration.
*/
- @NonNull
- String jetifyAs() default "";
+ @NonNull String jetifyAs() default "";
/**
* Specifies a class to use to get objects for instantiation rather than creating them
* directly. The class must have an accessible empty constructor, and a get() method that
* returns an instance of the class this annotation is on.
*/
- @NonNull
- Class<?> factory() default void.class;
+ @NonNull Class<?> factory() default void.class;
}
diff --git a/wear/compose/compose-foundation/api/current.txt b/wear/compose/compose-foundation/api/current.txt
index 77936fe..c9f66cc 100644
--- a/wear/compose/compose-foundation/api/current.txt
+++ b/wear/compose/compose-foundation/api/current.txt
@@ -548,9 +548,13 @@
}
public sealed interface TransformingLazyColumnLayoutInfo {
+ method public int getAfterContentPadding();
+ method public int getBeforeContentPadding();
method public int getTotalItemsCount();
method public long getViewportSize();
method public java.util.List<androidx.wear.compose.foundation.lazy.TransformingLazyColumnVisibleItemInfo> getVisibleItems();
+ property public abstract int afterContentPadding;
+ property public abstract int beforeContentPadding;
property public abstract int totalItemsCount;
property public abstract long viewportSize;
property public abstract java.util.List<androidx.wear.compose.foundation.lazy.TransformingLazyColumnVisibleItemInfo> visibleItems;
diff --git a/wear/compose/compose-foundation/api/restricted_current.txt b/wear/compose/compose-foundation/api/restricted_current.txt
index 77936fe..c9f66cc 100644
--- a/wear/compose/compose-foundation/api/restricted_current.txt
+++ b/wear/compose/compose-foundation/api/restricted_current.txt
@@ -548,9 +548,13 @@
}
public sealed interface TransformingLazyColumnLayoutInfo {
+ method public int getAfterContentPadding();
+ method public int getBeforeContentPadding();
method public int getTotalItemsCount();
method public long getViewportSize();
method public java.util.List<androidx.wear.compose.foundation.lazy.TransformingLazyColumnVisibleItemInfo> getVisibleItems();
+ property public abstract int afterContentPadding;
+ property public abstract int beforeContentPadding;
property public abstract int totalItemsCount;
property public abstract long viewportSize;
property public abstract java.util.List<androidx.wear.compose.foundation.lazy.TransformingLazyColumnVisibleItemInfo> visibleItems;
diff --git a/wear/compose/compose-foundation/src/androidTest/kotlin/androidx/wear/compose/foundation/lazy/TransformingLazyColumnContentPaddingMeasurementStrategyTest.kt b/wear/compose/compose-foundation/src/androidTest/kotlin/androidx/wear/compose/foundation/lazy/TransformingLazyColumnContentPaddingMeasurementStrategyTest.kt
index e8679b9..ab26871 100644
--- a/wear/compose/compose-foundation/src/androidTest/kotlin/androidx/wear/compose/foundation/lazy/TransformingLazyColumnContentPaddingMeasurementStrategyTest.kt
+++ b/wear/compose/compose-foundation/src/androidTest/kotlin/androidx/wear/compose/foundation/lazy/TransformingLazyColumnContentPaddingMeasurementStrategyTest.kt
@@ -155,6 +155,25 @@
assertThat(result.visibleItems.map { it.offset })
.isEqualTo(listOf(0 + topPaddingPx, screenHeight / 2 + topPaddingPx))
+ assertThat(result.beforeContentPadding).isEqualTo(topPaddingPx)
+ }
+
+ @Test
+ fun twoItemsWithLastOneAlignedWithPadding_measuredWithCorrectOffsets() {
+ val bottomPadding = 5.dp
+ val bottomPaddingPx = with(measureScope) { bottomPadding.roundToPx() }
+ val strategy =
+ TransformingLazyColumnContentPaddingMeasurementStrategy(
+ PaddingValues(bottom = bottomPadding),
+ measureScope
+ )
+
+ val result = strategy.measure(listOf(screenHeight / 2, screenHeight / 2))
+
+ assertThat(result.visibleItems.size).isEqualTo(2)
+
+ assertThat(result.visibleItems.map { it.offset }).isEqualTo(listOf(0, screenHeight / 2))
+ assertThat(result.afterContentPadding).isEqualTo(bottomPaddingPx)
}
@Test
diff --git a/wear/compose/compose-foundation/src/androidTest/kotlin/androidx/wear/compose/foundation/rotary/RotaryTest.kt b/wear/compose/compose-foundation/src/androidTest/kotlin/androidx/wear/compose/foundation/rotary/RotaryTest.kt
index c5d60a3..62bb4e0 100644
--- a/wear/compose/compose-foundation/src/androidTest/kotlin/androidx/wear/compose/foundation/rotary/RotaryTest.kt
+++ b/wear/compose/compose-foundation/src/androidTest/kotlin/androidx/wear/compose/foundation/rotary/RotaryTest.kt
@@ -23,6 +23,8 @@
import android.content.Context
import android.hardware.input.InputManager
import android.view.InputDevice.SOURCE_ROTARY_ENCODER
+import android.view.MotionEvent
+import android.view.ViewConfiguration
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.LocalOverscrollFactory
import androidx.compose.foundation.layout.height
@@ -43,6 +45,7 @@
import androidx.compose.ui.test.performRotaryScrollInput
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
+import androidx.core.view.ViewConfigurationCompat
import androidx.test.core.app.ApplicationProvider
import com.google.common.truth.Truth
import org.junit.Assume
@@ -294,15 +297,24 @@
}
private fun hasRotaryInputDevice(): Boolean {
- with(
- ApplicationProvider.getApplicationContext<Context>()
- .getSystemService(Context.INPUT_SERVICE) as InputManager
- ) {
+ val context = ApplicationProvider.getApplicationContext<Context>()
+ val viewConfiguration = ViewConfiguration.get(context)
+ with(context.getSystemService(Context.INPUT_SERVICE) as InputManager) {
inputDeviceIds.forEach { deviceId ->
+ // To validate that we have a valid rotary device we need to:
+ // 1) check that we have a rotary device.
+ // 2) check that getScaledMaximumFlingVelocity method returns us a valid fling speed
if (
getInputDevice(deviceId)?.motionRanges?.find {
it.source == SOURCE_ROTARY_ENCODER
- } != null
+ } != null &&
+ ViewConfigurationCompat.getScaledMaximumFlingVelocity(
+ context,
+ viewConfiguration,
+ deviceId,
+ MotionEvent.AXIS_SCROLL,
+ SOURCE_ROTARY_ENCODER
+ ) != Integer.MIN_VALUE
)
return true
}
diff --git a/wear/compose/compose-foundation/src/main/java/androidx/wear/compose/foundation/lazy/TransformingLazyColumnContentPaddingMeasurementStrategy.kt b/wear/compose/compose-foundation/src/main/java/androidx/wear/compose/foundation/lazy/TransformingLazyColumnContentPaddingMeasurementStrategy.kt
index 7077c64..2843c16 100644
--- a/wear/compose/compose-foundation/src/main/java/androidx/wear/compose/foundation/lazy/TransformingLazyColumnContentPaddingMeasurementStrategy.kt
+++ b/wear/compose/compose-foundation/src/main/java/androidx/wear/compose/foundation/lazy/TransformingLazyColumnContentPaddingMeasurementStrategy.kt
@@ -175,8 +175,8 @@
coroutineScope = coroutineScope,
density = density,
itemSpacing = itemSpacing,
- beforeContentPadding = 0,
- afterContentPadding = 0,
+ beforeContentPadding = beforeContentPadding,
+ afterContentPadding = afterContentPadding,
measureResult =
layout(containerConstraints.maxWidth, containerConstraints.maxHeight) {
visibleItems.fastForEach { it.place(this) }
diff --git a/wear/compose/compose-foundation/src/main/java/androidx/wear/compose/foundation/lazy/TransformingLazyColumnLayoutInfo.kt b/wear/compose/compose-foundation/src/main/java/androidx/wear/compose/foundation/lazy/TransformingLazyColumnLayoutInfo.kt
index 2d9c878..a1838833 100644
--- a/wear/compose/compose-foundation/src/main/java/androidx/wear/compose/foundation/lazy/TransformingLazyColumnLayoutInfo.kt
+++ b/wear/compose/compose-foundation/src/main/java/androidx/wear/compose/foundation/lazy/TransformingLazyColumnLayoutInfo.kt
@@ -127,4 +127,12 @@
/** The size of the viewport in pixels. */
val viewportSize: IntSize
+
+ /**
+ * The content padding in pixels applied before the first item in the direction of scrolling.
+ */
+ val beforeContentPadding: Int
+
+ /** The content padding in pixels applied after the last item in the direction of scrolling. */
+ val afterContentPadding: Int
}
diff --git a/wear/compose/compose-foundation/src/main/java/androidx/wear/compose/foundation/lazy/TransformingLazyColumnMeasureResult.kt b/wear/compose/compose-foundation/src/main/java/androidx/wear/compose/foundation/lazy/TransformingLazyColumnMeasureResult.kt
index 3a79e8d..6dd296b 100644
--- a/wear/compose/compose-foundation/src/main/java/androidx/wear/compose/foundation/lazy/TransformingLazyColumnMeasureResult.kt
+++ b/wear/compose/compose-foundation/src/main/java/androidx/wear/compose/foundation/lazy/TransformingLazyColumnMeasureResult.kt
@@ -41,8 +41,8 @@
val itemSpacing: Int,
/** Density of the last measure. */
val density: Density,
- val beforeContentPadding: Int,
- val afterContentPadding: Int,
+ override val beforeContentPadding: Int,
+ override val afterContentPadding: Int,
/** True if there is some space available to continue scrolling in the forward direction. */
var canScrollForward: Boolean,
/** True if there is some space available to continue scrolling in the backward direction. */
diff --git a/wear/compose/compose-foundation/src/main/java/androidx/wear/compose/foundation/lazy/TransformingLazyColumnScrollScope.kt b/wear/compose/compose-foundation/src/main/java/androidx/wear/compose/foundation/lazy/TransformingLazyColumnScrollScope.kt
index 8328720..444be94 100644
--- a/wear/compose/compose-foundation/src/main/java/androidx/wear/compose/foundation/lazy/TransformingLazyColumnScrollScope.kt
+++ b/wear/compose/compose-foundation/src/main/java/androidx/wear/compose/foundation/lazy/TransformingLazyColumnScrollScope.kt
@@ -61,10 +61,14 @@
val averageSize = layoutInfo.visibleItemsAverageHeight + layoutInfo.itemSpacing
val indexesDiff = targetIndex - layoutInfo.anchorItemIndex
(averageSize * indexesDiff) - layoutInfo.anchorItemScrollOffset
- } else {
- val visibleItem = layoutInfo.visibleItems.fastFirstOrNull { it.index == targetIndex }
- visibleItem?.offset ?: 0
- } + targetOffset
+ } else
+ if (targetIndex == layoutInfo.anchorItemIndex) {
+ -layoutInfo.anchorItemScrollOffset
+ } else {
+ val visibleItem =
+ layoutInfo.visibleItems.fastFirstOrNull { it.index == targetIndex }
+ (visibleItem?.offset ?: 0) - layoutInfo.viewportSize.height / 2
+ } + targetOffset
}
internal fun TransformingLazyColumnScrollScope.isItemVisible(index: Int): Boolean {
diff --git a/wear/compose/compose-material3/api/current.txt b/wear/compose/compose-material3/api/current.txt
index 479b13f..d24cd43 100644
--- a/wear/compose/compose-material3/api/current.txt
+++ b/wear/compose/compose-material3/api/current.txt
@@ -495,8 +495,7 @@
}
public final class DynamicColorSchemeKt {
- method public static androidx.wear.compose.material3.ColorScheme dynamicColorScheme(android.content.Context context, optional androidx.wear.compose.material3.ColorScheme defaultColorScheme);
- method public static boolean isDynamicColorSchemeEnabled(android.content.Context context);
+ method public static androidx.wear.compose.material3.ColorScheme? dynamicColorScheme(android.content.Context context);
}
public final class EdgeButtonDefaults {
diff --git a/wear/compose/compose-material3/api/restricted_current.txt b/wear/compose/compose-material3/api/restricted_current.txt
index 479b13f..d24cd43 100644
--- a/wear/compose/compose-material3/api/restricted_current.txt
+++ b/wear/compose/compose-material3/api/restricted_current.txt
@@ -495,8 +495,7 @@
}
public final class DynamicColorSchemeKt {
- method public static androidx.wear.compose.material3.ColorScheme dynamicColorScheme(android.content.Context context, optional androidx.wear.compose.material3.ColorScheme defaultColorScheme);
- method public static boolean isDynamicColorSchemeEnabled(android.content.Context context);
+ method public static androidx.wear.compose.material3.ColorScheme? dynamicColorScheme(android.content.Context context);
}
public final class EdgeButtonDefaults {
diff --git a/wear/compose/compose-material3/integration-tests/src/main/java/androidx/wear/compose/material3/demos/DynamicColorSchemeDemo.kt b/wear/compose/compose-material3/integration-tests/src/main/java/androidx/wear/compose/material3/demos/DynamicColorSchemeDemo.kt
index 63c54cb..0b08256 100644
--- a/wear/compose/compose-material3/integration-tests/src/main/java/androidx/wear/compose/material3/demos/DynamicColorSchemeDemo.kt
+++ b/wear/compose/compose-material3/integration-tests/src/main/java/androidx/wear/compose/material3/demos/DynamicColorSchemeDemo.kt
@@ -24,16 +24,17 @@
import androidx.compose.ui.text.style.TextAlign
import androidx.wear.compose.material3.Button
import androidx.wear.compose.material3.ButtonDefaults
+import androidx.wear.compose.material3.ColorScheme
import androidx.wear.compose.material3.ListHeader
import androidx.wear.compose.material3.MaterialTheme
import androidx.wear.compose.material3.Text
import androidx.wear.compose.material3.dynamicColorScheme
-import androidx.wear.compose.material3.isDynamicColorSchemeEnabled
@Composable
fun DynamicColorSchemeDemos() {
- MaterialTheme(colorScheme = dynamicColorScheme(LocalContext.current)) {
- val hasDynamicColors = isDynamicColorSchemeEnabled(LocalContext.current)
+ val dynamicColorScheme = dynamicColorScheme(LocalContext.current)
+ MaterialTheme(colorScheme = dynamicColorScheme(LocalContext.current) ?: ColorScheme()) {
+ val hasDynamicColors = dynamicColorScheme != null
ScalingLazyDemo {
if (!hasDynamicColors) {
item { ListHeader { Text("Dynamic color is not available.") } }
diff --git a/wear/compose/compose-material3/samples/src/main/java/androidx/wear/compose/material3/samples/AnimatedTextSample.kt b/wear/compose/compose-material3/samples/src/main/java/androidx/wear/compose/material3/samples/AnimatedTextSample.kt
index 3d10692..585289d8 100644
--- a/wear/compose/compose-material3/samples/src/main/java/androidx/wear/compose/material3/samples/AnimatedTextSample.kt
+++ b/wear/compose/compose-material3/samples/src/main/java/androidx/wear/compose/material3/samples/AnimatedTextSample.kt
@@ -18,6 +18,7 @@
import androidx.annotation.Sampled
import androidx.compose.animation.core.Animatable
+import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
@@ -40,7 +41,15 @@
@Sampled
@Composable
fun AnimatedTextSample() {
+ val scope = rememberCoroutineScope()
val animatable = remember { Animatable(0f) }
+ val animate = {
+ scope.launch {
+ // Animate from 0 to 1 and then back to 0.
+ animatable.animateTo(1f)
+ animatable.animateTo(0f)
+ }
+ }
val animatedTextFontRegistry =
rememberAnimatedTextFontRegistry(
// Variation axes at the start of the animation, width 10, weight 200
@@ -64,12 +73,9 @@
// Content alignment anchors the animation at the vertical center, expanding horizontally
contentAlignment = Alignment.CenterStart,
progressFraction = { animatable.value },
+ modifier = Modifier.clickable(onClick = { animate() })
)
- LaunchedEffect(Unit) {
- // Animate from 0 to 1 and then back to 0.
- animatable.animateTo(1f)
- animatable.animateTo(0f)
- }
+ LaunchedEffect(Unit) { animate() }
}
@Sampled
diff --git a/wear/compose/compose-material3/src/androidTest/kotlin/androidx/wear/compose/material3/DynamicColorSchemeTest.kt b/wear/compose/compose-material3/src/androidTest/kotlin/androidx/wear/compose/material3/DynamicColorSchemeTest.kt
index 3be8786..725ae92 100644
--- a/wear/compose/compose-material3/src/androidTest/kotlin/androidx/wear/compose/material3/DynamicColorSchemeTest.kt
+++ b/wear/compose/compose-material3/src/androidTest/kotlin/androidx/wear/compose/material3/DynamicColorSchemeTest.kt
@@ -38,10 +38,7 @@
var actualTertiary: Color = Color.Unspecified
rule.setContent {
- MaterialTheme(
- colorScheme =
- dynamicColorScheme(LocalContext.current, defaultColorScheme = expected)
- ) {
+ MaterialTheme(colorScheme = dynamicColorScheme(LocalContext.current) ?: expected) {
actualPrimary = MaterialTheme.colorScheme.primary
actualSecondary = MaterialTheme.colorScheme.secondary
actualTertiary = MaterialTheme.colorScheme.tertiary
diff --git a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/CircularProgressIndicator.kt b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/CircularProgressIndicator.kt
index daf64e5..ce09c83 100644
--- a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/CircularProgressIndicator.kt
+++ b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/CircularProgressIndicator.kt
@@ -332,17 +332,24 @@
var shouldAnimateProgress by remember { mutableStateOf(false) }
val updatedProgress by rememberUpdatedState(progress)
- val animatedProgress = remember { Animatable(updatedProgress()) }
- val animatedOverflowColor = remember { Animatable(if (updatedProgress() > 1f) 1f else 0f) }
+ val initialProgress = updatedProgress()
+ var lastProgress = initialProgress
+ val animatedProgress = remember { Animatable(initialProgress) }
+ val animatedOverflowColor = remember { Animatable(if (initialProgress > 1f) 1f else 0f) }
LaunchedEffect(Unit) {
snapshotFlow(updatedProgress).collectLatest {
val newProgress = it
+
+ val actualProgressAnimationSpec =
+ if ((newProgress - lastProgress).absoluteValue <= 1f) progressAnimationSpec
+ else createOverflowProgressAnimationSpec(newProgress, lastProgress)
+
if (!shouldAnimateProgress) {
shouldAnimateProgress = true
} else if (newProgress > 1f) {
// Animate the progress arc.
- animatedProgress.animateTo(newProgress, progressAnimationSpec) {
+ animatedProgress.animateTo(newProgress, actualProgressAnimationSpec) {
// Start overflow color transition when progress crosses 1 (full circle).
if (animatedProgress.value.equalsWithTolerance(1f)) {
launch { animatedOverflowColor.animateTo(1f, colorAnimationSpec) }
@@ -353,11 +360,15 @@
// same time.
launch {
awaitAll(
- async { animatedProgress.animateTo(newProgress, progressAnimationSpec) },
+ async {
+ animatedProgress.animateTo(newProgress, actualProgressAnimationSpec)
+ },
async { animatedOverflowColor.animateTo(0f, colorAnimationSpec) }
)
}
}
+
+ lastProgress = newProgress
}
}
diff --git a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/DynamicColorScheme.kt b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/DynamicColorScheme.kt
index 6b7478d..70f0c65 100644
--- a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/DynamicColorScheme.kt
+++ b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/DynamicColorScheme.kt
@@ -27,18 +27,16 @@
*
* Use this function to create a color scheme based on the current watchface. If the user changes
* the watchface colors, this color scheme will change accordingly. This function checks whether the
- * dynamic color scheme can be used and returns [defaultColorScheme] otherwise.
+ * dynamic color scheme can be used and returns null otherwise. It is expected that callers will
+ * check the return value and fallback to their own default color scheme if it is null.
*
* @param context The context required to get system resource data.
- * @param defaultColorScheme The fallback [ColorScheme] to return if the dynamic color scheme is
- * switched off or unavailable on this device.
*/
fun dynamicColorScheme(
context: Context,
- defaultColorScheme: ColorScheme = ColorScheme()
-): ColorScheme =
+): ColorScheme? =
if (!isDynamicColorSchemeEnabled(context)) {
- defaultColorScheme
+ null
} else {
ColorScheme(
primary = ResourceHelper.getColor(context, android.R.color.system_primary_fixed),
@@ -96,7 +94,7 @@
}
/** Returns whether dynamic color is currently enabled on this device. */
-fun isDynamicColorSchemeEnabled(context: Context): Boolean {
+private fun isDynamicColorSchemeEnabled(context: Context): Boolean {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
val overlaySetting =
Settings.Secure.getString(context.contentResolver, THEME_CUSTOMIZATION_OVERLAY_PACKAGES)
diff --git a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/ProgressIndicator.kt b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/ProgressIndicator.kt
index 9d72bf9..f147465 100644
--- a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/ProgressIndicator.kt
+++ b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/ProgressIndicator.kt
@@ -17,6 +17,8 @@
package androidx.wear.compose.material3
import androidx.compose.animation.core.AnimationSpec
+import androidx.compose.animation.core.LinearEasing
+import androidx.compose.animation.core.keyframes
import androidx.compose.runtime.Composable
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
@@ -28,6 +30,7 @@
import androidx.compose.ui.graphics.isSpecified
import androidx.compose.ui.graphics.lerp
import androidx.wear.compose.material3.tokens.ColorSchemeKeyTokens
+import androidx.wear.compose.material3.tokens.MotionTokens
import androidx.wear.compose.materialcore.toRadians
import kotlin.math.absoluteValue
import kotlin.math.cos
@@ -412,6 +415,64 @@
internal fun Float.equalsWithTolerance(number: Float, tolerance: Float = 0.1f) =
(this - number).absoluteValue < tolerance
+/**
+ * Animation spec for over 100% Progress animations.
+ *
+ * Consists of 3 phases:
+ * 1) Intro: A time-based animation that accelerates the progression from 0 degrees per second to
+ * the peak speed over a fixed duration using easing.
+ * 2) Peak Speed: A rotation at a constant speed, defined in degrees per second, with a variable
+ * duration.
+ * 3) Outro: A time-based animation that decelerates the progression from the peak speed back to 0
+ * degrees per second over a fixed duration using easing.
+ */
+internal fun createOverflowProgressAnimationSpec(
+ newProgress: Float,
+ oldProgress: Float
+): AnimationSpec<Float> {
+ val progressDiff = newProgress - oldProgress
+ val peakSpeed = OverflowProgressMiddlePhaseSpeed
+
+ // Calculate intro and outro progress distance from the area under the CubicBezier curve.
+ val introProgressDistance =
+ IntroCubicBezierCurveAreaFactor * peakSpeed * (OverflowProgressIntroPhaseDuration / 1000f)
+ val outroProgressDistance =
+ OutroCubicBezierCurveAreaFactor * peakSpeed * (OverflowProgressOutroPhaseDuration / 1000f)
+ val introProgress = if (progressDiff > 0) introProgressDistance else -introProgressDistance
+ val outroProgress = if (progressDiff > 0) outroProgressDistance else -outroProgressDistance
+ val midProgress = progressDiff - introProgress - outroProgress
+ // Calculate the duration of the middle phase by dividing distance(progress) with speed.
+ val midDuration = (midProgress.absoluteValue / peakSpeed * 1000).toInt()
+
+ return keyframes {
+ durationMillis =
+ OverflowProgressIntroPhaseDuration + OverflowProgressOutroPhaseDuration + midDuration
+ // Intro phase
+ oldProgress at 0 using OverflowProgressIntroPhaseEasing
+ // Middle phase
+ oldProgress + introProgress at OverflowProgressIntroPhaseDuration using LinearEasing
+ // Outro phase
+ oldProgress + introProgress + midProgress at
+ OverflowProgressIntroPhaseDuration + midDuration using
+ OverflowProgressOutroPhaseEasing
+ }
+}
+
+// The determinate circular indicator progress animation constants for progress over 100%
+internal val OverflowProgressIntroPhaseDuration = MotionTokens.DurationMedium1 // 250ms
+internal val OverflowProgressIntroPhaseEasing = MotionTokens.EasingStandardAccelerate
+internal val OverflowProgressOutroPhaseDuration = MotionTokens.DurationMedium4 // 400ms
+internal val OverflowProgressOutroPhaseEasing = MotionTokens.EasingStandardDecelerate
+internal val OverflowProgressMiddlePhaseSpeed = 2f // Full progress circle rotations per second
+
+/**
+ * The area under the Bezier curve for [MotionTokens.EasingStandardAccelerate], see
+ * https://github.com/Pomax/BezierInfo-2/issues/238 for how this is calculated.
+ */
+internal const val IntroCubicBezierCurveAreaFactor = 0.41f
+/** The area under the Bezier curve for [MotionTokens.EasingStandardDecelerate]. */
+internal const val OutroCubicBezierCurveAreaFactor = 0.2f
+
/** Progress animation spec for determinate [CircularProgressIndicator] */
internal val determinateCircularProgressAnimationSpec: AnimationSpec<Float>
@Composable get() = MaterialTheme.motionScheme.slowEffectsSpec()
diff --git a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/SegmentedCircularProgressIndicator.kt b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/SegmentedCircularProgressIndicator.kt
index 7626c74..76b1b8c 100644
--- a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/SegmentedCircularProgressIndicator.kt
+++ b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/SegmentedCircularProgressIndicator.kt
@@ -35,6 +35,7 @@
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.unit.Dp
+import kotlin.math.absoluteValue
import kotlin.math.asin
import kotlin.math.floor
import kotlin.math.min
@@ -97,22 +98,25 @@
var shouldAnimateProgress by remember { mutableStateOf(false) }
val updatedProgress by rememberUpdatedState(progress)
+ val initialProgress = updatedProgress()
+ var lastProgress = initialProgress
val animatedProgress = remember {
- Animatable(
- if (allowProgressOverflow) updatedProgress() else updatedProgress().coerceIn(0f, 1f)
- )
+ Animatable(if (allowProgressOverflow) initialProgress else initialProgress.coerceIn(0f, 1f))
}
- val animatedOverflowColor = remember { Animatable(if (updatedProgress() > 1f) 1f else 0f) }
+ val animatedOverflowColor = remember { Animatable(if (initialProgress > 1f) 1f else 0f) }
LaunchedEffect(Unit) {
snapshotFlow(updatedProgress).collectLatest {
val newProgress = if (allowProgressOverflow) it else it.coerceIn(0f, 1f)
+ val actualOverflowProgressAnimationSpec =
+ if ((newProgress - lastProgress).absoluteValue <= 1f) progressAnimationSpec
+ else createOverflowProgressAnimationSpec(newProgress, lastProgress)
if (!shouldAnimateProgress) {
shouldAnimateProgress = true
} else if (allowProgressOverflow && newProgress > 1f) {
// Animate the progress arc.
- animatedProgress.animateTo(newProgress, progressAnimationSpec) {
+ animatedProgress.animateTo(newProgress, actualOverflowProgressAnimationSpec) {
// Start overflow color transition when progress crosses 1 (full circle).
if (animatedProgress.value.equalsWithTolerance(1f)) {
launch { animatedOverflowColor.animateTo(1f, colorAnimationSpec) }
@@ -123,13 +127,20 @@
// same time.
launch {
awaitAll(
- async { animatedProgress.animateTo(newProgress, progressAnimationSpec) },
+ async {
+ animatedProgress.animateTo(
+ newProgress,
+ actualOverflowProgressAnimationSpec
+ )
+ },
async { animatedOverflowColor.animateTo(0f, colorAnimationSpec) }
)
}
} else {
animatedProgress.animateTo(newProgress, progressAnimationSpec)
}
+
+ lastProgress = newProgress
}
}
diff --git a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/Typography.kt b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/Typography.kt
index e8d2e70..e977633 100644
--- a/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/Typography.kt
+++ b/wear/compose/compose-material3/src/main/java/androidx/wear/compose/material3/Typography.kt
@@ -23,6 +23,7 @@
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.style.LineHeightStyle
+import androidx.compose.ui.text.style.TextMotion
import androidx.wear.compose.material3.tokens.TypographyKeyTokens
import androidx.wear.compose.material3.tokens.TypographyTokens
@@ -329,6 +330,7 @@
TextStyle.Default.copy(
platformStyle = PlatformTextStyle(includeFontPadding = DefaultIncludeFontPadding),
lineHeightStyle = DefaultLineHeightStyle,
+ textMotion = TextMotion.Animated,
)
/** Helper function for typography tokens. */
diff --git a/wear/compose/integration-tests/demos/build.gradle b/wear/compose/integration-tests/demos/build.gradle
index 8d1fba3..371e326 100644
--- a/wear/compose/integration-tests/demos/build.gradle
+++ b/wear/compose/integration-tests/demos/build.gradle
@@ -26,8 +26,8 @@
defaultConfig {
applicationId "androidx.wear.compose.integration.demos"
minSdk 25
- versionCode 55
- versionName "1.55"
+ versionCode 56
+ versionName "1.56"
}
buildTypes {
diff --git a/wear/protolayout/protolayout-expression-pipeline/build.gradle b/wear/protolayout/protolayout-expression-pipeline/build.gradle
index bb819f6..db0ef6e 100644
--- a/wear/protolayout/protolayout-expression-pipeline/build.gradle
+++ b/wear/protolayout/protolayout-expression-pipeline/build.gradle
@@ -29,6 +29,7 @@
}
dependencies {
+ api(libs.jspecify)
annotationProcessor(libs.nullaway)
api("androidx.annotation:annotation:1.8.1")
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/AnimatableNode.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/AnimatableNode.java
index 53b251e..3477006 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/AnimatableNode.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/AnimatableNode.java
@@ -23,12 +23,13 @@
import android.animation.IntEvaluator;
import android.animation.TypeEvaluator;
-import androidx.annotation.NonNull;
import androidx.annotation.UiThread;
import androidx.annotation.VisibleForTesting;
import androidx.core.util.Pair;
import androidx.wear.protolayout.expression.proto.AnimationParameterProto.AnimationSpec;
+import org.jspecify.annotations.NonNull;
+
/** Data animatable source node within a dynamic data pipeline. */
abstract class AnimatableNode {
static final ArgbEvaluator ARGB_EVALUATOR = new ArgbEvaluator();
@@ -36,8 +37,7 @@
static final FloatEvaluator FLOAT_EVALUATOR = new FloatEvaluator();
private boolean mIsVisible = false;
- @NonNull
- final QuotaAwareAnimator mQuotaAwareAnimator;
+ final @NonNull QuotaAwareAnimator mQuotaAwareAnimator;
protected AnimatableNode(
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/AnimationsHelper.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/AnimationsHelper.java
index 8cfd106..de6427f 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/AnimationsHelper.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/AnimationsHelper.java
@@ -22,8 +22,6 @@
import android.view.animation.LinearInterpolator;
import android.view.animation.PathInterpolator;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.core.util.Pair;
import androidx.wear.protolayout.expression.proto.AnimationParameterProto.AnimationParameters;
@@ -33,6 +31,9 @@
import androidx.wear.protolayout.expression.proto.AnimationParameterProto.RepeatMode;
import androidx.wear.protolayout.expression.proto.AnimationParameterProto.Repeatable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.time.Duration;
import java.util.EnumMap;
import java.util.Map;
@@ -64,8 +65,7 @@
/** Returns the main duration from the given {@link AnimationSpec} or default value if not
* set. */
@SuppressWarnings("deprecation") // Make sure the deprecated method is valid for compatibility
- @NonNull
- public static Duration getMainDurationOrDefault(@NonNull AnimationSpec spec) {
+ public static @NonNull Duration getMainDurationOrDefault(@NonNull AnimationSpec spec) {
return spec.hasAnimationParameters()
&& spec.getAnimationParameters().getDurationMillis() > 0
? Duration.ofMillis(spec.getAnimationParameters().getDurationMillis())
@@ -76,8 +76,7 @@
/** Returns the main delay from the given {@link AnimationSpec} or default value if not set. */
@SuppressWarnings("deprecation") // Make sure the deprecated method is valid for compatibility
- @NonNull
- public static Duration getMainDelayOrDefault(@NonNull AnimationSpec spec) {
+ public static @NonNull Duration getMainDelayOrDefault(@NonNull AnimationSpec spec) {
return spec.getAnimationParameters().hasDelayMillis()
? Duration.ofMillis(spec.getAnimationParameters().getDelayMillis())
: spec.getStartDelayMillis() > 0
@@ -90,8 +89,7 @@
* default value if not set.
*/
@SuppressWarnings("deprecation") // Make sure the deprecated method is valid for compatibility
- @NonNull
- public static Interpolator getMainInterpolatorOrDefault(@NonNull AnimationSpec spec) {
+ public static @NonNull Interpolator getMainInterpolatorOrDefault(@NonNull AnimationSpec spec) {
Interpolator interpolator = DEFAULT_ANIM_INTERPOLATOR;
Easing easing = null;
@@ -154,8 +152,8 @@
// public static Duration getOverrideForwardDurationOrDefault(@NonNull AnimationSpec spec) {...}
- @NonNull
- public static Duration getOverrideReverseDurationOrDefault(@NonNull AnimationSpec spec) {
+ public static @NonNull Duration getOverrideReverseDurationOrDefault(
+ @NonNull AnimationSpec spec) {
if (spec.hasRepeatable()) {
Repeatable repeatable = spec.getRepeatable();
if (repeatable.hasReverseRepeatOverride()) {
@@ -223,8 +221,7 @@
* main and aux animators which are played alternately. For other cases, null is returned as no
* split would happen.
*/
- @Nullable
- static Pair<AnimationSpec, AnimationSpec> maybeSplitToMainAndAuxAnimationSpec(
+ static @Nullable Pair<AnimationSpec, AnimationSpec> maybeSplitToMainAndAuxAnimationSpec(
@NonNull AnimationSpec spec) {
if (!hasCustomReverseDuration(spec)) {
return null;
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/BoundDynamicType.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/BoundDynamicType.java
index 243bc8e..b23dd75 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/BoundDynamicType.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/BoundDynamicType.java
@@ -16,11 +16,12 @@
package androidx.wear.protolayout.expression.pipeline;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.UiThread;
import androidx.annotation.VisibleForTesting;
+import org.jspecify.annotations.NonNull;
+
import java.util.List;
/**
@@ -84,7 +85,6 @@
* layout. The list may be empty if there are no animations.
* <p>This method is intended for internal use by ui-tooling libraries
*/
- @NonNull
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
- List<DynamicTypeAnimator> getAnimations();
+ @NonNull List<DynamicTypeAnimator> getAnimations();
}
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/BoundDynamicTypeImpl.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/BoundDynamicTypeImpl.java
index b255cea..1e5d2f4 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/BoundDynamicTypeImpl.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/BoundDynamicTypeImpl.java
@@ -20,9 +20,10 @@
import android.os.Looper;
import android.util.Log;
-import androidx.annotation.NonNull;
import androidx.annotation.UiThread;
+import org.jspecify.annotations.NonNull;
+
import java.util.List;
import java.util.stream.Collectors;
@@ -80,9 +81,8 @@
.count();
}
- @NonNull
@Override
- public List<DynamicTypeAnimator> getAnimations() {
+ public @NonNull List<DynamicTypeAnimator> getAnimations() {
List<QuotaAwareAnimator> animators =
mNodes.stream()
.filter(n -> n instanceof AnimatableNode)
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/ColorNodes.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/ColorNodes.java
index afc44fe..b732ff4 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/ColorNodes.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/ColorNodes.java
@@ -16,8 +16,6 @@
package androidx.wear.protolayout.expression.pipeline;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicColor;
import androidx.wear.protolayout.expression.proto.AnimationParameterProto.AnimationSpec;
@@ -25,6 +23,9 @@
import androidx.wear.protolayout.expression.proto.DynamicProto.StateColorSource;
import androidx.wear.protolayout.expression.proto.FixedProto.FixedColor;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/** Dynamic data nodes which yield colors. */
class ColorNodes {
private ColorNodes() {}
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/ConditionalOpNode.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/ConditionalOpNode.java
index 0817f67..8e243f4 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/ConditionalOpNode.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/ConditionalOpNode.java
@@ -16,8 +16,8 @@
package androidx.wear.protolayout.expression.pipeline;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/** Dynamic data nodes which yield result based on the given condition. */
class ConditionalOpNode<T> implements DynamicDataNode<T> {
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DataStore.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DataStore.java
index e4e92ef..8ac4f42 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DataStore.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DataStore.java
@@ -16,11 +16,12 @@
package androidx.wear.protolayout.expression.pipeline;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.wear.protolayout.expression.DynamicDataKey;
import androidx.wear.protolayout.expression.proto.DynamicDataProto.DynamicDataValue;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* {@link DynamicDataKey} to {@link DynamicDataValue} storage for ProtoLayout, which also supports
* sending callback when data items change.
@@ -44,6 +45,5 @@
* Retrieve the {@link DynamicDataValue} associated with the given {@link DynamicDataKey} in
* the store.
*/
- @Nullable
- abstract DynamicDataValue getDynamicDataValuesProto(@NonNull DynamicDataKey<?> key);
+ abstract @Nullable DynamicDataValue getDynamicDataValuesProto(@NonNull DynamicDataKey<?> key);
}
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicDataBiTransformNode.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicDataBiTransformNode.java
index 3e0208d7..887574b 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicDataBiTransformNode.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicDataBiTransformNode.java
@@ -18,8 +18,8 @@
import android.util.Log;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.util.function.BiFunction;
import java.util.function.Function;
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicDataTransformNode.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicDataTransformNode.java
index 0024b26..4ce8135 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicDataTransformNode.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicDataTransformNode.java
@@ -16,8 +16,8 @@
package androidx.wear.protolayout.expression.pipeline;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.util.function.Function;
import java.util.function.Predicate;
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeAnimator.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeAnimator.java
index 1af270d..cbba80e 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeAnimator.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeAnimator.java
@@ -18,10 +18,11 @@
import android.animation.TypeEvaluator;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* DynamicTypeAnimator interface defines the methods and properties of ProtoLayout animation.
*
@@ -44,8 +45,7 @@
*
* @return The type evaluator used for interpolation.
*/
- @NonNull
- TypeEvaluator<?> getTypeEvaluator();
+ @NonNull TypeEvaluator<?> getTypeEvaluator();
/**
* Sets the float values that this animation will animate between.
@@ -54,7 +54,7 @@
* @throws IllegalArgumentException if this {@link DynamicTypeAnimator} is not configured with a
* suitable {@link TypeEvaluator} for float values (e.g., {@link FloatEvaluator}).
*/
- void setFloatValues(@NonNull float... values);
+ void setFloatValues(float @NonNull ... values);
/**
* Sets the integer values that this animation will animate between.
@@ -64,7 +64,7 @@
* suitable {@link TypeEvaluator} for integer values (e.g., {@link IntEvaluator} or {@link
* ArgbEvaluator}).
*/
- void setIntValues(@NonNull int... values);
+ void setIntValues(int @NonNull ... values);
/**
* Advances the animation to the specified time.
@@ -78,24 +78,21 @@
*
* @return The start value of the animation or null if value wasn't set.
*/
- @Nullable
- Object getStartValue();
+ @Nullable Object getStartValue();
/**
* Gets the end value of the animation.
*
* @return The end value of the animation.
*/
- @Nullable
- Object getEndValue();
+ @Nullable Object getEndValue();
/**
* Gets the last value of the animated property at the current time in the animation.
*
* @return The last calculated animated value or null if value wasn't set.
*/
- @Nullable
- Object getCurrentValue();
+ @Nullable Object getCurrentValue();
/**
* Gets the duration of the animation, in milliseconds.
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeBindingRequest.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeBindingRequest.java
index b805b3f..732e497 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeBindingRequest.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeBindingRequest.java
@@ -18,8 +18,6 @@
import android.icu.util.ULocale;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.DynamicBuilders;
@@ -31,6 +29,9 @@
import androidx.wear.protolayout.expression.proto.DynamicProto.DynamicInt32;
import androidx.wear.protolayout.expression.proto.DynamicProto.DynamicString;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.time.Duration;
import java.time.Instant;
import java.util.concurrent.Executor;
@@ -57,9 +58,8 @@
* @param consumer The registered consumer for results of the evaluation. It will be called from
* UI thread.
*/
- @NonNull
- @RestrictTo(Scope.LIBRARY_GROUP)
- public static DynamicTypeBindingRequest forDynamicFloatInternal(
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ public static @NonNull DynamicTypeBindingRequest forDynamicFloatInternal(
@NonNull DynamicFloat floatSource, @NonNull DynamicTypeValueReceiver<Float> consumer) {
return new DynamicFloatBindingRequest(floatSource, consumer);
}
@@ -75,9 +75,8 @@
* @param executor The Executor to run the consumer on.
* @param consumer The registered consumer for results of the evaluation.
*/
- @NonNull
- public static DynamicTypeBindingRequest forDynamicFloat(
- @NonNull DynamicBuilders.DynamicFloat floatSource,
+ public static @NonNull DynamicTypeBindingRequest forDynamicFloat(
+ DynamicBuilders.@NonNull DynamicFloat floatSource,
@NonNull Executor executor,
@NonNull DynamicTypeValueReceiver<Float> consumer) {
return new DynamicFloatBindingRequest(
@@ -92,9 +91,8 @@
* @param consumer The registered consumer for results of the evaluation. It will be called from
* UI thread.
*/
- @NonNull
- @RestrictTo(Scope.LIBRARY_GROUP)
- public static DynamicTypeBindingRequest forDynamicInt32Internal(
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ public static @NonNull DynamicTypeBindingRequest forDynamicInt32Internal(
@NonNull DynamicInt32 int32Source,
@NonNull DynamicTypeValueReceiver<Integer> consumer) {
return new DynamicInt32BindingRequest(int32Source, consumer);
@@ -111,9 +109,8 @@
* @param executor The Executor to run the consumer on.
* @param consumer The registered consumer for results of the evaluation.
*/
- @NonNull
- public static DynamicTypeBindingRequest forDynamicInt32(
- @NonNull DynamicBuilders.DynamicInt32 int32Source,
+ public static @NonNull DynamicTypeBindingRequest forDynamicInt32(
+ DynamicBuilders.@NonNull DynamicInt32 int32Source,
@NonNull Executor executor,
@NonNull DynamicTypeValueReceiver<Integer> consumer) {
return new DynamicInt32BindingRequest(
@@ -128,9 +125,8 @@
* @param consumer The registered consumer for results of the evaluation. It will be called from
* UI thread.
*/
- @NonNull
- @RestrictTo(Scope.LIBRARY_GROUP)
- public static DynamicTypeBindingRequest forDynamicColorInternal(
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ public static @NonNull DynamicTypeBindingRequest forDynamicColorInternal(
@NonNull DynamicColor colorSource,
@NonNull DynamicTypeValueReceiver<Integer> consumer) {
return new DynamicColorBindingRequest(colorSource, consumer);
@@ -147,9 +143,8 @@
* @param executor The Executor to run the consumer on.
* @param consumer The registered consumer for results of the evaluation.
*/
- @NonNull
- public static DynamicTypeBindingRequest forDynamicColor(
- @NonNull DynamicBuilders.DynamicColor colorSource,
+ public static @NonNull DynamicTypeBindingRequest forDynamicColor(
+ DynamicBuilders.@NonNull DynamicColor colorSource,
@NonNull Executor executor,
@NonNull DynamicTypeValueReceiver<Integer> consumer) {
return new DynamicColorBindingRequest(
@@ -164,9 +159,8 @@
* @param consumer The registered consumer for results of the evaluation. It will be called from
* UI thread.
*/
- @NonNull
- @RestrictTo(Scope.LIBRARY_GROUP)
- public static DynamicTypeBindingRequest forDynamicBoolInternal(
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ public static @NonNull DynamicTypeBindingRequest forDynamicBoolInternal(
@NonNull DynamicBool boolSource, @NonNull DynamicTypeValueReceiver<Boolean> consumer) {
return new DynamicBoolBindingRequest(boolSource, consumer);
}
@@ -182,9 +176,8 @@
* @param executor The Executor to run the consumer on.
* @param consumer The registered consumer for results of the evaluation.
*/
- @NonNull
- public static DynamicTypeBindingRequest forDynamicBool(
- @NonNull DynamicBuilders.DynamicBool boolSource,
+ public static @NonNull DynamicTypeBindingRequest forDynamicBool(
+ DynamicBuilders.@NonNull DynamicBool boolSource,
@NonNull Executor executor,
@NonNull DynamicTypeValueReceiver<Boolean> consumer) {
return new DynamicBoolBindingRequest(boolSource.toDynamicBoolProto(), executor, consumer);
@@ -199,9 +192,8 @@
* UI thread.
* @param locale The locale used for the given String source.
*/
- @NonNull
- @RestrictTo(Scope.LIBRARY_GROUP)
- public static DynamicTypeBindingRequest forDynamicStringInternal(
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ public static @NonNull DynamicTypeBindingRequest forDynamicStringInternal(
@NonNull DynamicString stringSource,
@NonNull ULocale locale,
@NonNull DynamicTypeValueReceiver<String> consumer) {
@@ -220,9 +212,8 @@
* @param executor The Executor to run the consumer on.
* @param consumer The registered consumer for results of the evaluation.
*/
- @NonNull
- public static DynamicTypeBindingRequest forDynamicString(
- @NonNull DynamicBuilders.DynamicString stringSource,
+ public static @NonNull DynamicTypeBindingRequest forDynamicString(
+ DynamicBuilders.@NonNull DynamicString stringSource,
@NonNull ULocale locale,
@NonNull Executor executor,
@NonNull DynamicTypeValueReceiver<String> consumer) {
@@ -238,9 +229,8 @@
* @param consumer The registered consumer for results of the evaluation. It will be called from
* UI thread.
*/
- @NonNull
- @RestrictTo(Scope.LIBRARY_GROUP)
- public static DynamicTypeBindingRequest forDynamicDurationInternal(
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ public static @NonNull DynamicTypeBindingRequest forDynamicDurationInternal(
@NonNull DynamicDuration durationSource,
@NonNull DynamicTypeValueReceiver<Duration> consumer) {
return new DynamicDurationBindingRequest(durationSource, consumer);
@@ -257,9 +247,8 @@
* @param executor The Executor to run the consumer on.
* @param consumer The registered consumer for results of the evaluation.
*/
- @NonNull
- public static DynamicTypeBindingRequest forDynamicDuration(
- @NonNull DynamicBuilders.DynamicDuration durationSource,
+ public static @NonNull DynamicTypeBindingRequest forDynamicDuration(
+ DynamicBuilders.@NonNull DynamicDuration durationSource,
@NonNull Executor executor,
@NonNull DynamicTypeValueReceiver<Duration> consumer) {
return new DynamicDurationBindingRequest(
@@ -274,9 +263,8 @@
* @param consumer The registered consumer for results of the evaluation. It will be called from
* UI thread.
*/
- @NonNull
- @RestrictTo(Scope.LIBRARY_GROUP)
- public static DynamicTypeBindingRequest forDynamicInstantInternal(
+ @RestrictTo(Scope.LIBRARY_GROUP)
+ public static @NonNull DynamicTypeBindingRequest forDynamicInstantInternal(
@NonNull DynamicInstant instantSource,
@NonNull DynamicTypeValueReceiver<Instant> consumer) {
return new DynamicInstantBindingRequest(instantSource, consumer);
@@ -293,17 +281,15 @@
* @param executor The Executor to run the consumer on.
* @param consumer The registered consumer for results of the evaluation.
*/
- @NonNull
- public static DynamicTypeBindingRequest forDynamicInstant(
- @NonNull DynamicBuilders.DynamicInstant instantSource,
+ public static @NonNull DynamicTypeBindingRequest forDynamicInstant(
+ DynamicBuilders.@NonNull DynamicInstant instantSource,
@NonNull Executor executor,
@NonNull DynamicTypeValueReceiver<Instant> consumer) {
return new DynamicInstantBindingRequest(
instantSource.toDynamicInstantProto(), executor, consumer);
}
- @NonNull
- private static <T> DynamicTypeValueReceiverOnExecutor<T> createReceiver(
+ private static <T> @NonNull DynamicTypeValueReceiverOnExecutor<T> createReceiver(
@Nullable Executor executor, @NonNull DynamicTypeValueReceiver<T> consumer) {
if (executor != null) {
return new DynamicTypeValueReceiverOnExecutor<>(executor, consumer);
@@ -314,9 +300,9 @@
private static class DynamicFloatBindingRequest extends DynamicTypeBindingRequest {
- @NonNull private final DynamicFloat mFloatSource;
- @Nullable private final Executor mExecutor;
- @NonNull private final DynamicTypeValueReceiver<Float> mConsumer;
+ private final @NonNull DynamicFloat mFloatSource;
+ private final @Nullable Executor mExecutor;
+ private final @NonNull DynamicTypeValueReceiver<Float> mConsumer;
DynamicFloatBindingRequest(
@NonNull DynamicFloat floatSource,
@@ -343,9 +329,9 @@
private static class DynamicInt32BindingRequest extends DynamicTypeBindingRequest {
- @NonNull private final DynamicInt32 mInt32Source;
- @Nullable private final Executor mExecutor;
- @NonNull private final DynamicTypeValueReceiver<Integer> mConsumer;
+ private final @NonNull DynamicInt32 mInt32Source;
+ private final @Nullable Executor mExecutor;
+ private final @NonNull DynamicTypeValueReceiver<Integer> mConsumer;
DynamicInt32BindingRequest(
@NonNull DynamicInt32 int32Source,
@@ -372,9 +358,9 @@
private static class DynamicColorBindingRequest extends DynamicTypeBindingRequest {
- @NonNull private final DynamicColor mColorSource;
- @Nullable private final Executor mExecutor;
- @NonNull private final DynamicTypeValueReceiver<Integer> mConsumer;
+ private final @NonNull DynamicColor mColorSource;
+ private final @Nullable Executor mExecutor;
+ private final @NonNull DynamicTypeValueReceiver<Integer> mConsumer;
DynamicColorBindingRequest(
@NonNull DynamicColor colorSource,
@@ -401,9 +387,9 @@
private static class DynamicBoolBindingRequest extends DynamicTypeBindingRequest {
- @NonNull private final DynamicBool mBoolSource;
- @Nullable private final Executor mExecutor;
- @NonNull private final DynamicTypeValueReceiver<Boolean> mConsumer;
+ private final @NonNull DynamicBool mBoolSource;
+ private final @Nullable Executor mExecutor;
+ private final @NonNull DynamicTypeValueReceiver<Boolean> mConsumer;
DynamicBoolBindingRequest(
@NonNull DynamicBool boolSource,
@@ -430,10 +416,10 @@
private static class DynamicStringBindingRequest extends DynamicTypeBindingRequest {
- @NonNull private final DynamicString mStringSource;
- @NonNull private final ULocale mLocale;
- @Nullable private final Executor mExecutor;
- @NonNull private final DynamicTypeValueReceiver<String> mConsumer;
+ private final @NonNull DynamicString mStringSource;
+ private final @NonNull ULocale mLocale;
+ private final @Nullable Executor mExecutor;
+ private final @NonNull DynamicTypeValueReceiver<String> mConsumer;
DynamicStringBindingRequest(
@NonNull DynamicString stringSource,
@@ -465,9 +451,9 @@
private static class DynamicDurationBindingRequest extends DynamicTypeBindingRequest {
- @NonNull private final DynamicDuration mDurationSource;
- @Nullable private final Executor mExecutor;
- @NonNull private final DynamicTypeValueReceiver<Duration> mConsumer;
+ private final @NonNull DynamicDuration mDurationSource;
+ private final @Nullable Executor mExecutor;
+ private final @NonNull DynamicTypeValueReceiver<Duration> mConsumer;
DynamicDurationBindingRequest(
@NonNull DynamicDuration durationSource,
@@ -494,9 +480,9 @@
private static class DynamicInstantBindingRequest extends DynamicTypeBindingRequest {
- @NonNull private final DynamicInstant mInstantSource;
- @Nullable private final Executor mExecutor;
- @NonNull private final DynamicTypeValueReceiver<Instant> mConsumer;
+ private final @NonNull DynamicInstant mInstantSource;
+ private final @Nullable Executor mExecutor;
+ private final @NonNull DynamicTypeValueReceiver<Instant> mConsumer;
DynamicInstantBindingRequest(
@NonNull DynamicInstant instantSource,
@@ -528,8 +514,8 @@
private static class DynamicTypeValueReceiverOnExecutor<T>
implements DynamicTypeValueReceiverWithPreUpdate<T> {
- @NonNull private final Executor mExecutor;
- @NonNull private final DynamicTypeValueReceiver<T> mConsumer;
+ private final @NonNull Executor mExecutor;
+ private final @NonNull DynamicTypeValueReceiver<T> mConsumer;
DynamicTypeValueReceiverOnExecutor(@NonNull DynamicTypeValueReceiver<T> consumer) {
this(Runnable::run, consumer);
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeEvaluator.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeEvaluator.java
index db91f91..ba68a3c 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeEvaluator.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeEvaluator.java
@@ -21,8 +21,6 @@
import android.annotation.SuppressLint;
import android.icu.util.ULocale;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.annotation.VisibleForTesting;
@@ -84,6 +82,9 @@
import androidx.wear.protolayout.expression.proto.DynamicProto.DynamicString;
import androidx.wear.protolayout.expression.proto.DynamicProto.DynamicZonedDateTime;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.time.Duration;
import java.time.Instant;
import java.time.ZonedDateTime;
@@ -122,8 +123,7 @@
public void releaseQuota(int quota) {}
};
- @NonNull
- private static final QuotaManager DISABLED_ANIMATIONS_QUOTA_MANAGER =
+ private static final @NonNull QuotaManager DISABLED_ANIMATIONS_QUOTA_MANAGER =
new QuotaManager() {
@Override
public boolean tryAcquireQuota(int quota) {
@@ -144,26 +144,25 @@
}
}
- @NonNull private static final StateStore EMPTY_STATE_STORE = new StateStore(emptyMap());
+ private static final @NonNull StateStore EMPTY_STATE_STORE = new StateStore(emptyMap());
- @NonNull private final StateStore mStateStore;
- @NonNull private final PlatformDataStore mPlatformDataStore;
- @NonNull private final QuotaManager mAnimationQuotaManager;
- @NonNull private final QuotaManager mDynamicTypesQuotaManager;
- @NonNull private final EpochTimePlatformDataSource mTimeDataSource;
+ private final @NonNull StateStore mStateStore;
+ private final @NonNull PlatformDataStore mPlatformDataStore;
+ private final @NonNull QuotaManager mAnimationQuotaManager;
+ private final @NonNull QuotaManager mDynamicTypesQuotaManager;
+ private final @NonNull EpochTimePlatformDataSource mTimeDataSource;
/** Configuration for creating {@link DynamicTypeEvaluator}. */
public static final class Config {
- @Nullable private final StateStore mStateStore;
- @Nullable private final QuotaManager mAnimationQuotaManager;
- @Nullable private final QuotaManager mDynamicTypesQuotaManager;
+ private final @Nullable StateStore mStateStore;
+ private final @Nullable QuotaManager mAnimationQuotaManager;
+ private final @Nullable QuotaManager mDynamicTypesQuotaManager;
- @NonNull
- private final Map<PlatformDataKey<?>, PlatformDataProvider> mSourceKeyToDataProviders =
- new ArrayMap<>();
+ private final @NonNull Map<PlatformDataKey<?>, PlatformDataProvider>
+ mSourceKeyToDataProviders = new ArrayMap<>();
- @Nullable private final PlatformTimeUpdateNotifier mPlatformTimeUpdateNotifier;
- @Nullable private final Supplier<Instant> mClock;
+ private final @Nullable PlatformTimeUpdateNotifier mPlatformTimeUpdateNotifier;
+ private final @Nullable Supplier<Instant> mClock;
Config(
@Nullable StateStore stateStore,
@@ -182,16 +181,15 @@
/** Builds a {@link DynamicTypeEvaluator.Config}. */
public static final class Builder {
- @Nullable private StateStore mStateStore = null;
- @Nullable private QuotaManager mAnimationQuotaManager = null;
- @Nullable private QuotaManager mDynamicTypesQuotaManager = null;
+ private @Nullable StateStore mStateStore = null;
+ private @Nullable QuotaManager mAnimationQuotaManager = null;
+ private @Nullable QuotaManager mDynamicTypesQuotaManager = null;
- @NonNull
- private final Map<PlatformDataKey<?>, PlatformDataProvider> mSourceKeyToDataProviders =
- new ArrayMap<>();
+ private final @NonNull Map<PlatformDataKey<?>, PlatformDataProvider>
+ mSourceKeyToDataProviders = new ArrayMap<>();
- @Nullable private PlatformTimeUpdateNotifier mPlatformTimeUpdateNotifier = null;
- @Nullable private Supplier<Instant> mClock = null;
+ private @Nullable PlatformTimeUpdateNotifier mPlatformTimeUpdateNotifier = null;
+ private @Nullable Supplier<Instant> mClock = null;
/**
* Sets the state store that will be used for dereferencing the state keys in the
@@ -200,8 +198,7 @@
* <p>If not set, it's the equivalent of setting an empty state store (state bindings
* will trigger {@link DynamicTypeValueReceiver#onInvalidated()}).
*/
- @NonNull
- public Builder setStateStore(@NonNull StateStore value) {
+ public @NonNull Builder setStateStore(@NonNull StateStore value) {
mStateStore = value;
return this;
}
@@ -213,8 +210,7 @@
* <p>If not set, animations are disabled and non-infinite animations will have the end
* value immediately.
*/
- @NonNull
- public Builder setAnimationQuotaManager(@NonNull QuotaManager value) {
+ public @NonNull Builder setAnimationQuotaManager(@NonNull QuotaManager value) {
mAnimationQuotaManager = value;
return this;
}
@@ -225,8 +221,7 @@
*
* <p>If not set, number of dynamic types will not be restricted.
*/
- @NonNull
- public Builder setDynamicTypesQuotaManager(@NonNull QuotaManager value) {
+ public @NonNull Builder setDynamicTypesQuotaManager(@NonNull QuotaManager value) {
mDynamicTypesQuotaManager = value;
return this;
}
@@ -242,8 +237,7 @@
* or if a key has multiple data providers.
*/
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addPlatformDataProvider(
+ public @NonNull Builder addPlatformDataProvider(
@NonNull PlatformDataProvider platformDataProvider,
@NonNull Set<PlatformDataKey<?>> supportedDataKeys) {
if (supportedDataKeys.isEmpty()) {
@@ -268,8 +262,7 @@
* Sets the notifier used for updating the platform time data. If not set, by default
* platform time will be updated at 1Hz using a {@code Handler} on the main thread.
*/
- @NonNull
- public Builder setPlatformTimeUpdateNotifier(
+ public @NonNull Builder setPlatformTimeUpdateNotifier(
@NonNull PlatformTimeUpdateNotifier notifier) {
this.mPlatformTimeUpdateNotifier = notifier;
return this;
@@ -281,14 +274,12 @@
* {@link Instant#now()}.
*/
@VisibleForTesting
- @NonNull
- public Builder setClock(@NonNull Supplier<Instant> clock) {
+ public @NonNull Builder setClock(@NonNull Supplier<Instant> clock) {
this.mClock = clock;
return this;
}
- @NonNull
- public Config build() {
+ public @NonNull Config build() {
return new Config(
mStateStore,
mAnimationQuotaManager,
@@ -304,8 +295,7 @@
* types, or {@code null} which is equivalent to an empty state store (state bindings will
* trigger {@link DynamicTypeValueReceiver#onInvalidated()}).
*/
- @Nullable
- public StateStore getStateStore() {
+ public @Nullable StateStore getStateStore() {
return mStateStore;
}
@@ -314,8 +304,7 @@
* or {@code null} if animations are disabled, causing non-infinite animations to have to
* the end value immediately.
*/
- @Nullable
- public QuotaManager getAnimationQuotaManager() {
+ public @Nullable QuotaManager getAnimationQuotaManager() {
return mAnimationQuotaManager;
}
@@ -324,14 +313,12 @@
* pipeline, or {@code null} if there are no restriction on the number of dynamic types. If
* present, the quota manager is used to prevent unreasonably expensive expressions.
*/
- @Nullable
- public QuotaManager getDynamicTypesQuotaManager() {
+ public @Nullable QuotaManager getDynamicTypesQuotaManager() {
return mDynamicTypesQuotaManager;
}
/** Returns any available mapping between source key and its data provider. */
- @NonNull
- public Map<PlatformDataKey<?>, PlatformDataProvider> getPlatformDataProviders() {
+ public @NonNull Map<PlatformDataKey<?>, PlatformDataProvider> getPlatformDataProviders() {
return new ArrayMap<>(
(ArrayMap<PlatformDataKey<?>, PlatformDataProvider>) mSourceKeyToDataProviders);
}
@@ -342,14 +329,12 @@
* set to {@link Instant#now()}.
*/
@VisibleForTesting
- @Nullable
- public Supplier<Instant> getClock() {
+ public @Nullable Supplier<Instant> getClock() {
return mClock;
}
/** Gets the notifier used for updating the platform time data. */
- @Nullable
- public PlatformTimeUpdateNotifier getPlatformTimeUpdateNotifier() {
+ public @Nullable PlatformTimeUpdateNotifier getPlatformTimeUpdateNotifier() {
return mPlatformTimeUpdateNotifier;
}
}
@@ -385,8 +370,7 @@
* @throws EvaluationException when {@link QuotaManager} fails to allocate enough quota to bind
* the {@link DynamicTypeBindingRequest}.
*/
- @NonNull
- public BoundDynamicType bind(@NonNull DynamicTypeBindingRequest request)
+ public @NonNull BoundDynamicType bind(@NonNull DynamicTypeBindingRequest request)
throws EvaluationException {
BoundDynamicTypeImpl boundDynamicType = request.callBindOn(this);
if (!mDynamicTypesQuotaManager.tryAcquireQuota(boundDynamicType.getDynamicNodeCost())) {
@@ -397,9 +381,8 @@
return boundDynamicType;
}
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- BoundDynamicTypeImpl bindInternal(
+ @NonNull BoundDynamicTypeImpl bindInternal(
@NonNull DynamicString stringSource,
@NonNull ULocale locale,
@NonNull DynamicTypeValueReceiverWithPreUpdate<String> consumer) {
@@ -408,9 +391,8 @@
return new BoundDynamicTypeImpl(resultBuilder, mDynamicTypesQuotaManager);
}
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- BoundDynamicTypeImpl bindInternal(
+ @NonNull BoundDynamicTypeImpl bindInternal(
@NonNull DynamicInt32 int32Source,
@NonNull DynamicTypeValueReceiverWithPreUpdate<Integer> consumer) {
List<DynamicDataNode<?>> resultBuilder = new ArrayList<>();
@@ -418,9 +400,8 @@
return new BoundDynamicTypeImpl(resultBuilder, mDynamicTypesQuotaManager);
}
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- BoundDynamicTypeImpl bindInternal(
+ @NonNull BoundDynamicTypeImpl bindInternal(
@NonNull DynamicFloat floatSource,
@NonNull DynamicTypeValueReceiverWithPreUpdate<Float> consumer) {
List<DynamicDataNode<?>> resultBuilder = new ArrayList<>();
@@ -428,9 +409,8 @@
return new BoundDynamicTypeImpl(resultBuilder, mDynamicTypesQuotaManager);
}
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- BoundDynamicTypeImpl bindInternal(
+ @NonNull BoundDynamicTypeImpl bindInternal(
@NonNull DynamicColor colorSource,
@NonNull DynamicTypeValueReceiverWithPreUpdate<Integer> consumer) {
List<DynamicDataNode<?>> resultBuilder = new ArrayList<>();
@@ -438,9 +418,8 @@
return new BoundDynamicTypeImpl(resultBuilder, mDynamicTypesQuotaManager);
}
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- BoundDynamicTypeImpl bindInternal(
+ @NonNull BoundDynamicTypeImpl bindInternal(
@NonNull DynamicDuration durationSource,
@NonNull DynamicTypeValueReceiverWithPreUpdate<Duration> consumer) {
List<DynamicDataNode<?>> resultBuilder = new ArrayList<>();
@@ -448,9 +427,8 @@
return new BoundDynamicTypeImpl(resultBuilder, mDynamicTypesQuotaManager);
}
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- BoundDynamicTypeImpl bindInternal(
+ @NonNull BoundDynamicTypeImpl bindInternal(
@NonNull DynamicInstant instantSource,
@NonNull DynamicTypeValueReceiverWithPreUpdate<Instant> consumer) {
List<DynamicDataNode<?>> resultBuilder = new ArrayList<>();
@@ -458,9 +436,8 @@
return new BoundDynamicTypeImpl(resultBuilder, mDynamicTypesQuotaManager);
}
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- BoundDynamicTypeImpl bindInternal(
+ @NonNull BoundDynamicTypeImpl bindInternal(
@NonNull DynamicZonedDateTime zdtSource,
@NonNull DynamicTypeValueReceiverWithPreUpdate<ZonedDateTime> consumer) {
List<DynamicDataNode<?>> resultBuilder = new ArrayList<>();
@@ -468,9 +445,8 @@
return new BoundDynamicTypeImpl(resultBuilder, mDynamicTypesQuotaManager);
}
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- BoundDynamicTypeImpl bindInternal(
+ @NonNull BoundDynamicTypeImpl bindInternal(
@NonNull DynamicBool boolSource,
@NonNull DynamicTypeValueReceiverWithPreUpdate<Boolean> consumer) {
List<DynamicDataNode<?>> resultBuilder = new ArrayList<>();
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeValueReceiver.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeValueReceiver.java
index 98da824..b701476 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeValueReceiver.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeValueReceiver.java
@@ -16,7 +16,7 @@
package androidx.wear.protolayout.expression.pipeline;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* Callback for an evaluation result. This is intended to support two-step updates; first a
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/EpochTimePlatformDataSource.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/EpochTimePlatformDataSource.java
index 4b56178..0183995 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/EpochTimePlatformDataSource.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/EpochTimePlatformDataSource.java
@@ -16,11 +16,12 @@
package androidx.wear.protolayout.expression.pipeline;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.annotation.VisibleForTesting;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
@@ -28,12 +29,12 @@
/** Utility for time data source. */
class EpochTimePlatformDataSource {
- @NonNull private final MainThreadExecutor mExecutor = new MainThreadExecutor();
+ private final @NonNull MainThreadExecutor mExecutor = new MainThreadExecutor();
- @NonNull final List<DynamicTypeValueReceiverWithPreUpdate<Instant>> mConsumerToTimeCallback =
+ final @NonNull List<DynamicTypeValueReceiverWithPreUpdate<Instant>> mConsumerToTimeCallback =
new ArrayList<>();
- @NonNull private final Supplier<Instant> mClock;
- @Nullable private final PlatformTimeUpdateNotifier mUpdateNotifier;
+ private final @NonNull Supplier<Instant> mClock;
+ private final @Nullable PlatformTimeUpdateNotifier mUpdateNotifier;
private int mPendingConsumers = 0;
EpochTimePlatformDataSource(
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/FixedQuotaManagerImpl.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/FixedQuotaManagerImpl.java
index 1dfbd3e..eed3b0a 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/FixedQuotaManagerImpl.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/FixedQuotaManagerImpl.java
@@ -16,16 +16,17 @@
package androidx.wear.protolayout.expression.pipeline;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.annotation.VisibleForTesting;
+import org.jspecify.annotations.NonNull;
+
/** Quota manager with fixed quota cap. This class is not thread safe. */
@RestrictTo(Scope.LIBRARY_GROUP)
public class FixedQuotaManagerImpl implements QuotaManager {
private final int mQuotaCap;
- @NonNull private final String mQuotaName;
+ private final @NonNull String mQuotaName;
private int mQuotaCounter = 0;
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/FloatNodes.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/FloatNodes.java
index 418cd36..823df57 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/FloatNodes.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/FloatNodes.java
@@ -18,8 +18,6 @@
import android.util.Log;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicFloat;
import androidx.wear.protolayout.expression.proto.AnimationParameterProto.AnimationSpec;
@@ -29,6 +27,9 @@
import androidx.wear.protolayout.expression.proto.DynamicProto.StateFloatSource;
import androidx.wear.protolayout.expression.proto.FixedProto.FixedFloat;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/** Dynamic data nodes which yield floats. */
class FloatNodes {
@@ -36,7 +37,7 @@
/** Dynamic float node that has a fixed value. */
static class FixedFloatNode implements DynamicDataSourceNode<Float> {
- @Nullable private final Float mValue;
+ private final @Nullable Float mValue;
private final DynamicTypeValueReceiverWithPreUpdate<Float> mDownstream;
FixedFloatNode(
@@ -286,8 +287,7 @@
return value != null && Float.isFinite(value);
}
- @Nullable
- private static Float getValidValueOrNull(Float value) {
+ private static @Nullable Float getValidValueOrNull(Float value) {
return isValid(value) ? value : null;
}
}
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/InstantNodes.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/InstantNodes.java
index aa3a242..a04b3fa 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/InstantNodes.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/InstantNodes.java
@@ -16,12 +16,13 @@
package androidx.wear.protolayout.expression.pipeline;
-import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.wear.protolayout.expression.DynamicBuilders;
import androidx.wear.protolayout.expression.proto.DynamicProto;
import androidx.wear.protolayout.expression.proto.FixedProto.FixedInstant;
+import org.jspecify.annotations.Nullable;
+
import java.time.Instant;
/** Dynamic data nodes which yield instants. */
@@ -62,7 +63,7 @@
/** Dynamic Instant node that gets value from the platform source. */
static class PlatformTimeSourceNode implements DynamicDataSourceNode<Integer> {
- @Nullable private final EpochTimePlatformDataSource mEpochTimePlatformDataSource;
+ private final @Nullable EpochTimePlatformDataSource mEpochTimePlatformDataSource;
private final DynamicTypeValueReceiverWithPreUpdate<Instant> mDownstream;
PlatformTimeSourceNode(
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/Int32Nodes.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/Int32Nodes.java
index 5ebece0..468b2fb 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/Int32Nodes.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/Int32Nodes.java
@@ -20,8 +20,6 @@
import android.util.Log;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicInt32;
import androidx.wear.protolayout.expression.DynamicDataKey;
@@ -40,6 +38,9 @@
import androidx.wear.protolayout.expression.proto.DynamicProto.ZonedDateTimePartType;
import androidx.wear.protolayout.expression.proto.FixedProto.FixedInt32;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.time.Duration;
import java.time.ZonedDateTime;
import java.util.function.Function;
@@ -96,8 +97,7 @@
downstream);
}
- @NonNull
- private static DynamicDataKey<?> getDataKey(PlatformInt32SourceType type) {
+ private static @NonNull DynamicDataKey<?> getDataKey(PlatformInt32SourceType type) {
if (type == PlatformInt32SourceType.PLATFORM_INT32_SOURCE_TYPE_CURRENT_HEART_RATE) {
return PlatformHealthSources.Keys.HEART_RATE_BPM;
}
@@ -110,8 +110,7 @@
"Unknown DynamicInt32 platform source type: " + type);
}
- @NonNull
- private static Function<DynamicDataValue, Integer> getStateExtractor(
+ private static @NonNull Function<DynamicDataValue, Integer> getStateExtractor(
PlatformInt32SourceType type) {
if (type == PlatformInt32SourceType.PLATFORM_INT32_SOURCE_TYPE_CURRENT_HEART_RATE) {
return se -> (int) se.getFloatVal().getValue();
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/NumberFormatter.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/NumberFormatter.java
index 36152d5..4da7fa1 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/NumberFormatter.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/NumberFormatter.java
@@ -29,12 +29,13 @@
import android.os.Build.VERSION_CODES;
import android.util.Log;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting;
import androidx.wear.protolayout.expression.proto.DynamicProto.FloatFormatOp;
import androidx.wear.protolayout.expression.proto.DynamicProto.Int32FormatOp;
+import org.jspecify.annotations.NonNull;
+
/** Utility to number formatting. */
class NumberFormatter {
@@ -121,18 +122,15 @@
@RequiresApi(VERSION_CODES.R)
private static class Api30Impl {
- @NonNull
- static String callFormatToString(LocalizedNumberFormatter mFmt, int value) {
+ static @NonNull String callFormatToString(LocalizedNumberFormatter mFmt, int value) {
return mFmt.format(value).toString();
}
- @NonNull
- static String callFormatToString(LocalizedNumberFormatter mFmt, float value) {
+ static @NonNull String callFormatToString(LocalizedNumberFormatter mFmt, float value) {
return mFmt.format(value).toString();
}
- @NonNull
- static LocalizedNumberFormatter buildLocalizedNumberFormatter(
+ static @NonNull LocalizedNumberFormatter buildLocalizedNumberFormatter(
int minIntegerDigits,
int minFractionDigits,
int maxFractionDigits,
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformDataProvider.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformDataProvider.java
index 91a5bf0..1739e61 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformDataProvider.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformDataProvider.java
@@ -16,9 +16,10 @@
package androidx.wear.protolayout.expression.pipeline;
-import androidx.annotation.NonNull;
import androidx.wear.protolayout.expression.PlatformDataKey;
+import org.jspecify.annotations.NonNull;
+
import java.util.Set;
import java.util.concurrent.Executor;
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformDataReceiver.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformDataReceiver.java
index 83b0336..38fd876 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformDataReceiver.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformDataReceiver.java
@@ -16,9 +16,10 @@
package androidx.wear.protolayout.expression.pipeline;
-import androidx.annotation.NonNull;
-import androidx.wear.protolayout.expression.PlatformDataValues;
import androidx.wear.protolayout.expression.PlatformDataKey;
+import androidx.wear.protolayout.expression.PlatformDataValues;
+
+import org.jspecify.annotations.NonNull;
import java.util.Set;
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformDataStore.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformDataStore.java
index 9014ce5..57a343f 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformDataStore.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformDataStore.java
@@ -20,8 +20,6 @@
import android.util.Log;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.UiThread;
import androidx.collection.ArrayMap;
@@ -31,6 +29,9 @@
import androidx.wear.protolayout.expression.PlatformDataValues;
import androidx.wear.protolayout.expression.proto.DynamicDataProto.DynamicDataValue;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
@@ -50,17 +51,14 @@
private final Executor mUiExecutor;
- @NonNull
- private final Map<PlatformDataKey<?>, DynamicDataValue> mCurrentPlatformData =
+ private final @NonNull Map<PlatformDataKey<?>, DynamicDataValue> mCurrentPlatformData =
new ArrayMap<>();
- @NonNull
- private final Map<DynamicDataKey<?>,
+ private final @NonNull Map<DynamicDataKey<?>,
Set<DynamicTypeValueReceiverWithPreUpdate<DynamicDataValue>>>
mRegisteredCallbacks = new ArrayMap<>();
- @NonNull
- private final Map<PlatformDataKey<?>, PlatformDataProvider>
+ private final @NonNull Map<PlatformDataKey<?>, PlatformDataProvider>
mSourceKeyToDataProviders = new ArrayMap<>();
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
@@ -143,9 +141,8 @@
/** Gets dynamic value with the given {@code key}. */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@UiThread
- @Nullable
@Override
- public DynamicDataValue getDynamicDataValuesProto(@NonNull DynamicDataKey<?> key) {
+ public @Nullable DynamicDataValue getDynamicDataValuesProto(@NonNull DynamicDataKey<?> key) {
return mCurrentPlatformData.get(key);
}
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformTimeUpdateNotifier.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformTimeUpdateNotifier.java
index 831417f..29d093e 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformTimeUpdateNotifier.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformTimeUpdateNotifier.java
@@ -16,7 +16,7 @@
package androidx.wear.protolayout.expression.pipeline;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
import java.util.concurrent.Executor;
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformTimeUpdateNotifierImpl.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformTimeUpdateNotifierImpl.java
index 19414ce..c48a468 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformTimeUpdateNotifierImpl.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/PlatformTimeUpdateNotifierImpl.java
@@ -21,11 +21,12 @@
import android.os.SystemClock;
import android.util.Log;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
@@ -37,11 +38,11 @@
public class PlatformTimeUpdateNotifierImpl implements PlatformTimeUpdateNotifier {
private static final String TAG = "PlatformTimeUpdateNotifierImpl";
private final Handler mUiHandler = new Handler(Looper.getMainLooper());
- @Nullable private Runnable mRegisteredReceiver;
+ private @Nullable Runnable mRegisteredReceiver;
private final Runnable mNotifyAndSchedule = this::notifyAndScheduleNextSecond;
private long mLastScheduleTimeMillis = 0;
private boolean mUpdatesEnabled = true;
- @Nullable private Executor mRegisteredExecutor;
+ private @Nullable Executor mRegisteredExecutor;
/**
* Sets the callback to be called whenever platform time needs to be reevaluated. Note that this
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/QuotaAwareAnimator.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/QuotaAwareAnimator.java
index 8d317c4..4df4162 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/QuotaAwareAnimator.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/QuotaAwareAnimator.java
@@ -29,13 +29,14 @@
import android.os.Handler;
import android.os.Looper;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.core.os.HandlerCompat;
import androidx.wear.protolayout.expression.pipeline.AnimationsHelper.RepeatDelays;
import androidx.wear.protolayout.expression.proto.AnimationParameterProto.AnimationSpec;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.concurrent.atomic.AtomicBoolean;
/**
@@ -44,17 +45,17 @@
* on wrapped {@link Animator} will be replaced.
*/
class QuotaAwareAnimator implements DynamicTypeAnimator {
- @NonNull protected final ValueAnimator mAnimator;
- @NonNull protected final QuotaManager mQuotaManager;
- @NonNull protected final QuotaReleasingAnimatorListener mListener;
- @NonNull protected final Handler mUiHandler;
+ protected final @NonNull ValueAnimator mAnimator;
+ protected final @NonNull QuotaManager mQuotaManager;
+ protected final @NonNull QuotaReleasingAnimatorListener mListener;
+ protected final @NonNull Handler mUiHandler;
private final long mStartDelay;
protected Runnable mAcquireQuotaAndAnimateRunnable = this::acquireQuotaAndAnimate;
- @NonNull protected final TypeEvaluator<?> mEvaluator;
- @Nullable protected Object mLastAnimatedValue;
+ protected final @NonNull TypeEvaluator<?> mEvaluator;
+ protected @Nullable Object mLastAnimatedValue;
- @Nullable private Object mStartValue = null; // To cache the start value
- @Nullable private Object mEndValue = null; // To cache the end value
+ private @Nullable Object mStartValue = null; // To cache the start value
+ private @Nullable Object mEndValue = null; // To cache the end value
private boolean mIsTerminal = false;
interface UpdateCallback {
@@ -102,9 +103,8 @@
mEvaluator = evaluator;
}
- @NonNull
@Override
- public TypeEvaluator<?> getTypeEvaluator() {
+ public @NonNull TypeEvaluator<?> getTypeEvaluator() {
return mEvaluator;
}
@@ -127,7 +127,7 @@
* @param values A set of values that the animation will animate between over time.
*/
@Override
- public void setFloatValues(@NonNull float... values) {
+ public void setFloatValues(float @NonNull ... values) {
setFloatValues(mAnimator, mEvaluator, values);
mStartValue = values[0];
mEndValue = values[values.length - 1];
@@ -153,7 +153,7 @@
* @param values A set of values that the animation will animate between over time.
*/
@Override
- public void setIntValues(@NonNull int... values) {
+ public void setIntValues(int @NonNull ... values) {
setIntValues(mAnimator, mEvaluator, values);
mStartValue = values[0];
mEndValue = values[values.length - 1];
@@ -165,8 +165,7 @@
* @return The start value of the animation or null if value wasn't set.
*/
@Override
- @Nullable
- public Object getStartValue() {
+ public @Nullable Object getStartValue() {
return mStartValue;
}
@@ -176,8 +175,7 @@
* @return The end value of the animation.
*/
@Override
- @Nullable
- public Object getEndValue() {
+ public @Nullable Object getEndValue() {
return mEndValue;
}
@@ -300,9 +298,8 @@
mAnimator.setCurrentPlayTime(adjustedTime);
}
- @Nullable
@Override
- public Object getCurrentValue() {
+ public @Nullable Object getCurrentValue() {
return mLastAnimatedValue;
}
@@ -350,17 +347,17 @@
* animation.
*/
protected static final class QuotaReleasingAnimatorListener extends AnimatorListenerAdapter {
- @NonNull private final QuotaManager mQuotaManager;
+ private final @NonNull QuotaManager mQuotaManager;
// We need to keep track of whether the animation has started because pipeline has initiated
// and it has received quota, or it is skipped by calling {@link android.animation
// .Animator#end()} because no quota is available.
- @NonNull final AtomicBoolean mIsUsingQuota = new AtomicBoolean(false);
+ final @NonNull AtomicBoolean mIsUsingQuota = new AtomicBoolean(false);
private final int mRepeatMode;
private final long mForwardRepeatDelay;
private final long mReverseRepeatDelay;
- @NonNull private final Handler mHandler;
+ private final @NonNull Handler mHandler;
@NonNull Runnable mResumeRepeatRunnable;
private boolean mIsReverse;
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/QuotaAwareAnimatorWithAux.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/QuotaAwareAnimatorWithAux.java
index fda3478..7cd3a4e 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/QuotaAwareAnimatorWithAux.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/QuotaAwareAnimatorWithAux.java
@@ -22,11 +22,12 @@
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
-import androidx.annotation.NonNull;
import androidx.core.os.HandlerCompat;
import androidx.wear.protolayout.expression.pipeline.AnimationsHelper.RepeatDelays;
import androidx.wear.protolayout.expression.proto.AnimationParameterProto.AnimationSpec;
+import org.jspecify.annotations.NonNull;
+
/**
* This class handles the animation with custom reverse duration. To have different duration for
* forward and reverse animations, two animators are played alternately as follows:
@@ -40,8 +41,8 @@
*/
class QuotaAwareAnimatorWithAux extends QuotaAwareAnimator {
- @NonNull private final QuotaReleasingAnimatorListener mAuxListener;
- @NonNull private final ValueAnimator mAuxAnimator;
+ private final @NonNull QuotaReleasingAnimatorListener mAuxListener;
+ private final @NonNull ValueAnimator mAuxAnimator;
private boolean mSuppressForwardUpdate = false;
private boolean mSuppressReverseUpdate = false;
private final boolean mEndsWithForward;
@@ -95,7 +96,7 @@
}
@Override
- public void setFloatValues(@NonNull float... values) {
+ public void setFloatValues(float @NonNull ... values) {
super.setFloatValues(values);
// Create a copy of the values array before reversing it
@@ -112,7 +113,7 @@
}
@Override
- public void setIntValues(@NonNull int... values) {
+ public void setIntValues(int @NonNull ... values) {
super.setIntValues(values);
// Create a copy of the values array before reversing it
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/StateSourceNode.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/StateSourceNode.java
index 090891f..9e35c92 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/StateSourceNode.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/StateSourceNode.java
@@ -16,7 +16,6 @@
package androidx.wear.protolayout.expression.pipeline;
-import androidx.annotation.NonNull;
import androidx.annotation.UiThread;
import androidx.wear.protolayout.expression.AppDataKey;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicType;
@@ -24,12 +23,14 @@
import androidx.wear.protolayout.expression.PlatformDataKey;
import androidx.wear.protolayout.expression.proto.DynamicDataProto.DynamicDataValue;
+import org.jspecify.annotations.NonNull;
+
import java.util.function.Function;
class StateSourceNode<T>
implements DynamicDataSourceNode<T>,
DynamicTypeValueReceiverWithPreUpdate<DynamicDataValue> {
- @NonNull private static final String RESERVED_NAMESPACE = "protolayout";
+ private static final @NonNull String RESERVED_NAMESPACE = "protolayout";
private final DataStore mDataStore;
private final DynamicDataKey<?> mKey;
private final Function<DynamicDataValue, T> mStateExtractor;
@@ -109,8 +110,7 @@
mInitialDataSent = true;
}
- @NonNull
- static <T extends DynamicType> DynamicDataKey<T> createKey(
+ static <T extends DynamicType> @NonNull DynamicDataKey<T> createKey(
@NonNull String namespace, @NonNull String key) {
if (namespace.isEmpty()) {
return new AppDataKey<T>(key);
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/StateStore.java b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/StateStore.java
index 310ab9f..c7b9355 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/StateStore.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/main/java/androidx/wear/protolayout/expression/pipeline/StateStore.java
@@ -20,8 +20,6 @@
import android.annotation.SuppressLint;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.UiThread;
import androidx.collection.ArrayMap;
@@ -31,6 +29,9 @@
import androidx.wear.protolayout.expression.DynamicDataKey;
import androidx.wear.protolayout.expression.proto.DynamicDataProto.DynamicDataValue;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Collections;
import java.util.Map;
import java.util.Map.Entry;
@@ -50,12 +51,11 @@
private static final String TAG = "ProtoLayoutStateStore";
- @NonNull private final Map<AppDataKey<?>, DynamicDataValue> mCurrentAppState
+ private final @NonNull Map<AppDataKey<?>, DynamicDataValue> mCurrentAppState
= new ArrayMap<>();
- @NonNull
private final
- Map<DynamicDataKey<?>,
+ @NonNull Map<DynamicDataKey<?>,
Set<DynamicTypeValueReceiverWithPreUpdate<DynamicDataValue>>>
mRegisteredCallbacks = new ArrayMap<>();
@@ -65,8 +65,7 @@
* @throws IllegalStateException if number of initialState entries is greater than
* {@link StateStore#getMaxStateEntryCount()}.
*/
- @NonNull
- public static StateStore create(
+ public static @NonNull StateStore create(
@NonNull Map<AppDataKey<?>, DynamicDataBuilders.DynamicDataValue<?>>
initialState) {
return new StateStore(toProto(initialState));
@@ -148,9 +147,8 @@
/** Gets dynamic value with the given {@code key}. */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@UiThread
- @Nullable
@Override
- public DynamicDataValue getDynamicDataValuesProto(@NonNull DynamicDataKey<?> key) {
+ public @Nullable DynamicDataValue getDynamicDataValuesProto(@NonNull DynamicDataKey<?> key) {
return mCurrentAppState.get(key);
}
@@ -192,23 +190,20 @@
return MAX_STATE_ENTRY_COUNT;
}
- @NonNull
- private static Map<AppDataKey<?>, DynamicDataValue> toProto(
+ private static @NonNull Map<AppDataKey<?>, DynamicDataValue> toProto(
@NonNull Map<AppDataKey<?>, DynamicDataBuilders.DynamicDataValue<?>> value) {
return value.entrySet().stream()
.collect(toMap(Entry::getKey, entry -> entry.getValue().toDynamicDataValueProto()));
}
- @NonNull
- private Set<AppDataKey<?>> getRemovedAppKeys(
+ private @NonNull Set<AppDataKey<?>> getRemovedAppKeys(
@NonNull Map<AppDataKey<?>, DynamicDataValue> newState) {
Set<AppDataKey<?>> result = new ArraySet<>(mCurrentAppState.keySet());
result.removeAll(newState.keySet());
return result;
}
- @NonNull
- private Map<AppDataKey<?>, DynamicDataValue> getChangedAppEntries(
+ private @NonNull Map<AppDataKey<?>, DynamicDataValue> getChangedAppEntries(
@NonNull Map<AppDataKey<?>, DynamicDataValue> newState) {
Map<AppDataKey<?>, DynamicDataValue> result = new ArrayMap<>();
for (Entry<AppDataKey<?>, DynamicDataValue> newEntry
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/AddToListCallback.java b/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/AddToListCallback.java
index 7c3e32a..ac2b12c 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/AddToListCallback.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/AddToListCallback.java
@@ -16,14 +16,14 @@
package androidx.wear.protolayout.expression.pipeline;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.util.List;
public class AddToListCallback<T> implements DynamicTypeValueReceiverWithPreUpdate<T> {
private final List<T> mListToUpdate;
- @Nullable private final List<Boolean> mInvalidListToUpdate;
+ private final @Nullable List<Boolean> mInvalidListToUpdate;
private int mPreUpdateCallCounts = 0;
private int mUpdateCallCount = 0;
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/AnimatableNodeTest.java b/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/AnimatableNodeTest.java
index 4c5cff9..c80ef26 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/AnimatableNodeTest.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/AnimatableNodeTest.java
@@ -24,7 +24,6 @@
import android.graphics.Color;
import android.os.Looper;
-import androidx.annotation.NonNull;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.wear.protolayout.expression.proto.AnimationParameterProto;
import androidx.wear.protolayout.expression.proto.AnimationParameterProto.AnimationParameters;
@@ -34,6 +33,7 @@
import com.google.common.collect.Iterables;
import com.google.common.collect.Range;
+import org.jspecify.annotations.NonNull;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -393,8 +393,7 @@
}
}
- @NonNull
- AnimationSpec createAnimationSpec(
+ @NonNull AnimationSpec createAnimationSpec(
int iterations,
int forwardDuration,
int reverseDuration,
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeEvaluatorTest.java b/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeEvaluatorTest.java
index 0abb008..61f3e3c 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeEvaluatorTest.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/DynamicTypeEvaluatorTest.java
@@ -26,7 +26,6 @@
import android.icu.util.ULocale;
-import androidx.annotation.NonNull;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.wear.protolayout.expression.AppDataKey;
import androidx.wear.protolayout.expression.DynamicBuilders;
@@ -37,6 +36,7 @@
import androidx.wear.protolayout.expression.proto.DynamicProto;
import androidx.wear.protolayout.expression.proto.FixedProto;
+import org.jspecify.annotations.NonNull;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -153,21 +153,18 @@
}
}
- @NonNull
- private static DynamicTypeBindingRequest createSingleNodeDynamicBoolRequest(
+ private static @NonNull DynamicTypeBindingRequest createSingleNodeDynamicBoolRequest(
ArrayList<Boolean> results) {
return createDynamicBoolRequest(DynamicBool.from(new AppDataKey<>("key")), results);
}
- @NonNull
- private static DynamicTypeBindingRequest createDynamicBoolRequest(
+ private static @NonNull DynamicTypeBindingRequest createDynamicBoolRequest(
DynamicBuilders.DynamicBool dynamicBool, ArrayList<Boolean> results) {
return DynamicTypeBindingRequest.forDynamicBool(
dynamicBool, new MainThreadExecutor(), new AddToListCallback<>(results));
}
- @NonNull
- private static DynamicTypeBindingRequest createExpressionWithUnrecognizedEnum(
+ private static @NonNull DynamicTypeBindingRequest createExpressionWithUnrecognizedEnum(
ArrayList<Integer> results) {
return DynamicTypeBindingRequest.forDynamicInt32Internal(
DynamicProto.DynamicInt32.newBuilder()
@@ -185,8 +182,8 @@
new AddToListCallback<Integer>(results));
}
- @NonNull
- private static DynamicTypeBindingRequest createSingleNodeDynamicStringFromTimePlatformRequest(
+ private static @NonNull DynamicTypeBindingRequest
+ createSingleNodeDynamicStringFromTimePlatformRequest(
ArrayList<String> results) {
return DynamicTypeBindingRequest.forDynamicString(
DynamicBuilders.DynamicInstant.platformTimeWithSecondsPrecision()
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/EpochTimePlatformDataSourceTest.java b/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/EpochTimePlatformDataSourceTest.java
index 50cf167..9037a9f 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/EpochTimePlatformDataSourceTest.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/EpochTimePlatformDataSourceTest.java
@@ -18,9 +18,9 @@
import static com.google.common.truth.Truth.assertThat;
-import androidx.annotation.NonNull;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import org.jspecify.annotations.NonNull;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/ParametrizedDynamicTypeEvaluatorTest.java b/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/ParametrizedDynamicTypeEvaluatorTest.java
index b839904..ccdb1bd 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/ParametrizedDynamicTypeEvaluatorTest.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/ParametrizedDynamicTypeEvaluatorTest.java
@@ -29,7 +29,6 @@
import android.os.Build;
import android.os.Looper;
-import androidx.annotation.NonNull;
import androidx.wear.protolayout.expression.AppDataKey;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicBool;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicColor;
@@ -50,6 +49,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import org.jspecify.annotations.NonNull;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.ParameterizedRobolectricTestRunner;
@@ -596,8 +596,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return mName + " = " + mExpectedValue;
}
}
diff --git a/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/PlatformDataStoreTest.java b/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/PlatformDataStoreTest.java
index ed58ef8..b370ee34 100644
--- a/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/PlatformDataStoreTest.java
+++ b/wear/protolayout/protolayout-expression-pipeline/src/test/java/androidx/wear/protolayout/expression/pipeline/PlatformDataStoreTest.java
@@ -20,18 +20,18 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import androidx.annotation.NonNull;
import androidx.collection.ArraySet;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.wear.protolayout.expression.DynamicBuilders;
import androidx.wear.protolayout.expression.DynamicDataBuilders;
-import androidx.wear.protolayout.expression.PlatformDataValues;
import androidx.wear.protolayout.expression.PlatformDataKey;
+import androidx.wear.protolayout.expression.PlatformDataValues;
import androidx.wear.protolayout.expression.proto.DynamicDataProto.DynamicDataValue;
import androidx.wear.protolayout.expression.proto.FixedProto;
import com.google.common.truth.Expect;
+import org.jspecify.annotations.NonNull;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/wear/protolayout/protolayout-expression/build.gradle b/wear/protolayout/protolayout-expression/build.gradle
index abb1fb2f..ca1d5f1 100644
--- a/wear/protolayout/protolayout-expression/build.gradle
+++ b/wear/protolayout/protolayout-expression/build.gradle
@@ -30,6 +30,7 @@
}
dependencies {
+ api(libs.jspecify)
annotationProcessor(libs.nullaway)
api("androidx.annotation:annotation:1.8.1")
diff --git a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/AnimationParameterBuilders.java b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/AnimationParameterBuilders.java
index a800b2a..240b8f2 100644
--- a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/AnimationParameterBuilders.java
+++ b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/AnimationParameterBuilders.java
@@ -20,14 +20,15 @@
import androidx.annotation.IntDef;
import androidx.annotation.IntRange;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.proto.AnimationParameterProto;
import androidx.wear.protolayout.protobuf.ExtensionRegistryLite;
import androidx.wear.protolayout.protobuf.InvalidProtocolBufferException;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -58,7 +59,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
public static final class AnimationSpec {
private final AnimationParameterProto.AnimationSpec mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AnimationSpec(
AnimationParameterProto.AnimationSpec impl, @Nullable Fingerprint fingerprint) {
@@ -67,8 +68,7 @@
}
/** Gets animation parameters including duration, easing and repeat delay. */
- @Nullable
- public AnimationParameters getAnimationParameters() {
+ public @Nullable AnimationParameters getAnimationParameters() {
if (mImpl.hasAnimationParameters()) {
return AnimationParameters.fromProto(mImpl.getAnimationParameters());
} else {
@@ -80,8 +80,7 @@
* Gets the repeatable mode to be used for specifying repetition parameters for the
* animation.
*/
- @Nullable
- public Repeatable getRepeatable() {
+ public @Nullable Repeatable getRepeatable() {
if (mImpl.hasRepeatable()) {
return Repeatable.fromProto(mImpl.getRepeatable());
} else {
@@ -91,16 +90,14 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AnimationSpec fromProto(
- @NonNull AnimationParameterProto.AnimationSpec proto,
+ public static @NonNull AnimationSpec fromProto(
+ AnimationParameterProto.@NonNull AnimationSpec proto,
@Nullable Fingerprint fingerprint) {
return new AnimationSpec(proto, fingerprint);
}
@@ -110,22 +107,19 @@
* object created using this method can't be added to any other wrapper.
*/
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AnimationSpec fromProto(
- @NonNull AnimationParameterProto.AnimationSpec proto) {
+ public static @NonNull AnimationSpec fromProto(
+ AnimationParameterProto.@NonNull AnimationSpec proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public AnimationParameterProto.AnimationSpec toProto() {
+ public AnimationParameterProto.@NonNull AnimationSpec toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AnimationSpec{"
+ "animationParameters="
+ getAnimationParameters()
@@ -145,8 +139,7 @@
/** Sets animation parameters including duration, easing and repeat delay. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setAnimationParameters(
+ public @NonNull Builder setAnimationParameters(
@NonNull AnimationParameters animationParameters) {
mImpl.setAnimationParameters(animationParameters.toProto());
mFingerprint.recordPropertyUpdate(
@@ -160,8 +153,7 @@
* animation. If not set, animation won't be repeated.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setRepeatable(@NonNull Repeatable repeatable) {
+ public @NonNull Builder setRepeatable(@NonNull Repeatable repeatable) {
mImpl.setRepeatable(repeatable.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(repeatable.getFingerprint()).aggregateValueAsInt());
@@ -169,8 +161,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public AnimationSpec build() {
+ public @NonNull AnimationSpec build() {
return new AnimationSpec(mImpl.build(), mFingerprint);
}
}
@@ -180,7 +171,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
public static final class AnimationParameters {
private final AnimationParameterProto.AnimationParameters mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AnimationParameters(
AnimationParameterProto.AnimationParameters impl,
@@ -196,8 +187,7 @@
}
/** Gets the easing to be used for adjusting an animation's fraction. */
- @Nullable
- public Easing getEasing() {
+ public @Nullable Easing getEasing() {
if (mImpl.hasEasing()) {
return AnimationParameterBuilders.easingFromProto(mImpl.getEasing());
} else {
@@ -217,36 +207,31 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AnimationParameters fromProto(
- @NonNull AnimationParameterProto.AnimationParameters proto,
+ public static @NonNull AnimationParameters fromProto(
+ AnimationParameterProto.@NonNull AnimationParameters proto,
@Nullable Fingerprint fingerprint) {
return new AnimationParameters(proto, fingerprint);
}
- @NonNull
- static AnimationParameters fromProto(
- @NonNull AnimationParameterProto.AnimationParameters proto) {
+ static @NonNull AnimationParameters fromProto(
+ AnimationParameterProto.@NonNull AnimationParameters proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public AnimationParameterProto.AnimationParameters toProto() {
+ public AnimationParameterProto.@NonNull AnimationParameters toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AnimationParameters{"
+ "durationMillis="
+ getDurationMillis()
@@ -270,8 +255,7 @@
* Sets the duration of the animation in milliseconds. If not set, defaults to 300ms.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setDurationMillis(@IntRange(from = 0) long durationMillis) {
+ public @NonNull Builder setDurationMillis(@IntRange(from = 0) long durationMillis) {
mImpl.setDurationMillis(durationMillis);
mFingerprint.recordPropertyUpdate(1, Long.hashCode(durationMillis));
return this;
@@ -282,8 +266,7 @@
* defaults to Linear Interpolator.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setEasing(@NonNull Easing easing) {
+ public @NonNull Builder setEasing(@NonNull Easing easing) {
mImpl.setEasing(easing.toEasingProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(easing.getFingerprint()).aggregateValueAsInt());
@@ -296,16 +279,14 @@
* before repeating animation in milliseconds. If not set, no delay will be applied.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setDelayMillis(@IntRange(from = 0) long delayMillis) {
+ public @NonNull Builder setDelayMillis(@IntRange(from = 0) long delayMillis) {
mImpl.setDelayMillis(delayMillis);
mFingerprint.recordPropertyUpdate(3, Long.hashCode(delayMillis));
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public AnimationParameters build() {
+ public @NonNull AnimationParameters build() {
return new AnimationParameters(mImpl.build(), mFingerprint);
}
}
@@ -332,8 +313,7 @@
* and the second control point is tangent to the easing at the point (1, 1).
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- static Easing cubicBezier(float x1, float y1, float x2, float y2) {
+ static @NonNull Easing cubicBezier(float x1, float y1, float x2, float y2) {
return new CubicBezierEasing.Builder().setX1(x1).setY1(y1).setX2(x2).setY2(y2).build();
}
@@ -347,8 +327,7 @@
* <p>This is equivalent to the Compose {@code FastOutSlowInEasing}.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- Easing FAST_OUT_SLOW_IN_EASING = cubicBezier(0.4f, 0.0f, 0.2f, 1.0f);
+ @NonNull Easing FAST_OUT_SLOW_IN_EASING = cubicBezier(0.4f, 0.0f, 0.2f, 1.0f);
/**
* Incoming elements are animated using deceleration easing, which starts a transition at
@@ -357,8 +336,7 @@
* <p>This is equivalent to the Compose {@code LinearOutSlowInEasing}.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- Easing LINEAR_OUT_SLOW_IN_EASING = cubicBezier(0.0f, 0.0f, 0.2f, 1.0f);
+ @NonNull Easing LINEAR_OUT_SLOW_IN_EASING = cubicBezier(0.0f, 0.0f, 0.2f, 1.0f);
/**
* Elements exiting a screen use acceleration easing, where they start at rest and end at
@@ -367,17 +345,14 @@
* <p>This is equivalent to the Compose {@code FastOutLinearInEasing}.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- Easing FAST_OUT_LINEAR_IN_EASING = cubicBezier(0.4f, 0.0f, 1.0f, 1.0f);
+ @NonNull Easing FAST_OUT_LINEAR_IN_EASING = cubicBezier(0.4f, 0.0f, 1.0f, 1.0f);
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- AnimationParameterProto.Easing toEasingProto();
+ AnimationParameterProto.@NonNull Easing toEasingProto();
/** Creates a {@link Easing} from a byte array generated by {@link #toEasingByteArray()}. */
- @NonNull
- static Easing fromByteArray(@NonNull byte[] byteArray) {
+ static @NonNull Easing fromByteArray(byte @NonNull [] byteArray) {
try {
return easingFromProto(
AnimationParameterProto.Easing.parseFrom(
@@ -388,39 +363,34 @@
}
/** Creates a byte array that can later be used with {@link #fromByteArray(byte[])}. */
- @NonNull
- default byte[] toEasingByteArray() {
+ default byte @NonNull [] toEasingByteArray() {
return toEasingProto().toByteArray();
}
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link Easing} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- Easing build();
+ @NonNull Easing build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Easing easingFromProto(
- @NonNull AnimationParameterProto.Easing proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Easing easingFromProto(
+ AnimationParameterProto.@NonNull Easing proto, @Nullable Fingerprint fingerprint) {
if (proto.hasCubicBezier()) {
return CubicBezierEasing.fromProto(proto.getCubicBezier(), fingerprint);
}
throw new IllegalStateException("Proto was not a recognised instance of Easing");
}
- @NonNull
- static Easing easingFromProto(@NonNull AnimationParameterProto.Easing proto) {
+ static @NonNull Easing easingFromProto(AnimationParameterProto.@NonNull Easing proto) {
return easingFromProto(proto, null);
}
@@ -431,7 +401,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class CubicBezierEasing implements Easing {
private final AnimationParameterProto.CubicBezierEasing mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
CubicBezierEasing(
AnimationParameterProto.CubicBezierEasing impl, @Nullable Fingerprint fingerprint) {
@@ -473,42 +443,36 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static CubicBezierEasing fromProto(
- @NonNull AnimationParameterProto.CubicBezierEasing proto,
+ public static @NonNull CubicBezierEasing fromProto(
+ AnimationParameterProto.@NonNull CubicBezierEasing proto,
@Nullable Fingerprint fingerprint) {
return new CubicBezierEasing(proto, fingerprint);
}
- @NonNull
- static CubicBezierEasing fromProto(
- @NonNull AnimationParameterProto.CubicBezierEasing proto) {
+ static @NonNull CubicBezierEasing fromProto(
+ AnimationParameterProto.@NonNull CubicBezierEasing proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- AnimationParameterProto.CubicBezierEasing toProto() {
+ AnimationParameterProto.@NonNull CubicBezierEasing toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public AnimationParameterProto.Easing toEasingProto() {
+ public AnimationParameterProto.@NonNull Easing toEasingProto() {
return AnimationParameterProto.Easing.newBuilder().setCubicBezier(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "CubicBezierEasing{"
+ "x1="
+ getX1()
@@ -535,8 +499,7 @@
* and the first control point is tangent to the easing at the point (0, 0).
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setX1(float x1) {
+ public @NonNull Builder setX1(float x1) {
mImpl.setX1(x1);
mFingerprint.recordPropertyUpdate(1, Float.floatToIntBits(x1));
return this;
@@ -547,8 +510,7 @@
* and the first control point is tangent to the easing at the point (0, 0).
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setY1(float y1) {
+ public @NonNull Builder setY1(float y1) {
mImpl.setY1(y1);
mFingerprint.recordPropertyUpdate(2, Float.floatToIntBits(y1));
return this;
@@ -559,8 +521,7 @@
* and the second control point is tangent to the easing at the point (1, 1).
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setX2(float x2) {
+ public @NonNull Builder setX2(float x2) {
mImpl.setX2(x2);
mFingerprint.recordPropertyUpdate(3, Float.floatToIntBits(x2));
return this;
@@ -571,16 +532,14 @@
* and the second control point is tangent to the easing at the point (1, 1).
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setY2(float y2) {
+ public @NonNull Builder setY2(float y2) {
mImpl.setY2(y2);
mFingerprint.recordPropertyUpdate(4, Float.floatToIntBits(y2));
return this;
}
@Override
- @NonNull
- public CubicBezierEasing build() {
+ public @NonNull CubicBezierEasing build() {
return new CubicBezierEasing(mImpl.build(), mFingerprint);
}
}
@@ -603,7 +562,7 @@
new Repeatable.Builder().setRepeatMode(REPEAT_MODE_REVERSE).build();
private final AnimationParameterProto.Repeatable mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Repeatable(AnimationParameterProto.Repeatable impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -635,8 +594,7 @@
}
/** Gets optional custom parameters for the forward passes of animation. */
- @Nullable
- public AnimationParameters getForwardRepeatOverride() {
+ public @Nullable AnimationParameters getForwardRepeatOverride() {
if (mImpl.hasForwardRepeatOverride()) {
return AnimationParameters.fromProto(mImpl.getForwardRepeatOverride());
} else {
@@ -645,8 +603,7 @@
}
/** Gets optional custom parameters for the reverse passes of animation. */
- @Nullable
- public AnimationParameters getReverseRepeatOverride() {
+ public @Nullable AnimationParameters getReverseRepeatOverride() {
if (mImpl.hasReverseRepeatOverride()) {
return AnimationParameters.fromProto(mImpl.getReverseRepeatOverride());
} else {
@@ -656,29 +613,25 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Repeatable fromProto(
- @NonNull AnimationParameterProto.Repeatable proto,
+ public static @NonNull Repeatable fromProto(
+ AnimationParameterProto.@NonNull Repeatable proto,
@Nullable Fingerprint fingerprint) {
return new Repeatable(proto, fingerprint);
}
- @NonNull
- static Repeatable fromProto(@NonNull AnimationParameterProto.Repeatable proto) {
+ static @NonNull Repeatable fromProto(AnimationParameterProto.@NonNull Repeatable proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public AnimationParameterProto.Repeatable toProto() {
+ public AnimationParameterProto.@NonNull Repeatable toProto() {
return mImpl;
}
@@ -687,8 +640,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Repeatable{"
+ "iterations="
+ getIterations()
@@ -715,8 +667,7 @@
* defaults to repeating infinitely.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setIterations(@IntRange(from = 1) int iterations) {
+ public @NonNull Builder setIterations(@IntRange(from = 1) int iterations) {
mImpl.setIterations(iterations);
mFingerprint.recordPropertyUpdate(1, iterations);
return this;
@@ -727,8 +678,7 @@
* defaults to restart.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setRepeatMode(@RepeatMode int repeatMode) {
+ public @NonNull Builder setRepeatMode(@RepeatMode int repeatMode) {
mImpl.setRepeatMode(AnimationParameterProto.RepeatMode.forNumber(repeatMode));
mFingerprint.recordPropertyUpdate(2, repeatMode);
return this;
@@ -739,8 +689,7 @@
* the main animation parameters set outside of {@link Repeatable}.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setForwardRepeatOverride(
+ public @NonNull Builder setForwardRepeatOverride(
@NonNull AnimationParameters forwardRepeatOverride) {
mImpl.setForwardRepeatOverride(forwardRepeatOverride.toProto());
mFingerprint.recordPropertyUpdate(
@@ -754,8 +703,7 @@
* the main animation parameters set outside of {@link Repeatable}.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setReverseRepeatOverride(
+ public @NonNull Builder setReverseRepeatOverride(
@NonNull AnimationParameters reverseRepeatOverride) {
mImpl.setReverseRepeatOverride(reverseRepeatOverride.toProto());
mFingerprint.recordPropertyUpdate(
@@ -765,8 +713,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Repeatable build() {
+ public @NonNull Repeatable build() {
return new Repeatable(mImpl.build(), mFingerprint);
}
}
diff --git a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/AppDataKey.java b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/AppDataKey.java
index 9f5d2b6..d3bfd7b 100644
--- a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/AppDataKey.java
+++ b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/AppDataKey.java
@@ -16,7 +16,7 @@
package androidx.wear.protolayout.expression;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* Represent a {@link DynamicDataKey} that references app/tile pushed state data.
@@ -24,7 +24,7 @@
* @param <T> The data type of the dynamic values that this key is bound to.
*/
public final class AppDataKey<T extends DynamicBuilders.DynamicType> extends DynamicDataKey<T> {
- @NonNull private static final String DEFAULT_NAMESPACE = "";
+ private static final @NonNull String DEFAULT_NAMESPACE = "";
/**
* Create a {@link AppDataKey} with the specified key.
diff --git a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/ConditionScopes.java b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/ConditionScopes.java
index 5a088b9..536d30f 100644
--- a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/ConditionScopes.java
+++ b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/ConditionScopes.java
@@ -16,9 +16,10 @@
package androidx.wear.protolayout.expression;
-import androidx.annotation.NonNull;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicType;
+import org.jspecify.annotations.NonNull;
+
import java.util.function.Function;
/**
@@ -48,14 +49,12 @@
}
/** Sets the value to use as the value when true in a conditional expression. */
- @NonNull
- public IfTrueScope<T, RawT> use(T valueWhenTrue) {
+ public @NonNull IfTrueScope<T, RawT> use(T valueWhenTrue) {
return new IfTrueScope<>(valueWhenTrue, conditionBuilder, rawTypeMapper);
}
/** Sets the value to use as the value when true in a conditional expression. */
- @NonNull
- public IfTrueScope<T, RawT> use(RawT valueWhenTrue) {
+ public @NonNull IfTrueScope<T, RawT> use(RawT valueWhenTrue) {
return use(rawTypeMapper.apply(valueWhenTrue));
}
}
diff --git a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/DynamicBuilders.java b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/DynamicBuilders.java
index 552a1b8..7938a11 100644
--- a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/DynamicBuilders.java
+++ b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/DynamicBuilders.java
@@ -23,8 +23,6 @@
import androidx.annotation.ColorInt;
import androidx.annotation.IntDef;
import androidx.annotation.IntRange;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.AnimationParameterBuilders.AnimationSpec;
@@ -43,6 +41,9 @@
import androidx.wear.protolayout.protobuf.CodedOutputStream;
import androidx.wear.protolayout.protobuf.ExtensionRegistryLite;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -370,7 +371,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class PlatformInt32Source implements DynamicInt32 {
private final DynamicProto.PlatformInt32Source mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
PlatformInt32Source(
DynamicProto.PlatformInt32Source impl, @Nullable Fingerprint fingerprint) {
@@ -386,42 +387,37 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static PlatformInt32Source fromProto(
- @NonNull DynamicProto.PlatformInt32Source proto,
+ public static @NonNull PlatformInt32Source fromProto(
+ DynamicProto.@NonNull PlatformInt32Source proto,
@Nullable Fingerprint fingerprint) {
return new PlatformInt32Source(proto, fingerprint);
}
- @NonNull
- static PlatformInt32Source fromProto(@NonNull DynamicProto.PlatformInt32Source proto) {
+ static @NonNull PlatformInt32Source fromProto(
+ DynamicProto.@NonNull PlatformInt32Source proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.PlatformInt32Source toProto() {
+ DynamicProto.@NonNull PlatformInt32Source toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto() {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto() {
return DynamicProto.DynamicInt32.newBuilder().setPlatformSource(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicInt32.newBuilder()
.setPlatformSource(mImpl)
@@ -432,8 +428,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "PlatformInt32Source{" + "sourceType=" + getSourceType() + "}";
}
@@ -447,16 +442,14 @@
/** Sets the source to load data from. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setSourceType(@PlatformInt32SourceType int sourceType) {
+ public @NonNull Builder setSourceType(@PlatformInt32SourceType int sourceType) {
mImpl.setSourceType(DynamicProto.PlatformInt32SourceType.forNumber(sourceType));
mFingerprint.recordPropertyUpdate(1, sourceType);
return this;
}
@Override
- @NonNull
- public PlatformInt32Source build() {
+ public @NonNull PlatformInt32Source build() {
return new PlatformInt32Source(mImpl.build(), mFingerprint);
}
}
@@ -471,7 +464,7 @@
static final class ArithmeticInt32Op implements DynamicInt32 {
private final DynamicProto.ArithmeticInt32Op mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ArithmeticInt32Op(DynamicProto.ArithmeticInt32Op impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -479,8 +472,7 @@
}
/** Gets left hand side of the arithmetic operation. */
- @Nullable
- public DynamicInt32 getInputLhs() {
+ public @Nullable DynamicInt32 getInputLhs() {
if (mImpl.hasInputLhs()) {
return DynamicBuilders.dynamicInt32FromProto(mImpl.getInputLhs());
} else {
@@ -489,8 +481,7 @@
}
/** Gets right hand side of the arithmetic operation. */
- @Nullable
- public DynamicInt32 getInputRhs() {
+ public @Nullable DynamicInt32 getInputRhs() {
if (mImpl.hasInputRhs()) {
return DynamicBuilders.dynamicInt32FromProto(mImpl.getInputRhs());
} else {
@@ -507,42 +498,36 @@
/** */
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ArithmeticInt32Op fromProto(
- @NonNull DynamicProto.ArithmeticInt32Op proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ArithmeticInt32Op fromProto(
+ DynamicProto.@NonNull ArithmeticInt32Op proto, @Nullable Fingerprint fingerprint) {
return new ArithmeticInt32Op(proto, fingerprint);
}
- @NonNull
- static ArithmeticInt32Op fromProto(@NonNull DynamicProto.ArithmeticInt32Op proto) {
+ static @NonNull ArithmeticInt32Op fromProto(DynamicProto.@NonNull ArithmeticInt32Op proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.ArithmeticInt32Op toProto() {
+ DynamicProto.@NonNull ArithmeticInt32Op toProto() {
return mImpl;
}
/** */
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto() {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto() {
return DynamicProto.DynamicInt32.newBuilder().setArithmeticOperation(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicInt32.newBuilder()
.setArithmeticOperation(mImpl)
@@ -553,8 +538,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ArithmeticInt32Op{"
+ "inputLhs="
+ getInputLhs()
@@ -576,8 +560,7 @@
/** Sets left hand side of the arithmetic operation. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInputLhs(@NonNull DynamicInt32 inputLhs) {
+ public @NonNull Builder setInputLhs(@NonNull DynamicInt32 inputLhs) {
mImpl.setInputLhs(inputLhs.toDynamicInt32Proto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(inputLhs.getFingerprint()).aggregateValueAsInt());
@@ -586,8 +569,7 @@
/** Sets right hand side of the arithmetic operation. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInputRhs(@NonNull DynamicInt32 inputRhs) {
+ public @NonNull Builder setInputRhs(@NonNull DynamicInt32 inputRhs) {
mImpl.setInputRhs(inputRhs.toDynamicInt32Proto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(inputRhs.getFingerprint()).aggregateValueAsInt());
@@ -596,16 +578,14 @@
/** Sets the type of operation to carry out. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setOperationType(@ArithmeticOpType int operationType) {
+ public @NonNull Builder setOperationType(@ArithmeticOpType int operationType) {
mImpl.setOperationType(DynamicProto.ArithmeticOpType.forNumber(operationType));
mFingerprint.recordPropertyUpdate(3, operationType);
return this;
}
@Override
- @NonNull
- public ArithmeticInt32Op build() {
+ public @NonNull ArithmeticInt32Op build() {
return new ArithmeticInt32Op(mImpl.build(), mFingerprint);
}
}
@@ -615,7 +595,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class StateInt32Source implements DynamicInt32 {
private final DynamicProto.StateInt32Source mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
StateInt32Source(DynamicProto.StateInt32Source impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -623,54 +603,46 @@
}
/** Gets the key in the state to bind to. */
- @NonNull
- public String getSourceKey() {
+ public @NonNull String getSourceKey() {
return mImpl.getSourceKey();
}
/** Gets the namespace for the state key. */
- @NonNull
- public String getSourceNamespace() {
+ public @NonNull String getSourceNamespace() {
return mImpl.getSourceNamespace();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static StateInt32Source fromProto(
- @NonNull DynamicProto.StateInt32Source proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull StateInt32Source fromProto(
+ DynamicProto.@NonNull StateInt32Source proto, @Nullable Fingerprint fingerprint) {
return new StateInt32Source(proto, fingerprint);
}
- @NonNull
- static StateInt32Source fromProto(@NonNull DynamicProto.StateInt32Source proto) {
+ static @NonNull StateInt32Source fromProto(DynamicProto.@NonNull StateInt32Source proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.StateInt32Source toProto() {
+ DynamicProto.@NonNull StateInt32Source toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto() {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto() {
return DynamicProto.DynamicInt32.newBuilder().setStateSource(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicInt32.newBuilder()
.setStateSource(mImpl)
@@ -681,8 +653,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "StateInt32Source{"
+ "sourceKey="
+ getSourceKey()
@@ -701,8 +672,7 @@
/** Sets the key in the state to bind to. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setSourceKey(@NonNull String sourceKey) {
+ public @NonNull Builder setSourceKey(@NonNull String sourceKey) {
mImpl.setSourceKey(sourceKey);
mFingerprint.recordPropertyUpdate(1, sourceKey.hashCode());
return this;
@@ -710,16 +680,14 @@
/** Sets the namespace for the state key. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setSourceNamespace(@NonNull String sourceNamespace) {
+ public @NonNull Builder setSourceNamespace(@NonNull String sourceNamespace) {
mImpl.setSourceNamespace(sourceNamespace);
mFingerprint.recordPropertyUpdate(2, sourceNamespace.hashCode());
return this;
}
@Override
- @NonNull
- public StateInt32Source build() {
+ public @NonNull StateInt32Source build() {
return new StateInt32Source(mImpl.build(), mFingerprint);
}
}
@@ -733,7 +701,7 @@
static final class ConditionalInt32Op implements DynamicInt32 {
private final DynamicProto.ConditionalInt32Op mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ConditionalInt32Op(
DynamicProto.ConditionalInt32Op impl, @Nullable Fingerprint fingerprint) {
@@ -742,8 +710,7 @@
}
/** Gets the condition to use. */
- @Nullable
- public DynamicBool getCondition() {
+ public @Nullable DynamicBool getCondition() {
if (mImpl.hasCondition()) {
return DynamicBuilders.dynamicBoolFromProto(mImpl.getCondition());
} else {
@@ -752,8 +719,7 @@
}
/** Gets the integer to yield if condition is true. */
- @Nullable
- public DynamicInt32 getValueIfTrue() {
+ public @Nullable DynamicInt32 getValueIfTrue() {
if (mImpl.hasValueIfTrue()) {
return DynamicBuilders.dynamicInt32FromProto(mImpl.getValueIfTrue());
} else {
@@ -762,8 +728,7 @@
}
/** Gets the integer to yield if condition is false. */
- @Nullable
- public DynamicInt32 getValueIfFalse() {
+ public @Nullable DynamicInt32 getValueIfFalse() {
if (mImpl.hasValueIfFalse()) {
return DynamicBuilders.dynamicInt32FromProto(mImpl.getValueIfFalse());
} else {
@@ -774,42 +739,37 @@
/** */
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ConditionalInt32Op fromProto(
- @NonNull DynamicProto.ConditionalInt32Op proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ConditionalInt32Op fromProto(
+ DynamicProto.@NonNull ConditionalInt32Op proto, @Nullable Fingerprint fingerprint) {
return new ConditionalInt32Op(proto, fingerprint);
}
- @NonNull
- static ConditionalInt32Op fromProto(@NonNull DynamicProto.ConditionalInt32Op proto) {
+ static @NonNull ConditionalInt32Op fromProto(
+ DynamicProto.@NonNull ConditionalInt32Op proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.ConditionalInt32Op toProto() {
+ DynamicProto.@NonNull ConditionalInt32Op toProto() {
return mImpl;
}
/** */
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto() {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto() {
return DynamicProto.DynamicInt32.newBuilder().setConditionalOp(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicInt32.newBuilder()
.setConditionalOp(mImpl)
@@ -820,8 +780,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ConditionalInt32Op{"
+ "condition="
+ getCondition()
@@ -843,8 +802,7 @@
/** Sets the condition to use. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setCondition(@NonNull DynamicBool condition) {
+ public @NonNull Builder setCondition(@NonNull DynamicBool condition) {
mImpl.setCondition(condition.toDynamicBoolProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(condition.getFingerprint()).aggregateValueAsInt());
@@ -853,8 +811,7 @@
/** Sets the integer to yield if condition is true. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setValueIfTrue(@NonNull DynamicInt32 valueIfTrue) {
+ public @NonNull Builder setValueIfTrue(@NonNull DynamicInt32 valueIfTrue) {
mImpl.setValueIfTrue(valueIfTrue.toDynamicInt32Proto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(valueIfTrue.getFingerprint()).aggregateValueAsInt());
@@ -863,8 +820,7 @@
/** Sets the integer to yield if condition is false. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setValueIfFalse(@NonNull DynamicInt32 valueIfFalse) {
+ public @NonNull Builder setValueIfFalse(@NonNull DynamicInt32 valueIfFalse) {
mImpl.setValueIfFalse(valueIfFalse.toDynamicInt32Proto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(valueIfFalse.getFingerprint()).aggregateValueAsInt());
@@ -872,8 +828,7 @@
}
@Override
- @NonNull
- public ConditionalInt32Op build() {
+ public @NonNull ConditionalInt32Op build() {
return new ConditionalInt32Op(mImpl.build(), mFingerprint);
}
}
@@ -887,7 +842,7 @@
static final class ConditionalFloatOp implements DynamicFloat {
private final DynamicProto.ConditionalFloatOp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ConditionalFloatOp(
DynamicProto.ConditionalFloatOp impl, @Nullable Fingerprint fingerprint) {
@@ -896,8 +851,7 @@
}
/** Gets the condition to use. */
- @Nullable
- public DynamicBool getCondition() {
+ public @Nullable DynamicBool getCondition() {
if (mImpl.hasCondition()) {
return DynamicBuilders.dynamicBoolFromProto(mImpl.getCondition());
} else {
@@ -906,8 +860,7 @@
}
/** Gets the float to yield if condition is true. */
- @Nullable
- public DynamicFloat getValueIfTrue() {
+ public @Nullable DynamicFloat getValueIfTrue() {
if (mImpl.hasValueIfTrue()) {
return DynamicBuilders.dynamicFloatFromProto(mImpl.getValueIfTrue());
} else {
@@ -916,8 +869,7 @@
}
/** Gets the float to yield if condition is false. */
- @Nullable
- public DynamicFloat getValueIfFalse() {
+ public @Nullable DynamicFloat getValueIfFalse() {
if (mImpl.hasValueIfFalse()) {
return DynamicBuilders.dynamicFloatFromProto(mImpl.getValueIfFalse());
} else {
@@ -928,42 +880,37 @@
/** */
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ConditionalFloatOp fromProto(
- @NonNull DynamicProto.ConditionalFloatOp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ConditionalFloatOp fromProto(
+ DynamicProto.@NonNull ConditionalFloatOp proto, @Nullable Fingerprint fingerprint) {
return new ConditionalFloatOp(proto, fingerprint);
}
- @NonNull
- static ConditionalFloatOp fromProto(@NonNull DynamicProto.ConditionalFloatOp proto) {
+ static @NonNull ConditionalFloatOp fromProto(
+ DynamicProto.@NonNull ConditionalFloatOp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.ConditionalFloatOp toProto() {
+ DynamicProto.@NonNull ConditionalFloatOp toProto() {
return mImpl;
}
/** */
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicFloat toDynamicFloatProto() {
+ public DynamicProto.@NonNull DynamicFloat toDynamicFloatProto() {
return DynamicProto.DynamicFloat.newBuilder().setConditionalOp(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicFloat toDynamicFloatProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicFloat toDynamicFloatProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicFloat.newBuilder()
.setConditionalOp(mImpl)
@@ -974,8 +921,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ConditionalFloatOp{"
+ "condition="
+ getCondition()
@@ -997,8 +943,7 @@
/** Sets the condition to use. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setCondition(@NonNull DynamicBool condition) {
+ public @NonNull Builder setCondition(@NonNull DynamicBool condition) {
mImpl.setCondition(condition.toDynamicBoolProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(condition.getFingerprint()).aggregateValueAsInt());
@@ -1007,8 +952,7 @@
/** Sets the float to yield if condition is true. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setValueIfTrue(@NonNull DynamicFloat valueIfTrue) {
+ public @NonNull Builder setValueIfTrue(@NonNull DynamicFloat valueIfTrue) {
mImpl.setValueIfTrue(valueIfTrue.toDynamicFloatProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(valueIfTrue.getFingerprint()).aggregateValueAsInt());
@@ -1017,8 +961,7 @@
/** Sets the float to yield if condition is false. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setValueIfFalse(@NonNull DynamicFloat valueIfFalse) {
+ public @NonNull Builder setValueIfFalse(@NonNull DynamicFloat valueIfFalse) {
mImpl.setValueIfFalse(valueIfFalse.toDynamicFloatProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(valueIfFalse.getFingerprint()).aggregateValueAsInt());
@@ -1026,8 +969,7 @@
}
@Override
- @NonNull
- public ConditionalFloatOp build() {
+ public @NonNull ConditionalFloatOp build() {
return new ConditionalFloatOp(mImpl.build(), mFingerprint);
}
}
@@ -1037,7 +979,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class FloatToInt32Op implements DynamicInt32 {
private final DynamicProto.FloatToInt32Op mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FloatToInt32Op(DynamicProto.FloatToInt32Op impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -1045,8 +987,7 @@
}
/** Gets the float to round. */
- @Nullable
- public DynamicFloat getInput() {
+ public @Nullable DynamicFloat getInput() {
if (mImpl.hasInput()) {
return DynamicBuilders.dynamicFloatFromProto(mImpl.getInput());
} else {
@@ -1062,41 +1003,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static FloatToInt32Op fromProto(
- @NonNull DynamicProto.FloatToInt32Op proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull FloatToInt32Op fromProto(
+ DynamicProto.@NonNull FloatToInt32Op proto, @Nullable Fingerprint fingerprint) {
return new FloatToInt32Op(proto, fingerprint);
}
- @NonNull
- static FloatToInt32Op fromProto(@NonNull DynamicProto.FloatToInt32Op proto) {
+ static @NonNull FloatToInt32Op fromProto(DynamicProto.@NonNull FloatToInt32Op proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.FloatToInt32Op toProto() {
+ DynamicProto.@NonNull FloatToInt32Op toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto() {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto() {
return DynamicProto.DynamicInt32.newBuilder().setFloatToInt(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicInt32.newBuilder()
.setFloatToInt(mImpl)
@@ -1107,8 +1042,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "FloatToInt32Op{"
+ "input="
+ getInput()
@@ -1127,8 +1061,7 @@
/** Sets the float to round. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInput(@NonNull DynamicFloat input) {
+ public @NonNull Builder setInput(@NonNull DynamicFloat input) {
mImpl.setInput(input.toDynamicFloatProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(input.getFingerprint()).aggregateValueAsInt());
@@ -1137,16 +1070,14 @@
/** Sets the rounding mode to use. Defaults to ROUND_MODE_FLOOR if not specified. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setRoundMode(@FloatToInt32RoundMode int roundMode) {
+ public @NonNull Builder setRoundMode(@FloatToInt32RoundMode int roundMode) {
mImpl.setRoundMode(DynamicProto.FloatToInt32RoundMode.forNumber(roundMode));
mFingerprint.recordPropertyUpdate(2, roundMode);
return this;
}
@Override
- @NonNull
- public FloatToInt32Op build() {
+ public @NonNull FloatToInt32Op build() {
return new FloatToInt32Op(mImpl.build(), mFingerprint);
}
}
@@ -1156,7 +1087,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class AnimatableFixedInt32 implements DynamicInt32 {
private final DynamicProto.AnimatableFixedInt32 mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AnimatableFixedInt32(
DynamicProto.AnimatableFixedInt32 impl, @Nullable Fingerprint fingerprint) {
@@ -1175,8 +1106,7 @@
}
/** Gets the animation parameters for duration, delay, etc. */
- @Nullable
- public AnimationSpec getAnimationSpec() {
+ public @Nullable AnimationSpec getAnimationSpec() {
if (mImpl.hasAnimationSpec()) {
return AnimationSpec.fromProto(mImpl.getAnimationSpec());
} else {
@@ -1186,42 +1116,37 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AnimatableFixedInt32 fromProto(
- @NonNull DynamicProto.AnimatableFixedInt32 proto,
+ public static @NonNull AnimatableFixedInt32 fromProto(
+ DynamicProto.@NonNull AnimatableFixedInt32 proto,
@Nullable Fingerprint fingerprint) {
return new AnimatableFixedInt32(proto, fingerprint);
}
- @NonNull
- static AnimatableFixedInt32 fromProto(@NonNull DynamicProto.AnimatableFixedInt32 proto) {
+ static @NonNull AnimatableFixedInt32 fromProto(
+ DynamicProto.@NonNull AnimatableFixedInt32 proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.AnimatableFixedInt32 toProto() {
+ DynamicProto.@NonNull AnimatableFixedInt32 toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto() {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto() {
return DynamicProto.DynamicInt32.newBuilder().setAnimatableFixed(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicInt32.newBuilder()
.setAnimatableFixed(mImpl)
@@ -1232,8 +1157,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AnimatableFixedInt32{"
+ "fromValue="
+ getFromValue()
@@ -1254,8 +1178,7 @@
/** Sets the value to start animating from. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setFromValue(int fromValue) {
+ public @NonNull Builder setFromValue(int fromValue) {
mImpl.setFromValue(fromValue);
mFingerprint.recordPropertyUpdate(1, fromValue);
return this;
@@ -1263,8 +1186,7 @@
/** Sets the value to animate to. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setToValue(int toValue) {
+ public @NonNull Builder setToValue(int toValue) {
mImpl.setToValue(toValue);
mFingerprint.recordPropertyUpdate(2, toValue);
return this;
@@ -1272,8 +1194,7 @@
/** Sets the animation parameters for duration, delay, etc. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
+ public @NonNull Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
mImpl.setAnimationSpec(animationSpec.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(animationSpec.getFingerprint()).aggregateValueAsInt());
@@ -1281,8 +1202,7 @@
}
@Override
- @NonNull
- public AnimatableFixedInt32 build() {
+ public @NonNull AnimatableFixedInt32 build() {
return new AnimatableFixedInt32(mImpl.build(), mFingerprint);
}
}
@@ -1300,7 +1220,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class AnimatableDynamicInt32 implements DynamicInt32 {
private final DynamicProto.AnimatableDynamicInt32 mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AnimatableDynamicInt32(
DynamicProto.AnimatableDynamicInt32 impl, @Nullable Fingerprint fingerprint) {
@@ -1309,8 +1229,7 @@
}
/** Gets the value to watch, and animate when it changes. */
- @Nullable
- public DynamicInt32 getInput() {
+ public @Nullable DynamicInt32 getInput() {
if (mImpl.hasInput()) {
return dynamicInt32FromProto(mImpl.getInput());
} else {
@@ -1319,8 +1238,7 @@
}
/** Gets the animation parameters for duration, delay, etc. */
- @Nullable
- public AnimationSpec getAnimationSpec() {
+ public @Nullable AnimationSpec getAnimationSpec() {
if (mImpl.hasAnimationSpec()) {
return AnimationSpec.fromProto(mImpl.getAnimationSpec());
} else {
@@ -1330,43 +1248,37 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AnimatableDynamicInt32 fromProto(
- @NonNull DynamicProto.AnimatableDynamicInt32 proto,
+ public static @NonNull AnimatableDynamicInt32 fromProto(
+ DynamicProto.@NonNull AnimatableDynamicInt32 proto,
@Nullable Fingerprint fingerprint) {
return new AnimatableDynamicInt32(proto, fingerprint);
}
- @NonNull
- static AnimatableDynamicInt32 fromProto(
- @NonNull DynamicProto.AnimatableDynamicInt32 proto) {
+ static @NonNull AnimatableDynamicInt32 fromProto(
+ DynamicProto.@NonNull AnimatableDynamicInt32 proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.AnimatableDynamicInt32 toProto() {
+ DynamicProto.@NonNull AnimatableDynamicInt32 toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto() {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto() {
return DynamicProto.DynamicInt32.newBuilder().setAnimatableDynamic(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicInt32.newBuilder()
.setAnimatableDynamic(mImpl)
@@ -1377,8 +1289,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AnimatableDynamicInt32{"
+ "input="
+ getInput()
@@ -1397,8 +1308,7 @@
/** Sets the value to watch, and animate when it changes. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInput(@NonNull DynamicInt32 input) {
+ public @NonNull Builder setInput(@NonNull DynamicInt32 input) {
mImpl.setInput(input.toDynamicInt32Proto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(input.getFingerprint()).aggregateValueAsInt());
@@ -1407,8 +1317,7 @@
/** Sets the animation parameters for duration, delay, etc. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
+ public @NonNull Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
mImpl.setAnimationSpec(animationSpec.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(animationSpec.getFingerprint()).aggregateValueAsInt());
@@ -1416,8 +1325,7 @@
}
@Override
- @NonNull
- public AnimatableDynamicInt32 build() {
+ public @NonNull AnimatableDynamicInt32 build() {
return new AnimatableDynamicInt32(mImpl.build(), mFingerprint);
}
}
@@ -1448,13 +1356,11 @@
public interface DynamicInt32 extends DynamicType {
/** Get the protocol buffer representation of this object, without fingerprint. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DynamicProto.DynamicInt32 toDynamicInt32Proto();
+ DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto();
/** Get the protocol buffer representation of this object, with or without fingerprint. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DynamicProto.DynamicInt32 toDynamicInt32Proto(boolean withFingerprint);
+ DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto(boolean withFingerprint);
/**
* Creates a {@link DynamicInt32} from a byte array generated by {@link
@@ -1462,8 +1368,7 @@
*
* @throws IllegalArgumentException if the byte array does not contain a valid serialization
*/
- @NonNull
- static DynamicInt32 fromByteArray(@NonNull byte[] byteArray) {
+ static @NonNull DynamicInt32 fromByteArray(byte @NonNull [] byteArray) {
return fromByteArray(byteArray, 0, byteArray.length);
}
@@ -1474,8 +1379,8 @@
* @throws IllegalArgumentException if the byte array does not contain a valid serialization
* in the provided offset and length
*/
- @NonNull
- static DynamicInt32 fromByteArray(@NonNull byte[] byteArray, int offset, int length) {
+ static @NonNull DynamicInt32 fromByteArray(byte @NonNull [] byteArray, int offset,
+ int length) {
try {
return dynamicInt32FromProto(
DynamicProto.DynamicInt32.parseFrom(
@@ -1491,8 +1396,7 @@
* Serializes the {@link DynamicInt32} into a new byte array that can later be used with
* {@link #fromByteArray(byte[])}.
*/
- @NonNull
- default byte[] toDynamicInt32ByteArray() {
+ default byte @NonNull [] toDynamicInt32ByteArray() {
return toDynamicInt32Proto(/* withFingerprint= */ true).toByteArray();
}
@@ -1503,7 +1407,7 @@
*
* @throws IllegalArgumentException if the byte array is too small
*/
- default int toDynamicInt32ByteArray(@NonNull byte[] byteArray) {
+ default int toDynamicInt32ByteArray(byte @NonNull [] byteArray) {
return toDynamicInt32ByteArray(byteArray, 0, byteArray.length);
}
@@ -1514,7 +1418,7 @@
*
* @throws IllegalArgumentException if the byte array is too small
*/
- default int toDynamicInt32ByteArray(@NonNull byte[] byteArray, int offset, int length) {
+ default int toDynamicInt32ByteArray(byte @NonNull [] byteArray, int offset, int length) {
CodedOutputStream stream = CodedOutputStream.newInstance(byteArray, offset, length);
try {
toDynamicInt32Proto(/* withFingerprint= */ true).writeTo(stream);
@@ -1526,9 +1430,8 @@
}
/** Creates a constant-valued {@link DynamicInt32}. */
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicInt32 constant(int constant) {
+ static @NonNull DynamicInt32 constant(int constant) {
return new FixedInt32.Builder().setValue(constant).build();
}
@@ -1537,9 +1440,8 @@
*
* @param dynamicDataKey The source key to a {@link DynamicDataValue} with an int value.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicInt32 from(@NonNull DynamicDataKey<DynamicInt32> dynamicDataKey) {
+ static @NonNull DynamicInt32 from(@NonNull DynamicDataKey<DynamicInt32> dynamicDataKey) {
return new StateInt32Source.Builder()
.setSourceKey(dynamicDataKey.getKey())
.setSourceNamespace(dynamicDataKey.getNamespace())
@@ -1553,8 +1455,7 @@
* @param end The end value of the range.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- static DynamicInt32 animate(int start, int end) {
+ static @NonNull DynamicInt32 animate(int start, int end) {
return new AnimatableFixedInt32.Builder().setFromValue(start).setToValue(end).build();
}
@@ -1567,8 +1468,8 @@
* @param animationSpec The animation parameters.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- static DynamicInt32 animate(int start, int end, @NonNull AnimationSpec animationSpec) {
+ static @NonNull DynamicInt32 animate(int start, int end,
+ @NonNull AnimationSpec animationSpec) {
return new AnimatableFixedInt32.Builder()
.setFromValue(start)
.setToValue(end)
@@ -1584,8 +1485,7 @@
* @param dynamicDataKey The source key to a {@link DynamicDataValue} with an int value.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- static DynamicInt32 animate(@NonNull DynamicDataKey<DynamicInt32> dynamicDataKey) {
+ static @NonNull DynamicInt32 animate(@NonNull DynamicDataKey<DynamicInt32> dynamicDataKey) {
return new AnimatableDynamicInt32.Builder().setInput(from(dynamicDataKey)).build();
}
@@ -1598,8 +1498,7 @@
* @param animationSpec The animation parameters.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- static DynamicInt32 animate(
+ static @NonNull DynamicInt32 animate(
@NonNull DynamicDataKey<DynamicInt32> dynamicDataKey,
@NonNull AnimationSpec animationSpec) {
return new AnimatableDynamicInt32.Builder()
@@ -1616,8 +1515,7 @@
* @param animationSpec The animation parameters.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- default DynamicInt32 animate(@NonNull AnimationSpec animationSpec) {
+ default @NonNull DynamicInt32 animate(@NonNull AnimationSpec animationSpec) {
return new AnimatableDynamicInt32.Builder()
.setInput(this)
.setAnimationSpec(animationSpec)
@@ -1630,8 +1528,7 @@
* value.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- default DynamicInt32 animate() {
+ default @NonNull DynamicInt32 animate() {
return new AnimatableDynamicInt32.Builder().setInput(this).build();
}
@@ -1639,8 +1536,7 @@
* Convert the value represented by this {@link DynamicInt32} into a {@link DynamicFloat}.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- default DynamicFloat asFloat() {
+ default @NonNull DynamicFloat asFloat() {
return new Int32ToFloatOp.Builder().setInput(this).build();
}
@@ -1651,8 +1547,8 @@
* condition}.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- static ConditionScope<DynamicInt32, Integer> onCondition(@NonNull DynamicBool condition) {
+ static @NonNull ConditionScope<DynamicInt32, Integer> onCondition(
+ @NonNull DynamicBool condition) {
return new ConditionScopes.ConditionScope<>(
(trueValue, falseValue) ->
new ConditionalInt32Op.Builder()
@@ -1680,8 +1576,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicInt32 plus(@NonNull DynamicInt32 other) {
+ default @NonNull DynamicInt32 plus(@NonNull DynamicInt32 other) {
return new ArithmeticInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -1706,8 +1601,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicFloat plus(@NonNull DynamicFloat other) {
+ default @NonNull DynamicFloat plus(@NonNull DynamicFloat other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this.asFloat())
.setInputRhs(other)
@@ -1731,8 +1625,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicInt32 plus(int other) {
+ default @NonNull DynamicInt32 plus(int other) {
return new ArithmeticInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -1757,8 +1650,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicFloat plus(float other) {
+ default @NonNull DynamicFloat plus(float other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this.asFloat())
.setInputRhs(DynamicFloat.constant(other))
@@ -1783,8 +1675,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicInt32 minus(@NonNull DynamicInt32 other) {
+ default @NonNull DynamicInt32 minus(@NonNull DynamicInt32 other) {
return new ArithmeticInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -1809,8 +1700,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicFloat minus(@NonNull DynamicFloat other) {
+ default @NonNull DynamicFloat minus(@NonNull DynamicFloat other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this.asFloat())
.setInputRhs(other)
@@ -1835,8 +1725,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicInt32 minus(int other) {
+ default @NonNull DynamicInt32 minus(int other) {
return new ArithmeticInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -1861,8 +1750,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicFloat minus(float other) {
+ default @NonNull DynamicFloat minus(float other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this.asFloat())
.setInputRhs(DynamicFloat.constant(other))
@@ -1887,8 +1775,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicInt32 times(@NonNull DynamicInt32 other) {
+ default @NonNull DynamicInt32 times(@NonNull DynamicInt32 other) {
return new ArithmeticInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -1913,8 +1800,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicFloat times(@NonNull DynamicFloat other) {
+ default @NonNull DynamicFloat times(@NonNull DynamicFloat other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this.asFloat())
.setInputRhs(other)
@@ -1939,8 +1825,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicInt32 times(int other) {
+ default @NonNull DynamicInt32 times(int other) {
return new ArithmeticInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -1965,8 +1850,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicFloat times(float other) {
+ default @NonNull DynamicFloat times(float other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this.asFloat())
.setInputRhs(DynamicFloat.constant(other))
@@ -1991,8 +1875,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicInt32 div(@NonNull DynamicInt32 other) {
+ default @NonNull DynamicInt32 div(@NonNull DynamicInt32 other) {
return new ArithmeticInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -2017,8 +1900,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicFloat div(@NonNull DynamicFloat other) {
+ default @NonNull DynamicFloat div(@NonNull DynamicFloat other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this.asFloat())
.setInputRhs(other)
@@ -2043,8 +1925,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicInt32 div(int other) {
+ default @NonNull DynamicInt32 div(int other) {
return new ArithmeticInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -2069,8 +1950,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicFloat div(float other) {
+ default @NonNull DynamicFloat div(float other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this.asFloat())
.setInputRhs(DynamicFloat.constant(other))
@@ -2095,8 +1975,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicInt32 rem(@NonNull DynamicInt32 other) {
+ default @NonNull DynamicInt32 rem(@NonNull DynamicInt32 other) {
return new ArithmeticInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -2121,8 +2000,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicFloat rem(@NonNull DynamicFloat other) {
+ default @NonNull DynamicFloat rem(@NonNull DynamicFloat other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this.asFloat())
.setInputRhs(other)
@@ -2147,8 +2025,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicInt32 rem(int other) {
+ default @NonNull DynamicInt32 rem(int other) {
return new ArithmeticInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -2173,8 +2050,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressWarnings("KotlinOperator")
- @NonNull
- default DynamicFloat rem(float other) {
+ default @NonNull DynamicFloat rem(float other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this.asFloat())
.setInputRhs(DynamicFloat.constant(other))
@@ -2187,8 +2063,7 @@
* {@code other} are equal, otherwise it's false.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- default DynamicBool eq(@NonNull DynamicInt32 other) {
+ default @NonNull DynamicBool eq(@NonNull DynamicInt32 other) {
return new ComparisonInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -2201,8 +2076,7 @@
* {@code other} are equal, otherwise it's false.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- default DynamicBool eq(int other) {
+ default @NonNull DynamicBool eq(int other) {
return new ComparisonInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -2215,8 +2089,7 @@
* {@code other} are not equal, otherwise it's false.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- default DynamicBool ne(@NonNull DynamicInt32 other) {
+ default @NonNull DynamicBool ne(@NonNull DynamicInt32 other) {
return new ComparisonInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -2229,8 +2102,7 @@
* {@code other} are not equal, otherwise it's false.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- default DynamicBool ne(int other) {
+ default @NonNull DynamicBool ne(int other) {
return new ComparisonInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -2243,8 +2115,7 @@
* less than {@code other}, otherwise it's false.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- default DynamicBool lt(@NonNull DynamicInt32 other) {
+ default @NonNull DynamicBool lt(@NonNull DynamicInt32 other) {
return new ComparisonInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -2257,8 +2128,7 @@
* less than {@code other}, otherwise it's false.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- default DynamicBool lt(int other) {
+ default @NonNull DynamicBool lt(int other) {
return new ComparisonInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -2271,8 +2141,7 @@
* less than or equal to {@code other}, otherwise it's false.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- default DynamicBool lte(@NonNull DynamicInt32 other) {
+ default @NonNull DynamicBool lte(@NonNull DynamicInt32 other) {
return new ComparisonInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -2285,8 +2154,7 @@
* less than or equal to {@code other}, otherwise it's false.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- default DynamicBool lte(int other) {
+ default @NonNull DynamicBool lte(int other) {
return new ComparisonInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -2299,8 +2167,7 @@
* greater than {@code other}, otherwise it's false.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- default DynamicBool gt(@NonNull DynamicInt32 other) {
+ default @NonNull DynamicBool gt(@NonNull DynamicInt32 other) {
return new ComparisonInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -2313,8 +2180,7 @@
* greater than {@code other}, otherwise it's false.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- default DynamicBool gt(int other) {
+ default @NonNull DynamicBool gt(int other) {
return new ComparisonInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -2327,8 +2193,7 @@
* greater than or equal to {@code other}, otherwise it's false.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- default DynamicBool gte(@NonNull DynamicInt32 other) {
+ default @NonNull DynamicBool gte(@NonNull DynamicInt32 other) {
return new ComparisonInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -2341,8 +2206,7 @@
* greater than or equal to {@code other}, otherwise it's false.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- default DynamicBool gte(int other) {
+ default @NonNull DynamicBool gte(int other) {
return new ComparisonInt32Op.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -2362,8 +2226,7 @@
* The resulted {@link DynamicString} is subject to being truncated if it's too long.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- default DynamicString format() {
+ default @NonNull DynamicString format() {
return new IntFormatter.Builder().build().getInt32FormatOp(this);
}
@@ -2384,8 +2247,7 @@
* @param formatter The formatting parameter.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- default DynamicString format(@NonNull IntFormatter formatter) {
+ default @NonNull DynamicString format(@NonNull IntFormatter formatter) {
return formatter.getInt32FormatOp(this);
}
@@ -2394,14 +2256,13 @@
private final Int32FormatOp.Builder mInt32FormatOpBuilder;
private final Int32FormatOp mInt32FormatOp;
- IntFormatter(@NonNull Int32FormatOp.Builder int32FormatOpBuilder) {
+ IntFormatter(Int32FormatOp.@NonNull Builder int32FormatOpBuilder) {
mInt32FormatOpBuilder = int32FormatOpBuilder;
mInt32FormatOp = int32FormatOpBuilder.build();
}
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- Int32FormatOp getInt32FormatOp(@NonNull DynamicInt32 dynamicInt32) {
+ @NonNull Int32FormatOp getInt32FormatOp(@NonNull DynamicInt32 dynamicInt32) {
return mInt32FormatOpBuilder.setInput(dynamicInt32).build();
}
@@ -2430,9 +2291,9 @@
* specified. If minIntegerDigits is zero and the -1 < input < 1, the Integer part
* will not appear.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- public Builder setMinIntegerDigits(@IntRange(from = 0) int minIntegerDigits) {
+ public @NonNull Builder setMinIntegerDigits(
+ @IntRange(from = 0) int minIntegerDigits) {
mBuilder.setMinIntegerDigits(minIntegerDigits);
return this;
}
@@ -2451,16 +2312,14 @@
* .setGroupingUsed(true).build());
* </pre>
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- public Builder setGroupingUsed(boolean groupingUsed) {
+ public @NonNull Builder setGroupingUsed(boolean groupingUsed) {
mBuilder.setGroupingUsed(groupingUsed);
return this;
}
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- public IntFormatter build() {
+ public @NonNull IntFormatter build() {
throwIfExceedingMaxValue(
"MinIntegerDigits",
mBuilder.build().getMinIntegerDigits(),
@@ -2482,24 +2341,21 @@
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link DynamicInt32} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- DynamicInt32 build();
+ @NonNull DynamicInt32 build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DynamicInt32 dynamicInt32FromProto(
- @NonNull DynamicProto.DynamicInt32 proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull DynamicInt32 dynamicInt32FromProto(
+ DynamicProto.@NonNull DynamicInt32 proto, @Nullable Fingerprint fingerprint) {
if (proto.hasFixed()) {
return FixedInt32.fromProto(proto.getFixed(), fingerprint);
}
@@ -2538,8 +2394,8 @@
* created using this method can't be added to any other wrapper.
*/
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DynamicInt32 dynamicInt32FromProto(@NonNull DynamicProto.DynamicInt32 proto) {
+ public static @NonNull DynamicInt32 dynamicInt32FromProto(
+ DynamicProto.@NonNull DynamicInt32 proto) {
return dynamicInt32FromProto(proto, new Fingerprint(proto.getFingerprint()));
}
@@ -2547,7 +2403,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class Int32FormatOp implements DynamicString {
private final DynamicProto.Int32FormatOp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Int32FormatOp(DynamicProto.Int32FormatOp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -2555,8 +2411,7 @@
}
/** Gets the source of Int32 data to convert to a string. */
- @Nullable
- public DynamicInt32 getInput() {
+ public @Nullable DynamicInt32 getInput() {
if (mImpl.hasInput()) {
return DynamicBuilders.dynamicInt32FromProto(mImpl.getInput());
} else {
@@ -2585,41 +2440,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Int32FormatOp fromProto(
- @NonNull DynamicProto.Int32FormatOp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Int32FormatOp fromProto(
+ DynamicProto.@NonNull Int32FormatOp proto, @Nullable Fingerprint fingerprint) {
return new Int32FormatOp(proto, fingerprint);
}
- @NonNull
- static Int32FormatOp fromProto(@NonNull DynamicProto.Int32FormatOp proto) {
+ static @NonNull Int32FormatOp fromProto(DynamicProto.@NonNull Int32FormatOp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.Int32FormatOp toProto() {
+ DynamicProto.@NonNull Int32FormatOp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicString toDynamicStringProto() {
+ public DynamicProto.@NonNull DynamicString toDynamicStringProto() {
return DynamicProto.DynamicString.newBuilder().setInt32FormatOp(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicString toDynamicStringProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicString toDynamicStringProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicString.newBuilder()
.setInt32FormatOp(mImpl)
@@ -2630,8 +2479,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Int32FormatOp{"
+ "input="
+ getInput()
@@ -2652,8 +2500,7 @@
/** Sets the source of Int32 data to convert to a string. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInput(@NonNull DynamicInt32 input) {
+ public @NonNull Builder setInput(@NonNull DynamicInt32 input) {
mImpl.setInput(input.toDynamicInt32Proto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(input.getFingerprint()).aggregateValueAsInt());
@@ -2666,8 +2513,7 @@
* for locale en_US, applying minIntegerDigit=4 to 12 would yield "0012".
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setMinIntegerDigits(@IntRange(from = 0) int minIntegerDigits) {
+ public @NonNull Builder setMinIntegerDigits(@IntRange(from = 0) int minIntegerDigits) {
mImpl.setMinIntegerDigits(minIntegerDigits);
mFingerprint.recordPropertyUpdate(4, minIntegerDigits);
return this;
@@ -2680,16 +2526,14 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setGroupingUsed(boolean groupingUsed) {
+ public @NonNull Builder setGroupingUsed(boolean groupingUsed) {
mImpl.setGroupingUsed(groupingUsed);
mFingerprint.recordPropertyUpdate(5, Boolean.hashCode(groupingUsed));
return this;
}
@Override
- @NonNull
- public Int32FormatOp build() {
+ public @NonNull Int32FormatOp build() {
return new Int32FormatOp(mImpl.build(), mFingerprint);
}
}
@@ -2699,7 +2543,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class StateStringSource implements DynamicString {
private final DynamicProto.StateStringSource mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
StateStringSource(DynamicProto.StateStringSource impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -2707,54 +2551,46 @@
}
/** Gets the key in the state to bind to. */
- @NonNull
- public String getSourceKey() {
+ public @NonNull String getSourceKey() {
return mImpl.getSourceKey();
}
/** Gets the namespace for the state key. */
- @NonNull
- public String getSourceNamespace() {
+ public @NonNull String getSourceNamespace() {
return mImpl.getSourceNamespace();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static StateStringSource fromProto(
- @NonNull DynamicProto.StateStringSource proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull StateStringSource fromProto(
+ DynamicProto.@NonNull StateStringSource proto, @Nullable Fingerprint fingerprint) {
return new StateStringSource(proto, fingerprint);
}
- @NonNull
- static StateStringSource fromProto(@NonNull DynamicProto.StateStringSource proto) {
+ static @NonNull StateStringSource fromProto(DynamicProto.@NonNull StateStringSource proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.StateStringSource toProto() {
+ DynamicProto.@NonNull StateStringSource toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicString toDynamicStringProto() {
+ public DynamicProto.@NonNull DynamicString toDynamicStringProto() {
return DynamicProto.DynamicString.newBuilder().setStateSource(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicString toDynamicStringProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicString toDynamicStringProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicString.newBuilder()
.setStateSource(mImpl)
@@ -2765,8 +2601,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "StateStringSource{"
+ "sourceKey="
+ getSourceKey()
@@ -2785,8 +2620,7 @@
/** Sets the key in the state to bind to. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setSourceKey(@NonNull String sourceKey) {
+ public @NonNull Builder setSourceKey(@NonNull String sourceKey) {
mImpl.setSourceKey(sourceKey);
mFingerprint.recordPropertyUpdate(1, sourceKey.hashCode());
return this;
@@ -2794,16 +2628,14 @@
/** Sets the namespace for the state key. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setSourceNamespace(@NonNull String sourceNamespace) {
+ public @NonNull Builder setSourceNamespace(@NonNull String sourceNamespace) {
mImpl.setSourceNamespace(sourceNamespace);
mFingerprint.recordPropertyUpdate(2, sourceNamespace.hashCode());
return this;
}
@Override
- @NonNull
- public StateStringSource build() {
+ public @NonNull StateStringSource build() {
return new StateStringSource(mImpl.build(), mFingerprint);
}
}
@@ -2816,7 +2648,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class ConditionalStringOp implements DynamicString {
private final DynamicProto.ConditionalStringOp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ConditionalStringOp(
DynamicProto.ConditionalStringOp impl, @Nullable Fingerprint fingerprint) {
@@ -2825,8 +2657,7 @@
}
/** Gets the condition to use. */
- @Nullable
- public DynamicBool getCondition() {
+ public @Nullable DynamicBool getCondition() {
if (mImpl.hasCondition()) {
return DynamicBuilders.dynamicBoolFromProto(mImpl.getCondition());
} else {
@@ -2835,8 +2666,7 @@
}
/** Gets the string to yield if condition is true. */
- @Nullable
- public DynamicString getValueIfTrue() {
+ public @Nullable DynamicString getValueIfTrue() {
if (mImpl.hasValueIfTrue()) {
return DynamicBuilders.dynamicStringFromProto(mImpl.getValueIfTrue());
} else {
@@ -2845,8 +2675,7 @@
}
/** Gets the string to yield if condition is false. */
- @Nullable
- public DynamicString getValueIfFalse() {
+ public @Nullable DynamicString getValueIfFalse() {
if (mImpl.hasValueIfFalse()) {
return DynamicBuilders.dynamicStringFromProto(mImpl.getValueIfFalse());
} else {
@@ -2856,42 +2685,37 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ConditionalStringOp fromProto(
- @NonNull DynamicProto.ConditionalStringOp proto,
+ public static @NonNull ConditionalStringOp fromProto(
+ DynamicProto.@NonNull ConditionalStringOp proto,
@Nullable Fingerprint fingerprint) {
return new ConditionalStringOp(proto, fingerprint);
}
- @NonNull
- static ConditionalStringOp fromProto(@NonNull DynamicProto.ConditionalStringOp proto) {
+ static @NonNull ConditionalStringOp fromProto(
+ DynamicProto.@NonNull ConditionalStringOp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.ConditionalStringOp toProto() {
+ DynamicProto.@NonNull ConditionalStringOp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicString toDynamicStringProto() {
+ public DynamicProto.@NonNull DynamicString toDynamicStringProto() {
return DynamicProto.DynamicString.newBuilder().setConditionalOp(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicString toDynamicStringProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicString toDynamicStringProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicString.newBuilder()
.setConditionalOp(mImpl)
@@ -2902,8 +2726,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ConditionalStringOp{"
+ "condition="
+ getCondition()
@@ -2924,8 +2747,7 @@
/** Sets the condition to use. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setCondition(@NonNull DynamicBool condition) {
+ public @NonNull Builder setCondition(@NonNull DynamicBool condition) {
mImpl.setCondition(condition.toDynamicBoolProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(condition.getFingerprint()).aggregateValueAsInt());
@@ -2934,8 +2756,7 @@
/** Sets the string to yield if condition is true. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setValueIfTrue(@NonNull DynamicString valueIfTrue) {
+ public @NonNull Builder setValueIfTrue(@NonNull DynamicString valueIfTrue) {
mImpl.setValueIfTrue(valueIfTrue.toDynamicStringProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(valueIfTrue.getFingerprint()).aggregateValueAsInt());
@@ -2944,8 +2765,7 @@
/** Sets the string to yield if condition is false. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setValueIfFalse(@NonNull DynamicString valueIfFalse) {
+ public @NonNull Builder setValueIfFalse(@NonNull DynamicString valueIfFalse) {
mImpl.setValueIfFalse(valueIfFalse.toDynamicStringProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(valueIfFalse.getFingerprint()).aggregateValueAsInt());
@@ -2953,8 +2773,7 @@
}
@Override
- @NonNull
- public ConditionalStringOp build() {
+ public @NonNull ConditionalStringOp build() {
return new ConditionalStringOp(mImpl.build(), mFingerprint);
}
}
@@ -2965,7 +2784,7 @@
static final class ConcatStringOp implements DynamicString {
private final DynamicProto.ConcatStringOp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ConcatStringOp(DynamicProto.ConcatStringOp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -2973,8 +2792,7 @@
}
/** Gets left hand side of the concatenation operation. */
- @Nullable
- public DynamicString getInputLhs() {
+ public @Nullable DynamicString getInputLhs() {
if (mImpl.hasInputLhs()) {
return DynamicBuilders.dynamicStringFromProto(mImpl.getInputLhs());
} else {
@@ -2983,8 +2801,7 @@
}
/** Gets right hand side of the concatenation operation. */
- @Nullable
- public DynamicString getInputRhs() {
+ public @Nullable DynamicString getInputRhs() {
if (mImpl.hasInputRhs()) {
return DynamicBuilders.dynamicStringFromProto(mImpl.getInputRhs());
} else {
@@ -2994,41 +2811,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ConcatStringOp fromProto(
- @NonNull DynamicProto.ConcatStringOp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ConcatStringOp fromProto(
+ DynamicProto.@NonNull ConcatStringOp proto, @Nullable Fingerprint fingerprint) {
return new ConcatStringOp(proto, fingerprint);
}
- @NonNull
- static ConcatStringOp fromProto(@NonNull DynamicProto.ConcatStringOp proto) {
+ static @NonNull ConcatStringOp fromProto(DynamicProto.@NonNull ConcatStringOp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.ConcatStringOp toProto() {
+ DynamicProto.@NonNull ConcatStringOp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicString toDynamicStringProto() {
+ public DynamicProto.@NonNull DynamicString toDynamicStringProto() {
return DynamicProto.DynamicString.newBuilder().setConcatOp(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicString toDynamicStringProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicString toDynamicStringProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicString.newBuilder()
.setConcatOp(mImpl)
@@ -3039,8 +2850,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ConcatStringOp{"
+ "inputLhs="
+ getInputLhs()
@@ -3059,8 +2869,7 @@
/** Sets left hand side of the concatenation operation. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInputLhs(@NonNull DynamicString inputLhs) {
+ public @NonNull Builder setInputLhs(@NonNull DynamicString inputLhs) {
mImpl.setInputLhs(inputLhs.toDynamicStringProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(inputLhs.getFingerprint()).aggregateValueAsInt());
@@ -3069,8 +2878,7 @@
/** Sets right hand side of the concatenation operation. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInputRhs(@NonNull DynamicString inputRhs) {
+ public @NonNull Builder setInputRhs(@NonNull DynamicString inputRhs) {
mImpl.setInputRhs(inputRhs.toDynamicStringProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(inputRhs.getFingerprint()).aggregateValueAsInt());
@@ -3078,8 +2886,7 @@
}
@Override
- @NonNull
- public ConcatStringOp build() {
+ public @NonNull ConcatStringOp build() {
return new ConcatStringOp(mImpl.build(), mFingerprint);
}
}
@@ -3089,7 +2896,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class FloatFormatOp implements DynamicString {
private final DynamicProto.FloatFormatOp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FloatFormatOp(DynamicProto.FloatFormatOp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -3097,8 +2904,7 @@
}
/** Gets the source of Float data to convert to a string. */
- @Nullable
- public DynamicFloat getInput() {
+ public @Nullable DynamicFloat getInput() {
if (mImpl.hasInput()) {
return DynamicBuilders.dynamicFloatFromProto(mImpl.getInput());
} else {
@@ -3149,41 +2955,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static FloatFormatOp fromProto(
- @NonNull DynamicProto.FloatFormatOp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull FloatFormatOp fromProto(
+ DynamicProto.@NonNull FloatFormatOp proto, @Nullable Fingerprint fingerprint) {
return new FloatFormatOp(proto, fingerprint);
}
- @NonNull
- static FloatFormatOp fromProto(@NonNull DynamicProto.FloatFormatOp proto) {
+ static @NonNull FloatFormatOp fromProto(DynamicProto.@NonNull FloatFormatOp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.FloatFormatOp toProto() {
+ DynamicProto.@NonNull FloatFormatOp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicString toDynamicStringProto() {
+ public DynamicProto.@NonNull DynamicString toDynamicStringProto() {
return DynamicProto.DynamicString.newBuilder().setFloatFormatOp(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicString toDynamicStringProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicString toDynamicStringProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicString.newBuilder()
.setFloatFormatOp(mImpl)
@@ -3194,8 +2994,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "FloatFormatOp{"
+ "input="
+ getInput()
@@ -3220,8 +3019,7 @@
/** Sets the source of Float data to convert to a string. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInput(@NonNull DynamicFloat input) {
+ public @NonNull Builder setInput(@NonNull DynamicFloat input) {
mImpl.setInput(input.toDynamicFloatProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(input.getFingerprint()).aggregateValueAsInt());
@@ -3235,8 +3033,8 @@
* satisfied, then minimumFractionDigits will be used for both fields.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setMaxFractionDigits(@IntRange(from = 0) int maxFractionDigits) {
+ public @NonNull Builder setMaxFractionDigits(
+ @IntRange(from = 0) int maxFractionDigits) {
mImpl.setMaxFractionDigits(maxFractionDigits);
mFingerprint.recordPropertyUpdate(2, maxFractionDigits);
return this;
@@ -3249,8 +3047,8 @@
* will be used for both fields.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setMinFractionDigits(@IntRange(from = 0) int minFractionDigits) {
+ public @NonNull Builder setMinFractionDigits(
+ @IntRange(from = 0) int minFractionDigits) {
mImpl.setMinFractionDigits(minFractionDigits);
mFingerprint.recordPropertyUpdate(3, minFractionDigits);
return this;
@@ -3262,8 +3060,7 @@
* for locale en_US, applying minIntegerDigit=4 to 12.34 would yield "0012.34".
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setMinIntegerDigits(@IntRange(from = 0) int minIntegerDigits) {
+ public @NonNull Builder setMinIntegerDigits(@IntRange(from = 0) int minIntegerDigits) {
mImpl.setMinIntegerDigits(minIntegerDigits);
mFingerprint.recordPropertyUpdate(4, minIntegerDigits);
return this;
@@ -3276,16 +3073,14 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setGroupingUsed(boolean groupingUsed) {
+ public @NonNull Builder setGroupingUsed(boolean groupingUsed) {
mImpl.setGroupingUsed(groupingUsed);
mFingerprint.recordPropertyUpdate(5, Boolean.hashCode(groupingUsed));
return this;
}
@Override
- @NonNull
- public FloatFormatOp build() {
+ public @NonNull FloatFormatOp build() {
return new FloatFormatOp(mImpl.build(), mFingerprint);
}
}
@@ -3300,13 +3095,11 @@
public interface DynamicString extends DynamicType {
/** Get the protocol buffer representation of this object, without fingerprint. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DynamicProto.DynamicString toDynamicStringProto();
+ DynamicProto.@NonNull DynamicString toDynamicStringProto();
/** Get the protocol buffer representation of this object, with or without fingerprint. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DynamicProto.DynamicString toDynamicStringProto(boolean withFingerprint);
+ DynamicProto.@NonNull DynamicString toDynamicStringProto(boolean withFingerprint);
/**
* Creates a {@link DynamicString} from a byte array generated by {@link
@@ -3314,8 +3107,7 @@
*
* @throws IllegalArgumentException if the byte array does not contain a valid serialization
*/
- @NonNull
- static DynamicString fromByteArray(@NonNull byte[] byteArray) {
+ static @NonNull DynamicString fromByteArray(byte @NonNull [] byteArray) {
return fromByteArray(byteArray, 0, byteArray.length);
}
@@ -3326,8 +3118,8 @@
* @throws IllegalArgumentException if the byte array does not contain a valid serialization
* in the provided offset and length
*/
- @NonNull
- static DynamicString fromByteArray(@NonNull byte[] byteArray, int offset, int length) {
+ static @NonNull DynamicString fromByteArray(byte @NonNull [] byteArray, int offset,
+ int length) {
try {
return dynamicStringFromProto(
DynamicProto.DynamicString.parseFrom(
@@ -3343,8 +3135,7 @@
* Serializes the {@link DynamicString} into a new byte array that can later be used with
* {@link #fromByteArray(byte[])}.
*/
- @NonNull
- default byte[] toDynamicStringByteArray() {
+ default byte @NonNull [] toDynamicStringByteArray() {
return toDynamicStringProto(/* withFingerprint= */ true).toByteArray();
}
@@ -3355,7 +3146,7 @@
*
* @throws IllegalArgumentException if the byte array is too small
*/
- default int toDynamicStringByteArray(@NonNull byte[] byteArray) {
+ default int toDynamicStringByteArray(byte @NonNull [] byteArray) {
return toDynamicStringByteArray(byteArray, 0, byteArray.length);
}
@@ -3366,7 +3157,7 @@
*
* @throws IllegalArgumentException if the byte array is too small
*/
- default int toDynamicStringByteArray(@NonNull byte[] byteArray, int offset, int length) {
+ default int toDynamicStringByteArray(byte @NonNull [] byteArray, int offset, int length) {
CodedOutputStream stream = CodedOutputStream.newInstance(byteArray, offset, length);
try {
toDynamicStringProto(/* withFingerprint= */ true).writeTo(stream);
@@ -3381,9 +3172,8 @@
* Creates a constant-valued {@link DynamicString}. The resulted {@link DynamicString} is
* subject to being truncated if it's too long.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicString constant(@NonNull String constant) {
+ static @NonNull DynamicString constant(@NonNull String constant) {
return new FixedString.Builder().setValue(constant).build();
}
@@ -3393,9 +3183,8 @@
*
* @see DynamicFormatter
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicString format(@NonNull String format, @NonNull Object... args) {
+ static @NonNull DynamicString format(@NonNull String format, Object @NonNull ... args) {
return new DynamicFormatter().format(format, args);
}
@@ -3405,9 +3194,8 @@
*
* @param dynamicDataKey The source key to a {@link DynamicDataValue} with a string value.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicString from(@NonNull DynamicDataKey<DynamicString> dynamicDataKey) {
+ static @NonNull DynamicString from(@NonNull DynamicDataKey<DynamicString> dynamicDataKey) {
return new StateStringSource.Builder()
.setSourceKey(dynamicDataKey.getKey())
.setSourceNamespace(dynamicDataKey.getNamespace())
@@ -3422,9 +3210,9 @@
*
* @param condition The value used for evaluting this condition.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static ConditionScope<DynamicString, String> onCondition(@NonNull DynamicBool condition) {
+ static @NonNull ConditionScope<DynamicString, String> onCondition(
+ @NonNull DynamicBool condition) {
return new ConditionScopes.ConditionScope<>(
(trueValue, falseValue) ->
new ConditionalStringOp.Builder()
@@ -3442,9 +3230,8 @@
*
* @param other The right hand side operand of the concatenation.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicString concat(@NonNull DynamicString other) {
+ default @NonNull DynamicString concat(@NonNull DynamicString other) {
return new DynamicBuilders.ConcatStringOp.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -3453,24 +3240,21 @@
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link DynamicString} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- DynamicString build();
+ @NonNull DynamicString build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DynamicString dynamicStringFromProto(
- @NonNull DynamicProto.DynamicString proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull DynamicString dynamicStringFromProto(
+ DynamicProto.@NonNull DynamicString proto, @Nullable Fingerprint fingerprint) {
if (proto.hasFixed()) {
return FixedString.fromProto(proto.getFixed(), fingerprint);
}
@@ -3497,8 +3281,8 @@
* created using this method can't be added to any other wrapper.
*/
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DynamicString dynamicStringFromProto(@NonNull DynamicProto.DynamicString proto) {
+ public static @NonNull DynamicString dynamicStringFromProto(
+ DynamicProto.@NonNull DynamicString proto) {
return dynamicStringFromProto(proto, new Fingerprint(proto.getFingerprint()));
}
@@ -3511,7 +3295,7 @@
static final class ArithmeticFloatOp implements DynamicFloat {
private final DynamicProto.ArithmeticFloatOp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ArithmeticFloatOp(DynamicProto.ArithmeticFloatOp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -3519,8 +3303,7 @@
}
/** Gets left hand side of the arithmetic operation. */
- @Nullable
- public DynamicFloat getInputLhs() {
+ public @Nullable DynamicFloat getInputLhs() {
if (mImpl.hasInputLhs()) {
return DynamicBuilders.dynamicFloatFromProto(mImpl.getInputLhs());
} else {
@@ -3529,8 +3312,7 @@
}
/** Gets right hand side of the arithmetic operation. */
- @Nullable
- public DynamicFloat getInputRhs() {
+ public @Nullable DynamicFloat getInputRhs() {
if (mImpl.hasInputRhs()) {
return DynamicBuilders.dynamicFloatFromProto(mImpl.getInputRhs());
} else {
@@ -3547,42 +3329,36 @@
/** */
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ArithmeticFloatOp fromProto(
- @NonNull DynamicProto.ArithmeticFloatOp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ArithmeticFloatOp fromProto(
+ DynamicProto.@NonNull ArithmeticFloatOp proto, @Nullable Fingerprint fingerprint) {
return new ArithmeticFloatOp(proto, fingerprint);
}
- @NonNull
- static ArithmeticFloatOp fromProto(@NonNull DynamicProto.ArithmeticFloatOp proto) {
+ static @NonNull ArithmeticFloatOp fromProto(DynamicProto.@NonNull ArithmeticFloatOp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.ArithmeticFloatOp toProto() {
+ DynamicProto.@NonNull ArithmeticFloatOp toProto() {
return mImpl;
}
/** */
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicFloat toDynamicFloatProto() {
+ public DynamicProto.@NonNull DynamicFloat toDynamicFloatProto() {
return DynamicProto.DynamicFloat.newBuilder().setArithmeticOperation(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicFloat toDynamicFloatProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicFloat toDynamicFloatProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicFloat.newBuilder()
.setArithmeticOperation(mImpl)
@@ -3593,8 +3369,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ArithmeticFloatOp{"
+ "inputLhs="
+ getInputLhs()
@@ -3616,8 +3391,7 @@
/** Sets left hand side of the arithmetic operation. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInputLhs(@NonNull DynamicFloat inputLhs) {
+ public @NonNull Builder setInputLhs(@NonNull DynamicFloat inputLhs) {
mImpl.setInputLhs(inputLhs.toDynamicFloatProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(inputLhs.getFingerprint()).aggregateValueAsInt());
@@ -3626,8 +3400,7 @@
/** Sets right hand side of the arithmetic operation. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInputRhs(@NonNull DynamicFloat inputRhs) {
+ public @NonNull Builder setInputRhs(@NonNull DynamicFloat inputRhs) {
mImpl.setInputRhs(inputRhs.toDynamicFloatProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(inputRhs.getFingerprint()).aggregateValueAsInt());
@@ -3636,16 +3409,14 @@
/** Sets the type of operation to carry out. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setOperationType(@ArithmeticOpType int operationType) {
+ public @NonNull Builder setOperationType(@ArithmeticOpType int operationType) {
mImpl.setOperationType(DynamicProto.ArithmeticOpType.forNumber(operationType));
mFingerprint.recordPropertyUpdate(3, operationType);
return this;
}
@Override
- @NonNull
- public ArithmeticFloatOp build() {
+ public @NonNull ArithmeticFloatOp build() {
return new ArithmeticFloatOp(mImpl.build(), mFingerprint);
}
}
@@ -3655,7 +3426,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class StateFloatSource implements DynamicFloat {
private final DynamicProto.StateFloatSource mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
StateFloatSource(DynamicProto.StateFloatSource impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -3663,54 +3434,46 @@
}
/** Gets the key in the state to bind to. */
- @NonNull
- public String getSourceKey() {
+ public @NonNull String getSourceKey() {
return mImpl.getSourceKey();
}
/** Gets the namespace for the state key. */
- @NonNull
- public String getSourceNamespace() {
+ public @NonNull String getSourceNamespace() {
return mImpl.getSourceNamespace();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static StateFloatSource fromProto(
- @NonNull DynamicProto.StateFloatSource proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull StateFloatSource fromProto(
+ DynamicProto.@NonNull StateFloatSource proto, @Nullable Fingerprint fingerprint) {
return new StateFloatSource(proto, fingerprint);
}
- @NonNull
- static StateFloatSource fromProto(@NonNull DynamicProto.StateFloatSource proto) {
+ static @NonNull StateFloatSource fromProto(DynamicProto.@NonNull StateFloatSource proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.StateFloatSource toProto() {
+ DynamicProto.@NonNull StateFloatSource toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicFloat toDynamicFloatProto() {
+ public DynamicProto.@NonNull DynamicFloat toDynamicFloatProto() {
return DynamicProto.DynamicFloat.newBuilder().setStateSource(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicFloat toDynamicFloatProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicFloat toDynamicFloatProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicFloat.newBuilder()
.setStateSource(mImpl)
@@ -3721,8 +3484,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "StateFloatSource{"
+ "sourceKey="
+ getSourceKey()
@@ -3741,8 +3503,7 @@
/** Sets the key in the state to bind to. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setSourceKey(@NonNull String sourceKey) {
+ public @NonNull Builder setSourceKey(@NonNull String sourceKey) {
mImpl.setSourceKey(sourceKey);
mFingerprint.recordPropertyUpdate(1, sourceKey.hashCode());
return this;
@@ -3750,16 +3511,14 @@
/** Sets the namespace for the state key. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setSourceNamespace(@NonNull String sourceNamespace) {
+ public @NonNull Builder setSourceNamespace(@NonNull String sourceNamespace) {
mImpl.setSourceNamespace(sourceNamespace);
mFingerprint.recordPropertyUpdate(2, sourceNamespace.hashCode());
return this;
}
@Override
- @NonNull
- public StateFloatSource build() {
+ public @NonNull StateFloatSource build() {
return new StateFloatSource(mImpl.build(), mFingerprint);
}
}
@@ -3769,7 +3528,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class Int32ToFloatOp implements DynamicFloat {
private final DynamicProto.Int32ToFloatOp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Int32ToFloatOp(DynamicProto.Int32ToFloatOp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -3777,8 +3536,7 @@
}
/** Gets the input Int32 to convert to a Float. */
- @Nullable
- public DynamicInt32 getInput() {
+ public @Nullable DynamicInt32 getInput() {
if (mImpl.hasInput()) {
return DynamicBuilders.dynamicInt32FromProto(mImpl.getInput());
} else {
@@ -3788,41 +3546,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Int32ToFloatOp fromProto(
- @NonNull DynamicProto.Int32ToFloatOp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Int32ToFloatOp fromProto(
+ DynamicProto.@NonNull Int32ToFloatOp proto, @Nullable Fingerprint fingerprint) {
return new Int32ToFloatOp(proto, fingerprint);
}
- @NonNull
- static Int32ToFloatOp fromProto(@NonNull DynamicProto.Int32ToFloatOp proto) {
+ static @NonNull Int32ToFloatOp fromProto(DynamicProto.@NonNull Int32ToFloatOp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.Int32ToFloatOp toProto() {
+ DynamicProto.@NonNull Int32ToFloatOp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicFloat toDynamicFloatProto() {
+ public DynamicProto.@NonNull DynamicFloat toDynamicFloatProto() {
return DynamicProto.DynamicFloat.newBuilder().setInt32ToFloatOperation(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicFloat toDynamicFloatProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicFloat toDynamicFloatProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicFloat.newBuilder()
.setInt32ToFloatOperation(mImpl)
@@ -3833,8 +3585,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Int32ToFloatOp{" + "input=" + getInput() + "}";
}
@@ -3848,8 +3599,7 @@
/** Sets the input Int32 to convert to a Float. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInput(@NonNull DynamicInt32 input) {
+ public @NonNull Builder setInput(@NonNull DynamicInt32 input) {
mImpl.setInput(input.toDynamicInt32Proto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(input.getFingerprint()).aggregateValueAsInt());
@@ -3857,8 +3607,7 @@
}
@Override
- @NonNull
- public Int32ToFloatOp build() {
+ public @NonNull Int32ToFloatOp build() {
return new Int32ToFloatOp(mImpl.build(), mFingerprint);
}
}
@@ -3868,7 +3617,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class AnimatableFixedFloat implements DynamicFloat {
private final DynamicProto.AnimatableFixedFloat mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AnimatableFixedFloat(
DynamicProto.AnimatableFixedFloat impl, @Nullable Fingerprint fingerprint) {
@@ -3887,8 +3636,7 @@
}
/** Gets the animation parameters for duration, delay, etc. */
- @Nullable
- public AnimationSpec getAnimationSpec() {
+ public @Nullable AnimationSpec getAnimationSpec() {
if (mImpl.hasAnimationSpec()) {
return AnimationSpec.fromProto(mImpl.getAnimationSpec());
} else {
@@ -3898,42 +3646,37 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AnimatableFixedFloat fromProto(
- @NonNull DynamicProto.AnimatableFixedFloat proto,
+ public static @NonNull AnimatableFixedFloat fromProto(
+ DynamicProto.@NonNull AnimatableFixedFloat proto,
@Nullable Fingerprint fingerprint) {
return new AnimatableFixedFloat(proto, fingerprint);
}
- @NonNull
- static AnimatableFixedFloat fromProto(@NonNull DynamicProto.AnimatableFixedFloat proto) {
+ static @NonNull AnimatableFixedFloat fromProto(
+ DynamicProto.@NonNull AnimatableFixedFloat proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.AnimatableFixedFloat toProto() {
+ DynamicProto.@NonNull AnimatableFixedFloat toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicFloat toDynamicFloatProto() {
+ public DynamicProto.@NonNull DynamicFloat toDynamicFloatProto() {
return DynamicProto.DynamicFloat.newBuilder().setAnimatableFixed(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicFloat toDynamicFloatProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicFloat toDynamicFloatProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicFloat.newBuilder()
.setAnimatableFixed(mImpl)
@@ -3944,8 +3687,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AnimatableFixedFloat{"
+ "fromValue="
+ getFromValue()
@@ -3966,8 +3708,7 @@
/** Sets the number to start animating from. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setFromValue(float fromValue) {
+ public @NonNull Builder setFromValue(float fromValue) {
mImpl.setFromValue(fromValue);
mFingerprint.recordPropertyUpdate(1, Float.floatToIntBits(fromValue));
return this;
@@ -3975,8 +3716,7 @@
/** Sets the number to animate to. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setToValue(float toValue) {
+ public @NonNull Builder setToValue(float toValue) {
mImpl.setToValue(toValue);
mFingerprint.recordPropertyUpdate(2, Float.floatToIntBits(toValue));
return this;
@@ -3984,8 +3724,7 @@
/** Sets the animation parameters for duration, delay, etc. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
+ public @NonNull Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
mImpl.setAnimationSpec(animationSpec.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(animationSpec.getFingerprint()).aggregateValueAsInt());
@@ -3993,8 +3732,7 @@
}
@Override
- @NonNull
- public AnimatableFixedFloat build() {
+ public @NonNull AnimatableFixedFloat build() {
return new AnimatableFixedFloat(mImpl.build(), mFingerprint);
}
}
@@ -4012,7 +3750,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class AnimatableDynamicFloat implements DynamicFloat {
private final DynamicProto.AnimatableDynamicFloat mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AnimatableDynamicFloat(
DynamicProto.AnimatableDynamicFloat impl, @Nullable Fingerprint fingerprint) {
@@ -4021,8 +3759,7 @@
}
/** Gets the value to watch, and animate when it changes. */
- @Nullable
- public DynamicFloat getInput() {
+ public @Nullable DynamicFloat getInput() {
if (mImpl.hasInput()) {
return DynamicBuilders.dynamicFloatFromProto(mImpl.getInput());
} else {
@@ -4031,8 +3768,7 @@
}
/** Gets the animation parameters for duration, delay, etc. */
- @Nullable
- public AnimationSpec getAnimationSpec() {
+ public @Nullable AnimationSpec getAnimationSpec() {
if (mImpl.hasAnimationSpec()) {
return AnimationSpec.fromProto(mImpl.getAnimationSpec());
} else {
@@ -4042,43 +3778,37 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AnimatableDynamicFloat fromProto(
- @NonNull DynamicProto.AnimatableDynamicFloat proto,
+ public static @NonNull AnimatableDynamicFloat fromProto(
+ DynamicProto.@NonNull AnimatableDynamicFloat proto,
@Nullable Fingerprint fingerprint) {
return new AnimatableDynamicFloat(proto, fingerprint);
}
- @NonNull
- static AnimatableDynamicFloat fromProto(
- @NonNull DynamicProto.AnimatableDynamicFloat proto) {
+ static @NonNull AnimatableDynamicFloat fromProto(
+ DynamicProto.@NonNull AnimatableDynamicFloat proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.AnimatableDynamicFloat toProto() {
+ DynamicProto.@NonNull AnimatableDynamicFloat toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicFloat toDynamicFloatProto() {
+ public DynamicProto.@NonNull DynamicFloat toDynamicFloatProto() {
return DynamicProto.DynamicFloat.newBuilder().setAnimatableDynamic(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicFloat toDynamicFloatProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicFloat toDynamicFloatProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicFloat.newBuilder()
.setAnimatableDynamic(mImpl)
@@ -4089,8 +3819,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AnimatableDynamicFloat{"
+ "input="
+ getInput()
@@ -4109,8 +3838,7 @@
/** Sets the value to watch, and animate when it changes. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInput(@NonNull DynamicFloat input) {
+ public @NonNull Builder setInput(@NonNull DynamicFloat input) {
mImpl.setInput(input.toDynamicFloatProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(input.getFingerprint()).aggregateValueAsInt());
@@ -4119,8 +3847,7 @@
/** Sets the animation parameters for duration, delay, etc. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
+ public @NonNull Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
mImpl.setAnimationSpec(animationSpec.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(animationSpec.getFingerprint()).aggregateValueAsInt());
@@ -4128,8 +3855,7 @@
}
@Override
- @NonNull
- public AnimatableDynamicFloat build() {
+ public @NonNull AnimatableDynamicFloat build() {
return new AnimatableDynamicFloat(mImpl.build(), mFingerprint);
}
}
@@ -4160,13 +3886,11 @@
public interface DynamicFloat extends DynamicType {
/** Get the protocol buffer representation of this object, without fingerprint. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DynamicProto.DynamicFloat toDynamicFloatProto();
+ DynamicProto.@NonNull DynamicFloat toDynamicFloatProto();
/** Get the protocol buffer representation of this object, with or without fingerprint. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DynamicProto.DynamicFloat toDynamicFloatProto(boolean withFingerprint);
+ DynamicProto.@NonNull DynamicFloat toDynamicFloatProto(boolean withFingerprint);
/**
* Creates a {@link DynamicFloat} from a byte array generated by {@link
@@ -4174,8 +3898,7 @@
*
* @throws IllegalArgumentException if the byte array does not contain a valid serialization
*/
- @NonNull
- static DynamicFloat fromByteArray(@NonNull byte[] byteArray) {
+ static @NonNull DynamicFloat fromByteArray(byte @NonNull [] byteArray) {
return fromByteArray(byteArray, 0, byteArray.length);
}
@@ -4186,8 +3909,8 @@
* @throws IllegalArgumentException if the byte array does not contain a valid serialization
* in the provided offset and length
*/
- @NonNull
- static DynamicFloat fromByteArray(@NonNull byte[] byteArray, int offset, int length) {
+ static @NonNull DynamicFloat fromByteArray(byte @NonNull [] byteArray, int offset,
+ int length) {
try {
return dynamicFloatFromProto(
DynamicProto.DynamicFloat.parseFrom(
@@ -4203,8 +3926,7 @@
* Serializes the {@link DynamicFloat} into a new byte array that can later be used with
* {@link #fromByteArray(byte[])}.
*/
- @NonNull
- default byte[] toDynamicFloatByteArray() {
+ default byte @NonNull [] toDynamicFloatByteArray() {
return toDynamicFloatProto(/* withFingerprint= */ true).toByteArray();
}
@@ -4215,7 +3937,7 @@
*
* @throws IllegalArgumentException if the byte array is too small
*/
- default int toDynamicFloatByteArray(@NonNull byte[] byteArray) {
+ default int toDynamicFloatByteArray(byte @NonNull [] byteArray) {
return toDynamicFloatByteArray(byteArray, 0, byteArray.length);
}
@@ -4226,7 +3948,7 @@
*
* @throws IllegalArgumentException if the byte array is too small
*/
- default int toDynamicFloatByteArray(@NonNull byte[] byteArray, int offset, int length) {
+ default int toDynamicFloatByteArray(byte @NonNull [] byteArray, int offset, int length) {
CodedOutputStream stream = CodedOutputStream.newInstance(byteArray, offset, length);
try {
toDynamicFloatProto(/* withFingerprint= */ true).writeTo(stream);
@@ -4244,9 +3966,8 @@
* expression that uses this {@link DynamicFloat} will have an invalid result (which will be
* delivered through {@link DynamicTypeValueReceiver<T>#onInvalidate()}.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicFloat constant(float constant) {
+ static @NonNull DynamicFloat constant(float constant) {
return new FixedFloat.Builder().setValue(constant).build();
}
@@ -4255,9 +3976,8 @@
*
* @param dynamicDataKey The data source to a {@link DynamicDataValue} with a float value.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicFloat from(@NonNull DynamicDataKey<DynamicFloat> dynamicDataKey) {
+ static @NonNull DynamicFloat from(@NonNull DynamicDataKey<DynamicFloat> dynamicDataKey) {
return new StateFloatSource.Builder()
.setSourceKey(dynamicDataKey.getKey())
.setSourceNamespace(dynamicDataKey.getNamespace())
@@ -4271,9 +3991,8 @@
* @param start The start value of the range.
* @param end The end value of the range.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicFloat animate(float start, float end) {
+ static @NonNull DynamicFloat animate(float start, float end) {
return new AnimatableFixedFloat.Builder().setFromValue(start).setToValue(end).build();
}
@@ -4285,9 +4004,9 @@
* @param end The end value of the range.
* @param animationSpec The animation parameters.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicFloat animate(float start, float end, @NonNull AnimationSpec animationSpec) {
+ static @NonNull DynamicFloat animate(float start, float end,
+ @NonNull AnimationSpec animationSpec) {
return new AnimatableFixedFloat.Builder()
.setFromValue(start)
.setToValue(end)
@@ -4302,9 +4021,8 @@
*
* @param dynamicDataKey The data source to a {@link DynamicDataValue} with a float value.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicFloat animate(@NonNull DynamicDataKey<DynamicFloat> dynamicDataKey) {
+ static @NonNull DynamicFloat animate(@NonNull DynamicDataKey<DynamicFloat> dynamicDataKey) {
return new AnimatableDynamicFloat.Builder().setInput(from(dynamicDataKey)).build();
}
@@ -4316,9 +4034,8 @@
* @param dynamicDataKey The source key to a {@link DynamicDataValue} with a float value.
* @param animationSpec The animation parameters.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicFloat animate(
+ static @NonNull DynamicFloat animate(
@NonNull DynamicDataKey<DynamicFloat> dynamicDataKey,
@NonNull AnimationSpec animationSpec) {
return new AnimatableDynamicFloat.Builder()
@@ -4334,9 +4051,8 @@
*
* @param animationSpec The animation parameters.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicFloat animate(@NonNull AnimationSpec animationSpec) {
+ default @NonNull DynamicFloat animate(@NonNull AnimationSpec animationSpec) {
return new AnimatableDynamicFloat.Builder()
.setInput(this)
.setAnimationSpec(animationSpec)
@@ -4348,9 +4064,8 @@
* and every time its value is changing, it animates from its current value to the new
* value.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicFloat animate() {
+ default @NonNull DynamicFloat animate() {
return new AnimatableDynamicFloat.Builder().setInput(this).build();
}
@@ -4363,9 +4078,8 @@
* uses the {@link DynamicInt32} will have an invalid result (which will be delivered
* through {@link DynamicTypeValueReceiver<T>#onInvalidate()}.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicInt32 asInt() {
+ default @NonNull DynamicInt32 asInt() {
return new FloatToInt32Op.Builder()
.setRoundMode(DynamicBuilders.ROUND_MODE_FLOOR)
.setInput(this)
@@ -4388,9 +4102,8 @@
* @return a new instance of {@link DynamicFloat} containing the result of the operation.
*/
@SuppressWarnings("KotlinOperator")
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicFloat plus(@NonNull DynamicFloat other) {
+ default @NonNull DynamicFloat plus(@NonNull DynamicFloat other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -4414,9 +4127,8 @@
* @return a new instance of {@link DynamicFloat} containing the result of the operation.
*/
@SuppressWarnings("KotlinOperator")
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicFloat plus(float other) {
+ default @NonNull DynamicFloat plus(float other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -4440,9 +4152,8 @@
* @return a new instance of {@link DynamicFloat} containing the result of the operation.
*/
@SuppressWarnings("KotlinOperator")
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicFloat plus(@NonNull DynamicInt32 other) {
+ default @NonNull DynamicFloat plus(@NonNull DynamicInt32 other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(other.asFloat())
@@ -4466,9 +4177,8 @@
* @return a new instance of {@link DynamicFloat} containing the result of the operation.
*/
@SuppressWarnings("KotlinOperator")
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicFloat minus(@NonNull DynamicFloat other) {
+ default @NonNull DynamicFloat minus(@NonNull DynamicFloat other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -4492,9 +4202,8 @@
* @return a new instance of {@link DynamicFloat} containing the result of the operation.
*/
@SuppressWarnings("KotlinOperator")
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicFloat minus(float other) {
+ default @NonNull DynamicFloat minus(float other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -4518,9 +4227,8 @@
* @return a new instance of {@link DynamicFloat} containing the result of the operation.
*/
@SuppressWarnings("KotlinOperator")
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicFloat minus(@NonNull DynamicInt32 other) {
+ default @NonNull DynamicFloat minus(@NonNull DynamicInt32 other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(other.asFloat())
@@ -4544,9 +4252,8 @@
* @return a new instance of {@link DynamicFloat} containing the result of the operation.
*/
@SuppressWarnings("KotlinOperator")
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicFloat times(@NonNull DynamicFloat other) {
+ default @NonNull DynamicFloat times(@NonNull DynamicFloat other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -4570,9 +4277,8 @@
* @return a new instance of {@link DynamicFloat} containing the result of the operation.
*/
@SuppressWarnings("KotlinOperator")
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicFloat times(float other) {
+ default @NonNull DynamicFloat times(float other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -4596,9 +4302,8 @@
* @return a new instance of {@link DynamicFloat} containing the result of the operation.
*/
@SuppressWarnings("KotlinOperator")
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicFloat times(@NonNull DynamicInt32 other) {
+ default @NonNull DynamicFloat times(@NonNull DynamicInt32 other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(other.asFloat())
@@ -4622,9 +4327,8 @@
* @return a new instance of {@link DynamicFloat} containing the result of the operation.
*/
@SuppressWarnings("KotlinOperator")
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicFloat div(@NonNull DynamicFloat other) {
+ default @NonNull DynamicFloat div(@NonNull DynamicFloat other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -4648,9 +4352,8 @@
* @return a new instance of {@link DynamicFloat} containing the result of the operation.
*/
@SuppressWarnings("KotlinOperator")
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicFloat div(float other) {
+ default @NonNull DynamicFloat div(float other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -4674,9 +4377,8 @@
* @return a new instance of {@link DynamicFloat} containing the result of the operation.
*/
@SuppressWarnings("KotlinOperator")
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicFloat div(@NonNull DynamicInt32 other) {
+ default @NonNull DynamicFloat div(@NonNull DynamicInt32 other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(other.asFloat())
@@ -4700,9 +4402,8 @@
* @return a new instance of {@link DynamicFloat} containing the result of the operation.
*/
@SuppressWarnings("KotlinOperator")
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicFloat rem(@NonNull DynamicFloat other) {
+ default @NonNull DynamicFloat rem(@NonNull DynamicFloat other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -4726,9 +4427,8 @@
* @return a new instance of {@link DynamicFloat} containing the result of the operation.
*/
@SuppressWarnings("KotlinOperator")
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicFloat rem(float other) {
+ default @NonNull DynamicFloat rem(float other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -4752,9 +4452,8 @@
* @return a new instance of {@link DynamicFloat} containing the result of the operation.
*/
@SuppressWarnings("KotlinOperator")
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicFloat rem(@NonNull DynamicInt32 other) {
+ default @NonNull DynamicFloat rem(@NonNull DynamicInt32 other) {
return new ArithmeticFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(other.asFloat())
@@ -4766,9 +4465,8 @@
* Returns a {@link DynamicBool} that is true if the value of this {@link DynamicFloat} and
* {@code other} are equal, otherwise it's false.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicBool eq(@NonNull DynamicFloat other) {
+ default @NonNull DynamicBool eq(@NonNull DynamicFloat other) {
return new ComparisonFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -4780,9 +4478,8 @@
* Returns a {@link DynamicBool} that is true if the value of this {@link DynamicFloat} and
* {@code other} are equal, otherwise it's false.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicBool eq(float other) {
+ default @NonNull DynamicBool eq(float other) {
return new ComparisonFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -4794,9 +4491,8 @@
* Returns a {@link DynamicBool} that is true if the value of this {@link DynamicFloat} and
* {@code other} are not equal, otherwise it's false.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicBool ne(@NonNull DynamicFloat other) {
+ default @NonNull DynamicBool ne(@NonNull DynamicFloat other) {
return new ComparisonFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -4808,9 +4504,8 @@
* Returns a {@link DynamicBool} that is true if the value of this {@link DynamicFloat} and
* {@code other} are not equal, otherwise it's false.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicBool ne(float other) {
+ default @NonNull DynamicBool ne(float other) {
return new ComparisonFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -4822,9 +4517,8 @@
* Returns a {@link DynamicBool} that is true if the value of this {@link DynamicFloat} is
* less than {@code other}, otherwise it's false.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicBool lt(@NonNull DynamicFloat other) {
+ default @NonNull DynamicBool lt(@NonNull DynamicFloat other) {
return new ComparisonFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -4836,9 +4530,8 @@
* Returns a {@link DynamicBool} that is true if the value of this {@link DynamicFloat} is
* less than {@code other}, otherwise it's false.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicBool lt(float other) {
+ default @NonNull DynamicBool lt(float other) {
return new ComparisonFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -4850,9 +4543,8 @@
* Returns a {@link DynamicBool} that is true if the value of this {@link DynamicFloat} is
* less than or equal to {@code other}, otherwise it's false.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicBool lte(@NonNull DynamicFloat other) {
+ default @NonNull DynamicBool lte(@NonNull DynamicFloat other) {
return new ComparisonFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -4864,9 +4556,8 @@
* Returns a {@link DynamicBool} that is true if the value of this {@link DynamicFloat} is
* less than or equal to {@code other}, otherwise it's false.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicBool lte(float other) {
+ default @NonNull DynamicBool lte(float other) {
return new ComparisonFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -4878,9 +4569,8 @@
* Returns a {@link DynamicBool} that is true if the value of this {@link DynamicFloat} is
* greater than {@code other}, otherwise it's false.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicBool gt(@NonNull DynamicFloat other) {
+ default @NonNull DynamicBool gt(@NonNull DynamicFloat other) {
return new ComparisonFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -4892,9 +4582,8 @@
* Returns a {@link DynamicBool} that is true if the value of this {@link DynamicFloat} is
* greater than {@code other}, otherwise it's false.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicBool gt(float other) {
+ default @NonNull DynamicBool gt(float other) {
return new ComparisonFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -4906,9 +4595,8 @@
* Returns a {@link DynamicBool} that is true if the value of this {@link DynamicFloat} is
* greater than or equal to {@code other}, otherwise it's false.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicBool gte(@NonNull DynamicFloat other) {
+ default @NonNull DynamicBool gte(@NonNull DynamicFloat other) {
return new ComparisonFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -4920,9 +4608,8 @@
* Returns a {@link DynamicBool} that is true if the value of this {@link DynamicFloat} is
* greater than or equal to {@code other}, otherwise it's false.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicBool gte(float other) {
+ default @NonNull DynamicBool gte(float other) {
return new ComparisonFloatOp.Builder()
.setInputLhs(this)
.setInputRhs(constant(other))
@@ -4936,9 +4623,9 @@
* ConditionScopes.IfTrueScope#elseUse} depending on the value yielded from {@code
* condition}.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static ConditionScope<DynamicFloat, Float> onCondition(@NonNull DynamicBool condition) {
+ static @NonNull ConditionScope<DynamicFloat, Float> onCondition(
+ @NonNull DynamicBool condition) {
return new ConditionScopes.ConditionScope<>(
(trueValue, falseValue) ->
new ConditionalFloatOp.Builder()
@@ -4960,9 +4647,8 @@
*
* The resulted {@link DynamicString} is subject to being truncated if it's too long.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicString format() {
+ default @NonNull DynamicString format() {
return new FloatFormatter.Builder().build().getFloatFormatOp(this);
}
@@ -4982,9 +4668,8 @@
*
* @param formatter The formatting parameter.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicString format(@NonNull FloatFormatter formatter) {
+ default @NonNull DynamicString format(@NonNull FloatFormatter formatter) {
return formatter.getFloatFormatOp(this);
}
@@ -4999,8 +4684,7 @@
}
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- FloatFormatOp getFloatFormatOp(@NonNull DynamicFloat dynamicFloat) {
+ @NonNull FloatFormatOp getFloatFormatOp(@NonNull DynamicFloat dynamicFloat) {
return mFloatFormatOpBuilder.setInput(dynamicFloat).build();
}
@@ -5043,9 +4727,9 @@
* condition is not satisfied, then minimumFractionDigits will be used for both
* fields.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- public Builder setMinFractionDigits(@IntRange(from = 0) int minFractionDigits) {
+ public @NonNull Builder setMinFractionDigits(
+ @IntRange(from = 0) int minFractionDigits) {
mBuilder.setMinFractionDigits(minFractionDigits);
return this;
}
@@ -5056,9 +4740,9 @@
* condition is not satisfied, then minimumFractionDigits will be used for both
* fields.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- public Builder setMaxFractionDigits(@IntRange(from = 0) int maxFractionDigits) {
+ public @NonNull Builder setMaxFractionDigits(
+ @IntRange(from = 0) int maxFractionDigits) {
mBuilder.setMaxFractionDigits(maxFractionDigits);
return this;
}
@@ -5068,9 +4752,9 @@
* specified. If minIntegerDigits is zero and the -1 < input < 1, the Integer part
* will not appear.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- public Builder setMinIntegerDigits(@IntRange(from = 0) int minIntegerDigits) {
+ public @NonNull Builder setMinIntegerDigits(
+ @IntRange(from = 0) int minIntegerDigits) {
mBuilder.setMinIntegerDigits(minIntegerDigits);
return this;
}
@@ -5089,16 +4773,14 @@
* .setGroupingUsed(true).build());
* </pre>
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- public Builder setGroupingUsed(boolean groupingUsed) {
+ public @NonNull Builder setGroupingUsed(boolean groupingUsed) {
mBuilder.setGroupingUsed(groupingUsed);
return this;
}
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- public FloatFormatter build() {
+ public @NonNull FloatFormatter build() {
FloatFormatOp op = mBuilder.build();
throwIfExceedingMaxValue(
"MinFractionDigits",
@@ -5127,24 +4809,21 @@
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link DynamicFloat} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- DynamicFloat build();
+ @NonNull DynamicFloat build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DynamicFloat dynamicFloatFromProto(
- @NonNull DynamicProto.DynamicFloat proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull DynamicFloat dynamicFloatFromProto(
+ DynamicProto.@NonNull DynamicFloat proto, @Nullable Fingerprint fingerprint) {
if (proto.hasFixed()) {
return FixedFloat.fromProto(proto.getFixed(), fingerprint);
}
@@ -5174,8 +4853,8 @@
* created using this method can't be added to any other wrapper.
*/
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DynamicFloat dynamicFloatFromProto(@NonNull DynamicProto.DynamicFloat proto) {
+ public static @NonNull DynamicFloat dynamicFloatFromProto(
+ DynamicProto.@NonNull DynamicFloat proto) {
return dynamicFloatFromProto(proto, new Fingerprint(proto.getFingerprint()));
}
@@ -5183,7 +4862,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class StateBoolSource implements DynamicBool {
private final DynamicProto.StateBoolSource mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
StateBoolSource(DynamicProto.StateBoolSource impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -5191,54 +4870,46 @@
}
/** Gets the key in the state to bind to. */
- @NonNull
- public String getSourceKey() {
+ public @NonNull String getSourceKey() {
return mImpl.getSourceKey();
}
/** Gets the namespace for the state key. */
- @NonNull
- public String getSourceNamespace() {
+ public @NonNull String getSourceNamespace() {
return mImpl.getSourceNamespace();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static StateBoolSource fromProto(
- @NonNull DynamicProto.StateBoolSource proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull StateBoolSource fromProto(
+ DynamicProto.@NonNull StateBoolSource proto, @Nullable Fingerprint fingerprint) {
return new StateBoolSource(proto, fingerprint);
}
- @NonNull
- static StateBoolSource fromProto(@NonNull DynamicProto.StateBoolSource proto) {
+ static @NonNull StateBoolSource fromProto(DynamicProto.@NonNull StateBoolSource proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.StateBoolSource toProto() {
+ DynamicProto.@NonNull StateBoolSource toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicBool toDynamicBoolProto() {
+ public DynamicProto.@NonNull DynamicBool toDynamicBoolProto() {
return DynamicProto.DynamicBool.newBuilder().setStateSource(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicBool toDynamicBoolProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicBool toDynamicBoolProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicBool.newBuilder()
.setStateSource(mImpl)
@@ -5249,8 +4920,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "StateBoolSource{"
+ "sourceKey="
+ getSourceKey()
@@ -5270,8 +4940,7 @@
/** Sets the key in the state to bind to. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setSourceKey(@NonNull String sourceKey) {
+ public @NonNull Builder setSourceKey(@NonNull String sourceKey) {
mImpl.setSourceKey(sourceKey);
mFingerprint.recordPropertyUpdate(1, sourceKey.hashCode());
return this;
@@ -5279,16 +4948,14 @@
/** Sets the namespace for the state key. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setSourceNamespace(@NonNull String sourceNamespace) {
+ public @NonNull Builder setSourceNamespace(@NonNull String sourceNamespace) {
mImpl.setSourceNamespace(sourceNamespace);
mFingerprint.recordPropertyUpdate(2, sourceNamespace.hashCode());
return this;
}
@Override
- @NonNull
- public StateBoolSource build() {
+ public @NonNull StateBoolSource build() {
return new StateBoolSource(mImpl.build(), mFingerprint);
}
}
@@ -5303,7 +4970,7 @@
static final class ComparisonInt32Op implements DynamicBool {
private final DynamicProto.ComparisonInt32Op mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ComparisonInt32Op(DynamicProto.ComparisonInt32Op impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -5311,8 +4978,7 @@
}
/** Gets the left hand side of the comparison operation. */
- @Nullable
- public DynamicInt32 getInputLhs() {
+ public @Nullable DynamicInt32 getInputLhs() {
if (mImpl.hasInputLhs()) {
return DynamicBuilders.dynamicInt32FromProto(mImpl.getInputLhs());
} else {
@@ -5321,8 +4987,7 @@
}
/** Gets the right hand side of the comparison operation. */
- @Nullable
- public DynamicInt32 getInputRhs() {
+ public @Nullable DynamicInt32 getInputRhs() {
if (mImpl.hasInputRhs()) {
return DynamicBuilders.dynamicInt32FromProto(mImpl.getInputRhs());
} else {
@@ -5339,42 +5004,36 @@
/** */
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ComparisonInt32Op fromProto(
- @NonNull DynamicProto.ComparisonInt32Op proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ComparisonInt32Op fromProto(
+ DynamicProto.@NonNull ComparisonInt32Op proto, @Nullable Fingerprint fingerprint) {
return new ComparisonInt32Op(proto, fingerprint);
}
- @NonNull
- static ComparisonInt32Op fromProto(@NonNull DynamicProto.ComparisonInt32Op proto) {
+ static @NonNull ComparisonInt32Op fromProto(DynamicProto.@NonNull ComparisonInt32Op proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.ComparisonInt32Op toProto() {
+ DynamicProto.@NonNull ComparisonInt32Op toProto() {
return mImpl;
}
/** */
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicBool toDynamicBoolProto() {
+ public DynamicProto.@NonNull DynamicBool toDynamicBoolProto() {
return DynamicProto.DynamicBool.newBuilder().setInt32Comparison(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicBool toDynamicBoolProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicBool toDynamicBoolProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicBool.newBuilder()
.setInt32Comparison(mImpl)
@@ -5385,8 +5044,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ComparisonInt32Op{"
+ "inputLhs="
+ getInputLhs()
@@ -5408,8 +5066,7 @@
/** Sets the left hand side of the comparison operation. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInputLhs(@NonNull DynamicInt32 inputLhs) {
+ public @NonNull Builder setInputLhs(@NonNull DynamicInt32 inputLhs) {
mImpl.setInputLhs(inputLhs.toDynamicInt32Proto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(inputLhs.getFingerprint()).aggregateValueAsInt());
@@ -5418,8 +5075,7 @@
/** Sets the right hand side of the comparison operation. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInputRhs(@NonNull DynamicInt32 inputRhs) {
+ public @NonNull Builder setInputRhs(@NonNull DynamicInt32 inputRhs) {
mImpl.setInputRhs(inputRhs.toDynamicInt32Proto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(inputRhs.getFingerprint()).aggregateValueAsInt());
@@ -5428,16 +5084,14 @@
/** Sets the type of the operation. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setOperationType(@ComparisonOpType int operationType) {
+ public @NonNull Builder setOperationType(@ComparisonOpType int operationType) {
mImpl.setOperationType(DynamicProto.ComparisonOpType.forNumber(operationType));
mFingerprint.recordPropertyUpdate(3, operationType);
return this;
}
@Override
- @NonNull
- public ComparisonInt32Op build() {
+ public @NonNull ComparisonInt32Op build() {
return new ComparisonInt32Op(mImpl.build(), mFingerprint);
}
}
@@ -5452,7 +5106,7 @@
static final class ComparisonFloatOp implements DynamicBool {
private final DynamicProto.ComparisonFloatOp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ComparisonFloatOp(DynamicProto.ComparisonFloatOp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -5460,8 +5114,7 @@
}
/** Gets the left hand side of the comparison operation. */
- @Nullable
- public DynamicFloat getInputLhs() {
+ public @Nullable DynamicFloat getInputLhs() {
if (mImpl.hasInputLhs()) {
return DynamicBuilders.dynamicFloatFromProto(mImpl.getInputLhs());
} else {
@@ -5470,8 +5123,7 @@
}
/** Gets the right hand side of the comparison operation. */
- @Nullable
- public DynamicFloat getInputRhs() {
+ public @Nullable DynamicFloat getInputRhs() {
if (mImpl.hasInputRhs()) {
return DynamicBuilders.dynamicFloatFromProto(mImpl.getInputRhs());
} else {
@@ -5488,42 +5140,36 @@
/** */
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ComparisonFloatOp fromProto(
- @NonNull DynamicProto.ComparisonFloatOp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ComparisonFloatOp fromProto(
+ DynamicProto.@NonNull ComparisonFloatOp proto, @Nullable Fingerprint fingerprint) {
return new ComparisonFloatOp(proto, fingerprint);
}
- @NonNull
- static ComparisonFloatOp fromProto(@NonNull DynamicProto.ComparisonFloatOp proto) {
+ static @NonNull ComparisonFloatOp fromProto(DynamicProto.@NonNull ComparisonFloatOp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.ComparisonFloatOp toProto() {
+ DynamicProto.@NonNull ComparisonFloatOp toProto() {
return mImpl;
}
/** */
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicBool toDynamicBoolProto() {
+ public DynamicProto.@NonNull DynamicBool toDynamicBoolProto() {
return DynamicProto.DynamicBool.newBuilder().setFloatComparison(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicBool toDynamicBoolProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicBool toDynamicBoolProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicBool.newBuilder()
.setFloatComparison(mImpl)
@@ -5534,8 +5180,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ComparisonFloatOp{"
+ "inputLhs="
+ getInputLhs()
@@ -5557,8 +5202,7 @@
/** Sets the left hand side of the comparison operation. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInputLhs(@NonNull DynamicFloat inputLhs) {
+ public @NonNull Builder setInputLhs(@NonNull DynamicFloat inputLhs) {
mImpl.setInputLhs(inputLhs.toDynamicFloatProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(inputLhs.getFingerprint()).aggregateValueAsInt());
@@ -5567,8 +5211,7 @@
/** Sets the right hand side of the comparison operation. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInputRhs(@NonNull DynamicFloat inputRhs) {
+ public @NonNull Builder setInputRhs(@NonNull DynamicFloat inputRhs) {
mImpl.setInputRhs(inputRhs.toDynamicFloatProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(inputRhs.getFingerprint()).aggregateValueAsInt());
@@ -5577,16 +5220,14 @@
/** Sets the type of the operation. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setOperationType(@ComparisonOpType int operationType) {
+ public @NonNull Builder setOperationType(@ComparisonOpType int operationType) {
mImpl.setOperationType(DynamicProto.ComparisonOpType.forNumber(operationType));
mFingerprint.recordPropertyUpdate(3, operationType);
return this;
}
@Override
- @NonNull
- public ComparisonFloatOp build() {
+ public @NonNull ComparisonFloatOp build() {
return new ComparisonFloatOp(mImpl.build(), mFingerprint);
}
}
@@ -5596,7 +5237,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class NotBoolOp implements DynamicBool {
private final DynamicProto.NotBoolOp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
NotBoolOp(DynamicProto.NotBoolOp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -5604,8 +5245,7 @@
}
/** Gets the input, whose value to negate. */
- @Nullable
- public DynamicBool getInput() {
+ public @Nullable DynamicBool getInput() {
if (mImpl.hasInput()) {
return DynamicBuilders.dynamicBoolFromProto(mImpl.getInput());
} else {
@@ -5615,41 +5255,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static NotBoolOp fromProto(
- @NonNull DynamicProto.NotBoolOp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull NotBoolOp fromProto(
+ DynamicProto.@NonNull NotBoolOp proto, @Nullable Fingerprint fingerprint) {
return new NotBoolOp(proto, fingerprint);
}
- @NonNull
- static NotBoolOp fromProto(@NonNull DynamicProto.NotBoolOp proto) {
+ static @NonNull NotBoolOp fromProto(DynamicProto.@NonNull NotBoolOp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.NotBoolOp toProto() {
+ DynamicProto.@NonNull NotBoolOp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicBool toDynamicBoolProto() {
+ public DynamicProto.@NonNull DynamicBool toDynamicBoolProto() {
return DynamicProto.DynamicBool.newBuilder().setNotOp(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicBool toDynamicBoolProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicBool toDynamicBoolProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicBool.newBuilder()
.setNotOp(mImpl)
@@ -5660,8 +5294,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "NotBoolOp{" + "input=" + getInput() + "}";
}
@@ -5675,8 +5308,7 @@
/** Sets the input, whose value to negate. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInput(@NonNull DynamicBool input) {
+ public @NonNull Builder setInput(@NonNull DynamicBool input) {
mImpl.setInput(input.toDynamicBoolProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(input.getFingerprint()).aggregateValueAsInt());
@@ -5684,8 +5316,7 @@
}
@Override
- @NonNull
- public NotBoolOp build() {
+ public @NonNull NotBoolOp build() {
return new NotBoolOp(mImpl.build(), mFingerprint);
}
}
@@ -5698,7 +5329,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class LogicalBoolOp implements DynamicBool {
private final DynamicProto.LogicalBoolOp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
LogicalBoolOp(DynamicProto.LogicalBoolOp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -5706,8 +5337,7 @@
}
/** Gets the left hand side of the logical operation. */
- @Nullable
- public DynamicBool getInputLhs() {
+ public @Nullable DynamicBool getInputLhs() {
if (mImpl.hasInputLhs()) {
return DynamicBuilders.dynamicBoolFromProto(mImpl.getInputLhs());
} else {
@@ -5716,8 +5346,7 @@
}
/** Gets the right hand side of the logical operation. */
- @Nullable
- public DynamicBool getInputRhs() {
+ public @Nullable DynamicBool getInputRhs() {
if (mImpl.hasInputRhs()) {
return DynamicBuilders.dynamicBoolFromProto(mImpl.getInputRhs());
} else {
@@ -5733,41 +5362,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static LogicalBoolOp fromProto(
- @NonNull DynamicProto.LogicalBoolOp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull LogicalBoolOp fromProto(
+ DynamicProto.@NonNull LogicalBoolOp proto, @Nullable Fingerprint fingerprint) {
return new LogicalBoolOp(proto, fingerprint);
}
- @NonNull
- static LogicalBoolOp fromProto(@NonNull DynamicProto.LogicalBoolOp proto) {
+ static @NonNull LogicalBoolOp fromProto(DynamicProto.@NonNull LogicalBoolOp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.LogicalBoolOp toProto() {
+ DynamicProto.@NonNull LogicalBoolOp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicBool toDynamicBoolProto() {
+ public DynamicProto.@NonNull DynamicBool toDynamicBoolProto() {
return DynamicProto.DynamicBool.newBuilder().setLogicalOp(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicBool toDynamicBoolProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicBool toDynamicBoolProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicBool.newBuilder()
.setLogicalOp(mImpl)
@@ -5778,8 +5401,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "LogicalBoolOp{"
+ "inputLhs="
+ getInputLhs()
@@ -5800,8 +5422,7 @@
/** Sets the left hand side of the logical operation. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInputLhs(@NonNull DynamicBool inputLhs) {
+ public @NonNull Builder setInputLhs(@NonNull DynamicBool inputLhs) {
mImpl.setInputLhs(inputLhs.toDynamicBoolProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(inputLhs.getFingerprint()).aggregateValueAsInt());
@@ -5810,8 +5431,7 @@
/** Sets the right hand side of the logical operation. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInputRhs(@NonNull DynamicBool inputRhs) {
+ public @NonNull Builder setInputRhs(@NonNull DynamicBool inputRhs) {
mImpl.setInputRhs(inputRhs.toDynamicBoolProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(inputRhs.getFingerprint()).aggregateValueAsInt());
@@ -5820,16 +5440,14 @@
/** Sets the operation type to apply to LHS/RHS. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setOperationType(@LogicalOpType int operationType) {
+ public @NonNull Builder setOperationType(@LogicalOpType int operationType) {
mImpl.setOperationType(DynamicProto.LogicalOpType.forNumber(operationType));
mFingerprint.recordPropertyUpdate(3, operationType);
return this;
}
@Override
- @NonNull
- public LogicalBoolOp build() {
+ public @NonNull LogicalBoolOp build() {
return new LogicalBoolOp(mImpl.build(), mFingerprint);
}
}
@@ -5840,13 +5458,11 @@
public interface DynamicBool extends DynamicType {
/** Get the protocol buffer representation of this object, without fingerprint. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DynamicProto.DynamicBool toDynamicBoolProto();
+ DynamicProto.@NonNull DynamicBool toDynamicBoolProto();
/** Get the protocol buffer representation of this object, with or without fingerprint. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DynamicProto.DynamicBool toDynamicBoolProto(boolean withFingerprint);
+ DynamicProto.@NonNull DynamicBool toDynamicBoolProto(boolean withFingerprint);
/**
* Creates a {@link DynamicBool} from a byte array generated by {@link
@@ -5854,8 +5470,7 @@
*
* @throws IllegalArgumentException if the byte array does not contain a valid serialization
*/
- @NonNull
- static DynamicBool fromByteArray(@NonNull byte[] byteArray) {
+ static @NonNull DynamicBool fromByteArray(byte @NonNull [] byteArray) {
return fromByteArray(byteArray, 0, byteArray.length);
}
@@ -5866,8 +5481,8 @@
* @throws IllegalArgumentException if the byte array does not contain a valid serialization
* in the provided offset and length
*/
- @NonNull
- static DynamicBool fromByteArray(@NonNull byte[] byteArray, int offset, int length) {
+ static @NonNull DynamicBool fromByteArray(byte @NonNull [] byteArray, int offset,
+ int length) {
try {
return dynamicBoolFromProto(
DynamicProto.DynamicBool.parseFrom(
@@ -5883,8 +5498,7 @@
* Serializes the {@link DynamicBool} into a new byte array that can later be used with
* {@link #fromByteArray(byte[])}.
*/
- @NonNull
- default byte[] toDynamicBoolByteArray() {
+ default byte @NonNull [] toDynamicBoolByteArray() {
return toDynamicBoolProto(/* withFingerprint= */ true).toByteArray();
}
@@ -5895,7 +5509,7 @@
*
* @throws IllegalArgumentException if the byte array is too small
*/
- default int toDynamicBoolByteArray(@NonNull byte[] byteArray) {
+ default int toDynamicBoolByteArray(byte @NonNull [] byteArray) {
return toDynamicBoolByteArray(byteArray, 0, byteArray.length);
}
@@ -5906,7 +5520,7 @@
*
* @throws IllegalArgumentException if the byte array is too small
*/
- default int toDynamicBoolByteArray(@NonNull byte[] byteArray, int offset, int length) {
+ default int toDynamicBoolByteArray(byte @NonNull [] byteArray, int offset, int length) {
CodedOutputStream stream = CodedOutputStream.newInstance(byteArray, offset, length);
try {
toDynamicBoolProto(/* withFingerprint= */ true).writeTo(stream);
@@ -5918,9 +5532,8 @@
}
/** Creates a constant-valued {@link DynamicBool}. */
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicBool constant(boolean constant) {
+ static @NonNull DynamicBool constant(boolean constant) {
return new FixedBool.Builder().setValue(constant).build();
}
@@ -5929,9 +5542,8 @@
*
* @param dynamicDataKey The key to a {@link DynamicDataValue} with a boolean value.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicBool from(@NonNull DynamicDataKey<DynamicBool> dynamicDataKey) {
+ static @NonNull DynamicBool from(@NonNull DynamicDataKey<DynamicBool> dynamicDataKey) {
return new StateBoolSource.Builder()
.setSourceKey(dynamicDataKey.getKey())
.setSourceNamespace(dynamicDataKey.getNamespace())
@@ -5942,9 +5554,8 @@
* Returns a {@link DynamicBool} that has the opposite value of this {@link DynamicBool}.
* i.e. {code result = !this}
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicBool negate() {
+ default @NonNull DynamicBool negate() {
return new NotBoolOp.Builder().setInput(this).build();
}
@@ -5954,9 +5565,8 @@
*
* @param input The right hand operand of the "and" operation.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicBool and(@NonNull DynamicBool input) {
+ default @NonNull DynamicBool and(@NonNull DynamicBool input) {
return new LogicalBoolOp.Builder()
.setInputLhs(this)
.setInputRhs(input)
@@ -5970,9 +5580,8 @@
*
* @param input The right hand operand of the "or" operation.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicBool or(@NonNull DynamicBool input) {
+ default @NonNull DynamicBool or(@NonNull DynamicBool input) {
return new LogicalBoolOp.Builder()
.setInputLhs(this)
.setInputRhs(input)
@@ -5984,9 +5593,8 @@
* Returns a {@link DynamicBool} that is true if the value of this {@link DynamicBool} and
* {@code other} are equal, otherwise it's false.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicBool eq(@NonNull DynamicBool other) {
+ default @NonNull DynamicBool eq(@NonNull DynamicBool other) {
return new LogicalBoolOp.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -5998,9 +5606,8 @@
* Returns a {@link DynamicBool} that is true if the value of this {@link DynamicBool} and
* {@code other} are not equal, otherwise it's false.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicBool ne(@NonNull DynamicBool other) {
+ default @NonNull DynamicBool ne(@NonNull DynamicBool other) {
return new LogicalBoolOp.Builder()
.setInputLhs(this)
.setInputRhs(other)
@@ -6010,24 +5617,21 @@
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link DynamicBool} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- DynamicBool build();
+ @NonNull DynamicBool build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DynamicBool dynamicBoolFromProto(
- @NonNull DynamicProto.DynamicBool proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull DynamicBool dynamicBoolFromProto(
+ DynamicProto.@NonNull DynamicBool proto, @Nullable Fingerprint fingerprint) {
if (proto.hasFixed()) {
return FixedBool.fromProto(proto.getFixed(), fingerprint);
}
@@ -6054,8 +5658,8 @@
* created using this method can't be added to any other wrapper.
*/
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DynamicBool dynamicBoolFromProto(@NonNull DynamicProto.DynamicBool proto) {
+ public static @NonNull DynamicBool dynamicBoolFromProto(
+ DynamicProto.@NonNull DynamicBool proto) {
return dynamicBoolFromProto(proto, new Fingerprint(proto.getFingerprint()));
}
@@ -6063,7 +5667,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class StateColorSource implements DynamicColor {
private final DynamicProto.StateColorSource mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
StateColorSource(DynamicProto.StateColorSource impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -6071,54 +5675,46 @@
}
/** Gets the key in the state to bind to. */
- @NonNull
- public String getSourceKey() {
+ public @NonNull String getSourceKey() {
return mImpl.getSourceKey();
}
/** Gets the namespace for the state key. */
- @NonNull
- public String getSourceNamespace() {
+ public @NonNull String getSourceNamespace() {
return mImpl.getSourceNamespace();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static StateColorSource fromProto(
- @NonNull DynamicProto.StateColorSource proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull StateColorSource fromProto(
+ DynamicProto.@NonNull StateColorSource proto, @Nullable Fingerprint fingerprint) {
return new StateColorSource(proto, fingerprint);
}
- @NonNull
- static StateColorSource fromProto(@NonNull DynamicProto.StateColorSource proto) {
+ static @NonNull StateColorSource fromProto(DynamicProto.@NonNull StateColorSource proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.StateColorSource toProto() {
+ DynamicProto.@NonNull StateColorSource toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicColor toDynamicColorProto() {
+ public DynamicProto.@NonNull DynamicColor toDynamicColorProto() {
return DynamicProto.DynamicColor.newBuilder().setStateSource(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicColor toDynamicColorProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicColor toDynamicColorProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicColor.newBuilder()
.setStateSource(mImpl)
@@ -6129,8 +5725,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "StateColorSource{"
+ "sourceKey="
+ getSourceKey()
@@ -6149,8 +5744,7 @@
/** Sets the key in the state to bind to. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setSourceKey(@NonNull String sourceKey) {
+ public @NonNull Builder setSourceKey(@NonNull String sourceKey) {
mImpl.setSourceKey(sourceKey);
mFingerprint.recordPropertyUpdate(1, sourceKey.hashCode());
return this;
@@ -6158,16 +5752,14 @@
/** Sets the namespace for the state key. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setSourceNamespace(@NonNull String sourceNamespace) {
+ public @NonNull Builder setSourceNamespace(@NonNull String sourceNamespace) {
mImpl.setSourceNamespace(sourceNamespace);
mFingerprint.recordPropertyUpdate(2, sourceNamespace.hashCode());
return this;
}
@Override
- @NonNull
- public StateColorSource build() {
+ public @NonNull StateColorSource build() {
return new StateColorSource(mImpl.build(), mFingerprint);
}
}
@@ -6177,7 +5769,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class AnimatableFixedColor implements DynamicColor {
private final DynamicProto.AnimatableFixedColor mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AnimatableFixedColor(
DynamicProto.AnimatableFixedColor impl, @Nullable Fingerprint fingerprint) {
@@ -6198,8 +5790,7 @@
}
/** Gets the animation parameters for duration, delay, etc. */
- @Nullable
- public AnimationSpec getAnimationSpec() {
+ public @Nullable AnimationSpec getAnimationSpec() {
if (mImpl.hasAnimationSpec()) {
return AnimationSpec.fromProto(mImpl.getAnimationSpec());
} else {
@@ -6209,42 +5800,37 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AnimatableFixedColor fromProto(
- @NonNull DynamicProto.AnimatableFixedColor proto,
+ public static @NonNull AnimatableFixedColor fromProto(
+ DynamicProto.@NonNull AnimatableFixedColor proto,
@Nullable Fingerprint fingerprint) {
return new AnimatableFixedColor(proto, fingerprint);
}
- @NonNull
- static AnimatableFixedColor fromProto(@NonNull DynamicProto.AnimatableFixedColor proto) {
+ static @NonNull AnimatableFixedColor fromProto(
+ DynamicProto.@NonNull AnimatableFixedColor proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.AnimatableFixedColor toProto() {
+ DynamicProto.@NonNull AnimatableFixedColor toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicColor toDynamicColorProto() {
+ public DynamicProto.@NonNull DynamicColor toDynamicColorProto() {
return DynamicProto.DynamicColor.newBuilder().setAnimatableFixed(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicColor toDynamicColorProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicColor toDynamicColorProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicColor.newBuilder()
.setAnimatableFixed(mImpl)
@@ -6255,8 +5841,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AnimatableFixedColor{"
+ "fromArgb="
+ getFromArgb()
@@ -6277,8 +5862,7 @@
/** Sets the color value (in ARGB format) to start animating from. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setFromArgb(@ColorInt int fromArgb) {
+ public @NonNull Builder setFromArgb(@ColorInt int fromArgb) {
mImpl.setFromArgb(fromArgb);
mFingerprint.recordPropertyUpdate(1, fromArgb);
return this;
@@ -6286,8 +5870,7 @@
/** Sets the color value (in ARGB format) to animate to. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setToArgb(@ColorInt int toArgb) {
+ public @NonNull Builder setToArgb(@ColorInt int toArgb) {
mImpl.setToArgb(toArgb);
mFingerprint.recordPropertyUpdate(2, toArgb);
return this;
@@ -6295,8 +5878,7 @@
/** Sets the animation parameters for duration, delay, etc. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
+ public @NonNull Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
mImpl.setAnimationSpec(animationSpec.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(animationSpec.getFingerprint()).aggregateValueAsInt());
@@ -6304,8 +5886,7 @@
}
@Override
- @NonNull
- public AnimatableFixedColor build() {
+ public @NonNull AnimatableFixedColor build() {
return new AnimatableFixedColor(mImpl.build(), mFingerprint);
}
}
@@ -6323,7 +5904,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class AnimatableDynamicColor implements DynamicColor {
private final DynamicProto.AnimatableDynamicColor mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AnimatableDynamicColor(
DynamicProto.AnimatableDynamicColor impl, @Nullable Fingerprint fingerprint) {
@@ -6332,8 +5913,7 @@
}
/** Gets the value to watch, and animate when it changes. */
- @Nullable
- public DynamicColor getInput() {
+ public @Nullable DynamicColor getInput() {
if (mImpl.hasInput()) {
return DynamicBuilders.dynamicColorFromProto(mImpl.getInput());
} else {
@@ -6342,8 +5922,7 @@
}
/** Gets the animation parameters for duration, delay, etc. */
- @Nullable
- public AnimationSpec getAnimationSpec() {
+ public @Nullable AnimationSpec getAnimationSpec() {
if (mImpl.hasAnimationSpec()) {
return AnimationSpec.fromProto(mImpl.getAnimationSpec());
} else {
@@ -6353,43 +5932,37 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AnimatableDynamicColor fromProto(
- @NonNull DynamicProto.AnimatableDynamicColor proto,
+ public static @NonNull AnimatableDynamicColor fromProto(
+ DynamicProto.@NonNull AnimatableDynamicColor proto,
@Nullable Fingerprint fingerprint) {
return new AnimatableDynamicColor(proto, fingerprint);
}
- @NonNull
- static AnimatableDynamicColor fromProto(
- @NonNull DynamicProto.AnimatableDynamicColor proto) {
+ static @NonNull AnimatableDynamicColor fromProto(
+ DynamicProto.@NonNull AnimatableDynamicColor proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.AnimatableDynamicColor toProto() {
+ DynamicProto.@NonNull AnimatableDynamicColor toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicColor toDynamicColorProto() {
+ public DynamicProto.@NonNull DynamicColor toDynamicColorProto() {
return DynamicProto.DynamicColor.newBuilder().setAnimatableDynamic(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicColor toDynamicColorProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicColor toDynamicColorProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicColor.newBuilder()
.setAnimatableDynamic(mImpl)
@@ -6400,8 +5973,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AnimatableDynamicColor{"
+ "input="
+ getInput()
@@ -6420,8 +5992,7 @@
/** Sets the value to watch, and animate when it changes. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInput(@NonNull DynamicColor input) {
+ public @NonNull Builder setInput(@NonNull DynamicColor input) {
mImpl.setInput(input.toDynamicColorProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(input.getFingerprint()).aggregateValueAsInt());
@@ -6430,8 +6001,7 @@
/** Sets the animation parameters for duration, delay, etc. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
+ public @NonNull Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
mImpl.setAnimationSpec(animationSpec.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(animationSpec.getFingerprint()).aggregateValueAsInt());
@@ -6439,8 +6009,7 @@
}
@Override
- @NonNull
- public AnimatableDynamicColor build() {
+ public @NonNull AnimatableDynamicColor build() {
return new AnimatableDynamicColor(mImpl.build(), mFingerprint);
}
}
@@ -6457,7 +6026,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class ConditionalColorOp implements DynamicColor {
private final DynamicProto.ConditionalColorOp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ConditionalColorOp(
DynamicProto.ConditionalColorOp impl, @Nullable Fingerprint fingerprint) {
@@ -6466,8 +6035,7 @@
}
/** Gets the condition to use. */
- @Nullable
- public DynamicBool getCondition() {
+ public @Nullable DynamicBool getCondition() {
if (mImpl.hasCondition()) {
return DynamicBuilders.dynamicBoolFromProto(mImpl.getCondition());
} else {
@@ -6476,8 +6044,7 @@
}
/** Gets the color to yield if condition is true. */
- @Nullable
- public DynamicColor getValueIfTrue() {
+ public @Nullable DynamicColor getValueIfTrue() {
if (mImpl.hasValueIfTrue()) {
return DynamicBuilders.dynamicColorFromProto(mImpl.getValueIfTrue());
} else {
@@ -6486,8 +6053,7 @@
}
/** Gets the color to yield if condition is false. */
- @Nullable
- public DynamicColor getValueIfFalse() {
+ public @Nullable DynamicColor getValueIfFalse() {
if (mImpl.hasValueIfFalse()) {
return DynamicBuilders.dynamicColorFromProto(mImpl.getValueIfFalse());
} else {
@@ -6497,41 +6063,36 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ConditionalColorOp fromProto(
- @NonNull DynamicProto.ConditionalColorOp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ConditionalColorOp fromProto(
+ DynamicProto.@NonNull ConditionalColorOp proto, @Nullable Fingerprint fingerprint) {
return new ConditionalColorOp(proto, fingerprint);
}
- @NonNull
- static ConditionalColorOp fromProto(@NonNull DynamicProto.ConditionalColorOp proto) {
+ static @NonNull ConditionalColorOp fromProto(
+ DynamicProto.@NonNull ConditionalColorOp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.ConditionalColorOp toProto() {
+ DynamicProto.@NonNull ConditionalColorOp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicColor toDynamicColorProto() {
+ public DynamicProto.@NonNull DynamicColor toDynamicColorProto() {
return DynamicProto.DynamicColor.newBuilder().setConditionalOp(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicColor toDynamicColorProto(boolean withFringerprint) {
+ public DynamicProto.@NonNull DynamicColor toDynamicColorProto(boolean withFringerprint) {
if (withFringerprint) {
return DynamicProto.DynamicColor.newBuilder()
.setConditionalOp(mImpl)
@@ -6542,8 +6103,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ConditionalColorOp{"
+ "condition="
+ getCondition()
@@ -6564,8 +6124,7 @@
/** Sets the condition to use. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setCondition(@NonNull DynamicBool condition) {
+ public @NonNull Builder setCondition(@NonNull DynamicBool condition) {
mImpl.setCondition(condition.toDynamicBoolProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(condition.getFingerprint()).aggregateValueAsInt());
@@ -6574,8 +6133,7 @@
/** Sets the color to yield if condition is true. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setValueIfTrue(@NonNull DynamicColor valueIfTrue) {
+ public @NonNull Builder setValueIfTrue(@NonNull DynamicColor valueIfTrue) {
mImpl.setValueIfTrue(valueIfTrue.toDynamicColorProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(valueIfTrue.getFingerprint()).aggregateValueAsInt());
@@ -6584,8 +6142,7 @@
/** Sets the color to yield if condition is false. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setValueIfFalse(@NonNull DynamicColor valueIfFalse) {
+ public @NonNull Builder setValueIfFalse(@NonNull DynamicColor valueIfFalse) {
mImpl.setValueIfFalse(valueIfFalse.toDynamicColorProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(valueIfFalse.getFingerprint()).aggregateValueAsInt());
@@ -6593,8 +6150,7 @@
}
@Override
- @NonNull
- public ConditionalColorOp build() {
+ public @NonNull ConditionalColorOp build() {
return new ConditionalColorOp(mImpl.build(), mFingerprint);
}
}
@@ -6605,13 +6161,11 @@
public interface DynamicColor extends DynamicType {
/** Get the protocol buffer representation of this object, without fingerprint. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DynamicProto.DynamicColor toDynamicColorProto();
+ DynamicProto.@NonNull DynamicColor toDynamicColorProto();
/** Get the protocol buffer representation of this object, with or without fingerprint. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DynamicProto.DynamicColor toDynamicColorProto(boolean withFingerprint);
+ DynamicProto.@NonNull DynamicColor toDynamicColorProto(boolean withFingerprint);
/**
* Creates a {@link DynamicColor} from a byte array generated by {@link
@@ -6619,8 +6173,7 @@
*
* @throws IllegalArgumentException if the byte array does not contain a valid serialization
*/
- @NonNull
- static DynamicColor fromByteArray(@NonNull byte[] byteArray) {
+ static @NonNull DynamicColor fromByteArray(byte @NonNull [] byteArray) {
return fromByteArray(byteArray, 0, byteArray.length);
}
@@ -6631,8 +6184,8 @@
* @throws IllegalArgumentException if the byte array does not contain a valid serialization
* in the provided offset and length
*/
- @NonNull
- static DynamicColor fromByteArray(@NonNull byte[] byteArray, int offset, int length) {
+ static @NonNull DynamicColor fromByteArray(byte @NonNull [] byteArray, int offset,
+ int length) {
try {
return dynamicColorFromProto(
DynamicProto.DynamicColor.parseFrom(
@@ -6648,8 +6201,7 @@
* Serializes the {@link DynamicColor} into a new byte array that can later be used with
* {@link #fromByteArray(byte[])}.
*/
- @NonNull
- default byte[] toDynamicColorByteArray() {
+ default byte @NonNull [] toDynamicColorByteArray() {
return toDynamicColorProto(/* withFingerprint= */ true).toByteArray();
}
@@ -6660,7 +6212,7 @@
*
* @throws IllegalArgumentException if the byte array is too small
*/
- default int toDynamicColorByteArray(@NonNull byte[] byteArray) {
+ default int toDynamicColorByteArray(byte @NonNull [] byteArray) {
return toDynamicColorByteArray(byteArray, 0, byteArray.length);
}
@@ -6671,7 +6223,7 @@
*
* @throws IllegalArgumentException if the byte array is too small
*/
- default int toDynamicColorByteArray(@NonNull byte[] byteArray, int offset, int length) {
+ default int toDynamicColorByteArray(byte @NonNull [] byteArray, int offset, int length) {
CodedOutputStream stream = CodedOutputStream.newInstance(byteArray, offset, length);
try {
toDynamicColorProto(/* withFingerprint= */ true).writeTo(stream);
@@ -6683,9 +6235,8 @@
}
/** Creates a constant-valued {@link DynamicColor}. */
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicColor constant(@ColorInt int constant) {
+ static @NonNull DynamicColor constant(@ColorInt int constant) {
return new FixedColor.Builder().setArgb(constant).build();
}
@@ -6694,9 +6245,8 @@
*
* @param dynamicDataKey The source key to a {@link DynamicDataValue} with a color value.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicColor from(@NonNull DynamicDataKey<DynamicColor> dynamicDataKey) {
+ static @NonNull DynamicColor from(@NonNull DynamicDataKey<DynamicColor> dynamicDataKey) {
return new StateColorSource.Builder()
.setSourceKey(dynamicDataKey.getKey())
.setSourceNamespace(dynamicDataKey.getNamespace())
@@ -6710,9 +6260,8 @@
* @param start The start value of the range.
* @param end The end value of the range.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicColor animate(@ColorInt int start, @ColorInt int end) {
+ static @NonNull DynamicColor animate(@ColorInt int start, @ColorInt int end) {
return new AnimatableFixedColor.Builder().setFromArgb(start).setToArgb(end).build();
}
@@ -6724,9 +6273,8 @@
* @param end The end value of the range.
* @param animationSpec The animation parameters.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicColor animate(
+ static @NonNull DynamicColor animate(
@ColorInt int start, @ColorInt int end, @NonNull AnimationSpec animationSpec) {
return new AnimatableFixedColor.Builder()
.setFromArgb(start)
@@ -6742,9 +6290,8 @@
*
* @param dynamicDataKey The source key to a {@link DynamicDataValue} with a color value.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicColor animate(@NonNull DynamicDataKey<DynamicColor> dynamicDataKey) {
+ static @NonNull DynamicColor animate(@NonNull DynamicDataKey<DynamicColor> dynamicDataKey) {
return new AnimatableDynamicColor.Builder().setInput(from(dynamicDataKey)).build();
}
@@ -6756,9 +6303,8 @@
* @param dynamicDataKey The source key to a {@link DynamicDataValue} with a color value.
* @param animationSpec The animation parameters.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicColor animate(
+ static @NonNull DynamicColor animate(
@NonNull DynamicDataKey<DynamicColor> dynamicDataKey,
@NonNull AnimationSpec animationSpec) {
return new AnimatableDynamicColor.Builder()
@@ -6774,9 +6320,8 @@
*
* @param animationSpec The animation parameters.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicColor animate(@NonNull AnimationSpec animationSpec) {
+ default @NonNull DynamicColor animate(@NonNull AnimationSpec animationSpec) {
return new AnimatableDynamicColor.Builder()
.setInput(this)
.setAnimationSpec(animationSpec)
@@ -6788,9 +6333,8 @@
* and every time its value is changing, it animates from its current value to the new
* value.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicColor animate() {
+ default @NonNull DynamicColor animate() {
return new AnimatableDynamicColor.Builder().setInput(this).build();
}
@@ -6800,9 +6344,9 @@
* ConditionScopes.IfTrueScope#elseUse} depending on the value yielded from {@code
* condition}.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static ConditionScope<DynamicColor, Integer> onCondition(@NonNull DynamicBool condition) {
+ static @NonNull ConditionScope<DynamicColor, Integer> onCondition(
+ @NonNull DynamicBool condition) {
return new ConditionScopes.ConditionScope<>(
(trueValue, falseValue) ->
new ConditionalColorOp.Builder()
@@ -6815,24 +6359,21 @@
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link DynamicColor} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- DynamicColor build();
+ @NonNull DynamicColor build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DynamicColor dynamicColorFromProto(
- @NonNull DynamicProto.DynamicColor proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull DynamicColor dynamicColorFromProto(
+ DynamicProto.@NonNull DynamicColor proto, @Nullable Fingerprint fingerprint) {
if (proto.hasFixed()) {
return FixedColor.fromProto(proto.getFixed(), fingerprint);
}
@@ -6856,8 +6397,8 @@
* created using this method can't be added to any other wrapper.
*/
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DynamicColor dynamicColorFromProto(@NonNull DynamicProto.DynamicColor proto) {
+ public static @NonNull DynamicColor dynamicColorFromProto(
+ DynamicProto.@NonNull DynamicColor proto) {
return dynamicColorFromProto(proto, new Fingerprint(proto.getFingerprint()));
}
@@ -6865,7 +6406,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class PlatformTimeSource implements DynamicInstant {
private final DynamicProto.PlatformTimeSource mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
PlatformTimeSource(
DynamicProto.PlatformTimeSource impl, @Nullable Fingerprint fingerprint) {
@@ -6875,41 +6416,36 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static PlatformTimeSource fromProto(
- @NonNull DynamicProto.PlatformTimeSource proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull PlatformTimeSource fromProto(
+ DynamicProto.@NonNull PlatformTimeSource proto, @Nullable Fingerprint fingerprint) {
return new PlatformTimeSource(proto, fingerprint);
}
- @NonNull
- static PlatformTimeSource fromProto(@NonNull DynamicProto.PlatformTimeSource proto) {
+ static @NonNull PlatformTimeSource fromProto(
+ DynamicProto.@NonNull PlatformTimeSource proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.PlatformTimeSource toProto() {
+ DynamicProto.@NonNull PlatformTimeSource toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInstant toDynamicInstantProto() {
+ public DynamicProto.@NonNull DynamicInstant toDynamicInstantProto() {
return DynamicProto.DynamicInstant.newBuilder().setPlatformSource(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInstant toDynamicInstantProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicInstant toDynamicInstantProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicInstant.newBuilder()
.setPlatformSource(mImpl)
@@ -6920,8 +6456,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "PlatformTimeSource";
}
@@ -6934,8 +6469,7 @@
public Builder() {}
@Override
- @NonNull
- public PlatformTimeSource build() {
+ public @NonNull PlatformTimeSource build() {
return new PlatformTimeSource(mImpl.build(), mFingerprint);
}
}
@@ -6952,7 +6486,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class ConditionalInstantOp implements DynamicInstant {
private final DynamicProto.ConditionalInstantOp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ConditionalInstantOp(
DynamicProto.ConditionalInstantOp impl, @Nullable Fingerprint fingerprint) {
@@ -6961,8 +6495,7 @@
}
/** Gets the condition to use. */
- @Nullable
- public DynamicBool getCondition() {
+ public @Nullable DynamicBool getCondition() {
if (mImpl.hasCondition()) {
return DynamicBuilders.dynamicBoolFromProto(mImpl.getCondition());
} else {
@@ -6971,8 +6504,7 @@
}
/** Gets the instant to yield if condition is true. */
- @Nullable
- public DynamicInstant getValueIfTrue() {
+ public @Nullable DynamicInstant getValueIfTrue() {
if (mImpl.hasValueIfTrue()) {
return DynamicBuilders.dynamicInstantFromProto(mImpl.getValueIfTrue());
} else {
@@ -6981,8 +6513,7 @@
}
/** Gets the instant to yield if condition is false. */
- @Nullable
- public DynamicInstant getValueIfFalse() {
+ public @Nullable DynamicInstant getValueIfFalse() {
if (mImpl.hasValueIfFalse()) {
return DynamicBuilders.dynamicInstantFromProto(mImpl.getValueIfFalse());
} else {
@@ -6992,42 +6523,37 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ConditionalInstantOp fromProto(
- @NonNull DynamicProto.ConditionalInstantOp proto,
+ public static @NonNull ConditionalInstantOp fromProto(
+ DynamicProto.@NonNull ConditionalInstantOp proto,
@Nullable Fingerprint fingerprint) {
return new ConditionalInstantOp(proto, fingerprint);
}
- @NonNull
- static ConditionalInstantOp fromProto(@NonNull DynamicProto.ConditionalInstantOp proto) {
+ static @NonNull ConditionalInstantOp fromProto(
+ DynamicProto.@NonNull ConditionalInstantOp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.ConditionalInstantOp toProto() {
+ DynamicProto.@NonNull ConditionalInstantOp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInstant toDynamicInstantProto() {
+ public DynamicProto.@NonNull DynamicInstant toDynamicInstantProto() {
return DynamicProto.DynamicInstant.newBuilder().setConditionalOp(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInstant toDynamicInstantProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicInstant toDynamicInstantProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicInstant.newBuilder()
.setConditionalOp(mImpl)
@@ -7039,8 +6565,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ConditionalInstantOp{"
+ "condition="
+ getCondition()
@@ -7061,8 +6586,7 @@
/** Sets the condition to use. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setCondition(@NonNull DynamicBool condition) {
+ public @NonNull Builder setCondition(@NonNull DynamicBool condition) {
mImpl.setCondition(condition.toDynamicBoolProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(condition.getFingerprint()).aggregateValueAsInt());
@@ -7071,8 +6595,7 @@
/** Sets the instant to yield if condition is true. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setValueIfTrue(@NonNull DynamicInstant valueIfTrue) {
+ public @NonNull Builder setValueIfTrue(@NonNull DynamicInstant valueIfTrue) {
mImpl.setValueIfTrue(valueIfTrue.toDynamicInstantProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(valueIfTrue.getFingerprint()).aggregateValueAsInt());
@@ -7081,8 +6604,7 @@
/** Sets the instant to yield if condition is false. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setValueIfFalse(@NonNull DynamicInstant valueIfFalse) {
+ public @NonNull Builder setValueIfFalse(@NonNull DynamicInstant valueIfFalse) {
mImpl.setValueIfFalse(valueIfFalse.toDynamicInstantProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(valueIfFalse.getFingerprint()).aggregateValueAsInt());
@@ -7090,8 +6612,7 @@
}
@Override
- @NonNull
- public ConditionalInstantOp build() {
+ public @NonNull ConditionalInstantOp build() {
return new ConditionalInstantOp(mImpl.build(), mFingerprint);
}
}
@@ -7107,13 +6628,11 @@
public interface DynamicInstant extends DynamicType {
/** Get the protocol buffer representation of this object, without fingerprint. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DynamicProto.DynamicInstant toDynamicInstantProto();
+ DynamicProto.@NonNull DynamicInstant toDynamicInstantProto();
/** Get the protocol buffer representation of this object, with or without fingerprint. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DynamicProto.DynamicInstant toDynamicInstantProto(boolean withFingerprint);
+ DynamicProto.@NonNull DynamicInstant toDynamicInstantProto(boolean withFingerprint);
/**
* Creates a {@link DynamicInstant} from a byte array generated by {@link
@@ -7121,8 +6640,7 @@
*
* @throws IllegalArgumentException if the byte array does not contain a valid serialization
*/
- @NonNull
- static DynamicInstant fromByteArray(@NonNull byte[] byteArray) {
+ static @NonNull DynamicInstant fromByteArray(byte @NonNull [] byteArray) {
return fromByteArray(byteArray, 0, byteArray.length);
}
@@ -7133,8 +6651,8 @@
* @throws IllegalArgumentException if the byte array does not contain a valid serialization
* in the provided offset and length
*/
- @NonNull
- static DynamicInstant fromByteArray(@NonNull byte[] byteArray, int offset, int length) {
+ static @NonNull DynamicInstant fromByteArray(byte @NonNull [] byteArray, int offset,
+ int length) {
try {
return dynamicInstantFromProto(
DynamicProto.DynamicInstant.parseFrom(
@@ -7150,8 +6668,7 @@
* Serializes the {@link DynamicInstant} into a new byte array that can later be used with
* {@link #fromByteArray(byte[])}.
*/
- @NonNull
- default byte[] toDynamicInstantByteArray() {
+ default byte @NonNull [] toDynamicInstantByteArray() {
return toDynamicInstantProto(/* withFingerprint= */ true).toByteArray();
}
@@ -7162,7 +6679,7 @@
*
* @throws IllegalArgumentException if the byte array is too small
*/
- default int toDynamicInstantByteArray(@NonNull byte[] byteArray) {
+ default int toDynamicInstantByteArray(byte @NonNull [] byteArray) {
return toDynamicInstantByteArray(byteArray, 0, byteArray.length);
}
@@ -7173,7 +6690,7 @@
*
* @throws IllegalArgumentException if the byte array is too small
*/
- default int toDynamicInstantByteArray(@NonNull byte[] byteArray, int offset, int length) {
+ default int toDynamicInstantByteArray(byte @NonNull [] byteArray, int offset, int length) {
CodedOutputStream stream = CodedOutputStream.newInstance(byteArray, offset, length);
try {
toDynamicInstantProto(/* withFingerprint= */ true).writeTo(stream);
@@ -7190,9 +6707,9 @@
* @param dynamicDataKey The source key to a {@link DynamicDataValue} with an {@link
* Instant} value.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 300)
- static DynamicInstant from(@NonNull DynamicDataKey<DynamicInstant> dynamicDataKey) {
+ static @NonNull DynamicInstant from(
+ @NonNull DynamicDataKey<DynamicInstant> dynamicDataKey) {
return new StateInstantSource.Builder()
.setSourceKey(dynamicDataKey.getKey())
.setSourceNamespace(dynamicDataKey.getNamespace())
@@ -7204,9 +6721,8 @@
* Instant} precision is greater than seconds, then any excess precision information will be
* dropped.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicInstant withSecondsPrecision(@NonNull Instant instant) {
+ static @NonNull DynamicInstant withSecondsPrecision(@NonNull Instant instant) {
return new FixedInstant.Builder().setEpochSeconds(instant.getEpochSecond()).build();
}
@@ -7214,9 +6730,8 @@
* Creates a {@link DynamicInstant} that updates its value periodically from the system
* time.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicInstant platformTimeWithSecondsPrecision() {
+ static @NonNull DynamicInstant platformTimeWithSecondsPrecision() {
return new PlatformTimeSource.Builder().build();
}
@@ -7233,9 +6748,8 @@
*
* @return a new instance of {@link DynamicDuration} containing the result of the operation.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicDuration durationUntil(@NonNull DynamicInstant to) {
+ default @NonNull DynamicDuration durationUntil(@NonNull DynamicInstant to) {
return new BetweenDuration.Builder()
.setStartInclusive(this)
.setEndExclusive(to)
@@ -7252,8 +6766,7 @@
* </pre>
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- default DynamicInt32 getYear(@NonNull ZoneId zoneId) {
+ default @NonNull DynamicInt32 getYear(@NonNull ZoneId zoneId) {
return this.atZone(zoneId).getYear();
}
@@ -7267,8 +6780,7 @@
* </pre>
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- default DynamicInt32 getMonth(@NonNull ZoneId zoneId) {
+ default @NonNull DynamicInt32 getMonth(@NonNull ZoneId zoneId) {
return this.atZone(zoneId).getMonth();
}
@@ -7282,8 +6794,7 @@
* </pre>
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- default DynamicInt32 getDayOfMonth(@NonNull ZoneId zoneId) {
+ default @NonNull DynamicInt32 getDayOfMonth(@NonNull ZoneId zoneId) {
return this.atZone(zoneId).getDayOfMonth();
}
@@ -7298,8 +6809,7 @@
* </pre>
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- default DynamicInt32 getDayOfWeek(@NonNull ZoneId zoneId) {
+ default @NonNull DynamicInt32 getDayOfWeek(@NonNull ZoneId zoneId) {
return this.atZone(zoneId).getDayOfWeek();
}
@@ -7313,8 +6823,7 @@
* </pre>
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- default DynamicInt32 getHour(@NonNull ZoneId zoneId) {
+ default @NonNull DynamicInt32 getHour(@NonNull ZoneId zoneId) {
return this.atZone(zoneId).getHour();
}
@@ -7328,8 +6837,7 @@
* </pre>
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- default DynamicInt32 getMinute(@NonNull ZoneId zoneId) {
+ default @NonNull DynamicInt32 getMinute(@NonNull ZoneId zoneId) {
return this.atZone(zoneId).getMinute();
}
@@ -7343,8 +6851,7 @@
* </pre>
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- default DynamicInt32 getSecond(@NonNull ZoneId zoneId) {
+ default @NonNull DynamicInt32 getSecond(@NonNull ZoneId zoneId) {
return this.atZone(zoneId).getSecond();
}
@@ -7362,9 +6869,8 @@
* DynamicInstant} in the specified time-zone.
*/
@RestrictTo(Scope.LIBRARY)
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 300)
- default DynamicZonedDateTime atZone(@NonNull ZoneId zoneId) {
+ default @NonNull DynamicZonedDateTime atZone(@NonNull ZoneId zoneId) {
return new InstantToZonedDateTimeOp.Builder()
.setInstant(this)
.setZoneId(zoneId.getId())
@@ -7377,9 +6883,9 @@
* ConditionScopes.IfTrueScope#elseUse} depending on the value yielded from {@code
* condition}.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static ConditionScope<DynamicInstant, Instant> onCondition(@NonNull DynamicBool condition) {
+ static @NonNull ConditionScope<DynamicInstant, Instant> onCondition(
+ @NonNull DynamicBool condition) {
return new ConditionScopes.ConditionScope<>(
(trueValue, falseValue) ->
new ConditionalInstantOp.Builder()
@@ -7392,24 +6898,21 @@
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link DynamicInstant} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- DynamicInstant build();
+ @NonNull DynamicInstant build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DynamicInstant dynamicInstantFromProto(
- @NonNull DynamicProto.DynamicInstant proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull DynamicInstant dynamicInstantFromProto(
+ DynamicProto.@NonNull DynamicInstant proto, @Nullable Fingerprint fingerprint) {
if (proto.hasFixed()) {
return FixedInstant.fromProto(proto.getFixed(), fingerprint);
}
@@ -7430,9 +6933,8 @@
* created using this method can't be added to any other wrapper.
*/
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DynamicInstant dynamicInstantFromProto(
- @NonNull DynamicProto.DynamicInstant proto) {
+ public static @NonNull DynamicInstant dynamicInstantFromProto(
+ DynamicProto.@NonNull DynamicInstant proto) {
return dynamicInstantFromProto(proto, new Fingerprint(proto.getFingerprint()));
}
@@ -7446,8 +6948,7 @@
interface DynamicZonedDateTime extends DynamicType {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DynamicProto.DynamicZonedDateTime toDynamicZonedDateTimeProto();
+ DynamicProto.@NonNull DynamicZonedDateTime toDynamicZonedDateTimeProto();
/**
* Creates a {@link DynamicZonedDateTime} from a byte array generated by {@link
@@ -7455,8 +6956,7 @@
*
* @throws IllegalArgumentException if the byte array does not contain a valid serialization
*/
- @NonNull
- static DynamicZonedDateTime fromByteArray(@NonNull byte[] byteArray) {
+ static @NonNull DynamicZonedDateTime fromByteArray(byte @NonNull [] byteArray) {
return fromByteArray(byteArray, 0, byteArray.length);
}
@@ -7468,9 +6968,8 @@
* @throws IllegalArgumentException if the byte array does not contain a valid serialization
* in the provided offset and length
*/
- @NonNull
- static DynamicZonedDateTime fromByteArray(
- @NonNull byte[] byteArray, int offset, int length) {
+ static @NonNull DynamicZonedDateTime fromByteArray(
+ byte @NonNull [] byteArray, int offset, int length) {
try {
return dynamicZonedDateTimeFromProto(
DynamicProto.DynamicZonedDateTime.parseFrom(
@@ -7486,8 +6985,7 @@
* Serializes the {@link DynamicZonedDateTime} into a new byte array that can later be used
* with {@link #fromByteArray(byte[])}.
*/
- @NonNull
- default byte[] toDynamicZonedDateTimeByteArray() {
+ default byte @NonNull [] toDynamicZonedDateTimeByteArray() {
return toDynamicZonedDateTimeProto().toByteArray();
}
@@ -7498,7 +6996,7 @@
*
* @throws IllegalArgumentException if the byte array is too small
*/
- default int toDynamicZonedDateTimeByteArray(@NonNull byte[] byteArray) {
+ default int toDynamicZonedDateTimeByteArray(byte @NonNull [] byteArray) {
return toDynamicZonedDateTimeByteArray(byteArray, 0, byteArray.length);
}
@@ -7510,7 +7008,7 @@
* @throws IllegalArgumentException if the byte array is too small
*/
default int toDynamicZonedDateTimeByteArray(
- @NonNull byte[] byteArray, int offset, int length) {
+ byte @NonNull [] byteArray, int offset, int length) {
CodedOutputStream stream = CodedOutputStream.newInstance(byteArray, offset, length);
try {
toDynamicZonedDateTimeProto().writeTo(stream);
@@ -7532,9 +7030,8 @@
* .getYear();
* </pre>
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 300)
- default DynamicInt32 getYear() {
+ default @NonNull DynamicInt32 getYear() {
return new GetZonedDateTimePartOp.Builder()
.setInput(this)
.setPartType(ZONED_DATE_TIME_PART_YEAR)
@@ -7551,9 +7048,8 @@
* .getMonth();
* </pre>
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 300)
- default DynamicInt32 getMonth() {
+ default @NonNull DynamicInt32 getMonth() {
return new GetZonedDateTimePartOp.Builder()
.setInput(this)
.setPartType(ZONED_DATE_TIME_PART_MONTH)
@@ -7570,9 +7066,8 @@
* .getDayOfMonth();
* </pre>
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 300)
- default DynamicInt32 getDayOfMonth() {
+ default @NonNull DynamicInt32 getDayOfMonth() {
return new GetZonedDateTimePartOp.Builder()
.setInput(this)
.setPartType(ZONED_DATE_TIME_PART_DAY_OF_MONTH)
@@ -7590,9 +7085,8 @@
* .getDayOfWeek();
* </pre>
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 300)
- default DynamicInt32 getDayOfWeek() {
+ default @NonNull DynamicInt32 getDayOfWeek() {
return new GetZonedDateTimePartOp.Builder()
.setInput(this)
.setPartType(ZONED_DATE_TIME_PART_DAY_OF_WEEK)
@@ -7609,9 +7103,8 @@
* .getHour();
* </pre>
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 300)
- default DynamicInt32 getHour() {
+ default @NonNull DynamicInt32 getHour() {
return new GetZonedDateTimePartOp.Builder()
.setInput(this)
.setPartType(ZONED_DATE_TIME_PART_HOUR_24H)
@@ -7628,9 +7121,8 @@
* .getMinute();
* </pre>
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 300)
- default DynamicInt32 getMinute() {
+ default @NonNull DynamicInt32 getMinute() {
return new GetZonedDateTimePartOp.Builder()
.setInput(this)
.setPartType(ZONED_DATE_TIME_PART_MINUTE)
@@ -7647,9 +7139,8 @@
* .getSecond();
* </pre>
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 300)
- default DynamicInt32 getSecond() {
+ default @NonNull DynamicInt32 getSecond() {
return new GetZonedDateTimePartOp.Builder()
.setInput(this)
.setPartType(ZONED_DATE_TIME_PART_SECOND)
@@ -7658,24 +7149,21 @@
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link DynamicZonedDateTime} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- DynamicZonedDateTime build();
+ @NonNull DynamicZonedDateTime build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DynamicZonedDateTime dynamicZonedDateTimeFromProto(
- @NonNull DynamicProto.DynamicZonedDateTime proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull DynamicZonedDateTime dynamicZonedDateTimeFromProto(
+ DynamicProto.@NonNull DynamicZonedDateTime proto, @Nullable Fingerprint fingerprint) {
if (proto.hasInstantToZonedDateTime()) {
return InstantToZonedDateTimeOp.fromProto(
proto.getInstantToZonedDateTime(), fingerprint);
@@ -7689,9 +7177,8 @@
* created using this method can't be added to any other wrapper.
*/
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DynamicZonedDateTime dynamicZonedDateTimeFromProto(
- @NonNull DynamicProto.DynamicZonedDateTime proto) {
+ public static @NonNull DynamicZonedDateTime dynamicZonedDateTimeFromProto(
+ DynamicProto.@NonNull DynamicZonedDateTime proto) {
return dynamicZonedDateTimeFromProto(proto, null);
}
@@ -7699,7 +7186,7 @@
@RequiresSchemaVersion(major = 1, minor = 300)
static final class InstantToZonedDateTimeOp implements DynamicZonedDateTime {
private final DynamicProto.InstantToZonedDateTimeOp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
InstantToZonedDateTimeOp(
DynamicProto.InstantToZonedDateTimeOp impl, @Nullable Fingerprint fingerprint) {
@@ -7708,8 +7195,7 @@
}
/** Gets the instant to convert. */
- @Nullable
- public DynamicInstant getInstant() {
+ public @Nullable DynamicInstant getInstant() {
if (mImpl.hasInstant()) {
return DynamicBuilders.dynamicInstantFromProto(mImpl.getInstant());
} else {
@@ -7718,51 +7204,44 @@
}
/** Gets the ZoneId following the time-zone ID format used by java {@link ZoneId}. */
- @NonNull
- public String getZoneId() {
+ public @NonNull String getZoneId() {
return mImpl.getZoneId();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static InstantToZonedDateTimeOp fromProto(
- @NonNull DynamicProto.InstantToZonedDateTimeOp proto,
+ public static @NonNull InstantToZonedDateTimeOp fromProto(
+ DynamicProto.@NonNull InstantToZonedDateTimeOp proto,
@Nullable Fingerprint fingerprint) {
return new InstantToZonedDateTimeOp(proto, fingerprint);
}
- @NonNull
- static InstantToZonedDateTimeOp fromProto(
- @NonNull DynamicProto.InstantToZonedDateTimeOp proto) {
+ static @NonNull InstantToZonedDateTimeOp fromProto(
+ DynamicProto.@NonNull InstantToZonedDateTimeOp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.InstantToZonedDateTimeOp toProto() {
+ DynamicProto.@NonNull InstantToZonedDateTimeOp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicZonedDateTime toDynamicZonedDateTimeProto() {
+ public DynamicProto.@NonNull DynamicZonedDateTime toDynamicZonedDateTimeProto() {
return DynamicProto.DynamicZonedDateTime.newBuilder()
.setInstantToZonedDateTime(mImpl)
.build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "InstantToZonedDateTimeOp{"
+ "instant="
+ getInstant()
@@ -7782,8 +7261,7 @@
/** Sets the instant to convert. */
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setInstant(@NonNull DynamicInstant instant) {
+ public @NonNull Builder setInstant(@NonNull DynamicInstant instant) {
mImpl.setInstant(instant.toDynamicInstantProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(instant.getFingerprint()).aggregateValueAsInt());
@@ -7792,8 +7270,7 @@
/** Sets the ZoneId following the time-zone ID format used by java {@link ZoneId}. */
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setZoneId(@NonNull String zoneId) {
+ public @NonNull Builder setZoneId(@NonNull String zoneId) {
mImpl.setZoneId(zoneId);
mFingerprint.recordPropertyUpdate(2, zoneId.hashCode());
return this;
@@ -7801,8 +7278,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public InstantToZonedDateTimeOp build() {
+ public @NonNull InstantToZonedDateTimeOp build() {
return new InstantToZonedDateTimeOp(mImpl.build(), mFingerprint);
}
}
@@ -7815,7 +7291,7 @@
@RequiresSchemaVersion(major = 1, minor = 300)
static final class GetZonedDateTimePartOp implements DynamicInt32 {
private final DynamicProto.GetZonedDateTimePartOp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
GetZonedDateTimePartOp(
DynamicProto.GetZonedDateTimePartOp impl, @Nullable Fingerprint fingerprint) {
@@ -7824,8 +7300,7 @@
}
/** Gets the zoned date-time input. */
- @Nullable
- public DynamicZonedDateTime getInput() {
+ public @Nullable DynamicZonedDateTime getInput() {
if (mImpl.hasInput()) {
return DynamicBuilders.dynamicZonedDateTimeFromProto(mImpl.getInput());
} else {
@@ -7841,43 +7316,37 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static GetZonedDateTimePartOp fromProto(
- @NonNull DynamicProto.GetZonedDateTimePartOp proto,
+ public static @NonNull GetZonedDateTimePartOp fromProto(
+ DynamicProto.@NonNull GetZonedDateTimePartOp proto,
@Nullable Fingerprint fingerprint) {
return new GetZonedDateTimePartOp(proto, fingerprint);
}
- @NonNull
- static GetZonedDateTimePartOp fromProto(
- @NonNull DynamicProto.GetZonedDateTimePartOp proto) {
+ static @NonNull GetZonedDateTimePartOp fromProto(
+ DynamicProto.@NonNull GetZonedDateTimePartOp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.GetZonedDateTimePartOp toProto() {
+ DynamicProto.@NonNull GetZonedDateTimePartOp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto() {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto() {
return DynamicProto.DynamicInt32.newBuilder().setZonedDateTimePart(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicInt32.newBuilder()
.setZonedDateTimePart(mImpl)
@@ -7889,8 +7358,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "GetZonedDateTimePartOp{"
+ "input="
+ getInput()
@@ -7910,8 +7378,7 @@
/** Sets the zoned date-time input. */
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setInput(@NonNull DynamicZonedDateTime input) {
+ public @NonNull Builder setInput(@NonNull DynamicZonedDateTime input) {
mImpl.setInput(input.toDynamicZonedDateTimeProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(input.getFingerprint()).aggregateValueAsInt());
@@ -7920,8 +7387,7 @@
/** Sets the date-time part to retrieve. */
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setPartType(@ZonedDateTimePartType int partType) {
+ public @NonNull Builder setPartType(@ZonedDateTimePartType int partType) {
mImpl.setPartType(DynamicProto.ZonedDateTimePartType.forNumber(partType));
mFingerprint.recordPropertyUpdate(2, partType);
return this;
@@ -7929,8 +7395,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public GetZonedDateTimePartOp build() {
+ public @NonNull GetZonedDateTimePartOp build() {
return new GetZonedDateTimePartOp(mImpl.build(), mFingerprint);
}
}
@@ -7940,7 +7405,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class BetweenDuration implements DynamicDuration {
private final DynamicProto.BetweenDuration mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
BetweenDuration(DynamicProto.BetweenDuration impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -7948,8 +7413,7 @@
}
/** Gets the time instant value marking the start of the duration. */
- @Nullable
- public DynamicInstant getStartInclusive() {
+ public @Nullable DynamicInstant getStartInclusive() {
if (mImpl.hasStartInclusive()) {
return DynamicBuilders.dynamicInstantFromProto(mImpl.getStartInclusive());
} else {
@@ -7958,8 +7422,7 @@
}
/** Gets the time instant value marking the end of the duration. */
- @Nullable
- public DynamicInstant getEndExclusive() {
+ public @Nullable DynamicInstant getEndExclusive() {
if (mImpl.hasEndExclusive()) {
return DynamicBuilders.dynamicInstantFromProto(mImpl.getEndExclusive());
} else {
@@ -7969,41 +7432,36 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static BetweenDuration fromProto(
- @NonNull DynamicProto.BetweenDuration proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull BetweenDuration fromProto(
+ DynamicProto.@NonNull BetweenDuration proto, @Nullable Fingerprint fingerprint) {
return new BetweenDuration(proto, fingerprint);
}
- @NonNull
- static BetweenDuration fromProto(@NonNull DynamicProto.BetweenDuration proto) {
+ static @NonNull BetweenDuration fromProto(DynamicProto.@NonNull BetweenDuration proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.BetweenDuration toProto() {
+ DynamicProto.@NonNull BetweenDuration toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicDuration toDynamicDurationProto() {
+ public DynamicProto.@NonNull DynamicDuration toDynamicDurationProto() {
return DynamicProto.DynamicDuration.newBuilder().setBetween(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicDuration toDynamicDurationProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicDuration toDynamicDurationProto(
+ boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicDuration.newBuilder()
.setBetween(mImpl)
@@ -8014,8 +7472,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "BetweenDuration{"
+ "startInclusive="
+ getStartInclusive()
@@ -8034,8 +7491,7 @@
/** Sets the time instant value marking the start of the duration. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setStartInclusive(@NonNull DynamicInstant startInclusive) {
+ public @NonNull Builder setStartInclusive(@NonNull DynamicInstant startInclusive) {
mImpl.setStartInclusive(startInclusive.toDynamicInstantProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(startInclusive.getFingerprint()).aggregateValueAsInt());
@@ -8044,8 +7500,7 @@
/** Sets the time instant value marking the end of the duration. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setEndExclusive(@NonNull DynamicInstant endExclusive) {
+ public @NonNull Builder setEndExclusive(@NonNull DynamicInstant endExclusive) {
mImpl.setEndExclusive(endExclusive.toDynamicInstantProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(endExclusive.getFingerprint()).aggregateValueAsInt());
@@ -8053,8 +7508,7 @@
}
@Override
- @NonNull
- public BetweenDuration build() {
+ public @NonNull BetweenDuration build() {
return new BetweenDuration(mImpl.build(), mFingerprint);
}
}
@@ -8071,7 +7525,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class ConditionalDurationOp implements DynamicDuration {
private final DynamicProto.ConditionalDurationOp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ConditionalDurationOp(
DynamicProto.ConditionalDurationOp impl, @Nullable Fingerprint fingerprint) {
@@ -8080,8 +7534,7 @@
}
/** Gets the condition to use. */
- @Nullable
- public DynamicBool getCondition() {
+ public @Nullable DynamicBool getCondition() {
if (mImpl.hasCondition()) {
return DynamicBuilders.dynamicBoolFromProto(mImpl.getCondition());
} else {
@@ -8090,8 +7543,7 @@
}
/** Gets the duration to yield if condition is true. */
- @Nullable
- public DynamicDuration getValueIfTrue() {
+ public @Nullable DynamicDuration getValueIfTrue() {
if (mImpl.hasValueIfTrue()) {
return DynamicBuilders.dynamicDurationFromProto(mImpl.getValueIfTrue());
} else {
@@ -8100,8 +7552,7 @@
}
/** Gets the duration to yield if condition is false. */
- @Nullable
- public DynamicDuration getValueIfFalse() {
+ public @Nullable DynamicDuration getValueIfFalse() {
if (mImpl.hasValueIfFalse()) {
return DynamicBuilders.dynamicDurationFromProto(mImpl.getValueIfFalse());
} else {
@@ -8111,42 +7562,38 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ConditionalDurationOp fromProto(
- @NonNull DynamicProto.ConditionalDurationOp proto,
+ public static @NonNull ConditionalDurationOp fromProto(
+ DynamicProto.@NonNull ConditionalDurationOp proto,
@Nullable Fingerprint fingerprint) {
return new ConditionalDurationOp(proto, fingerprint);
}
- @NonNull
- static ConditionalDurationOp fromProto(@NonNull DynamicProto.ConditionalDurationOp proto) {
+ static @NonNull ConditionalDurationOp fromProto(
+ DynamicProto.@NonNull ConditionalDurationOp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.ConditionalDurationOp toProto() {
+ DynamicProto.@NonNull ConditionalDurationOp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicDuration toDynamicDurationProto() {
+ public DynamicProto.@NonNull DynamicDuration toDynamicDurationProto() {
return DynamicProto.DynamicDuration.newBuilder().setConditionalOp(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicDuration toDynamicDurationProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicDuration toDynamicDurationProto(
+ boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicDuration.newBuilder()
.setConditionalOp(mImpl)
@@ -8157,8 +7604,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ConditionalDurationOp{"
+ "condition="
+ getCondition()
@@ -8179,8 +7625,7 @@
/** Sets the condition to use. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setCondition(@NonNull DynamicBool condition) {
+ public @NonNull Builder setCondition(@NonNull DynamicBool condition) {
mImpl.setCondition(condition.toDynamicBoolProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(condition.getFingerprint()).aggregateValueAsInt());
@@ -8189,8 +7634,7 @@
/** Sets the duration to yield if condition is true. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setValueIfTrue(@NonNull DynamicDuration valueIfTrue) {
+ public @NonNull Builder setValueIfTrue(@NonNull DynamicDuration valueIfTrue) {
mImpl.setValueIfTrue(valueIfTrue.toDynamicDurationProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(valueIfTrue.getFingerprint()).aggregateValueAsInt());
@@ -8199,8 +7643,7 @@
/** Sets the duration to yield if condition is false. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setValueIfFalse(@NonNull DynamicDuration valueIfFalse) {
+ public @NonNull Builder setValueIfFalse(@NonNull DynamicDuration valueIfFalse) {
mImpl.setValueIfFalse(valueIfFalse.toDynamicDurationProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(valueIfFalse.getFingerprint()).aggregateValueAsInt());
@@ -8208,8 +7651,7 @@
}
@Override
- @NonNull
- public ConditionalDurationOp build() {
+ public @NonNull ConditionalDurationOp build() {
return new ConditionalDurationOp(mImpl.build(), mFingerprint);
}
}
@@ -8220,13 +7662,11 @@
public interface DynamicDuration extends DynamicType {
/** Get the protocol buffer representation of this object, without fingerprint. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DynamicProto.DynamicDuration toDynamicDurationProto();
+ DynamicProto.@NonNull DynamicDuration toDynamicDurationProto();
/** Get the protocol buffer representation of this object, with or without fingerprint. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DynamicProto.DynamicDuration toDynamicDurationProto(boolean withFingerprint);
+ DynamicProto.@NonNull DynamicDuration toDynamicDurationProto(boolean withFingerprint);
/**
* Creates a {@link DynamicDuration} from a byte array generated by {@link
@@ -8234,8 +7674,7 @@
*
* @throws IllegalArgumentException if the byte array does not contain a valid serialization
*/
- @NonNull
- static DynamicDuration fromByteArray(@NonNull byte[] byteArray) {
+ static @NonNull DynamicDuration fromByteArray(byte @NonNull [] byteArray) {
return fromByteArray(byteArray, 0, byteArray.length);
}
@@ -8246,8 +7685,8 @@
* @throws IllegalArgumentException if the byte array does not contain a valid serialization
* in the provided offset and length
*/
- @NonNull
- static DynamicDuration fromByteArray(@NonNull byte[] byteArray, int offset, int length) {
+ static @NonNull DynamicDuration fromByteArray(byte @NonNull [] byteArray, int offset,
+ int length) {
try {
return dynamicDurationFromProto(
DynamicProto.DynamicDuration.parseFrom(
@@ -8263,8 +7702,7 @@
* Serializes the {@link DynamicDuration} into a new byte array that can later be used with
* {@link #fromByteArray(byte[])}.
*/
- @NonNull
- default byte[] toDynamicDurationByteArray() {
+ default byte @NonNull [] toDynamicDurationByteArray() {
return toDynamicDurationProto(/* withFingerprint= */ true).toByteArray();
}
@@ -8275,7 +7713,7 @@
*
* @throws IllegalArgumentException if the byte array is too small
*/
- default int toDynamicDurationByteArray(@NonNull byte[] byteArray) {
+ default int toDynamicDurationByteArray(byte @NonNull [] byteArray) {
return toDynamicDurationByteArray(byteArray, 0, byteArray.length);
}
@@ -8286,7 +7724,7 @@
*
* @throws IllegalArgumentException if the byte array is too small
*/
- default int toDynamicDurationByteArray(@NonNull byte[] byteArray, int offset, int length) {
+ default int toDynamicDurationByteArray(byte @NonNull [] byteArray, int offset, int length) {
CodedOutputStream stream = CodedOutputStream.newInstance(byteArray, offset, length);
try {
toDynamicDurationProto(/* withFingerprint= */ true).writeTo(stream);
@@ -8303,9 +7741,9 @@
* @param dynamicDataKey The source key to a {@link DynamicDataValue} with an {@link
* Duration} value.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 300)
- static DynamicDuration from(@NonNull DynamicDataKey<DynamicDuration> dynamicDataKey) {
+ static @NonNull DynamicDuration from(
+ @NonNull DynamicDataKey<DynamicDuration> dynamicDataKey) {
return new StateDurationSource.Builder()
.setSourceKey(dynamicDataKey.getKey())
.setSourceNamespace(dynamicDataKey.getNamespace())
@@ -8317,9 +7755,8 @@
* Duration} precision is greater than seconds, then any excess precision information will
* be dropped.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicDuration withSecondsPrecision(@NonNull Duration duration) {
+ static @NonNull DynamicDuration withSecondsPrecision(@NonNull Duration duration) {
return new FixedDuration.Builder().setSeconds(duration.getSeconds()).build();
}
@@ -8339,9 +7776,8 @@
* Integer overflow can occur if the result of the operation is larger than {@link
* Integer#MAX_VALUE}.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicInt32 toIntDays() {
+ default @NonNull DynamicInt32 toIntDays() {
return new GetDurationPartOp.Builder()
.setInput(this)
.setDurationPart(DURATION_PART_TYPE_TOTAL_DAYS)
@@ -8363,9 +7799,8 @@
* Integer overflow can occur if the result of the operation is larger than {@link
* Integer#MAX_VALUE}.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicInt32 toIntHours() {
+ default @NonNull DynamicInt32 toIntHours() {
return new GetDurationPartOp.Builder()
.setInput(this)
.setDurationPart(DURATION_PART_TYPE_TOTAL_HOURS)
@@ -8387,9 +7822,8 @@
* Integer overflow can occur if the result of the operation is larger than {@link
* Integer#MAX_VALUE}.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicInt32 toIntMinutes() {
+ default @NonNull DynamicInt32 toIntMinutes() {
return new GetDurationPartOp.Builder()
.setInput(this)
.setDurationPart(DURATION_PART_TYPE_TOTAL_MINUTES)
@@ -8411,9 +7845,8 @@
* Integer overflow can occur if the result of the operation is larger than {@link
* Integer#MAX_VALUE}.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicInt32 toIntSeconds() {
+ default @NonNull DynamicInt32 toIntSeconds() {
return new GetDurationPartOp.Builder()
.setInput(this)
.setDurationPart(DURATION_PART_TYPE_TOTAL_SECONDS)
@@ -8436,9 +7869,8 @@
* Integer overflow can occur if the result of the operation is larger than {@link
* Integer#MAX_VALUE}.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicInt32 getIntDaysPart() {
+ default @NonNull DynamicInt32 getIntDaysPart() {
return new GetDurationPartOp.Builder()
.setInput(this)
.setDurationPart(DURATION_PART_TYPE_DAYS)
@@ -8459,9 +7891,8 @@
*
* @return a new instance of {@link DynamicInt32} containing the result of the operation.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicInt32 getHoursPart() {
+ default @NonNull DynamicInt32 getHoursPart() {
return new GetDurationPartOp.Builder()
.setInput(this)
.setDurationPart(DURATION_PART_TYPE_HOURS)
@@ -8482,9 +7913,8 @@
*
* @return a new instance of {@link DynamicInt32} containing the result of the operation.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicInt32 getMinutesPart() {
+ default @NonNull DynamicInt32 getMinutesPart() {
return new GetDurationPartOp.Builder()
.setInput(this)
.setDurationPart(DURATION_PART_TYPE_MINUTES)
@@ -8505,9 +7935,8 @@
*
* @return a new instance of {@link DynamicInt32} containing the result of the operation.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- default DynamicInt32 getSecondsPart() {
+ default @NonNull DynamicInt32 getSecondsPart() {
return new GetDurationPartOp.Builder()
.setInput(this)
.setDurationPart(DURATION_PART_TYPE_SECONDS)
@@ -8520,9 +7949,8 @@
* ConditionScopes.IfTrueScope#elseUse} depending on the value yielded from {@code
* condition}.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static ConditionScope<DynamicDuration, Duration> onCondition(
+ static @NonNull ConditionScope<DynamicDuration, Duration> onCondition(
@NonNull DynamicBool condition) {
return new ConditionScopes.ConditionScope<>(
(trueValue, falseValue) ->
@@ -8536,24 +7964,21 @@
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link DynamicDuration} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- DynamicDuration build();
+ @NonNull DynamicDuration build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DynamicDuration dynamicDurationFromProto(
- @NonNull DynamicProto.DynamicDuration proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull DynamicDuration dynamicDurationFromProto(
+ DynamicProto.@NonNull DynamicDuration proto, @Nullable Fingerprint fingerprint) {
if (proto.hasBetween()) {
return BetweenDuration.fromProto(proto.getBetween(), fingerprint);
}
@@ -8574,9 +7999,8 @@
* created using this method can't be added to any other wrapper.
*/
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DynamicDuration dynamicDurationFromProto(
- @NonNull DynamicProto.DynamicDuration proto) {
+ public static @NonNull DynamicDuration dynamicDurationFromProto(
+ DynamicProto.@NonNull DynamicDuration proto) {
return dynamicDurationFromProto(proto, new Fingerprint(proto.getFingerprint()));
}
@@ -8587,7 +8011,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class GetDurationPartOp implements DynamicInt32 {
private final DynamicProto.GetDurationPartOp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
GetDurationPartOp(DynamicProto.GetDurationPartOp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -8595,8 +8019,7 @@
}
/** Gets the duration input. */
- @Nullable
- public DynamicDuration getInput() {
+ public @Nullable DynamicDuration getInput() {
if (mImpl.hasInput()) {
return DynamicBuilders.dynamicDurationFromProto(mImpl.getInput());
} else {
@@ -8612,41 +8035,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static GetDurationPartOp fromProto(
- @NonNull DynamicProto.GetDurationPartOp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull GetDurationPartOp fromProto(
+ DynamicProto.@NonNull GetDurationPartOp proto, @Nullable Fingerprint fingerprint) {
return new GetDurationPartOp(proto, fingerprint);
}
- @NonNull
- static GetDurationPartOp fromProto(@NonNull DynamicProto.GetDurationPartOp proto) {
+ static @NonNull GetDurationPartOp fromProto(DynamicProto.@NonNull GetDurationPartOp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.GetDurationPartOp toProto() {
+ DynamicProto.@NonNull GetDurationPartOp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto() {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto() {
return DynamicProto.DynamicInt32.newBuilder().setDurationPart(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicInt32.newBuilder()
.setDurationPart(mImpl)
@@ -8657,8 +8074,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "GetDurationPartOp{"
+ "input="
+ getInput()
@@ -8677,8 +8093,7 @@
/** Sets the duration input. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInput(@NonNull DynamicDuration input) {
+ public @NonNull Builder setInput(@NonNull DynamicDuration input) {
mImpl.setInput(input.toDynamicDurationProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(input.getFingerprint()).aggregateValueAsInt());
@@ -8687,16 +8102,14 @@
/** Sets the duration part to retrieve. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setDurationPart(@DurationPartType int durationPart) {
+ public @NonNull Builder setDurationPart(@DurationPartType int durationPart) {
mImpl.setDurationPart(DynamicProto.DurationPartType.forNumber(durationPart));
mFingerprint.recordPropertyUpdate(2, durationPart);
return this;
}
@Override
- @NonNull
- public GetDurationPartOp build() {
+ public @NonNull GetDurationPartOp build() {
return new GetDurationPartOp(mImpl.build(), mFingerprint);
}
}
@@ -8706,7 +8119,7 @@
@RequiresSchemaVersion(major = 1, minor = 300)
static final class StateInstantSource implements DynamicInstant {
private final DynamicProto.StateInstantSource mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
StateInstantSource(
DynamicProto.StateInstantSource impl, @Nullable Fingerprint fingerprint) {
@@ -8715,54 +8128,47 @@
}
/** Gets the key in the state to bind to. */
- @NonNull
- public String getSourceKey() {
+ public @NonNull String getSourceKey() {
return mImpl.getSourceKey();
}
/** Gets the namespace for the state key. */
- @NonNull
- public String getSourceNamespace() {
+ public @NonNull String getSourceNamespace() {
return mImpl.getSourceNamespace();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static StateInstantSource fromProto(
- @NonNull DynamicProto.StateInstantSource proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull StateInstantSource fromProto(
+ DynamicProto.@NonNull StateInstantSource proto, @Nullable Fingerprint fingerprint) {
return new StateInstantSource(proto, fingerprint);
}
- @NonNull
- static StateInstantSource fromProto(@NonNull DynamicProto.StateInstantSource proto) {
+ static @NonNull StateInstantSource fromProto(
+ DynamicProto.@NonNull StateInstantSource proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.StateInstantSource toProto() {
+ DynamicProto.@NonNull StateInstantSource toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInstant toDynamicInstantProto() {
+ public DynamicProto.@NonNull DynamicInstant toDynamicInstantProto() {
return DynamicProto.DynamicInstant.newBuilder().setStateSource(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInstant toDynamicInstantProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicInstant toDynamicInstantProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicInstant.newBuilder()
.setStateSource(mImpl)
@@ -8773,8 +8179,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "StateInstantSource{"
+ "sourceKey="
+ getSourceKey()
@@ -8794,8 +8199,7 @@
/** Sets the key in the state to bind to. */
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setSourceKey(@NonNull String sourceKey) {
+ public @NonNull Builder setSourceKey(@NonNull String sourceKey) {
mImpl.setSourceKey(sourceKey);
mFingerprint.recordPropertyUpdate(1, sourceKey.hashCode());
return this;
@@ -8803,8 +8207,7 @@
/** Sets the namespace for the state key. */
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setSourceNamespace(@NonNull String sourceNamespace) {
+ public @NonNull Builder setSourceNamespace(@NonNull String sourceNamespace) {
mImpl.setSourceNamespace(sourceNamespace);
mFingerprint.recordPropertyUpdate(2, sourceNamespace.hashCode());
return this;
@@ -8812,8 +8215,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public StateInstantSource build() {
+ public @NonNull StateInstantSource build() {
return new StateInstantSource(mImpl.build(), mFingerprint);
}
}
@@ -8823,7 +8225,7 @@
@RequiresSchemaVersion(major = 1, minor = 300)
static final class StateDurationSource implements DynamicDuration {
private final DynamicProto.StateDurationSource mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
StateDurationSource(
DynamicProto.StateDurationSource impl, @Nullable Fingerprint fingerprint) {
@@ -8832,55 +8234,49 @@
}
/** Gets the key in the state to bind to. */
- @NonNull
- public String getSourceKey() {
+ public @NonNull String getSourceKey() {
return mImpl.getSourceKey();
}
/** Gets the namespace for the state key. */
- @NonNull
- public String getSourceNamespace() {
+ public @NonNull String getSourceNamespace() {
return mImpl.getSourceNamespace();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static StateDurationSource fromProto(
- @NonNull DynamicProto.StateDurationSource proto,
+ public static @NonNull StateDurationSource fromProto(
+ DynamicProto.@NonNull StateDurationSource proto,
@Nullable Fingerprint fingerprint) {
return new StateDurationSource(proto, fingerprint);
}
- @NonNull
- static StateDurationSource fromProto(@NonNull DynamicProto.StateDurationSource proto) {
+ static @NonNull StateDurationSource fromProto(
+ DynamicProto.@NonNull StateDurationSource proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DynamicProto.StateDurationSource toProto() {
+ DynamicProto.@NonNull StateDurationSource toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicDuration toDynamicDurationProto() {
+ public DynamicProto.@NonNull DynamicDuration toDynamicDurationProto() {
return DynamicProto.DynamicDuration.newBuilder().setStateSource(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicDuration toDynamicDurationProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicDuration toDynamicDurationProto(
+ boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicDuration.newBuilder()
.setStateSource(mImpl)
@@ -8891,8 +8287,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "StateDurationSource{"
+ "sourceKey="
+ getSourceKey()
@@ -8912,8 +8307,7 @@
/** Sets the key in the state to bind to. */
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setSourceKey(@NonNull String sourceKey) {
+ public @NonNull Builder setSourceKey(@NonNull String sourceKey) {
mImpl.setSourceKey(sourceKey);
mFingerprint.recordPropertyUpdate(1, sourceKey.hashCode());
return this;
@@ -8921,8 +8315,7 @@
/** Sets the namespace for the state key. */
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setSourceNamespace(@NonNull String sourceNamespace) {
+ public @NonNull Builder setSourceNamespace(@NonNull String sourceNamespace) {
mImpl.setSourceNamespace(sourceNamespace);
mFingerprint.recordPropertyUpdate(2, sourceNamespace.hashCode());
return this;
@@ -8930,8 +8323,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public StateDurationSource build() {
+ public @NonNull StateDurationSource build() {
return new StateDurationSource(mImpl.build(), mFingerprint);
}
}
diff --git a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/DynamicDataBuilders.java b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/DynamicDataBuilders.java
index c3b5c45..1c391d0 100644
--- a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/DynamicDataBuilders.java
+++ b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/DynamicDataBuilders.java
@@ -17,8 +17,6 @@
package androidx.wear.protolayout.expression;
import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicBool;
@@ -40,6 +38,9 @@
import androidx.wear.protolayout.protobuf.CodedOutputStream;
import androidx.wear.protolayout.protobuf.ExtensionRegistryLite;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.IOException;
import java.time.Duration;
import java.time.Instant;
@@ -53,8 +54,7 @@
public interface DynamicDataValue<T extends DynamicBuilders.DynamicType> {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DynamicDataProto.DynamicDataValue toDynamicDataValueProto();
+ DynamicDataProto.@NonNull DynamicDataValue toDynamicDataValueProto();
/**
* Creates a {@link DynamicDataValue} from a byte array generated by {@link
@@ -62,8 +62,7 @@
*
* @throws IllegalArgumentException if the byte array does not contain a valid serialization
*/
- @NonNull
- static DynamicDataValue<?> fromByteArray(@NonNull byte[] byteArray) {
+ static @NonNull DynamicDataValue<?> fromByteArray(byte @NonNull [] byteArray) {
return fromByteArray(byteArray, 0, byteArray.length);
}
@@ -75,9 +74,8 @@
* @throws IllegalArgumentException if the byte array does not contain a valid serialization
* in the provided offset and length
*/
- @NonNull
- static DynamicDataValue<?> fromByteArray(
- @NonNull byte[] byteArray, int offset, int length) {
+ static @NonNull DynamicDataValue<?> fromByteArray(
+ byte @NonNull [] byteArray, int offset, int length) {
try {
return dynamicDataValueFromProto(
DynamicDataProto.DynamicDataValue.parseFrom(
@@ -93,8 +91,7 @@
* Serializes the {@link DynamicDataValue} into a new byte array that can later be used with
* {@link #fromByteArray(byte[])}.
*/
- @NonNull
- default byte[] toDynamicDataValueByteArray() {
+ default byte @NonNull [] toDynamicDataValueByteArray() {
return toDynamicDataValueProto().toByteArray();
}
@@ -105,7 +102,7 @@
*
* @throws IllegalArgumentException if the byte array is too small
*/
- default int toDynamicDataValueByteArray(@NonNull byte[] byteArray) {
+ default int toDynamicDataValueByteArray(byte @NonNull [] byteArray) {
return toDynamicDataValueByteArray(byteArray, 0, byteArray.length);
}
@@ -116,7 +113,8 @@
*
* @throws IllegalArgumentException if the byte array is too small
*/
- default int toDynamicDataValueByteArray(@NonNull byte[] byteArray, int offset, int length) {
+ default int toDynamicDataValueByteArray(byte @NonNull [] byteArray, int offset,
+ int length) {
CodedOutputStream stream = CodedOutputStream.newInstance(byteArray, offset, length);
try {
toDynamicDataValueProto().writeTo(stream);
@@ -128,51 +126,44 @@
}
/** Creates a boolean {@link DynamicDataValue}. */
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicDataValue<DynamicBool> fromBool(boolean constant) {
+ static @NonNull DynamicDataValue<DynamicBool> fromBool(boolean constant) {
return new FixedBool.Builder().setValue(constant).build();
}
/** Creates a int {@link DynamicDataValue}. */
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicDataValue<DynamicInt32> fromInt(int constant) {
+ static @NonNull DynamicDataValue<DynamicInt32> fromInt(int constant) {
return new FixedInt32.Builder().setValue(constant).build();
}
/** Creates a float {@link DynamicDataValue}. */
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicDataValue<DynamicFloat> fromFloat(float constant) {
+ static @NonNull DynamicDataValue<DynamicFloat> fromFloat(float constant) {
return new FixedFloat.Builder().setValue(constant).build();
}
/** Creates a color {@link DynamicDataValue}. */
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicDataValue<DynamicColor> fromColor(@ColorInt int constant) {
+ static @NonNull DynamicDataValue<DynamicColor> fromColor(@ColorInt int constant) {
return new FixedColor.Builder().setArgb(constant).build();
}
/** Creates a string {@link DynamicDataValue}. */
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- static DynamicDataValue<DynamicString> fromString(@NonNull String constant) {
+ static @NonNull DynamicDataValue<DynamicString> fromString(@NonNull String constant) {
return new FixedString.Builder().setValue(constant).build();
}
/** Creates an {@link Instant} {@link DynamicDataValue}. */
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 300)
- static DynamicDataValue<DynamicInstant> fromInstant(@NonNull Instant constant) {
+ static @NonNull DynamicDataValue<DynamicInstant> fromInstant(@NonNull Instant constant) {
return new FixedInstant.Builder().setEpochSeconds(constant.getEpochSecond()).build();
}
/** Creates a {@link Duration} {@link DynamicDataValue}. */
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 300)
- static DynamicDataValue<DynamicDuration> fromDuration(@NonNull Duration constant) {
+ static @NonNull DynamicDataValue<DynamicDuration> fromDuration(@NonNull Duration constant) {
return new FixedDuration.Builder().setSeconds(constant.getSeconds()).build();
}
@@ -304,16 +295,14 @@
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link DynamicDataValue} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder<T extends DynamicBuilders.DynamicType> {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- DynamicDataValue<T> build();
+ @NonNull DynamicDataValue<T> build();
}
}
@@ -322,17 +311,15 @@
* created using this method can't be added to any other wrapper.
*/
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DynamicDataValue<?> dynamicDataValueFromProto(
- @NonNull DynamicDataProto.DynamicDataValue proto) {
+ public static @NonNull DynamicDataValue<?> dynamicDataValueFromProto(
+ DynamicDataProto.@NonNull DynamicDataValue proto) {
return dynamicDataValueFromProto(proto, null);
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DynamicDataValue<?> dynamicDataValueFromProto(
- @NonNull DynamicDataProto.DynamicDataValue proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull DynamicDataValue<?> dynamicDataValueFromProto(
+ DynamicDataProto.@NonNull DynamicDataValue proto, @Nullable Fingerprint fingerprint) {
if (proto.hasStringVal()) {
return FixedString.fromProto(proto.getStringVal(), fingerprint);
}
diff --git a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/DynamicDataKey.java b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/DynamicDataKey.java
index 1b3689d..7a8df46 100644
--- a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/DynamicDataKey.java
+++ b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/DynamicDataKey.java
@@ -16,8 +16,8 @@
package androidx.wear.protolayout.expression;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.util.Objects;
@@ -28,8 +28,8 @@
* @param <T> The data type of the dynamic values that this key is bound to.
*/
public abstract class DynamicDataKey<T extends DynamicBuilders.DynamicType> {
- @NonNull private final String mKey;
- @NonNull private final String mNamespace;
+ private final @NonNull String mKey;
+ private final @NonNull String mNamespace;
/**
* Create a {@link DynamicDataKey} with the specified key in the given namespace.
@@ -43,14 +43,12 @@
}
/** Gets the key that references the dynamic data source */
- @NonNull
- public String getKey() {
+ public @NonNull String getKey() {
return mKey;
}
/** Gets the namespace of the key for the dynamic data source. */
- @NonNull
- public String getNamespace() {
+ public @NonNull String getNamespace() {
return mNamespace;
}
@@ -74,9 +72,8 @@
return Objects.hash(mKey, mNamespace);
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
return String.format("DynamicDataKey{namespace=%s, key=%s}", mNamespace, mKey);
}
}
diff --git a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/Fingerprint.java b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/Fingerprint.java
index 9693204..5ffb446 100644
--- a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/Fingerprint.java
+++ b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/Fingerprint.java
@@ -16,12 +16,13 @@
package androidx.wear.protolayout.expression;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.proto.FingerprintProto.NodeFingerprint;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
diff --git a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/FixedValueBuilders.java b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/FixedValueBuilders.java
index e16e059..9605352 100644
--- a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/FixedValueBuilders.java
+++ b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/FixedValueBuilders.java
@@ -21,14 +21,15 @@
import android.annotation.SuppressLint;
import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.proto.DynamicDataProto;
import androidx.wear.protolayout.expression.proto.DynamicProto;
import androidx.wear.protolayout.expression.proto.FixedProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.time.Duration;
import java.time.Instant;
@@ -45,7 +46,7 @@
implements DynamicBuilders.DynamicInt32,
DynamicDataBuilders.DynamicDataValue<DynamicBuilders.DynamicInt32> {
private final FixedProto.FixedInt32 mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FixedInt32(FixedProto.FixedInt32 impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -59,41 +60,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static FixedInt32 fromProto(
- @NonNull FixedProto.FixedInt32 proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull FixedInt32 fromProto(
+ FixedProto.@NonNull FixedInt32 proto, @Nullable Fingerprint fingerprint) {
return new FixedInt32(proto, fingerprint);
}
- @NonNull
- static FixedInt32 fromProto(@NonNull FixedProto.FixedInt32 proto) {
+ static @NonNull FixedInt32 fromProto(FixedProto.@NonNull FixedInt32 proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- FixedProto.FixedInt32 toProto() {
+ FixedProto.@NonNull FixedInt32 toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto() {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto() {
return DynamicProto.DynamicInt32.newBuilder().setFixed(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicInt32.newBuilder()
.setFixed(mImpl)
@@ -105,14 +100,12 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicDataProto.DynamicDataValue toDynamicDataValueProto() {
+ public DynamicDataProto.@NonNull DynamicDataValue toDynamicDataValueProto() {
return DynamicDataProto.DynamicDataValue.newBuilder().setInt32Val(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "FixedInt32{" + "value=" + getValue() + "}";
}
@@ -148,16 +141,14 @@
/** Sets the value. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setValue(int value) {
+ public @NonNull Builder setValue(int value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
@Override
- @NonNull
- public FixedInt32 build() {
+ public @NonNull FixedInt32 build() {
return new FixedInt32(mImpl.build(), mFingerprint);
}
}
@@ -169,7 +160,7 @@
implements DynamicBuilders.DynamicString,
DynamicDataBuilders.DynamicDataValue<DynamicBuilders.DynamicString> {
private final FixedProto.FixedString mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FixedString(FixedProto.FixedString impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -177,48 +168,41 @@
}
/** Gets the value. */
- @NonNull
- public String getValue() {
+ public @NonNull String getValue() {
return mImpl.getValue();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static FixedString fromProto(
- @NonNull FixedProto.FixedString proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull FixedString fromProto(
+ FixedProto.@NonNull FixedString proto, @Nullable Fingerprint fingerprint) {
return new FixedString(proto, fingerprint);
}
- @NonNull
- static FixedString fromProto(@NonNull FixedProto.FixedString proto) {
+ static @NonNull FixedString fromProto(FixedProto.@NonNull FixedString proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- FixedProto.FixedString toProto() {
+ FixedProto.@NonNull FixedString toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicString toDynamicStringProto() {
+ public DynamicProto.@NonNull DynamicString toDynamicStringProto() {
return DynamicProto.DynamicString.newBuilder().setFixed(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicString toDynamicStringProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicString toDynamicStringProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicString.newBuilder()
.setFixed(mImpl)
@@ -230,14 +214,12 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicDataProto.DynamicDataValue toDynamicDataValueProto() {
+ public DynamicDataProto.@NonNull DynamicDataValue toDynamicDataValueProto() {
return DynamicDataProto.DynamicDataValue.newBuilder().setStringVal(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "FixedString{" + "value=" + getValue() + "}";
}
@@ -275,16 +257,14 @@
/** Sets the value. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setValue(@NonNull String value) {
+ public @NonNull Builder setValue(@NonNull String value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, value.hashCode());
return this;
}
@Override
- @NonNull
- public FixedString build() {
+ public @NonNull FixedString build() {
return new FixedString(mImpl.build(), mFingerprint);
}
}
@@ -296,7 +276,7 @@
implements DynamicBuilders.DynamicFloat,
DynamicDataBuilders.DynamicDataValue<DynamicBuilders.DynamicFloat> {
private final FixedProto.FixedFloat mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FixedFloat(FixedProto.FixedFloat impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -314,41 +294,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static FixedFloat fromProto(
- @NonNull FixedProto.FixedFloat proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull FixedFloat fromProto(
+ FixedProto.@NonNull FixedFloat proto, @Nullable Fingerprint fingerprint) {
return new FixedFloat(proto, fingerprint);
}
- @NonNull
- static FixedFloat fromProto(@NonNull FixedProto.FixedFloat proto) {
+ static @NonNull FixedFloat fromProto(FixedProto.@NonNull FixedFloat proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- FixedProto.FixedFloat toProto() {
+ FixedProto.@NonNull FixedFloat toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicFloat toDynamicFloatProto() {
+ public DynamicProto.@NonNull DynamicFloat toDynamicFloatProto() {
return DynamicProto.DynamicFloat.newBuilder().setFixed(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicFloat toDynamicFloatProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicFloat toDynamicFloatProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicFloat.newBuilder()
.setFixed(mImpl)
@@ -360,14 +334,12 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicDataProto.DynamicDataValue toDynamicDataValueProto() {
+ public DynamicDataProto.@NonNull DynamicDataValue toDynamicDataValueProto() {
return DynamicDataProto.DynamicDataValue.newBuilder().setFloatVal(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "FixedFloat{" + "value=" + getValue() + "}";
}
@@ -407,16 +379,14 @@
* DynamicTypeValueReceiver<T>#onInvalidate()}.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setValue(float value) {
+ public @NonNull Builder setValue(float value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, Float.floatToIntBits(value));
return this;
}
@Override
- @NonNull
- public FixedFloat build() {
+ public @NonNull FixedFloat build() {
return new FixedFloat(mImpl.build(), mFingerprint);
}
}
@@ -428,7 +398,7 @@
implements DynamicBuilders.DynamicBool,
DynamicDataBuilders.DynamicDataValue<DynamicBuilders.DynamicBool> {
private final FixedProto.FixedBool mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FixedBool(FixedProto.FixedBool impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -442,41 +412,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static FixedBool fromProto(
- @NonNull FixedProto.FixedBool proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull FixedBool fromProto(
+ FixedProto.@NonNull FixedBool proto, @Nullable Fingerprint fingerprint) {
return new FixedBool(proto, fingerprint);
}
- @NonNull
- static FixedBool fromProto(@NonNull FixedProto.FixedBool proto) {
+ static @NonNull FixedBool fromProto(FixedProto.@NonNull FixedBool proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- FixedProto.FixedBool toProto() {
+ FixedProto.@NonNull FixedBool toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicBool toDynamicBoolProto() {
+ public DynamicProto.@NonNull DynamicBool toDynamicBoolProto() {
return DynamicProto.DynamicBool.newBuilder().setFixed(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicBool toDynamicBoolProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicBool toDynamicBoolProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicBool.newBuilder()
.setFixed(mImpl)
@@ -488,14 +452,12 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicDataProto.DynamicDataValue toDynamicDataValueProto() {
+ public DynamicDataProto.@NonNull DynamicDataValue toDynamicDataValueProto() {
return DynamicDataProto.DynamicDataValue.newBuilder().setBoolVal(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "FixedBool{" + "value=" + getValue() + "}";
}
@@ -532,16 +494,14 @@
/** Sets the value. */
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setValue(boolean value) {
+ public @NonNull Builder setValue(boolean value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, Boolean.hashCode(value));
return this;
}
@Override
- @NonNull
- public FixedBool build() {
+ public @NonNull FixedBool build() {
return new FixedBool(mImpl.build(), mFingerprint);
}
}
@@ -553,7 +513,7 @@
implements DynamicBuilders.DynamicColor,
DynamicDataBuilders.DynamicDataValue<DynamicBuilders.DynamicColor> {
private final FixedProto.FixedColor mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FixedColor(FixedProto.FixedColor impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -568,41 +528,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static FixedColor fromProto(
- @NonNull FixedProto.FixedColor proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull FixedColor fromProto(
+ FixedProto.@NonNull FixedColor proto, @Nullable Fingerprint fingerprint) {
return new FixedColor(proto, fingerprint);
}
- @NonNull
- static FixedColor fromProto(@NonNull FixedProto.FixedColor proto) {
+ static @NonNull FixedColor fromProto(FixedProto.@NonNull FixedColor proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- FixedProto.FixedColor toProto() {
+ FixedProto.@NonNull FixedColor toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicColor toDynamicColorProto() {
+ public DynamicProto.@NonNull DynamicColor toDynamicColorProto() {
return DynamicProto.DynamicColor.newBuilder().setFixed(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicColor toDynamicColorProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicColor toDynamicColorProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicColor.newBuilder()
.setFixed(mImpl)
@@ -614,14 +568,12 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicDataProto.DynamicDataValue toDynamicDataValueProto() {
+ public DynamicDataProto.@NonNull DynamicDataValue toDynamicDataValueProto() {
return DynamicDataProto.DynamicDataValue.newBuilder().setColorVal(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "FixedColor{" + "argb=" + getArgb() + "}";
}
@@ -657,16 +609,14 @@
/** Sets the color value, in ARGB format. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setArgb(@ColorInt int argb) {
+ public @NonNull Builder setArgb(@ColorInt int argb) {
mImpl.setArgb(argb);
mFingerprint.recordPropertyUpdate(1, argb);
return this;
}
@Override
- @NonNull
- public FixedColor build() {
+ public @NonNull FixedColor build() {
return new FixedColor(mImpl.build(), mFingerprint);
}
}
@@ -678,7 +628,7 @@
implements DynamicBuilders.DynamicInstant,
DynamicDataBuilders.DynamicDataValue<DynamicBuilders.DynamicInstant> {
private final FixedProto.FixedInstant mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FixedInstant(FixedProto.FixedInstant impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -707,48 +657,41 @@
* doesn't contain an {@link Instant} value.
*/
@Override
- @NonNull
- public Instant getInstantValue() {
+ public @NonNull Instant getInstantValue() {
return Instant.ofEpochSecond(mImpl.getEpochSeconds());
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static FixedInstant fromProto(
- @NonNull FixedProto.FixedInstant proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull FixedInstant fromProto(
+ FixedProto.@NonNull FixedInstant proto, @Nullable Fingerprint fingerprint) {
return new FixedInstant(proto, fingerprint);
}
- @NonNull
- static FixedInstant fromProto(@NonNull FixedProto.FixedInstant proto) {
+ static @NonNull FixedInstant fromProto(FixedProto.@NonNull FixedInstant proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- FixedProto.FixedInstant toProto() {
+ FixedProto.@NonNull FixedInstant toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInstant toDynamicInstantProto() {
+ public DynamicProto.@NonNull DynamicInstant toDynamicInstantProto() {
return DynamicProto.DynamicInstant.newBuilder().setFixed(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicInstant toDynamicInstantProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicInstant toDynamicInstantProto(boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicInstant.newBuilder()
.setFixed(mImpl)
@@ -760,14 +703,12 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicDataProto.DynamicDataValue toDynamicDataValueProto() {
+ public DynamicDataProto.@NonNull DynamicDataValue toDynamicDataValueProto() {
return DynamicDataProto.DynamicDataValue.newBuilder().setInstantVal(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "FixedInstant{" + "epochSeconds=" + getEpochSeconds() + "}";
}
@@ -784,16 +725,14 @@
* Sets the number of seconds that have elapsed since 00:00:00 UTC on 1 January 1970.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setEpochSeconds(long epochSeconds) {
+ public @NonNull Builder setEpochSeconds(long epochSeconds) {
mImpl.setEpochSeconds(epochSeconds);
mFingerprint.recordPropertyUpdate(1, Long.hashCode(epochSeconds));
return this;
}
@Override
- @NonNull
- public FixedInstant build() {
+ public @NonNull FixedInstant build() {
return new FixedInstant(mImpl.build(), mFingerprint);
}
}
@@ -805,7 +744,7 @@
implements DynamicBuilders.DynamicDuration,
DynamicDataBuilders.DynamicDataValue<DynamicBuilders.DynamicDuration> {
private final FixedProto.FixedDuration mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FixedDuration(FixedProto.FixedDuration impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -834,48 +773,42 @@
* doesn't contain a {@link Duration} value.
*/
@Override
- @NonNull
- public Duration getDurationValue() {
+ public @NonNull Duration getDurationValue() {
return Duration.ofSeconds(mImpl.getSeconds());
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static FixedDuration fromProto(
- @NonNull FixedProto.FixedDuration proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull FixedDuration fromProto(
+ FixedProto.@NonNull FixedDuration proto, @Nullable Fingerprint fingerprint) {
return new FixedDuration(proto, fingerprint);
}
- @NonNull
- static FixedDuration fromProto(@NonNull FixedProto.FixedDuration proto) {
+ static @NonNull FixedDuration fromProto(FixedProto.@NonNull FixedDuration proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- FixedProto.FixedDuration toProto() {
+ FixedProto.@NonNull FixedDuration toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicDuration toDynamicDurationProto() {
+ public DynamicProto.@NonNull DynamicDuration toDynamicDurationProto() {
return DynamicProto.DynamicDuration.newBuilder().setFixed(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicProto.DynamicDuration toDynamicDurationProto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicDuration toDynamicDurationProto(
+ boolean withFingerprint) {
if (withFingerprint) {
return DynamicProto.DynamicDuration.newBuilder()
.setFixed(mImpl)
@@ -887,14 +820,12 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DynamicDataProto.DynamicDataValue toDynamicDataValueProto() {
+ public DynamicDataProto.@NonNull DynamicDataValue toDynamicDataValueProto() {
return DynamicDataProto.DynamicDataValue.newBuilder().setDurationVal(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "FixedDuration{" + "seconds=" + getSeconds() + "}";
}
@@ -909,16 +840,14 @@
/** Sets duration in seconds. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setSeconds(long seconds) {
+ public @NonNull Builder setSeconds(long seconds) {
mImpl.setSeconds(seconds);
mFingerprint.recordPropertyUpdate(1, Long.hashCode(seconds));
return this;
}
@Override
- @NonNull
- public FixedDuration build() {
+ public @NonNull FixedDuration build() {
return new FixedDuration(mImpl.build(), mFingerprint);
}
}
diff --git a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/PlatformDataKey.java b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/PlatformDataKey.java
index b1fd7cf..b4c061f 100644
--- a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/PlatformDataKey.java
+++ b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/PlatformDataKey.java
@@ -16,9 +16,10 @@
package androidx.wear.protolayout.expression;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Represent a {@link DynamicDataKey} that references real-time data from the platform.
*
@@ -34,7 +35,7 @@
*/
public final class PlatformDataKey<T extends DynamicBuilders.DynamicType>
extends DynamicDataKey<T> {
- @NonNull private static final String RESERVED_NAMESPACE = "protolayout";
+ private static final @NonNull String RESERVED_NAMESPACE = "protolayout";
/**
* Create a {@link PlatformDataKey} with the specified key in the given namespace.
diff --git a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/PlatformDataValues.java b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/PlatformDataValues.java
index dfe1c6c..d3b01ac 100644
--- a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/PlatformDataValues.java
+++ b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/PlatformDataValues.java
@@ -18,25 +18,25 @@
import static java.util.Collections.unmodifiableMap;
-import androidx.annotation.NonNull;
import androidx.collection.ArrayMap;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicType;
import androidx.wear.protolayout.expression.DynamicDataBuilders.DynamicDataValue;
+import org.jspecify.annotations.NonNull;
+
import java.util.Map;
/** Typed mapping of {@link PlatformDataKey} to {@link DynamicDataValue}. */
public final class PlatformDataValues {
- @NonNull final Map<PlatformDataKey<?>, DynamicDataValue<?>> data;
+ final @NonNull Map<PlatformDataKey<?>, DynamicDataValue<?>> data;
/** Builder for {@link PlatformDataValues}. */
public static final class Builder {
- @NonNull final Map<PlatformDataKey<?>, DynamicDataValue<?>> data = new ArrayMap<>();
+ final @NonNull Map<PlatformDataKey<?>, DynamicDataValue<?>> data = new ArrayMap<>();
/** Puts a key/value pair. */
- @NonNull
@SuppressWarnings("BuilderSetStyle") // Map-style builder, getter is generic get().
- public <T extends DynamicType> Builder put(
+ public <T extends DynamicType> @NonNull Builder put(
@NonNull PlatformDataKey<T> key, @NonNull DynamicDataValue<T> value) {
data.put(key, value);
return this;
@@ -47,23 +47,20 @@
*
* <p>Values not in {@code other} are not removed from this {@link Builder}.
*/
- @NonNull
@SuppressWarnings("BuilderSetStyle") // Map-style builder, getter is generic get().
- public Builder putAll(@NonNull PlatformDataValues other) {
+ public @NonNull Builder putAll(@NonNull PlatformDataValues other) {
data.putAll(other.data);
return this;
}
/** Builds the {@link PlatformDataValues}. */
- @NonNull
- public PlatformDataValues build() {
+ public @NonNull PlatformDataValues build() {
return new PlatformDataValues(unmodifiableMap(data));
}
}
/** Creates a {@link PlatformDataValues} from a single key/value pair. */
- @NonNull
- public static <T extends DynamicType> PlatformDataValues of(
+ public static <T extends DynamicType> @NonNull PlatformDataValues of(
@NonNull PlatformDataKey<T> key, @NonNull DynamicDataValue<T> value) {
return new PlatformDataValues(Map.of(key, value));
}
@@ -73,14 +70,12 @@
}
/** Returns the key-value mapping. */
- @NonNull
- public Map<PlatformDataKey<?>, DynamicDataValue<?>> getAll() {
+ public @NonNull Map<PlatformDataKey<?>, DynamicDataValue<?>> getAll() {
return unmodifiableMap(data);
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return String.format("PlatformDataValues{%s}", data);
}
}
diff --git a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/PlatformHealthSources.java b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/PlatformHealthSources.java
index dddced3..dd8396b 100644
--- a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/PlatformHealthSources.java
+++ b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/PlatformHealthSources.java
@@ -19,8 +19,6 @@
import android.Manifest;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresPermission;
import androidx.annotation.RestrictTo;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicFloat;
@@ -28,6 +26,9 @@
import androidx.wear.protolayout.expression.DynamicDataBuilders.DynamicDataValue;
import androidx.wear.protolayout.expression.proto.DynamicProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -68,18 +69,16 @@
private Keys() {}
/** The data source key for heart rate bpm data from platform health sources. */
- @NonNull
@RequiresPermission(Manifest.permission.BODY_SENSORS)
- public static final PlatformDataKey<DynamicFloat> HEART_RATE_BPM =
+ public static final @NonNull PlatformDataKey<DynamicFloat> HEART_RATE_BPM =
new PlatformDataKey<>("HeartRate");
/**
* The data source key for heart rate sensor accuracy data from platform health sources. The
* accuracy value is one of {@code HEART_RATE_ACCURACY_*} constants.
*/
- @NonNull
@RequiresPermission(Manifest.permission.BODY_SENSORS)
- public static final PlatformDataKey<DynamicHeartRateAccuracy> HEART_RATE_ACCURACY =
+ public static final @NonNull PlatformDataKey<DynamicHeartRateAccuracy> HEART_RATE_ACCURACY =
new PlatformDataKey<>("HeartRate Accuracy");
/**
@@ -88,9 +87,8 @@
* timezone set at that time). This can result in the DAILY period being greater than or
* less than 24 hours when the timezone of the device is changed.
*/
- @NonNull
@RequiresPermission(Manifest.permission.ACTIVITY_RECOGNITION)
- public static final PlatformDataKey<DynamicInt32> DAILY_STEPS =
+ public static final @NonNull PlatformDataKey<DynamicInt32> DAILY_STEPS =
new PlatformDataKey<>("Daily Steps");
/**
@@ -99,9 +97,8 @@
* the timezone set at that time). This can result in the DAILY period being greater than or
* less than 24 hours when the timezone of the device is changed.
*/
- @NonNull
@RequiresPermission(Manifest.permission.ACTIVITY_RECOGNITION)
- public static final PlatformDataKey<DynamicFloat> DAILY_DISTANCE_METERS =
+ public static final @NonNull PlatformDataKey<DynamicFloat> DAILY_DISTANCE_METERS =
new PlatformDataKey<>("Daily Distance");
/**
@@ -111,9 +108,8 @@
* result in the DAILY period being greater than or less than 24 hours when the timezone of
* the device is changed.
*/
- @NonNull
@RequiresPermission(Manifest.permission.ACTIVITY_RECOGNITION)
- public static final PlatformDataKey<DynamicFloat> DAILY_CALORIES =
+ public static final @NonNull PlatformDataKey<DynamicFloat> DAILY_CALORIES =
new PlatformDataKey<>("Daily Calories");
/**
@@ -122,9 +118,8 @@
* the timezone set at that time). This can result in the DAILY period being greater than or
* less than 24 hours when the timezone of the device is changed.
*/
- @NonNull
@RequiresPermission(Manifest.permission.ACTIVITY_RECOGNITION)
- public static final PlatformDataKey<DynamicFloat> DAILY_FLOORS =
+ public static final @NonNull PlatformDataKey<DynamicFloat> DAILY_FLOORS =
new PlatformDataKey<>("Daily Floors");
}
@@ -137,9 +132,8 @@
* Keys#HEART_RATE_BPM} directly.
*/
@RequiresPermission(Manifest.permission.BODY_SENSORS)
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- public static DynamicFloat heartRateBpm() {
+ public static @NonNull DynamicFloat heartRateBpm() {
return DynamicFloat.from(Keys.HEART_RATE_BPM);
}
@@ -150,9 +144,8 @@
* <p>The accuracy value is one of {@link DynamicHeartRateAccuracy} constants.
*/
@RequiresPermission(Manifest.permission.BODY_SENSORS)
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- public static DynamicHeartRateAccuracy heartRateAccuracy() {
+ public static @NonNull DynamicHeartRateAccuracy heartRateAccuracy() {
return new DynamicHeartRateAccuracy(
new DynamicBuilders.StateInt32Source.Builder()
.setSourceKey(Keys.HEART_RATE_ACCURACY.getKey())
@@ -170,9 +163,8 @@
* Keys#DAILY_STEPS} directly.
*/
@RequiresPermission(Manifest.permission.ACTIVITY_RECOGNITION)
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- public static DynamicInt32 dailySteps() {
+ public static @NonNull DynamicInt32 dailySteps() {
return DynamicInt32.from(Keys.DAILY_STEPS);
}
@@ -183,9 +175,8 @@
* being greater than or less than 24 hours when the timezone of the device is changed.
*/
@RequiresPermission(Manifest.permission.ACTIVITY_RECOGNITION)
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- public static DynamicFloat dailyFloors() {
+ public static @NonNull DynamicFloat dailyFloors() {
return DynamicFloat.from(Keys.DAILY_FLOORS);
}
@@ -197,9 +188,8 @@
* timezone of the device is changed.
*/
@RequiresPermission(Manifest.permission.ACTIVITY_RECOGNITION)
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- public static DynamicFloat dailyCalories() {
+ public static @NonNull DynamicFloat dailyCalories() {
return DynamicFloat.from(Keys.DAILY_CALORIES);
}
@@ -210,9 +200,8 @@
* period being greater than or less than 24 hours when the timezone of the device is changed.
*/
@RequiresPermission(Manifest.permission.ACTIVITY_RECOGNITION)
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- public static DynamicFloat dailyDistanceMeters() {
+ public static @NonNull DynamicFloat dailyDistanceMeters() {
return DynamicFloat.from(Keys.DAILY_DISTANCE_METERS);
}
@@ -225,40 +214,35 @@
}
/** Creates a constant-valued {@link DynamicHeartRateAccuracy}. */
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 200)
- public static DynamicHeartRateAccuracy constant(@HeartRateAccuracy int val) {
+ public static @NonNull DynamicHeartRateAccuracy constant(@HeartRateAccuracy int val) {
return new DynamicHeartRateAccuracy(DynamicInt32.constant(val));
}
/** Creates a value to be provided from a {@code PlatformDataProvider}. */
- @NonNull
@SuppressWarnings("unchecked") // DynamicHeartRateAccuracy acts like DynamicInt32.
@RequiresSchemaVersion(major = 1, minor = 200)
- public static DynamicDataValue<DynamicHeartRateAccuracy> dynamicDataValueOf(
+ public static @NonNull DynamicDataValue<DynamicHeartRateAccuracy> dynamicDataValueOf(
@HeartRateAccuracy int val) {
return (DynamicDataValue<DynamicHeartRateAccuracy>)
(DynamicDataValue<?>) DynamicDataValue.fromInt(val);
}
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
- @NonNull
@Override
- public DynamicProto.DynamicInt32 toDynamicInt32Proto() {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto() {
return mImpl.toDynamicInt32Proto();
}
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
- @NonNull
@Override
- public DynamicProto.DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
+ public DynamicProto.@NonNull DynamicInt32 toDynamicInt32Proto(boolean withFingerprint) {
return mImpl.toDynamicInt32Proto(withFingerprint);
}
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
- @Nullable
@Override
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mImpl.getFingerprint();
}
}
diff --git a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/Preconditions.java b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/Preconditions.java
index 2ffaa76..a699a05 100644
--- a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/Preconditions.java
+++ b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/Preconditions.java
@@ -16,19 +16,19 @@
package androidx.wear.protolayout.expression;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/** Preconditions for use within this library. */
@RestrictTo(Scope.LIBRARY_GROUP)
public final class Preconditions {
private Preconditions() {}
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static <T> T checkNotNull(@Nullable T value) {
+ public static <T> @NonNull T checkNotNull(@Nullable T value) {
if (value == null) {
throw new NullPointerException();
}
diff --git a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/VersionBuilders.java b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/VersionBuilders.java
index 7c0196c..e48a67c 100644
--- a/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/VersionBuilders.java
+++ b/wear/protolayout/protolayout-expression/src/main/java/androidx/wear/protolayout/expression/VersionBuilders.java
@@ -16,12 +16,13 @@
package androidx.wear.protolayout.expression;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.proto.VersionProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Objects;
/** Builders for the schema version information of a layout (or an expression). */
@@ -35,7 +36,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class VersionInfo implements Comparable<VersionInfo> {
private final VersionProto.VersionInfo mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
VersionInfo(VersionProto.VersionInfo impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -60,16 +61,14 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static VersionInfo fromProto(
- @NonNull VersionProto.VersionInfo proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull VersionInfo fromProto(
+ VersionProto.@NonNull VersionInfo proto, @Nullable Fingerprint fingerprint) {
return new VersionInfo(proto, fingerprint);
}
@@ -78,21 +77,18 @@
* object created using this method can't be added to any other wrapper.
*/
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static VersionInfo fromProto(@NonNull VersionProto.VersionInfo proto) {
+ public static @NonNull VersionInfo fromProto(VersionProto.@NonNull VersionInfo proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public VersionProto.VersionInfo toProto() {
+ public VersionProto.@NonNull VersionInfo toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "VersionInfo{" + "major=" + getMajor() + ", minor=" + getMinor() + "}";
}
@@ -131,8 +127,7 @@
* guaranteed across major versions).
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setMajor(int major) {
+ public @NonNull Builder setMajor(int major) {
mImpl.setMajor(major);
mFingerprint.recordPropertyUpdate(1, major);
return this;
@@ -143,16 +138,14 @@
* Anything consuming a payload can safely consume anything with a lower minor version.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setMinor(int minor) {
+ public @NonNull Builder setMinor(int minor) {
mImpl.setMinor(minor);
mFingerprint.recordPropertyUpdate(2, minor);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public VersionInfo build() {
+ public @NonNull VersionInfo build() {
return new VersionInfo(mImpl.build(), mFingerprint);
}
}
diff --git a/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicDurationTest.java b/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicDurationTest.java
index 24e0137..57bf394 100644
--- a/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicDurationTest.java
+++ b/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicDurationTest.java
@@ -16,10 +16,10 @@
package androidx.wear.protolayout.expression;
-import static com.google.common.truth.Truth.assertThat;
-
import static androidx.wear.protolayout.expression.DynamicBuilders.dynamicDurationFromProto;
+import static com.google.common.truth.Truth.assertThat;
+
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicDuration;
import androidx.wear.protolayout.expression.proto.DynamicProto;
import androidx.wear.protolayout.proto.FingerprintProto.NodeFingerprint;
diff --git a/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicFloatTest.java b/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicFloatTest.java
index 67f6f37..1e1679a2 100644
--- a/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicFloatTest.java
+++ b/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicFloatTest.java
@@ -17,7 +17,6 @@
package androidx.wear.protolayout.expression;
import static androidx.wear.protolayout.expression.AnimationParameterBuilders.REPEAT_MODE_REVERSE;
-
import static androidx.wear.protolayout.expression.DynamicBuilders.dynamicFloatFromProto;
import static com.google.common.truth.Truth.assertThat;
diff --git a/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicInstantTest.java b/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicInstantTest.java
index 09797b6..1646cf3f 100644
--- a/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicInstantTest.java
+++ b/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicInstantTest.java
@@ -16,10 +16,10 @@
package androidx.wear.protolayout.expression;
-import static com.google.common.truth.Truth.assertThat;
-
import static androidx.wear.protolayout.expression.DynamicBuilders.dynamicInstantFromProto;
+import static com.google.common.truth.Truth.assertThat;
+
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicInstant;
import androidx.wear.protolayout.expression.proto.DynamicProto;
import androidx.wear.protolayout.proto.FingerprintProto.NodeFingerprint;
diff --git a/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicInt32Test.java b/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicInt32Test.java
index a06e5c0..d3ff74a 100644
--- a/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicInt32Test.java
+++ b/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicInt32Test.java
@@ -16,12 +16,12 @@
package androidx.wear.protolayout.expression;
+import static androidx.wear.protolayout.expression.DynamicBuilders.dynamicInt32FromProto;
+
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
-import static androidx.wear.protolayout.expression.DynamicBuilders.dynamicInt32FromProto;
-
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicFloat;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicInt32;
import androidx.wear.protolayout.expression.proto.DynamicProto;
diff --git a/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicStringTest.java b/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicStringTest.java
index 53ab704..624e6091 100644
--- a/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicStringTest.java
+++ b/wear/protolayout/protolayout-expression/src/test/java/androidx/wear/protolayout/expression/DynamicStringTest.java
@@ -16,12 +16,12 @@
package androidx.wear.protolayout.expression;
+import static androidx.wear.protolayout.expression.DynamicBuilders.dynamicStringFromProto;
+
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
-import static androidx.wear.protolayout.expression.DynamicBuilders.dynamicStringFromProto;
-
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicBool;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicString;
import androidx.wear.protolayout.expression.proto.DynamicProto;
diff --git a/wear/protolayout/protolayout-material-core/build.gradle b/wear/protolayout/protolayout-material-core/build.gradle
index d4c27e0..996c22e 100644
--- a/wear/protolayout/protolayout-material-core/build.gradle
+++ b/wear/protolayout/protolayout-material-core/build.gradle
@@ -42,6 +42,7 @@
}
dependencies {
+ api(libs.jspecify)
annotationProcessor(libs.nullaway)
api("androidx.annotation:annotation:1.8.1")
api(project(":wear:protolayout:protolayout"))
diff --git a/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/Button.java b/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/Button.java
index 886fcc5..8766647 100644
--- a/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/Button.java
+++ b/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/Button.java
@@ -28,8 +28,6 @@
import android.graphics.Color;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.ColorBuilders.ColorProp;
@@ -47,6 +45,9 @@
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.HashMap;
@@ -97,7 +98,7 @@
*/
public static final String METADATA_TAG_CUSTOM_CONTENT = "CSTBTN";
- @NonNull private final Box mElement;
+ private final @NonNull Box mElement;
Button(@NonNull Box element) {
mElement = element;
@@ -119,7 +120,7 @@
/** Button type to be used when setting a content which is a custom one. */
public static final int CUSTOM_CONTENT = 3;
- @NonNull static final Map<Integer, String> TYPE_TO_TAG = new HashMap<>();
+ static final @NonNull Map<Integer, String> TYPE_TO_TAG = new HashMap<>();
/** Button types. */
@RestrictTo(Scope.LIBRARY)
@@ -127,12 +128,12 @@
@IntDef({NOT_SET, ICON, TEXT, IMAGE, CUSTOM_CONTENT})
public @interface ButtonType {}
- @NonNull private final Clickable mClickable;
- @Nullable private StringProp mContentDescription;
- @NonNull private DpProp mSize = dp(0f);
+ private final @NonNull Clickable mClickable;
+ private @Nullable StringProp mContentDescription;
+ private @NonNull DpProp mSize = dp(0f);
@ButtonType private int mType = NOT_SET;
- @NonNull private ColorProp mBackgroundColor = argb(Color.BLACK);
- @Nullable private LayoutElement mContent;
+ private @NonNull ColorProp mBackgroundColor = argb(Color.BLACK);
+ private @Nullable LayoutElement mContent;
static {
TYPE_TO_TAG.put(ICON, METADATA_TAG_ICON);
@@ -159,22 +160,19 @@
* <p>While this field is statically accessible from 1.0, it's only bindable since version
* 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
- @NonNull
- public Builder setContentDescription(@NonNull StringProp contentDescription) {
+ public @NonNull Builder setContentDescription(@NonNull StringProp contentDescription) {
this.mContentDescription = contentDescription;
return this;
}
/** Sets the size for the {@link Button}. If not set, Button won't be shown. */
- @NonNull
- public Builder setSize(@NonNull DpProp size) {
+ public @NonNull Builder setSize(@NonNull DpProp size) {
mSize = size;
return this;
}
/** Sets the background colors for the {@link Button}. If not set, black is used. */
- @NonNull
- public Builder setBackgroundColor(@NonNull ColorProp backgroundColor) {
+ public @NonNull Builder setBackgroundColor(@NonNull ColorProp backgroundColor) {
mBackgroundColor = backgroundColor;
return this;
}
@@ -183,8 +181,7 @@
* Sets the content for this Button. Any previously added content will be overridden.
* Provided content should be styled and sized.
*/
- @NonNull
- public Builder setContent(@NonNull LayoutElement content, @ButtonType int type) {
+ public @NonNull Builder setContent(@NonNull LayoutElement content, @ButtonType int type) {
this.mContent = content;
this.mType = type;
return this;
@@ -192,9 +189,8 @@
/** Constructs and returns {@link Button} with the provided field and look. */
@SuppressLint("CheckResult") // (b/247804720)
- @NonNull
@Override
- public Button build() {
+ public @NonNull Button build() {
Modifiers.Builder modifiers =
new Modifiers.Builder()
.setClickable(mClickable)
@@ -233,20 +229,17 @@
}
/** Returns the content of this Button if it has been added. Otherwise, it returns null. */
- @Nullable
- public LayoutElement getContent() {
+ public @Nullable LayoutElement getContent() {
return mElement.getContents().get(0);
}
/** Returns click event action associated with this Button. */
- @NonNull
- public Clickable getClickable() {
+ public @NonNull Clickable getClickable() {
return checkNotNull(checkNotNull(mElement.getModifiers()).getClickable());
}
/** Returns content description for this Button. */
- @Nullable
- public StringProp getContentDescription() {
+ public @Nullable StringProp getContentDescription() {
Semantics semantics = checkNotNull(mElement.getModifiers()).getSemantics();
if (semantics == null) {
return null;
@@ -255,21 +248,18 @@
}
/** Returns size for this Button. */
- @NonNull
- public ContainerDimension getSize() {
+ public @NonNull ContainerDimension getSize() {
return checkNotNull(mElement.getWidth());
}
/** Returns the background color for this Button. */
- @NonNull
- public ColorProp getBackgroundColor() {
+ public @NonNull ColorProp getBackgroundColor() {
return checkNotNull(
checkNotNull(checkNotNull(mElement.getModifiers()).getBackground()).getColor());
}
/** Returns metadata tag set to this Button. */
- @NonNull
- public String getMetadataTag() {
+ public @NonNull String getMetadataTag() {
return getMetadataTagName(
checkNotNull(checkNotNull(mElement.getModifiers()).getMetadata()));
}
@@ -279,8 +269,7 @@
* content with {@code container.getContents().get(index)}) if that element can be converted to
* Button. Otherwise, it will return null.
*/
- @Nullable
- public static Button fromLayoutElement(@NonNull LayoutElement element) {
+ public static @Nullable Button fromLayoutElement(@NonNull LayoutElement element) {
if (element instanceof Button) {
return (Button) element;
}
@@ -295,16 +284,14 @@
return new Button(boxElement);
}
- @NonNull
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return checkNotNull(mElement.toLayoutElementProto());
}
- @Nullable
@Override
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mElement.getFingerprint();
}
}
diff --git a/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/Chip.java b/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/Chip.java
index 0dafa26..754f1ccc 100644
--- a/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/Chip.java
+++ b/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/Chip.java
@@ -31,8 +31,6 @@
import android.graphics.Color;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.ColorBuilders.ColorProp;
@@ -57,6 +55,9 @@
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.HashMap;
@@ -112,10 +113,10 @@
private static final int LABELS_INDEX_ICON = 2;
/** Outer tappable Box. */
- @NonNull private final Box mImpl;
+ private final @NonNull Box mImpl;
/** Inner visible Box with all Chip elements. */
- @NonNull private final Box mElement;
+ private final @NonNull Box mElement;
Chip(@NonNull Box impl) {
mImpl = impl;
@@ -142,21 +143,21 @@
@IntDef({NOT_SET, TEXT, ICON, CUSTOM_CONTENT})
public @interface ChipType {}
- @Nullable private LayoutElement mCustomContent;
- @Nullable private LayoutElement mIconContent = null;
- @Nullable private LayoutElement mPrimaryLabelContent = null;
- @Nullable private LayoutElement mSecondaryLabelContent = null;
- @NonNull private final Clickable mClickable;
- @Nullable private StringProp mContentDescription = null;
- @NonNull private ContainerDimension mWidth = dp(0);
- @NonNull private DpProp mHeight = dp(0);
- @NonNull private ColorProp mBackgroundColor = argb(Color.BLACK);
+ private @Nullable LayoutElement mCustomContent;
+ private @Nullable LayoutElement mIconContent = null;
+ private @Nullable LayoutElement mPrimaryLabelContent = null;
+ private @Nullable LayoutElement mSecondaryLabelContent = null;
+ private final @NonNull Clickable mClickable;
+ private @Nullable StringProp mContentDescription = null;
+ private @NonNull ContainerDimension mWidth = dp(0);
+ private @NonNull DpProp mHeight = dp(0);
+ private @NonNull ColorProp mBackgroundColor = argb(Color.BLACK);
@HorizontalAlignment private int mHorizontalAlign = HORIZONTAL_ALIGN_START;
- @NonNull private DpProp mHorizontalPadding = dp(0);
- @NonNull private DpProp mIconSpacerWidth = dp(0);
- @NonNull private DpProp mMinTappableSquareLength = dp(0);
+ private @NonNull DpProp mHorizontalPadding = dp(0);
+ private @NonNull DpProp mIconSpacerWidth = dp(0);
+ private @NonNull DpProp mMinTappableSquareLength = dp(0);
- @NonNull static final Map<Integer, String> TYPE_TO_TAG = new HashMap<>();
+ static final @NonNull Map<Integer, String> TYPE_TO_TAG = new HashMap<>();
static {
TYPE_TO_TAG.put(ICON, METADATA_TAG_ICON);
@@ -176,15 +177,13 @@
}
/** Sets the width of {@link Chip}. If not set, Chip won't be shown. */
- @NonNull
- public Builder setWidth(@NonNull ContainerDimension width) {
+ public @NonNull Builder setWidth(@NonNull ContainerDimension width) {
mWidth = width;
return this;
}
/** Sets the height of {@link Chip}. If not set, Chip won't be shown. */
- @NonNull
- public Builder setHeight(@NonNull DpProp height) {
+ public @NonNull Builder setHeight(@NonNull DpProp height) {
mHeight = height;
return this;
}
@@ -193,8 +192,7 @@
* Sets the custom content for the {@link Chip}. Any previously added content will be
* overridden. Provided content should be styled and sized.
*/
- @NonNull
- public Builder setCustomContent(@NonNull LayoutElement content) {
+ public @NonNull Builder setCustomContent(@NonNull LayoutElement content) {
this.mCustomContent = content;
this.mPrimaryLabelContent = null;
this.mSecondaryLabelContent = null;
@@ -203,8 +201,7 @@
}
/** Sets the background colors for the {@link Button}. If not set, black is used. */
- @NonNull
- public Builder setBackgroundColor(@NonNull ColorProp backgroundColor) {
+ public @NonNull Builder setBackgroundColor(@NonNull ColorProp backgroundColor) {
mBackgroundColor = backgroundColor;
return this;
}
@@ -216,8 +213,7 @@
* <p>While this field is statically accessible from 1.0, it's only bindable since version
* 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
- @NonNull
- public Builder setContentDescription(@NonNull StringProp contentDescription) {
+ public @NonNull Builder setContentDescription(@NonNull StringProp contentDescription) {
this.mContentDescription = contentDescription;
return this;
}
@@ -226,8 +222,7 @@
* Sets the primary label for the {@link Chip}. Any previously added custom content will be
* overridden. This should be styled and sized by the caller.
*/
- @NonNull
- public Builder setPrimaryLabelContent(@NonNull LayoutElement primaryLabel) {
+ public @NonNull Builder setPrimaryLabelContent(@NonNull LayoutElement primaryLabel) {
this.mPrimaryLabelContent = primaryLabel;
this.mCustomContent = null;
return this;
@@ -238,8 +233,7 @@
* be overridden. If secondary label is set, primary label must be set too with {@link
* #setPrimaryLabelContent}. This should be styled and sized by the caller.
*/
- @NonNull
- public Builder setSecondaryLabelContent(@NonNull LayoutElement secondaryLabel) {
+ public @NonNull Builder setSecondaryLabelContent(@NonNull LayoutElement secondaryLabel) {
this.mSecondaryLabelContent = secondaryLabel;
this.mCustomContent = null;
return this;
@@ -250,8 +244,7 @@
* overridden. If icon is set, primary label must be set too with {@link
* #setPrimaryLabelContent}. This should be styled and sized by the caller.
*/
- @NonNull
- public Builder setIconContent(@NonNull LayoutElement imageResourceId) {
+ public @NonNull Builder setIconContent(@NonNull LayoutElement imageResourceId) {
this.mIconContent = imageResourceId;
this.mCustomContent = null;
return this;
@@ -261,37 +254,33 @@
* Sets the horizontal alignment in the chip. If not set, {@link
* HorizontalAlignment#HORIZONTAL_ALIGN_START} will be used.
*/
- @NonNull
- public Builder setHorizontalAlignment(@HorizontalAlignment int horizontalAlignment) {
+ public @NonNull Builder setHorizontalAlignment(
+ @HorizontalAlignment int horizontalAlignment) {
mHorizontalAlign = horizontalAlignment;
return this;
}
/** Sets the width of spacer used next to the icon if set. */
- @NonNull
- public Builder setIconSpacerWidth(@NonNull DpProp iconSpacerWidth) {
+ public @NonNull Builder setIconSpacerWidth(@NonNull DpProp iconSpacerWidth) {
mIconSpacerWidth = iconSpacerWidth;
return this;
}
/** Sets the length of minimal tappable square for this chip. */
- @NonNull
- public Builder setMinimalTappableSquareLength(@NonNull DpProp tappableLength) {
+ public @NonNull Builder setMinimalTappableSquareLength(@NonNull DpProp tappableLength) {
mMinTappableSquareLength = tappableLength;
return this;
}
/** Sets the horizontal padding in the chip. */
- @NonNull
- public Builder setHorizontalPadding(@NonNull DpProp horizontalPadding) {
+ public @NonNull Builder setHorizontalPadding(@NonNull DpProp horizontalPadding) {
this.mHorizontalPadding = horizontalPadding;
return this;
}
/** Constructs and returns {@link Chip} with the provided content and look. */
- @NonNull
@Override
- public Chip build() {
+ public @NonNull Chip build() {
Modifiers.Builder modifiers =
new Modifiers.Builder()
.setClickable(mClickable)
@@ -363,8 +352,7 @@
return max(mHeight.getValue(), mMinTappableSquareLength.getValue());
}
- @NonNull
- private StringProp getCorrectContentDescription() {
+ private @NonNull StringProp getCorrectContentDescription() {
if (mContentDescription == null) {
String staticValue = "";
if (mPrimaryLabelContent != null) {
@@ -389,8 +377,7 @@
}
@SuppressLint("CheckResult") // (b/247804720)
- @NonNull
- private LayoutElement getCorrectContent() {
+ private @NonNull LayoutElement getCorrectContent() {
if (mCustomContent != null) {
return mCustomContent;
}
@@ -435,33 +422,28 @@
}
/** Returns the visible height of this Chip. */
- @NonNull
- public ContainerDimension getHeight() {
+ public @NonNull ContainerDimension getHeight() {
return checkNotNull(mElement.getHeight());
}
/** Returns width of this Chip. */
- @NonNull
- public ContainerDimension getWidth() {
+ public @NonNull ContainerDimension getWidth() {
return checkNotNull(mElement.getWidth());
}
/** Returns click event action associated with this Chip. */
- @NonNull
- public Clickable getClickable() {
+ public @NonNull Clickable getClickable() {
return checkNotNull(checkNotNull(mElement.getModifiers()).getClickable());
}
/** Returns background color of this Chip. */
- @NonNull
- public ColorProp getBackgroundColor() {
+ public @NonNull ColorProp getBackgroundColor() {
return checkNotNull(
checkNotNull(checkNotNull(mElement.getModifiers()).getBackground()).getColor());
}
/** Returns content description of this Chip. */
- @Nullable
- public StringProp getContentDescription() {
+ public @Nullable StringProp getContentDescription() {
// Semantics are applied to the visible view.
Semantics semantics = checkNotNull(mElement.getModifiers()).getSemantics();
if (semantics == null) {
@@ -471,8 +453,7 @@
}
/** Returns custom content from this Chip if it has been added. Otherwise, it returns null. */
- @Nullable
- public LayoutElement getCustomContent() {
+ public @Nullable LayoutElement getCustomContent() {
if (getMetadataTag().equals(METADATA_TAG_CUSTOM_CONTENT)) {
return checkNotNull(checkNotNull(mElement.getContents()).get(0));
}
@@ -480,20 +461,17 @@
}
/** Returns primary label from this Chip if it has been added. Otherwise, it returns null. */
- @Nullable
- public LayoutElement getPrimaryLabelContent() {
+ public @Nullable LayoutElement getPrimaryLabelContent() {
return getPrimaryOrSecondaryLabelContent(PRIMARY_LABEL_INDEX);
}
/** Returns secondary label from this Chip if it has been added. Otherwise, it returns null. */
- @Nullable
- public LayoutElement getSecondaryLabelContent() {
+ public @Nullable LayoutElement getSecondaryLabelContent() {
return getPrimaryOrSecondaryLabelContent(SECONDARY_LABEL_INDEX);
}
/** Returns icon id from this Chip if it has been added. Otherwise, it returns null. */
- @Nullable
- public LayoutElement getIconContent() {
+ public @Nullable LayoutElement getIconContent() {
if (!getMetadataTag().equals(METADATA_TAG_ICON)) {
return null;
}
@@ -505,8 +483,7 @@
: topLevel;
}
- @Nullable
- private LayoutElement getPrimaryOrSecondaryLabelContent(int index) {
+ private @Nullable LayoutElement getPrimaryOrSecondaryLabelContent(int index) {
String metadataTag = getMetadataTag();
if (metadataTag.equals(METADATA_TAG_CUSTOM_CONTENT)) {
return null;
@@ -550,8 +527,7 @@
}
/** Returns metadata tag set to this Chip. */
- @NonNull
- public String getMetadataTag() {
+ public @NonNull String getMetadataTag() {
return getMetadataTagName(checkNotNull(checkNotNull(mImpl.getModifiers()).getMetadata()));
}
@@ -560,8 +536,7 @@
* content with {@code container.getContents().get(index)}) if that element can be converted to
* Chip. Otherwise, it will return null.
*/
- @Nullable
- public static Chip fromLayoutElement(@NonNull LayoutElement element) {
+ public static @Nullable Chip fromLayoutElement(@NonNull LayoutElement element) {
if (element instanceof Chip) {
return (Chip) element;
}
@@ -576,16 +551,14 @@
return new Chip(boxElement);
}
- @NonNull
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mImpl.toLayoutElementProto();
}
- @Nullable
@Override
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mImpl.getFingerprint();
}
}
diff --git a/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/Helper.java b/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/Helper.java
index 59ff55f..aab8cd3 100644
--- a/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/Helper.java
+++ b/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/Helper.java
@@ -18,8 +18,6 @@
import static androidx.wear.protolayout.DimensionBuilders.dp;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.wear.protolayout.DeviceParametersBuilders;
import androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters;
import androidx.wear.protolayout.DimensionBuilders.DpProp;
@@ -28,6 +26,9 @@
import androidx.wear.protolayout.TypeBuilders.FloatProp;
import androidx.wear.protolayout.TypeBuilders.StringProp;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
@@ -37,8 +38,7 @@
private Helper() {}
/** Returns given value if not null or throws {@code NullPointerException} otherwise. */
- @NonNull
- public static <T> T checkNotNull(@Nullable T value) {
+ public static <T> @NonNull T checkNotNull(@Nullable T value) {
if (value == null) {
throw new NullPointerException();
}
@@ -46,32 +46,27 @@
}
/** Returns radius in {@link DpProp} of the given diameter. */
- @NonNull
- public static DpProp radiusOf(@NonNull DpProp diameter) {
+ public static @NonNull DpProp radiusOf(@NonNull DpProp diameter) {
return dp(diameter.getValue() / 2);
}
/** Returns String representation of tag from byte array. */
- @NonNull
- public static String getTagName(@NonNull byte[] tagData) {
+ public static @NonNull String getTagName(byte @NonNull [] tagData) {
return new String(tagData, StandardCharsets.UTF_8);
}
/** Returns byte array representation of tag from String. */
- @NonNull
- public static byte[] getTagBytes(@NonNull String tagName) {
+ public static byte @NonNull [] getTagBytes(@NonNull String tagName) {
return tagName.getBytes(StandardCharsets.UTF_8);
}
/** Returns the String representation of metadata tag from the given ElementMetadata. */
- @NonNull
- public static String getMetadataTagName(@NonNull ElementMetadata metadata) {
+ public static @NonNull String getMetadataTagName(@NonNull ElementMetadata metadata) {
return getTagName(getMetadataTagBytes(metadata));
}
/** Returns the metadata tag from the given ElementMetadata. */
- @NonNull
- public static byte[] getMetadataTagBytes(@NonNull ElementMetadata metadata) {
+ public static byte @NonNull [] getMetadataTagBytes(@NonNull ElementMetadata metadata) {
return checkNotNull(metadata).getTagData();
}
@@ -98,7 +93,8 @@
* given String and its length is of the given base array.
*/
public static boolean checkTag(
- @Nullable Modifiers modifiers, @NonNull String validPrefix, @NonNull byte[] validBase) {
+ @Nullable Modifiers modifiers, @NonNull String validPrefix,
+ byte @NonNull [] validBase) {
if (modifiers == null || modifiers.getMetadata() == null) {
return false;
}
@@ -113,14 +109,12 @@
}
/** Returns a {@link StringProp} for the given string value. */
- @NonNull
- public static StringProp staticString(@NonNull String value) {
+ public static @NonNull StringProp staticString(@NonNull String value) {
return new StringProp.Builder(value).build();
}
/** Returns a {@link FloatProp} for the given float value. */
- @NonNull
- public static FloatProp staticFloat(float staticValue) {
+ public static @NonNull FloatProp staticFloat(float staticValue) {
return new FloatProp.Builder(staticValue).build();
}
}
diff --git a/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/fontscaling/FontScaleConverter.java b/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/fontscaling/FontScaleConverter.java
index 98351ea..7de3944 100644
--- a/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/fontscaling/FontScaleConverter.java
+++ b/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/fontscaling/FontScaleConverter.java
@@ -16,9 +16,10 @@
package androidx.wear.protolayout.materialcore.fontscaling;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
import java.util.Arrays;
/**
@@ -51,7 +52,7 @@
* @param toDp array of dimensions in DP that correspond to an SP value in fromSp
* @throws IllegalArgumentException if the array lengths don't match or are empty
*/
- FontScaleConverter(@NonNull float[] fromSp, @NonNull float[] toDp) {
+ FontScaleConverter(float @NonNull [] fromSp, float @NonNull [] toDp) {
if (fromSp.length != toDp.length || fromSp.length == 0) {
throw new IllegalArgumentException("Array lengths must match and be nonzero");
}
@@ -142,9 +143,8 @@
return result;
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
return "FontScaleConverter{"
+ "fromSpValues="
+ Arrays.toString(mFromSpValues)
diff --git a/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/fontscaling/FontScaleConverterFactory.java b/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/fontscaling/FontScaleConverterFactory.java
index 5b8b3f7..2ae937e 100644
--- a/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/fontscaling/FontScaleConverterFactory.java
+++ b/wear/protolayout/protolayout-material-core/src/main/java/androidx/wear/protolayout/materialcore/fontscaling/FontScaleConverterFactory.java
@@ -19,11 +19,12 @@
import android.content.res.Configuration;
import android.util.SparseArray;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/** Stores lookup tables for creating {@link FontScaleConverter}s at various scales. */
// This is copied from
// https://cs.android.com/android/_/android/platform/frameworks/base/+/2a4e99a798cc69944f64d54b81aee987fbea45d6:core/java/android/content/res/FontScaleConverterFactory.java
@@ -103,8 +104,7 @@
* @param fontScale the scale factor, usually from {@link Configuration#fontScale}.
* @return a converter for the given scale, or null if non-linear scaling should not be used.
*/
- @Nullable
- public static FontScaleConverter forScale(float fontScale) {
+ public static @Nullable FontScaleConverter forScale(float fontScale) {
if (!isNonLinearFontScalingActive(fontScale)) {
return null;
}
@@ -146,8 +146,7 @@
}
}
- @NonNull
- private static FontScaleConverter createInterpolatedTableBetween(
+ private static @NonNull FontScaleConverter createInterpolatedTableBetween(
FontScaleConverter start, FontScaleConverter end, float interpolationPoint) {
float[] commonSpSizes = new float[] {8f, 10f, 12f, 14f, 18f, 20f, 24f, 30f, 100f};
float[] dpInterpolated = new float[commonSpSizes.length];
@@ -174,8 +173,7 @@
LOOKUP_TABLES.put(getKey(scaleKey), fontScaleConverter);
}
- @Nullable
- private static FontScaleConverter get(float scaleKey) {
+ private static @Nullable FontScaleConverter get(float scaleKey) {
return LOOKUP_TABLES.get(getKey(scaleKey));
}
}
diff --git a/wear/protolayout/protolayout-material-core/src/test/java/androidx/wear/protolayout/materialcore/ButtonTest.java b/wear/protolayout/protolayout-material-core/src/test/java/androidx/wear/protolayout/materialcore/ButtonTest.java
index d59d2d0..3dafff3 100644
--- a/wear/protolayout/protolayout-material-core/src/test/java/androidx/wear/protolayout/materialcore/ButtonTest.java
+++ b/wear/protolayout/protolayout-material-core/src/test/java/androidx/wear/protolayout/materialcore/ButtonTest.java
@@ -31,8 +31,6 @@
import android.graphics.Color;
import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.wear.protolayout.ActionBuilders.LaunchAction;
import androidx.wear.protolayout.DimensionBuilders.DpProp;
@@ -45,6 +43,8 @@
import androidx.wear.protolayout.TypeBuilders.StringProp;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicString;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.internal.DoNotInstrument;
diff --git a/wear/protolayout/protolayout-material-core/src/test/java/androidx/wear/protolayout/materialcore/ChipTest.java b/wear/protolayout/protolayout-material-core/src/test/java/androidx/wear/protolayout/materialcore/ChipTest.java
index 1bdd33f..6a5525a 100644
--- a/wear/protolayout/protolayout-material-core/src/test/java/androidx/wear/protolayout/materialcore/ChipTest.java
+++ b/wear/protolayout/protolayout-material-core/src/test/java/androidx/wear/protolayout/materialcore/ChipTest.java
@@ -28,8 +28,6 @@
import android.graphics.Color;
import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.wear.protolayout.ActionBuilders.LaunchAction;
import androidx.wear.protolayout.LayoutElementBuilders.Box;
@@ -42,6 +40,8 @@
import androidx.wear.protolayout.TypeBuilders.StringProp;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicString;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.internal.DoNotInstrument;
diff --git a/wear/protolayout/protolayout-material/build.gradle b/wear/protolayout/protolayout-material/build.gradle
index 37c2ec8..4832ca7 100644
--- a/wear/protolayout/protolayout-material/build.gradle
+++ b/wear/protolayout/protolayout-material/build.gradle
@@ -30,6 +30,7 @@
}
dependencies {
+ api(libs.jspecify)
annotationProcessor(libs.nullaway)
api("androidx.annotation:annotation:1.8.1")
api(project(":wear:protolayout:protolayout"))
diff --git a/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/RunnerUtils.java b/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/RunnerUtils.java
index dd901e5..39f1872 100644
--- a/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/RunnerUtils.java
+++ b/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/RunnerUtils.java
@@ -24,7 +24,6 @@
import android.util.DisplayMetrics;
import android.util.Log;
-import androidx.annotation.NonNull;
import androidx.test.core.app.ActivityScenario;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.screenshot.AndroidXScreenshotTestRule;
@@ -32,6 +31,8 @@
import androidx.wear.protolayout.LayoutElementBuilders.Layout;
import androidx.wear.protolayout.material.test.GoldenTestActivity;
+import org.jspecify.annotations.NonNull;
+
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
diff --git a/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/TestCasesGenerator.java b/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/TestCasesGenerator.java
index b36d18c..8d33738 100644
--- a/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/TestCasesGenerator.java
+++ b/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/TestCasesGenerator.java
@@ -29,7 +29,6 @@
import android.content.Context;
import android.graphics.Color;
-import androidx.annotation.NonNull;
import androidx.wear.protolayout.ActionBuilders.LaunchAction;
import androidx.wear.protolayout.DeviceParametersBuilders;
import androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters;
@@ -44,6 +43,8 @@
import com.google.common.collect.ImmutableMap;
+import org.jspecify.annotations.NonNull;
+
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -63,10 +64,9 @@
* as it should point on the same size independent image. These test cases are meant to be
* tested in RTL and LTR modes.
*/
- @NonNull
- static ImmutableMap<String, Layout> generateTestCases(
+ static @NonNull ImmutableMap<String, Layout> generateTestCases(
@NonNull Context context,
- @NonNull DeviceParametersBuilders.DeviceParameters deviceParameters,
+ DeviceParametersBuilders.@NonNull DeviceParameters deviceParameters,
@NonNull String goldenSuffix) {
Clickable clickable =
new Clickable.Builder()
@@ -374,8 +374,7 @@
* Generates test cases for text only material components. The text is provided in English and
* suitable for LTR tests. {@code _en} will be appended to the {@code goldenSuffix}.
*/
- @NonNull
- static ImmutableMap<String, Layout> generateTextTestCasesLtrOnly(
+ static @NonNull ImmutableMap<String, Layout> generateTextTestCasesLtrOnly(
@NonNull Context context,
@NonNull DeviceParameters deviceParameters,
@NonNull String goldenSuffix) {
@@ -393,8 +392,7 @@
* Generates test cases for text only material components. The text is provided in Arabic and
* suitable for RTL tests. {@code _ar} will be appended to the {@code goldenSuffix}.
*/
- @NonNull
- static ImmutableMap<String, Layout> generateTextTestCasesRtlOnly(
+ static @NonNull ImmutableMap<String, Layout> generateTextTestCasesRtlOnly(
@NonNull Context context,
@NonNull DeviceParameters deviceParameters,
@NonNull String goldenSuffix) {
@@ -413,9 +411,8 @@
* different for different user font sizes. Note that some of the golden will have the same name
* as it should point on the same size independent image.
*/
- @NonNull
@SuppressWarnings("deprecation") // TEXT_OVERFLOW_ELLIPSIZE_END
- private static ImmutableMap<String, Layout> generateTextTestCasesForLanguage(
+ private static @NonNull ImmutableMap<String, Layout> generateTextTestCasesForLanguage(
@NonNull Context context,
@NonNull DeviceParameters deviceParameters,
@NonNull String goldenSuffix,
diff --git a/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/layouts/TestCasesGenerator.java b/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/layouts/TestCasesGenerator.java
index 261749c..ece1a6a 100644
--- a/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/layouts/TestCasesGenerator.java
+++ b/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/layouts/TestCasesGenerator.java
@@ -28,7 +28,6 @@
import android.graphics.Color;
import androidx.annotation.Dimension;
-import androidx.annotation.NonNull;
import androidx.wear.protolayout.ActionBuilders.LaunchAction;
import androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters;
import androidx.wear.protolayout.LayoutElementBuilders;
@@ -55,6 +54,8 @@
import androidx.wear.protolayout.material.TitleChip;
import androidx.wear.protolayout.material.Typography;
+import org.jspecify.annotations.NonNull;
+
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -70,8 +71,7 @@
* different for different user font sizes. Note that some of the golden will have the same name
* as it should point on the same size independent image.
*/
- @NonNull
- static Map<String, Layout> generateTestCases(
+ static @NonNull Map<String, Layout> generateTestCases(
@NonNull Context context,
@NonNull DeviceParameters deviceParameters,
@NonNull String goldenSuffix) {
@@ -923,16 +923,14 @@
entry -> Layout.fromLayoutElement(entry.getValue())));
}
- @NonNull
- private static Text buildTextLabel(@NonNull Context context, @NonNull String text) {
+ private static @NonNull Text buildTextLabel(@NonNull Context context, @NonNull String text) {
return new Text.Builder(context, text)
.setTypography(Typography.TYPOGRAPHY_CAPTION1)
.setColor(argb(Color.WHITE))
.build();
}
- @NonNull
- private static Box buildColoredBoxMSL(int color) {
+ private static @NonNull Box buildColoredBoxMSL(int color) {
return new Box.Builder()
.setWidth(dp(45))
.setHeight(dp(45))
@@ -944,8 +942,7 @@
.build();
}
- @NonNull
- private static Box buildColoredBoxPLL(int color) {
+ private static @NonNull Box buildColoredBoxPLL(int color) {
return new Box.Builder()
.setWidth(expand())
.setHeight(dp(60))
diff --git a/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/test/GoldenTestActivity.java b/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/test/GoldenTestActivity.java
index 8717539d..a232649 100644
--- a/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/test/GoldenTestActivity.java
+++ b/wear/protolayout/protolayout-material/src/androidTest/java/androidx/wear/protolayout/material/test/GoldenTestActivity.java
@@ -33,8 +33,6 @@
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.wear.protolayout.LayoutElementBuilders.Layout;
import androidx.wear.protolayout.ResourceBuilders.AndroidImageResourceByResId;
import androidx.wear.protolayout.ResourceBuilders.ImageResource;
@@ -44,6 +42,9 @@
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Locale;
import java.util.concurrent.ExecutionException;
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Button.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Button.java
index 83ec3f1..609024f 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Button.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Button.java
@@ -38,8 +38,6 @@
import android.content.Context;
import androidx.annotation.Dimension;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.ColorBuilders.ColorProp;
@@ -55,6 +53,9 @@
import androidx.wear.protolayout.materialcore.Button.Builder.ButtonType;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* ProtoLayout component {@link Button} that represents clickable button with the given content.
*
@@ -84,25 +85,25 @@
* }</pre>
*/
public class Button implements LayoutElement {
- @NonNull private final androidx.wear.protolayout.materialcore.Button mElement;
+ private final androidx.wear.protolayout.materialcore.@NonNull Button mElement;
- Button(@NonNull androidx.wear.protolayout.materialcore.Button element) {
+ Button(androidx.wear.protolayout.materialcore.@NonNull Button element) {
mElement = element;
}
/** Builder class for {@link Button}. */
public static final class Builder implements LayoutElement.Builder {
- @NonNull private final Context mContext;
- @Nullable private LayoutElement mCustomContent;
- @NonNull private DpProp mSize = DEFAULT_SIZE;
- @Nullable private String mText = null;
- @Nullable private Integer mTypographyName = null;
- @Nullable private String mIcon = null;
- @Nullable private DpProp mIconSize = null;
- @Nullable private String mImage = null;
- @NonNull private ButtonColors mButtonColors = PRIMARY_COLORS;
+ private final @NonNull Context mContext;
+ private @Nullable LayoutElement mCustomContent;
+ private @NonNull DpProp mSize = DEFAULT_SIZE;
+ private @Nullable String mText = null;
+ private @Nullable Integer mTypographyName = null;
+ private @Nullable String mIcon = null;
+ private @Nullable DpProp mIconSize = null;
+ private @Nullable String mImage = null;
+ private @NonNull ButtonColors mButtonColors = PRIMARY_COLORS;
@ButtonType private int mType = NOT_SET;
- @NonNull private final androidx.wear.protolayout.materialcore.Button.Builder mCoreBuilder;
+ private final androidx.wear.protolayout.materialcore.Button.@NonNull Builder mCoreBuilder;
/**
* Creates a builder for the {@link Button} from the given content. Custom content should be
@@ -126,8 +127,7 @@
* Sets the static content description for the {@link Button}. It is highly recommended to
* provide this for button containing icon or image.
*/
- @NonNull
- public Builder setContentDescription(@NonNull CharSequence contentDescription) {
+ public @NonNull Builder setContentDescription(@NonNull CharSequence contentDescription) {
return setContentDescription(staticString(contentDescription.toString()));
}
@@ -138,8 +138,7 @@
* <p>While this field is statically accessible from 1.0, it's only bindable since version
* 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
- @NonNull
- public Builder setContentDescription(@NonNull StringProp contentDescription) {
+ public @NonNull Builder setContentDescription(@NonNull StringProp contentDescription) {
mCoreBuilder.setContentDescription(contentDescription);
return this;
}
@@ -150,8 +149,7 @@
* ButtonDefaults#EXTRA_LARGE_SIZE}. If not set, {@link ButtonDefaults#DEFAULT_SIZE} will be
* used.
*/
- @NonNull
- public Builder setSize(@NonNull DpProp size) {
+ public @NonNull Builder setSize(@NonNull DpProp size) {
mSize = size;
mCoreBuilder.setSize(size);
return this;
@@ -163,8 +161,7 @@
* ButtonDefaults#EXTRA_LARGE_SIZE}. If not set, {@link ButtonDefaults#DEFAULT_SIZE} will be
* used.
*/
- @NonNull
- public Builder setSize(@Dimension(unit = DP) float size) {
+ public @NonNull Builder setSize(@Dimension(unit = DP) float size) {
return setSize(dp(size));
}
@@ -175,8 +172,7 @@
* <p>Note: The content color will be ignored (and won't be returned by the getter) if the
* Button content is an image.
*/
- @NonNull
- public Builder setButtonColors(@NonNull ButtonColors buttonColors) {
+ public @NonNull Builder setButtonColors(@NonNull ButtonColors buttonColors) {
mButtonColors = buttonColors;
mCoreBuilder.setBackgroundColor(buttonColors.getBackgroundColor());
return this;
@@ -185,8 +181,7 @@
/**
* Sets the custom content for this Button. Any previously added content will be overridden.
*/
- @NonNull
- public Builder setCustomContent(@NonNull LayoutElement content) {
+ public @NonNull Builder setCustomContent(@NonNull LayoutElement content) {
resetContent();
this.mCustomContent = content;
this.mType = CUSTOM_CONTENT;
@@ -199,8 +194,8 @@
* from {@link ButtonColors} and with the given size. This icon should be image with chosen
* alpha channel and not an actual image.
*/
- @NonNull
- public Builder setIconContent(@NonNull String imageResourceId, @NonNull DpProp size) {
+ public @NonNull Builder setIconContent(@NonNull String imageResourceId,
+ @NonNull DpProp size) {
resetContent();
this.mIcon = imageResourceId;
this.mType = ICON;
@@ -214,8 +209,7 @@
* icon will be tinted to the given content color from {@link ButtonColors}. This icon
* should be image with chosen alpha channel and not an actual image.
*/
- @NonNull
- public Builder setIconContent(@NonNull String imageResourceId) {
+ public @NonNull Builder setIconContent(@NonNull String imageResourceId) {
resetContent();
this.mIcon = imageResourceId;
this.mType = ICON;
@@ -230,8 +224,7 @@
* Any previously added content will be overridden. Text should contain no more than 3
* characters, otherwise it will overflow from the edges.
*/
- @NonNull
- public Builder setTextContent(@NonNull String text) {
+ public @NonNull Builder setTextContent(@NonNull String text) {
resetContent();
this.mText = text;
this.mType = TEXT;
@@ -244,8 +237,8 @@
* Text} component. Any previously added content will be overridden. Text should contain no
* more than 3 characters, otherwise it will overflow from the edges.
*/
- @NonNull
- public Builder setTextContent(@NonNull String text, @TypographyName int typographyName) {
+ public @NonNull Builder setTextContent(@NonNull String text,
+ @TypographyName int typographyName) {
resetContent();
this.mText = text;
this.mTypographyName = typographyName;
@@ -257,8 +250,7 @@
* Sets the content of this Button to be the given image, i.e. contacts photo. Any
* previously added content will be overridden.
*/
- @NonNull
- public Builder setImageContent(@NonNull String imageResourceId) {
+ public @NonNull Builder setImageContent(@NonNull String imageResourceId) {
resetContent();
this.mImage = imageResourceId;
this.mType = IMAGE;
@@ -275,17 +267,15 @@
}
/** Constructs and returns {@link Button} with the provided field and look. */
- @NonNull
@Override
- public Button build() {
+ public @NonNull Button build() {
// getCorrectContent will apply styling.
mCoreBuilder.setContent(getCorrectContent(), mType);
return new Button(mCoreBuilder.build());
}
- @NonNull
- private LayoutElement getCorrectContent() {
+ private @NonNull LayoutElement getCorrectContent() {
LayoutElement.Builder content;
switch (mType) {
case ICON:
@@ -357,8 +347,7 @@
/**
* Returns the custom content of this Button if it has been added. Otherwise, it returns null.
*/
- @Nullable
- public LayoutElement getCustomContent() {
+ public @Nullable LayoutElement getCustomContent() {
if (!getMetadataTag().equals(METADATA_TAG_CUSTOM_CONTENT)) {
return null;
}
@@ -366,8 +355,7 @@
}
/** Returns the icon content of this Button if it has been added. Otherwise, it returns null. */
- @Nullable
- public String getIconContent() {
+ public @Nullable String getIconContent() {
Image icon = getIconContentObject();
return icon != null ? checkNotNull(icon.getResourceId()).getValue() : null;
}
@@ -375,42 +363,36 @@
/**
* Returns the image content of this Button if it has been added. Otherwise, it returns null.
*/
- @Nullable
- public String getImageContent() {
+ public @Nullable String getImageContent() {
Image image = getImageContentObject();
return image != null ? checkNotNull(image.getResourceId()).getValue() : null;
}
/** Returns the text content of this Button if it has been added. Otherwise, it returns null. */
- @Nullable
- public String getTextContent() {
+ public @Nullable String getTextContent() {
Text text = getTextContentObject();
return text != null ? text.getText().getValue() : null;
}
- @NonNull
- private LayoutElement getAnyContent() {
+ private @NonNull LayoutElement getAnyContent() {
return checkNotNull(mElement.getContent());
}
- @Nullable
- private Image getIconContentObject() {
+ private @Nullable Image getIconContentObject() {
if (!getMetadataTag().equals(METADATA_TAG_ICON)) {
return null;
}
return (Image) getAnyContent();
}
- @Nullable
- private Text getTextContentObject() {
+ private @Nullable Text getTextContentObject() {
if (!getMetadataTag().equals(METADATA_TAG_TEXT)) {
return null;
}
return Text.fromLayoutElement(getAnyContent());
}
- @Nullable
- private Image getImageContentObject() {
+ private @Nullable Image getImageContentObject() {
if (!getMetadataTag().equals(METADATA_TAG_IMAGE)) {
return null;
}
@@ -418,20 +400,17 @@
}
/** Returns click event action associated with this Button. */
- @NonNull
- public Clickable getClickable() {
+ public @NonNull Clickable getClickable() {
return mElement.getClickable();
}
/** Returns content description for this Button. */
- @Nullable
- public StringProp getContentDescription() {
+ public @Nullable StringProp getContentDescription() {
return mElement.getContentDescription();
}
/** Returns size for this Button. */
- @NonNull
- public ContainerDimension getSize() {
+ public @NonNull ContainerDimension getSize() {
return mElement.getSize();
}
@@ -440,8 +419,7 @@
*
* <p>Note that the content color will be unset if the content of this Button is an image.
*/
- @NonNull
- public ButtonColors getButtonColors() {
+ public @NonNull ButtonColors getButtonColors() {
ColorProp backgroundColor = mElement.getBackgroundColor();
ColorProp contentColor = null;
@@ -468,8 +446,7 @@
}
/** Returns metadata tag set to this Button. */
- @NonNull
- String getMetadataTag() {
+ @NonNull String getMetadataTag() {
return mElement.getMetadataTag();
}
@@ -478,8 +455,7 @@
* content with {@code container.getContents().get(index)}) if that element can be converted to
* Button. Otherwise, it will return null.
*/
- @Nullable
- public static Button fromLayoutElement(@NonNull LayoutElement element) {
+ public static @Nullable Button fromLayoutElement(@NonNull LayoutElement element) {
if (element instanceof Button) {
return (Button) element;
}
@@ -489,17 +465,15 @@
return coreButton == null ? null : new Button(coreButton);
}
- @NonNull
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return checkNotNull(mElement.toLayoutElementProto());
}
- @Nullable
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mElement.getFingerprint();
}
}
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ButtonColors.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ButtonColors.java
index c1c830f..816ffb1 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ButtonColors.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ButtonColors.java
@@ -19,9 +19,10 @@
import static androidx.wear.protolayout.ColorBuilders.argb;
import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
import androidx.wear.protolayout.ColorBuilders.ColorProp;
+import org.jspecify.annotations.NonNull;
+
/**
* Represents the background and content colors used in {@link Button}.
*
@@ -30,8 +31,8 @@
* secondary styled {@link Button}.
*/
public class ButtonColors {
- @NonNull private final ColorProp mBackgroundColor;
- @NonNull private final ColorProp mContentColor;
+ private final @NonNull ColorProp mBackgroundColor;
+ private final @NonNull ColorProp mContentColor;
/**
* Constructor for {@link ButtonColors} object.
@@ -61,8 +62,7 @@
* Returns a {@link ButtonColors} object, using the current Primary colors from the given {@link
* Colors}.
*/
- @NonNull
- public static ButtonColors primaryButtonColors(@NonNull Colors colors) {
+ public static @NonNull ButtonColors primaryButtonColors(@NonNull Colors colors) {
return new ButtonColors(colors.getPrimary(), colors.getOnPrimary());
}
@@ -70,20 +70,17 @@
* Returns a {@link ButtonColors} object, using the current Surface colors from the given {@link
* Colors}.
*/
- @NonNull
- public static ButtonColors secondaryButtonColors(@NonNull Colors colors) {
+ public static @NonNull ButtonColors secondaryButtonColors(@NonNull Colors colors) {
return new ButtonColors(colors.getSurface(), colors.getOnSurface());
}
/** The background color to be used on {@link Button}. */
- @NonNull
- public ColorProp getBackgroundColor() {
+ public @NonNull ColorProp getBackgroundColor() {
return mBackgroundColor;
}
/** The content or tint color to be used on {@link Button}. */
- @NonNull
- public ColorProp getContentColor() {
+ public @NonNull ColorProp getContentColor() {
return mContentColor;
}
}
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ButtonDefaults.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ButtonDefaults.java
index e34b352..769383a 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ButtonDefaults.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ButtonDefaults.java
@@ -20,41 +20,38 @@
import static androidx.wear.protolayout.DimensionBuilders.dp;
import androidx.annotation.Dimension;
-import androidx.annotation.NonNull;
import androidx.wear.protolayout.DimensionBuilders.DpProp;
+import org.jspecify.annotations.NonNull;
+
/** Contains the default values used by {@link Button}. */
public class ButtonDefaults {
private ButtonDefaults() {}
/** The default size for standard {@link Button}. */
- @NonNull public static final DpProp DEFAULT_SIZE = dp(52);
+ public static final @NonNull DpProp DEFAULT_SIZE = dp(52);
/** The recommended size for large {@link Button}. */
- @NonNull public static final DpProp LARGE_SIZE = dp(60);
+ public static final @NonNull DpProp LARGE_SIZE = dp(60);
/** The recommended size for extra large {@link Button}. */
- @NonNull public static final DpProp EXTRA_LARGE_SIZE = dp(88);
+ public static final @NonNull DpProp EXTRA_LARGE_SIZE = dp(88);
/** Returns the recommended icon size for the given size of {@link Button}. */
- @NonNull
- public static DpProp recommendedIconSize(@NonNull DpProp buttonSize) {
+ public static @NonNull DpProp recommendedIconSize(@NonNull DpProp buttonSize) {
return recommendedIconSize(buttonSize.getValue());
}
/** Returns the recommended icon size for the given size of {@link Button}. */
- @NonNull
- public static DpProp recommendedIconSize(@Dimension(unit = DP) float buttonSize) {
+ public static @NonNull DpProp recommendedIconSize(@Dimension(unit = DP) float buttonSize) {
return dp(buttonSize / 2);
}
/** The recommended colors for a primary {@link Button}. */
- @NonNull
- public static final ButtonColors PRIMARY_COLORS =
+ public static final @NonNull ButtonColors PRIMARY_COLORS =
ButtonColors.primaryButtonColors(Colors.DEFAULT);
/** The recommended colors for a secondary {@link Button}. */
- @NonNull
- public static final ButtonColors SECONDARY_COLORS =
+ public static final @NonNull ButtonColors SECONDARY_COLORS =
ButtonColors.secondaryButtonColors(Colors.DEFAULT);
}
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Chip.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Chip.java
index 08c81d9..e28d43c 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Chip.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Chip.java
@@ -35,8 +35,6 @@
import android.content.Context;
import androidx.annotation.Dimension;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.ColorBuilders.ColorProp;
@@ -54,6 +52,9 @@
import androidx.wear.protolayout.material.Typography.TypographyName;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* ProtoLayout component {@link Chip} that represents clickable object with the text, optional label
* and optional icon or with custom content.
@@ -90,27 +91,27 @@
* used inside of {@link androidx.wear.protolayout.material.layouts.PrimaryLayout}.
*/
public class Chip implements LayoutElement {
- @NonNull private final androidx.wear.protolayout.materialcore.Chip mElement;
+ private final androidx.wear.protolayout.materialcore.@NonNull Chip mElement;
- Chip(@NonNull androidx.wear.protolayout.materialcore.Chip element) {
+ Chip(androidx.wear.protolayout.materialcore.@NonNull Chip element) {
mElement = element;
}
/** Builder class for {@link Chip}. */
public static final class Builder implements LayoutElement.Builder {
- @NonNull private final Context mContext;
- @Nullable private LayoutElement mCustomContent;
- @Nullable private String mImageResourceId = null;
- @Nullable private String mPrimaryLabel = null;
- @Nullable private String mSecondaryLabel = null;
- @Nullable private StringProp mContentDescription = null;
- @NonNull private ChipColors mChipColors = PRIMARY_COLORS;
- @NonNull private DpProp mIconSize = ICON_SIZE;
+ private final @NonNull Context mContext;
+ private @Nullable LayoutElement mCustomContent;
+ private @Nullable String mImageResourceId = null;
+ private @Nullable String mPrimaryLabel = null;
+ private @Nullable String mSecondaryLabel = null;
+ private @Nullable StringProp mContentDescription = null;
+ private @NonNull ChipColors mChipColors = PRIMARY_COLORS;
+ private @NonNull DpProp mIconSize = ICON_SIZE;
@HorizontalAlignment private int mHorizontalAlign = HORIZONTAL_ALIGN_UNDEFINED;
@TypographyName private int mPrimaryLabelTypography;
private boolean mIsScalable = true;
private int mMaxLines = 0; // 0 indicates that is not set.
- @NonNull private final androidx.wear.protolayout.materialcore.Chip.Builder mCoreBuilder;
+ private final androidx.wear.protolayout.materialcore.Chip.@NonNull Builder mCoreBuilder;
/**
* Creates a builder for the {@link Chip} with associated action. It is required to add
@@ -141,8 +142,7 @@
/**
* Sets the width of {@link Chip}. If not set, default value will be set to fill the screen.
*/
- @NonNull
- public Builder setWidth(@NonNull ContainerDimension width) {
+ public @NonNull Builder setWidth(@NonNull ContainerDimension width) {
mCoreBuilder.setWidth(width);
return this;
}
@@ -151,8 +151,7 @@
* Sets the width of {@link Chip}. If not set, default value will be set to fill the
* screen.
*/
- @NonNull
- public Builder setWidth(@Dimension(unit = DP) float width) {
+ public @NonNull Builder setWidth(@Dimension(unit = DP) float width) {
return setWidth(dp(width));
}
@@ -160,8 +159,7 @@
* Sets the custom content for the {@link Chip}. Any previously added content will be
* overridden.
*/
- @NonNull
- public Builder setCustomContent(@NonNull LayoutElement content) {
+ public @NonNull Builder setCustomContent(@NonNull LayoutElement content) {
this.mCustomContent = content;
this.mPrimaryLabel = null;
this.mSecondaryLabel = null;
@@ -173,8 +171,7 @@
* Sets the static content description for the {@link Chip}. It is highly recommended to
* provide this for chip containing icon.
*/
- @NonNull
- public Builder setContentDescription(@NonNull CharSequence contentDescription) {
+ public @NonNull Builder setContentDescription(@NonNull CharSequence contentDescription) {
return setContentDescription(staticString(contentDescription.toString()));
}
@@ -185,8 +182,7 @@
* <p>While this field is statically accessible from 1.0, it's only bindable since version
* 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
- @NonNull
- public Builder setContentDescription(@NonNull StringProp contentDescription) {
+ public @NonNull Builder setContentDescription(@NonNull StringProp contentDescription) {
this.mContentDescription = contentDescription;
return this;
}
@@ -196,8 +192,7 @@
* overridden. Primary label can be on 1 or 2 lines, depending on the length and existence
* of secondary label.
*/
- @NonNull
- public Builder setPrimaryLabelContent(@NonNull String primaryLabel) {
+ public @NonNull Builder setPrimaryLabelContent(@NonNull String primaryLabel) {
this.mPrimaryLabel = primaryLabel;
this.mCustomContent = null;
return this;
@@ -208,8 +203,7 @@
*
* <p>Sets the font for the primary label and should only be used internally.
*/
- @NonNull
- Builder setPrimaryLabelTypography(@TypographyName int typography) {
+ @NonNull Builder setPrimaryLabelTypography(@TypographyName int typography) {
this.mPrimaryLabelTypography = typography;
return this;
}
@@ -219,8 +213,7 @@
*
* <p>Sets the icon size and should only be used internally.
*/
- @NonNull
- Builder setIconSize(@NonNull DpProp size) {
+ @NonNull Builder setIconSize(@NonNull DpProp size) {
this.mIconSize = size;
return this;
}
@@ -230,8 +223,7 @@
*
* <p>Sets whether the font for the primary label is scalable.
*/
- @NonNull
- Builder setIsPrimaryLabelScalable(boolean isScalable) {
+ @NonNull Builder setIsPrimaryLabelScalable(boolean isScalable) {
this.mIsScalable = isScalable;
return this;
}
@@ -241,8 +233,7 @@
* be overridden. If secondary label is set, primary label must be set too with {@link
* #setPrimaryLabelContent}.
*/
- @NonNull
- public Builder setSecondaryLabelContent(@NonNull String secondaryLabel) {
+ public @NonNull Builder setSecondaryLabelContent(@NonNull String secondaryLabel) {
this.mSecondaryLabel = secondaryLabel;
this.mCustomContent = null;
return this;
@@ -254,8 +245,7 @@
* ChipColors}. This icon should be image with chosen alpha channel and not an actual image.
* If icon is set, primary label must be set too with {@link #setPrimaryLabelContent}.
*/
- @NonNull
- public Builder setIconContent(@NonNull String imageResourceId) {
+ public @NonNull Builder setIconContent(@NonNull String imageResourceId) {
this.mImageResourceId = imageResourceId;
this.mCustomContent = null;
return this;
@@ -268,8 +258,7 @@
* ChipColors#getIconColor()} will be used as color for the icon itself. If not set, {@link
* ChipDefaults#PRIMARY_COLORS} will be used.
*/
- @NonNull
- public Builder setChipColors(@NonNull ChipColors chipColors) {
+ public @NonNull Builder setChipColors(@NonNull ChipColors chipColors) {
mChipColors = chipColors;
mCoreBuilder.setBackgroundColor(chipColors.getBackgroundColor());
return this;
@@ -281,37 +270,33 @@
* HorizontalAlignment#HORIZONTAL_ALIGN_CENTER} will be used when only a primary label is
* present. Otherwise {@link HorizontalAlignment#HORIZONTAL_ALIGN_START} will be used.
*/
- @NonNull
- public Builder setHorizontalAlignment(@HorizontalAlignment int horizontalAlignment) {
+ public @NonNull Builder setHorizontalAlignment(
+ @HorizontalAlignment int horizontalAlignment) {
mHorizontalAlign = horizontalAlignment;
return this;
}
/** Used for creating {@code CompactChip} and {@code TitleChip}. */
- @NonNull
- Builder setHorizontalPadding(@NonNull DpProp horizontalPadding) {
+ @NonNull Builder setHorizontalPadding(@NonNull DpProp horizontalPadding) {
mCoreBuilder.setHorizontalPadding(horizontalPadding);
return this;
}
/** Used for creating {@code CompactChip} and {@code TitleChip}. */
- @NonNull
- Builder setHeight(@NonNull DpProp height) {
+ @NonNull Builder setHeight(@NonNull DpProp height) {
mCoreBuilder.setHeight(height);
return this;
}
/** Used for creating {@code CompactChip} and {@code TitleChip}. */
- @NonNull
- Builder setMaxLines(int maxLines) {
+ @NonNull Builder setMaxLines(int maxLines) {
this.mMaxLines = maxLines;
return this;
}
/** Constructs and returns {@link Chip} with the provided content and look. */
- @NonNull
@Override
- public Chip build() {
+ public @NonNull Chip build() {
mCoreBuilder.setContentDescription(getCorrectContentDescription());
mCoreBuilder.setHorizontalAlignment(getCorrectHorizontalAlignment());
@@ -324,8 +309,7 @@
return new Chip(mCoreBuilder.build());
}
- @NonNull
- private StringProp getCorrectContentDescription() {
+ private @NonNull StringProp getCorrectContentDescription() {
if (mContentDescription == null) {
String staticValue = "";
if (mPrimaryLabel != null) {
@@ -409,26 +393,22 @@
}
/** Returns the visible height of this Chip. */
- @NonNull
- public ContainerDimension getHeight() {
+ public @NonNull ContainerDimension getHeight() {
return mElement.getHeight();
}
/** Returns width of this Chip. */
- @NonNull
- public ContainerDimension getWidth() {
+ public @NonNull ContainerDimension getWidth() {
return mElement.getWidth();
}
/** Returns click event action associated with this Chip. */
- @NonNull
- public Clickable getClickable() {
+ public @NonNull Clickable getClickable() {
return mElement.getClickable();
}
/** Returns chip colors of this Chip. */
- @NonNull
- public ChipColors getChipColors() {
+ public @NonNull ChipColors getChipColors() {
ColorProp backgroundColor = mElement.getBackgroundColor();
ColorProp contentColor = null;
ColorProp secondaryContentColor = null;
@@ -466,40 +446,34 @@
}
/** Returns content description of this Chip. */
- @Nullable
- public StringProp getContentDescription() {
+ public @Nullable StringProp getContentDescription() {
return mElement.getContentDescription();
}
/** Returns custom content from this Chip if it has been added. Otherwise, it returns null. */
- @Nullable
- public LayoutElement getCustomContent() {
+ public @Nullable LayoutElement getCustomContent() {
return mElement.getCustomContent();
}
/** Returns primary label from this Chip if it has been added. Otherwise, it returns null. */
- @Nullable
- public String getPrimaryLabelContent() {
+ public @Nullable String getPrimaryLabelContent() {
Text primaryLabel = getPrimaryLabelContentObject();
return primaryLabel != null ? primaryLabel.getText().getValue() : null;
}
/** Returns secondary label from this Chip if it has been added. Otherwise, it returns null. */
- @Nullable
- public String getSecondaryLabelContent() {
+ public @Nullable String getSecondaryLabelContent() {
Text secondaryLabel = getSecondaryLabelContentObject();
return secondaryLabel != null ? secondaryLabel.getText().getValue() : null;
}
/** Returns icon id from this Chip if it has been added. Otherwise, it returns null. */
- @Nullable
- public String getIconContent() {
+ public @Nullable String getIconContent() {
Image icon = getIconContentObject();
return icon != null ? checkNotNull(icon.getResourceId()).getValue() : null;
}
- @Nullable
- private Text getPrimaryLabelContentObject() {
+ private @Nullable Text getPrimaryLabelContentObject() {
LayoutElement content = mElement.getPrimaryLabelContent();
if (content != null) {
return Text.fromLayoutElement(content);
@@ -507,8 +481,7 @@
return null;
}
- @Nullable
- private Text getSecondaryLabelContentObject() {
+ private @Nullable Text getSecondaryLabelContentObject() {
LayoutElement content = mElement.getSecondaryLabelContent();
if (content != null) {
return Text.fromLayoutElement(content);
@@ -516,8 +489,7 @@
return null;
}
- @Nullable
- private Image getIconContentObject() {
+ private @Nullable Image getIconContentObject() {
LayoutElement content = mElement.getIconContent();
return content instanceof Image ? (Image) content : null;
}
@@ -529,8 +501,7 @@
}
/** Returns metadata tag set to this Chip. */
- @NonNull
- String getMetadataTag() {
+ @NonNull String getMetadataTag() {
return mElement.getMetadataTag();
}
@@ -539,8 +510,7 @@
* content with {@code container.getContents().get(index)}) if that element can be converted to
* Chip. Otherwise, it will return null.
*/
- @Nullable
- public static Chip fromLayoutElement(@NonNull LayoutElement element) {
+ public static @Nullable Chip fromLayoutElement(@NonNull LayoutElement element) {
if (element instanceof Chip) {
return (Chip) element;
}
@@ -549,17 +519,15 @@
return coreChip == null ? null : new Chip(coreChip);
}
- @NonNull
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mElement.toLayoutElementProto();
}
- @Nullable
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mElement.getFingerprint();
}
}
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ChipColors.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ChipColors.java
index 069a260..8b92fee 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ChipColors.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ChipColors.java
@@ -19,9 +19,10 @@
import static androidx.wear.protolayout.ColorBuilders.argb;
import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
import androidx.wear.protolayout.ColorBuilders.ColorProp;
+import org.jspecify.annotations.NonNull;
+
/**
* Represents the background and content colors used in {@link Chip}.
*
@@ -30,10 +31,10 @@
* styled {@link Chip}.
*/
public class ChipColors {
- @NonNull private final ColorProp mBackgroundColor;
- @NonNull private final ColorProp mIconColor;
- @NonNull private final ColorProp mContentColor;
- @NonNull private final ColorProp mSecondaryContentColor;
+ private final @NonNull ColorProp mBackgroundColor;
+ private final @NonNull ColorProp mIconColor;
+ private final @NonNull ColorProp mContentColor;
+ private final @NonNull ColorProp mSecondaryContentColor;
/**
* Constructor for the {@link ChipColors} object.
@@ -108,8 +109,7 @@
* Returns a {@link ChipColors} object, using the current Primary colors from the given {@link
* Colors}.
*/
- @NonNull
- public static ChipColors primaryChipColors(@NonNull Colors colors) {
+ public static @NonNull ChipColors primaryChipColors(@NonNull Colors colors) {
return new ChipColors(colors.getPrimary(), colors.getOnPrimary());
}
@@ -117,32 +117,27 @@
* Returns a {@link ChipColors} object, using the current Surface colors from the given {@link
* Colors}.
*/
- @NonNull
- public static ChipColors secondaryChipColors(@NonNull Colors colors) {
+ public static @NonNull ChipColors secondaryChipColors(@NonNull Colors colors) {
return new ChipColors(colors.getSurface(), colors.getOnSurface());
}
/** The background color to be used on {@link Chip}. */
- @NonNull
- public ColorProp getBackgroundColor() {
+ public @NonNull ColorProp getBackgroundColor() {
return mBackgroundColor;
}
/** The icon color to be used on {@link Chip}. */
- @NonNull
- public ColorProp getIconColor() {
+ public @NonNull ColorProp getIconColor() {
return mIconColor;
}
/** The main text color to be used on {@link Chip}. */
- @NonNull
- public ColorProp getContentColor() {
+ public @NonNull ColorProp getContentColor() {
return mContentColor;
}
/** The label text color to be used on {@link Chip}. */
- @NonNull
- public ColorProp getSecondaryContentColor() {
+ public @NonNull ColorProp getSecondaryContentColor() {
return mSecondaryContentColor;
}
}
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ChipDefaults.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ChipDefaults.java
index 0441297..d78040d 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ChipDefaults.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ChipDefaults.java
@@ -18,39 +18,35 @@
import static androidx.wear.protolayout.DimensionBuilders.dp;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.DimensionBuilders.DpProp;
+import org.jspecify.annotations.NonNull;
+
/** Contains the default values used by {@link Chip}. */
public class ChipDefaults {
private ChipDefaults() {}
/** The default height for standard {@link Chip} */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final DpProp DEFAULT_HEIGHT = dp(52);
+ public static final @NonNull DpProp DEFAULT_HEIGHT = dp(52);
/** The default height for standard {@link CompactChip} */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final DpProp COMPACT_HEIGHT = dp(32);
+ public static final @NonNull DpProp COMPACT_HEIGHT = dp(32);
/** The default minimum width for standard {@link CompactChip} */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final DpProp COMPACT_MIN_WIDTH = dp(52);
+ public static final @NonNull DpProp COMPACT_MIN_WIDTH = dp(52);
/** The minimum size of tappable target area. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final DpProp MIN_TAPPABLE_SQUARE_LENGTH = dp(48);
+ public static final @NonNull DpProp MIN_TAPPABLE_SQUARE_LENGTH = dp(48);
/** The default height for standard {@link TitleChip} */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final DpProp TITLE_HEIGHT = dp(60);
+ public static final @NonNull DpProp TITLE_HEIGHT = dp(60);
/** The recommended horizontal margin used for width for standard {@link Chip} */
@RestrictTo(Scope.LIBRARY_GROUP)
@@ -58,54 +54,46 @@
/** The recommended horizontal padding for standard {@link Chip} */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final DpProp HORIZONTAL_PADDING = dp(14);
+ public static final @NonNull DpProp HORIZONTAL_PADDING = dp(14);
/** The recommended horizontal padding for standard {@link CompactChip} */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final DpProp COMPACT_HORIZONTAL_PADDING = dp(12);
+ public static final @NonNull DpProp COMPACT_HORIZONTAL_PADDING = dp(12);
/** The recommended horizontal padding for standard {@link TitleChip} */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final DpProp TITLE_HORIZONTAL_PADDING = dp(16);
+ public static final @NonNull DpProp TITLE_HORIZONTAL_PADDING = dp(16);
/** The recommended vertical space between icon and text in standard {@link Chip} */
- @NonNull static final DpProp ICON_SPACER_WIDTH = dp(6);
+ static final @NonNull DpProp ICON_SPACER_WIDTH = dp(6);
/** The icon size used in standard {@link Chip} */
- @NonNull static final DpProp ICON_SIZE = dp(24);
+ static final @NonNull DpProp ICON_SIZE = dp(24);
/** The icon size used in standard {@link CompactChip} */
- @NonNull static final DpProp COMPACT_ICON_SIZE = dp(20);
+ static final @NonNull DpProp COMPACT_ICON_SIZE = dp(20);
/** The recommended colors for a primary {@link Chip}. */
- @NonNull
- public static final ChipColors PRIMARY_COLORS = ChipColors.primaryChipColors(Colors.DEFAULT);
+ public static final @NonNull ChipColors PRIMARY_COLORS =
+ ChipColors.primaryChipColors(Colors.DEFAULT);
/** The recommended colors for a secondary {@link Chip}. */
- @NonNull
- public static final ChipColors SECONDARY_COLORS =
+ public static final @NonNull ChipColors SECONDARY_COLORS =
ChipColors.secondaryChipColors(Colors.DEFAULT);
/** The recommended colors for a primary {@link CompactChip}. */
- @NonNull
- public static final ChipColors COMPACT_PRIMARY_COLORS =
+ public static final @NonNull ChipColors COMPACT_PRIMARY_COLORS =
ChipColors.primaryChipColors(Colors.DEFAULT);
/** The recommended colors for a secondary {@link CompactChip}. */
- @NonNull
- public static final ChipColors COMPACT_SECONDARY_COLORS =
+ public static final @NonNull ChipColors COMPACT_SECONDARY_COLORS =
ChipColors.secondaryChipColors(Colors.DEFAULT);
/** The recommended colors for a primary {@link TitleChip}. */
- @NonNull
- public static final ChipColors TITLE_PRIMARY_COLORS =
+ public static final @NonNull ChipColors TITLE_PRIMARY_COLORS =
ChipColors.primaryChipColors(Colors.DEFAULT);
/** The recommended colors for a secondary {@link TitleChip}. */
- @NonNull
- public static final ChipColors TITLE_SECONDARY_COLORS =
+ public static final @NonNull ChipColors TITLE_SECONDARY_COLORS =
ChipColors.secondaryChipColors(Colors.DEFAULT);
}
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/CircularProgressIndicator.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/CircularProgressIndicator.java
index b9d4517..bdb7a68 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/CircularProgressIndicator.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/CircularProgressIndicator.java
@@ -35,8 +35,6 @@
import androidx.annotation.Dimension;
import androidx.annotation.FloatRange;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.DimensionBuilders.AngularLayoutConstraint;
@@ -58,6 +56,9 @@
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* ProtoLayout component {@link CircularProgressIndicator} that represents circular progress
* indicator which supports a gap in the circular track between startAngle and endAngle.
@@ -99,9 +100,9 @@
*/
static final String METADATA_TAG = "CPI";
- @NonNull private final Arc mElement;
- @NonNull private final ArcLine mProgress;
- @NonNull private final ArcLine mBackground;
+ private final @NonNull Arc mElement;
+ private final @NonNull ArcLine mProgress;
+ private final @NonNull ArcLine mBackground;
CircularProgressIndicator(@NonNull Arc element) {
this.mElement = element;
@@ -111,12 +112,12 @@
/** Builder class for {@link CircularProgressIndicator} */
public static final class Builder implements LayoutElement.Builder {
- @NonNull private ProgressIndicatorColors mCircularProgressIndicatorColors = DEFAULT_COLORS;
- @NonNull private DpProp mStrokeWidth = DEFAULT_STROKE_WIDTH;
- @Nullable private StringProp mContentDescription;
- @NonNull private DegreesProp mStartAngle = degrees(DEFAULT_START_ANGLE);
- @NonNull private DegreesProp mEndAngle = degrees(DEFAULT_END_ANGLE);
- @NonNull private FloatProp mProgress = staticFloat(0f);
+ private @NonNull ProgressIndicatorColors mCircularProgressIndicatorColors = DEFAULT_COLORS;
+ private @NonNull DpProp mStrokeWidth = DEFAULT_STROKE_WIDTH;
+ private @Nullable StringProp mContentDescription;
+ private @NonNull DegreesProp mStartAngle = degrees(DEFAULT_START_ANGLE);
+ private @NonNull DegreesProp mEndAngle = degrees(DEFAULT_END_ANGLE);
+ private @NonNull FloatProp mProgress = staticFloat(0f);
private boolean mIsMarginApplied = true;
/** Creates a builder for the {@link CircularProgressIndicator}. */
@@ -127,8 +128,7 @@
* value between 0 and 1. If not set, 0 will be used. Progress will be colored in {@link
* ProgressIndicatorColors#getIndicatorColor()}.
*/
- @NonNull
- public Builder setProgress(@FloatRange(from = 0, to = 1) float progressRatio) {
+ public @NonNull Builder setProgress(@FloatRange(from = 0, to = 1) float progressRatio) {
this.mProgress = staticFloat(progressRatio);
return this;
}
@@ -145,8 +145,7 @@
* value. The static value of {@code progressRatio} will be considered as 0 if it's
* smaller than zero and as 1 if it's larger than one.
*/
- @NonNull
- public Builder setProgress(@NonNull FloatProp progressRatio) {
+ public @NonNull Builder setProgress(@NonNull FloatProp progressRatio) {
this.mProgress = progressRatio;
return this;
}
@@ -157,8 +156,7 @@
* start arc from the 9 o'clock. If not set 0 will be used and the indicator will have full
* length.
*/
- @NonNull
- public Builder setStartAngle(float startAngle) {
+ public @NonNull Builder setStartAngle(float startAngle) {
this.mStartAngle = degrees(startAngle);
return this;
}
@@ -168,8 +166,7 @@
* 0 is 12 o'clock. End angle doesn't need to be within 0-360 range, but it must be larger
* than start angle. If not set 360 will be used and the indicator will have full length.
*/
- @NonNull
- public Builder setEndAngle(float endAngle) {
+ public @NonNull Builder setEndAngle(float endAngle) {
this.mEndAngle = degrees(endAngle);
return this;
}
@@ -178,8 +175,7 @@
* Sets the static content description of the {@link CircularProgressIndicator} to be used
* for accessibility support.
*/
- @NonNull
- public Builder setContentDescription(@NonNull CharSequence contentDescription) {
+ public @NonNull Builder setContentDescription(@NonNull CharSequence contentDescription) {
this.mContentDescription =
new StringProp.Builder(contentDescription.toString()).build();
return this;
@@ -192,8 +188,7 @@
* <p>While this field is statically accessible from 1.0, it's only bindable since version
* 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
- @NonNull
- public Builder setContentDescription(@NonNull StringProp contentDescription) {
+ public @NonNull Builder setContentDescription(@NonNull StringProp contentDescription) {
this.mContentDescription = contentDescription;
return this;
}
@@ -204,8 +199,7 @@
* made, while {@link ProgressIndicatorColors#getTrackColor()} will be used for a background
* full size arc. If not set, {@link ProgressIndicatorDefaults#DEFAULT_COLORS} will be used.
*/
- @NonNull
- public Builder setCircularProgressIndicatorColors(
+ public @NonNull Builder setCircularProgressIndicatorColors(
@NonNull ProgressIndicatorColors circularProgressIndicatorColors) {
this.mCircularProgressIndicatorColors = circularProgressIndicatorColors;
return this;
@@ -215,8 +209,7 @@
* Sets the stroke width of the {@link CircularProgressIndicator}. Strongly recommended
* value is {@link ProgressIndicatorDefaults#DEFAULT_STROKE_WIDTH}.
*/
- @NonNull
- public Builder setStrokeWidth(@NonNull DpProp strokeWidth) {
+ public @NonNull Builder setStrokeWidth(@NonNull DpProp strokeWidth) {
this.mStrokeWidth = strokeWidth;
return this;
}
@@ -225,8 +218,7 @@
* Sets the stroke width of the {@link CircularProgressIndicator}. Strongly recommended
* value is {@link ProgressIndicatorDefaults#DEFAULT_STROKE_WIDTH}.
*/
- @NonNull
- public Builder setStrokeWidth(@Dimension(unit = DP) float strokeWidth) {
+ public @NonNull Builder setStrokeWidth(@Dimension(unit = DP) float strokeWidth) {
this.mStrokeWidth = dp(strokeWidth);
return this;
}
@@ -243,8 +235,7 @@
*
* <p>If not set, defaults to true.
*/
- @NonNull
- public Builder setOuterMarginApplied(boolean isApplied) {
+ public @NonNull Builder setOuterMarginApplied(boolean isApplied) {
this.mIsMarginApplied = isApplied;
return this;
}
@@ -253,9 +244,8 @@
* Constructs and returns {@link CircularProgressIndicator} with the provided field and
* look.
*/
- @NonNull
@Override
- public CircularProgressIndicator build() {
+ public @NonNull CircularProgressIndicator build() {
checkAngles();
DegreesProp length = getLength();
@@ -341,8 +331,7 @@
}
}
- @NonNull
- private DegreesProp getLength() {
+ private @NonNull DegreesProp getLength() {
float startAngle = mStartAngle.getValue();
float endAngle = mEndAngle.getValue();
if (endAngle <= startAngle) {
@@ -353,40 +342,34 @@
}
/** Returns angle representing progressed part of this CircularProgressIndicator. */
- @NonNull
- public DegreesProp getProgress() {
+ public @NonNull DegreesProp getProgress() {
return checkNotNull(mProgress.getLength());
}
/** Returns stroke width of this CircularProgressIndicator. */
- @NonNull
- public DpProp getStrokeWidth() {
+ public @NonNull DpProp getStrokeWidth() {
return checkNotNull(mProgress.getThickness());
}
/** Returns start angle of this CircularProgressIndicator. */
- @NonNull
- public DegreesProp getStartAngle() {
+ public @NonNull DegreesProp getStartAngle() {
return checkNotNull(mElement.getAnchorAngle());
}
/** Returns start angle of this CircularProgressIndicator. */
- @NonNull
- public DegreesProp getEndAngle() {
+ public @NonNull DegreesProp getEndAngle() {
float backArcLength = checkNotNull(mBackground.getLength()).getValue();
return degrees(getStartAngle().getValue() + backArcLength);
}
/** Returns main arc color of this CircularProgressIndicator. */
- @NonNull
- public ProgressIndicatorColors getCircularProgressIndicatorColors() {
+ public @NonNull ProgressIndicatorColors getCircularProgressIndicatorColors() {
return new ProgressIndicatorColors(
checkNotNull(mProgress.getColor()), checkNotNull(mBackground.getColor()));
}
/** Returns content description of this CircularProgressIndicator. */
- @Nullable
- public StringProp getContentDescription() {
+ public @Nullable StringProp getContentDescription() {
Semantics semantics = checkNotNull(mElement.getModifiers()).getSemantics();
if (semantics == null) {
return null;
@@ -398,8 +381,7 @@
* Returns metadata tag set to this CircularProgressIndicator, which should be {@link
* #METADATA_TAG}.
*/
- @NonNull
- String getMetadataTag() {
+ @NonNull String getMetadataTag() {
return getMetadataTagName(
checkNotNull(checkNotNull(mElement.getModifiers()).getMetadata()));
}
@@ -415,8 +397,8 @@
* from a container's content with {@code container.getContents().get(index)}) if that element
* can be converted to CircularProgressIndicator. Otherwise, it will return null.
*/
- @Nullable
- public static CircularProgressIndicator fromLayoutElement(@NonNull LayoutElement element) {
+ public static @Nullable CircularProgressIndicator fromLayoutElement(
+ @NonNull LayoutElement element) {
if (element instanceof CircularProgressIndicator) {
return (CircularProgressIndicator) element;
}
@@ -431,17 +413,15 @@
return new CircularProgressIndicator(arcElement);
}
- @NonNull
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mElement.toLayoutElementProto();
}
- @Nullable
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mElement.getFingerprint();
}
}
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Colors.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Colors.java
index ee465ae..5506192 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Colors.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Colors.java
@@ -17,10 +17,11 @@
package androidx.wear.protolayout.material;
import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
+import org.jspecify.annotations.NonNull;
+
/**
* Represent the container for default color scheme in your Tile, that can be used to create color
* objects for all Material components.
@@ -50,8 +51,8 @@
public static final int ON_SURFACE = 0xFFFFFFFF;
/** The default color scheme to be used in ProtoLayout Material components. */
- @NonNull
- public static final Colors DEFAULT = new Colors(PRIMARY, ON_PRIMARY, SURFACE, ON_SURFACE);
+ public static final @NonNull Colors DEFAULT =
+ new Colors(PRIMARY, ON_PRIMARY, SURFACE, ON_SURFACE);
@ColorInt private final int mPrimary;
@ColorInt private final int mOnPrimary;
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/CompactChip.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/CompactChip.java
index 47115ab..3d58c62 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/CompactChip.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/CompactChip.java
@@ -29,8 +29,6 @@
import android.content.Context;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.OptIn;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
@@ -43,6 +41,9 @@
import androidx.wear.protolayout.expression.ProtoLayoutExperimental;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* ProtoLayout component {@link CompactChip} that represents clickable object with the text.
*
@@ -74,7 +75,7 @@
* }</pre>
*/
public class CompactChip implements LayoutElement {
- @NonNull private final Chip mElement;
+ private final @NonNull Chip mElement;
CompactChip(@NonNull Chip element) {
this.mElement = element;
@@ -82,13 +83,13 @@
/** Builder class for {@link CompactChip}. */
public static final class Builder implements LayoutElement.Builder {
- @NonNull private final Context mContext;
- @Nullable private String mText;
- @NonNull private final Clickable mClickable;
- @NonNull private final DeviceParameters mDeviceParameters;
- @NonNull private ChipColors mChipColors = COMPACT_PRIMARY_COLORS;
- @Nullable private String mIconResourceId = null;
- @Nullable private StringProp mContentDescription = null;
+ private final @NonNull Context mContext;
+ private @Nullable String mText;
+ private final @NonNull Clickable mClickable;
+ private final @NonNull DeviceParameters mDeviceParameters;
+ private @NonNull ChipColors mChipColors = COMPACT_PRIMARY_COLORS;
+ private @Nullable String mIconResourceId = null;
+ private @Nullable StringProp mContentDescription = null;
/**
* Creates a builder for the {@link CompactChip} with associated action and the given text.
@@ -130,8 +131,7 @@
/** Sets the text for the {@link CompactChip}. */
@SuppressWarnings("MissingGetterMatchingBuilder") // Exists as getText
- @NonNull
- public Builder setTextContent(@NonNull String text) {
+ public @NonNull Builder setTextContent(@NonNull String text) {
this.mText = text;
return this;
}
@@ -142,8 +142,7 @@
* ChipColors#getContentColor()} for the text. If not set, {@link
* ChipDefaults#COMPACT_PRIMARY_COLORS} will be used.
*/
- @NonNull
- public Builder setChipColors(@NonNull ChipColors chipColors) {
+ public @NonNull Builder setChipColors(@NonNull ChipColors chipColors) {
mChipColors = chipColors;
return this;
}
@@ -153,8 +152,7 @@
* content color from {@link ChipColors}. This icon should be image with chosen alpha
* channel that can be tinted.
*/
- @NonNull
- public Builder setIconContent(@NonNull String imageResourceId) {
+ public @NonNull Builder setIconContent(@NonNull String imageResourceId) {
this.mIconResourceId = imageResourceId;
return this;
}
@@ -163,8 +161,7 @@
* Sets the static content description for the {@link CompactChip}. It is highly recommended
* to provide this for chip containing an icon.
*/
- @NonNull
- public Builder setContentDescription(@NonNull CharSequence contentDescription) {
+ public @NonNull Builder setContentDescription(@NonNull CharSequence contentDescription) {
return setContentDescription(staticString(contentDescription.toString()));
}
@@ -175,18 +172,16 @@
* <p>While this field is statically accessible from 1.0, it's only bindable since version
* 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
- @NonNull
- public Builder setContentDescription(@NonNull StringProp contentDescription) {
+ public @NonNull Builder setContentDescription(@NonNull StringProp contentDescription) {
this.mContentDescription = contentDescription;
return this;
}
/** Constructs and returns {@link CompactChip} with the provided content and look. */
- @NonNull
@Override
@OptIn(markerClass = ProtoLayoutExperimental.class)
- public CompactChip build() {
+ public @NonNull CompactChip build() {
if (mText == null && mIconResourceId == null) {
throw new IllegalArgumentException("At least one of text or icon must be set.");
}
@@ -235,14 +230,12 @@
}
/** Returns click event action associated with this Chip. */
- @NonNull
- public Clickable getClickable() {
+ public @NonNull Clickable getClickable() {
return mElement.getClickable();
}
/** Returns chip color of this Chip. */
- @NonNull
- public ChipColors getChipColors() {
+ public @NonNull ChipColors getChipColors() {
return mElement.getChipColors();
}
@@ -251,8 +244,7 @@
* {@link Builder#setTextContent} or constructor, this method will return an empty String.
* Whether text content exists on this Chip, that can be checked with {@link #hasText()}.
*/
- @NonNull
- public String getText() {
+ public @NonNull String getText() {
return hasText() ? checkNotNull(mElement.getPrimaryLabelContent()) : "";
}
@@ -264,14 +256,12 @@
}
/** Returns icon id from this CompactChip if it has been added. Otherwise, it returns null. */
- @Nullable
- public String getIconContent() {
+ public @Nullable String getIconContent() {
return mElement.getIconContent();
}
/** Returns metadata tag set to this CompactChip. */
- @NonNull
- String getMetadataTag() {
+ @NonNull String getMetadataTag() {
return mElement.getMetadataTag();
}
@@ -280,8 +270,7 @@
* container's content with {@code container.getContents().get(index)}) if that element can be
* converted to CompactChip. Otherwise, it will return null.
*/
- @Nullable
- public static CompactChip fromLayoutElement(@NonNull LayoutElement element) {
+ public static @Nullable CompactChip fromLayoutElement(@NonNull LayoutElement element) {
if (element instanceof CompactChip) {
return (CompactChip) element;
}
@@ -291,22 +280,19 @@
}
/** Returns content description of this CompactChip. */
- @Nullable
- public StringProp getContentDescription() {
+ public @Nullable StringProp getContentDescription() {
return mElement.getContentDescription();
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
@Override
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mElement.toLayoutElementProto();
}
- @Nullable
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mElement.getFingerprint();
}
}
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ProgressIndicatorColors.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ProgressIndicatorColors.java
index 5fc3693..ca8ffec 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ProgressIndicatorColors.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ProgressIndicatorColors.java
@@ -19,9 +19,10 @@
import static androidx.wear.protolayout.ColorBuilders.argb;
import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
import androidx.wear.protolayout.ColorBuilders.ColorProp;
+import org.jspecify.annotations.NonNull;
+
/**
* Represents the indicator and track colors used in {@link CircularProgressIndicator}.
*
@@ -29,8 +30,8 @@
* CircularProgressIndicator}.
*/
public class ProgressIndicatorColors {
- @NonNull private final ColorProp mIndicatorColor;
- @NonNull private final ColorProp mTrackColor;
+ private final @NonNull ColorProp mIndicatorColor;
+ private final @NonNull ColorProp mTrackColor;
/**
* Constructor for {@link ProgressIndicatorColors} object.
@@ -63,20 +64,17 @@
* indicator color and the current Surface color for the track color from the given {@link
* Colors}.
*/
- @NonNull
- public static ProgressIndicatorColors progressIndicatorColors(@NonNull Colors colors) {
+ public static @NonNull ProgressIndicatorColors progressIndicatorColors(@NonNull Colors colors) {
return new ProgressIndicatorColors(colors.getPrimary(), colors.getSurface());
}
/** The indicator color to be used for {@link CircularProgressIndicator}. */
- @NonNull
- public ColorProp getIndicatorColor() {
+ public @NonNull ColorProp getIndicatorColor() {
return mIndicatorColor;
}
/** The background track color to be used for {@link CircularProgressIndicator}. */
- @NonNull
- public ColorProp getTrackColor() {
+ public @NonNull ColorProp getTrackColor() {
return mTrackColor;
}
}
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ProgressIndicatorDefaults.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ProgressIndicatorDefaults.java
index 6bd4d0d..e38c569 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ProgressIndicatorDefaults.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/ProgressIndicatorDefaults.java
@@ -18,26 +18,25 @@
import static androidx.wear.protolayout.DimensionBuilders.dp;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.DimensionBuilders.DpProp;
+import org.jspecify.annotations.NonNull;
+
/** Contains the default values used by {@link CircularProgressIndicator}. */
public class ProgressIndicatorDefaults {
private ProgressIndicatorDefaults() {}
/** The default stroke width for {@link CircularProgressIndicator} */
- @NonNull public static final DpProp DEFAULT_STROKE_WIDTH = dp(8);
+ public static final @NonNull DpProp DEFAULT_STROKE_WIDTH = dp(8);
/** The default padding for {@link CircularProgressIndicator} */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final DpProp DEFAULT_PADDING = dp(6);
+ public static final @NonNull DpProp DEFAULT_PADDING = dp(6);
/** The recommended colors for {@link CircularProgressIndicator}. */
- @NonNull
- public static final ProgressIndicatorColors DEFAULT_COLORS =
+ public static final @NonNull ProgressIndicatorColors DEFAULT_COLORS =
ProgressIndicatorColors.progressIndicatorColors(Colors.DEFAULT);
static final float DEFAULT_GAP_LENGTH = 47.8f;
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Text.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Text.java
index efd8e42..874da04 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Text.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Text.java
@@ -28,8 +28,6 @@
import android.content.Context;
import androidx.annotation.IntRange;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.ColorBuilders.ColorProp;
@@ -46,6 +44,9 @@
import androidx.wear.protolayout.material.Typography.TypographyName;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* ProtoLayout component {@link Text} that represents text object holding any information.
*
@@ -73,27 +74,26 @@
*/
public class Text implements LayoutElement {
- @NonNull private final LayoutElementBuilders.Text mText;
+ private final LayoutElementBuilders.@NonNull Text mText;
- Text(@NonNull LayoutElementBuilders.Text mText) {
+ Text(LayoutElementBuilders.@NonNull Text mText) {
this.mText = mText;
}
/** Builder class for {@link Text}. */
public static final class Builder implements LayoutElement.Builder {
- @NonNull private final Context mContext;
- @NonNull private ColorProp mColor = argb(Colors.DEFAULT.getOnPrimary());
+ private final @NonNull Context mContext;
+ private @NonNull ColorProp mColor = argb(Colors.DEFAULT.getOnPrimary());
@TypographyName private int mTypographyName = TYPOGRAPHY_DISPLAY1;
private boolean mItalic = false;
private boolean mUnderline = false;
private boolean mIsScalable = true;
- @Nullable private Integer mCustomWeight = null;
+ private @Nullable Integer mCustomWeight = null;
- @NonNull
@SuppressWarnings(
"deprecation") // Default value from initial release is TEXT_OVERFLOW_ELLIPSIZE_END
// so we can't change it as it would be a breaking change for developers.
- private final LayoutElementBuilders.Text.Builder mElementBuilder =
+ private final LayoutElementBuilders.Text.@NonNull Builder mElementBuilder =
new LayoutElementBuilders.Text.Builder()
.setMaxLines(1)
.setMultilineAlignment(TEXT_ALIGN_CENTER)
@@ -134,12 +134,11 @@
* Sets the typography for the {@link Text}. If not set, {@link
* Typography#TYPOGRAPHY_DISPLAY1} will be used.
*/
- @NonNull
@SuppressWarnings("MissingGetterMatchingBuilder")
// There is getFontStyle matching getter for this setter as the serialized format of the
// ProtoLayout do not allow for a direct reconstruction of the all arguments, but it has
// FontStyle object of that text.
- public Builder setTypography(@TypographyName int typography) {
+ public @NonNull Builder setTypography(@TypographyName int typography) {
this.mTypographyName = typography;
return this;
}
@@ -151,9 +150,8 @@
// Text size is always set in SP, however, by setting this field, we do calculation to
// interpret it like DP. When getting the text font's size in getters, there is no way to
// know whether that size was scaled or not.
- @NonNull
@SuppressWarnings("MissingGetterMatchingBuilder")
- public Builder setScalable(boolean isScalable) {
+ public @NonNull Builder setScalable(boolean isScalable) {
this.mIsScalable = isScalable;
return this;
}
@@ -162,29 +160,25 @@
* Sets the color for the {@link Text}. If not set, onPrimary color from the {@link
* Colors#DEFAULT} will be used.
*/
- @NonNull
- public Builder setColor(@NonNull ColorProp color) {
+ public @NonNull Builder setColor(@NonNull ColorProp color) {
this.mColor = color;
return this;
}
/** Sets the text to be italic. If not set, false will be used. */
- @NonNull
- public Builder setItalic(boolean italic) {
+ public @NonNull Builder setItalic(boolean italic) {
this.mItalic = italic;
return this;
}
/** Sets the text to be underlined. If not set, false will be used. */
- @NonNull
- public Builder setUnderline(boolean underline) {
+ public @NonNull Builder setUnderline(boolean underline) {
this.mUnderline = underline;
return this;
}
/** Sets the maximum lines of text. If not set, 1 will be used. */
- @NonNull
- public Builder setMaxLines(@IntRange(from = 1) int maxLines) {
+ public @NonNull Builder setMaxLines(@IntRange(from = 1) int maxLines) {
this.mElementBuilder.setMaxLines(maxLines);
return this;
}
@@ -195,15 +189,13 @@
* container should be used. If not set, {@link TextAlignment#TEXT_ALIGN_CENTER} will be
* used.
*/
- @NonNull
- public Builder setMultilineAlignment(@TextAlignment int multilineAlignment) {
+ public @NonNull Builder setMultilineAlignment(@TextAlignment int multilineAlignment) {
this.mElementBuilder.setMultilineAlignment(multilineAlignment);
return this;
}
/** Sets the modifiers of text. */
- @NonNull
- public Builder setModifiers(@NonNull Modifiers modifiers) {
+ public @NonNull Builder setModifiers(@NonNull Modifiers modifiers) {
this.mElementBuilder.setModifiers(modifiers);
return this;
}
@@ -212,8 +204,7 @@
* Sets the overflow for text. If not set, {@link TextAlignment#TEXT_OVERFLOW_ELLIPSIZE_END}
* will be used.
*/
- @NonNull
- public Builder setOverflow(@TextOverflow int overflow) {
+ public @NonNull Builder setOverflow(@TextOverflow int overflow) {
this.mElementBuilder.setOverflow(overflow);
return this;
}
@@ -222,16 +213,14 @@
* Sets the weight of the font. If not set, default weight for the chosen Typography will be
* used.
*/
- @NonNull
- public Builder setWeight(@FontWeight int weight) {
+ public @NonNull Builder setWeight(@FontWeight int weight) {
this.mCustomWeight = weight;
return this;
}
/** Constructs and returns {@link Text} with the provided content and look. */
- @NonNull
@Override
- public Text build() {
+ public @NonNull Text build() {
FontStyle.Builder fontStyleBuilder =
getFontStyleBuilder(mTypographyName, mContext, mIsScalable)
.setColor(mColor)
@@ -248,20 +237,17 @@
}
/** Returns the text of this Text element. */
- @NonNull
- public StringProp getText() {
+ public @NonNull StringProp getText() {
return checkNotNull(mText.getText());
}
/** Returns the color of this Text element. */
- @NonNull
- public ColorProp getColor() {
+ public @NonNull ColorProp getColor() {
return checkNotNull(checkNotNull(mText.getFontStyle()).getColor());
}
/** Returns the font style of this Text element. */
- @NonNull
- public FontStyle getFontStyle() {
+ public @NonNull FontStyle getFontStyle() {
return checkNotNull(mText.getFontStyle());
}
@@ -282,8 +268,7 @@
}
/** Returns the modifiers of this Text element. */
- @NonNull
- public Modifiers getModifiers() {
+ public @NonNull Modifiers getModifiers() {
return checkNotNull(mText.getModifiers());
}
@@ -314,8 +299,7 @@
* container's content with {@code container.getContents().get(index)}) if that element can be
* converted to Material Text. Otherwise, it will return null.
*/
- @Nullable
- public static Text fromLayoutElement(@NonNull LayoutElement element) {
+ public static @Nullable Text fromLayoutElement(@NonNull LayoutElement element) {
if (element instanceof Text) {
return (Text) element;
}
@@ -328,17 +312,15 @@
return new Text(textElement);
}
- @NonNull
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mText.toLayoutElementProto();
}
- @Nullable
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mText.getFingerprint();
}
}
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/TitleChip.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/TitleChip.java
index c6fc2be..9209b89 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/TitleChip.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/TitleChip.java
@@ -29,8 +29,6 @@
import android.content.Context;
import androidx.annotation.Dimension;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters;
@@ -42,6 +40,9 @@
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* ProtoLayout component {@link TitleChip} that represents clickable object with the text.
*
@@ -75,7 +76,7 @@
* TitleChip is used inside of {@link androidx.wear.protolayout.material.layouts.PrimaryLayout}.
*/
public class TitleChip implements LayoutElement {
- @NonNull private final Chip mElement;
+ private final @NonNull Chip mElement;
TitleChip(@NonNull Chip element) {
this.mElement = element;
@@ -83,18 +84,18 @@
/** Builder class for {@link TitleChip}. */
public static final class Builder implements LayoutElement.Builder {
- @NonNull private final Context mContext;
- @NonNull private final String mText;
- @NonNull private final Clickable mClickable;
- @NonNull private final DeviceParameters mDeviceParameters;
- @NonNull private ChipColors mChipColors = TITLE_PRIMARY_COLORS;
+ private final @NonNull Context mContext;
+ private final @NonNull String mText;
+ private final @NonNull Clickable mClickable;
+ private final @NonNull DeviceParameters mDeviceParameters;
+ private @NonNull ChipColors mChipColors = TITLE_PRIMARY_COLORS;
@HorizontalAlignment private int mHorizontalAlign = HORIZONTAL_ALIGN_UNDEFINED;
- @Nullable private StringProp mContentDescription = null;
+ private @Nullable StringProp mContentDescription = null;
// Indicates that the width isn't set, so it will be automatically set by Chip.Builder
// constructor.
- @Nullable private ContainerDimension mWidth = null;
- @Nullable private String mIconResourceId = null;
+ private @Nullable ContainerDimension mWidth = null;
+ private @Nullable String mIconResourceId = null;
/**
* Creates a builder for the {@link TitleChip} with associated action and the given text
@@ -123,15 +124,14 @@
* ChipColors#getContentColor()} for the text. If not set, {@link
* ChipDefaults#TITLE_PRIMARY_COLORS} will be used.
*/
- @NonNull
- public Builder setChipColors(@NonNull ChipColors chipColors) {
+ public @NonNull Builder setChipColors(@NonNull ChipColors chipColors) {
mChipColors = chipColors;
return this;
}
/** Sets the horizontal alignment in the chip. If not set, content will be centered. */
- @NonNull
- public Builder setHorizontalAlignment(@HorizontalAlignment int horizontalAlignment) {
+ public @NonNull Builder setHorizontalAlignment(
+ @HorizontalAlignment int horizontalAlignment) {
mHorizontalAlign = horizontalAlignment;
return this;
}
@@ -140,8 +140,7 @@
* Sets the width of {@link TitleChip}. If not set, default value will be set to fill the
* screen.
*/
- @NonNull
- public Builder setWidth(@NonNull ContainerDimension width) {
+ public @NonNull Builder setWidth(@NonNull ContainerDimension width) {
mWidth = width;
return this;
}
@@ -150,8 +149,7 @@
* Sets the width of {@link TitleChip}. If not set, default value will be set to fill the
* screen.
*/
- @NonNull
- public Builder setWidth(@Dimension(unit = DP) float width) {
+ public @NonNull Builder setWidth(@Dimension(unit = DP) float width) {
mWidth = dp(width);
return this;
}
@@ -161,8 +159,7 @@
* content color from {@link ChipColors}. This icon should be image with chosen alpha
* channel that can be tinted.
*/
- @NonNull
- public Builder setIconContent(@NonNull String imageResourceId) {
+ public @NonNull Builder setIconContent(@NonNull String imageResourceId) {
this.mIconResourceId = imageResourceId;
return this;
}
@@ -171,8 +168,7 @@
* Sets the static content description for the {@link TitleChip}. It is highly recommended
* to provide this for chip containing an icon.
*/
- @NonNull
- public Builder setContentDescription(@NonNull CharSequence contentDescription) {
+ public @NonNull Builder setContentDescription(@NonNull CharSequence contentDescription) {
return setContentDescription(staticString(contentDescription.toString()));
}
@@ -183,16 +179,14 @@
* <p>While this field is statically accessible from 1.0, it's only bindable since version
* 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
- @NonNull
- public Builder setContentDescription(@NonNull StringProp contentDescription) {
+ public @NonNull Builder setContentDescription(@NonNull StringProp contentDescription) {
this.mContentDescription = contentDescription;
return this;
}
/** Constructs and returns {@link TitleChip} with the provided content and look. */
- @NonNull
@Override
- public TitleChip build() {
+ public @NonNull TitleChip build() {
Chip.Builder chipBuilder =
new Chip.Builder(mContext, mClickable, mDeviceParameters)
.setChipColors(mChipColors)
@@ -224,26 +218,22 @@
}
/** Returns width of this Chip. */
- @NonNull
- public ContainerDimension getWidth() {
+ public @NonNull ContainerDimension getWidth() {
return mElement.getWidth();
}
/** Returns click event action associated with this Chip. */
- @NonNull
- public Clickable getClickable() {
+ public @NonNull Clickable getClickable() {
return mElement.getClickable();
}
/** Returns chip color of this Chip. */
- @NonNull
- public ChipColors getChipColors() {
+ public @NonNull ChipColors getChipColors() {
return mElement.getChipColors();
}
/** Returns text content of this Chip. */
- @NonNull
- public String getText() {
+ public @NonNull String getText() {
return checkNotNull(mElement.getPrimaryLabelContent());
}
@@ -254,14 +244,12 @@
}
/** Returns icon id from this TitleChip if it has been added. Otherwise, it returns null. */
- @Nullable
- public String getIconContent() {
+ public @Nullable String getIconContent() {
return mElement.getIconContent();
}
/** Returns metadata tag set to this TitleChip. */
- @NonNull
- String getMetadataTag() {
+ @NonNull String getMetadataTag() {
return mElement.getMetadataTag();
}
@@ -270,8 +258,7 @@
* content with {@code container.getContents().get(index)}) if that element can be converted to
* TitleChip. Otherwise, it will return null.
*/
- @Nullable
- public static TitleChip fromLayoutElement(@NonNull LayoutElement element) {
+ public static @Nullable TitleChip fromLayoutElement(@NonNull LayoutElement element) {
if (element instanceof TitleChip) {
return (TitleChip) element;
}
@@ -281,22 +268,19 @@
}
/** Returns content description of this TitleChip. */
- @Nullable
- public StringProp getContentDescription() {
+ public @Nullable StringProp getContentDescription() {
return mElement.getContentDescription();
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
@Override
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mElement.toLayoutElementProto();
}
- @Nullable
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mElement.getFingerprint();
}
}
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Typography.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Typography.java
index da9219f..d6a9677a 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Typography.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/Typography.java
@@ -34,7 +34,6 @@
import androidx.annotation.Dimension;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.DimensionBuilders;
@@ -45,6 +44,8 @@
import androidx.wear.protolayout.materialcore.fontscaling.FontScaleConverter;
import androidx.wear.protolayout.materialcore.fontscaling.FontScaleConverterFactory;
+import org.jspecify.annotations.NonNull;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.HashMap;
@@ -107,8 +108,8 @@
@interface TypographyName {}
/** Mapping for line height for different typography. */
- @NonNull
- private static final Map<Integer, Float> TYPOGRAPHY_TO_LINE_HEIGHT_SP = new HashMap<>();
+ private static final @NonNull Map<Integer, Float> TYPOGRAPHY_TO_LINE_HEIGHT_SP =
+ new HashMap<>();
static {
TYPOGRAPHY_TO_LINE_HEIGHT_SP.put(TYPOGRAPHY_DISPLAY1, 46f);
@@ -131,8 +132,7 @@
* Returns the {@link FontStyle.Builder} for the given FontStyle code with the recommended size,
* weight and letter spacing. Font will be scalable.
*/
- @NonNull
- static FontStyle.Builder getFontStyleBuilder(
+ static FontStyle.@NonNull Builder getFontStyleBuilder(
@TypographyName int fontStyleCode, @NonNull Context context) {
return getFontStyleBuilder(fontStyleCode, context, true);
}
@@ -141,8 +141,7 @@
* Returns the {@link FontStyle.Builder} for the given Typography code with the recommended
* size, weight and letter spacing, with the option to make this font not scalable.
*/
- @NonNull
- static FontStyle.Builder getFontStyleBuilder(
+ static FontStyle.@NonNull Builder getFontStyleBuilder(
@TypographyName int typographyCode, @NonNull Context context, boolean isScalable) {
switch (typographyCode) {
case TYPOGRAPHY_BODY1:
@@ -180,8 +179,7 @@
* Returns the recommended line height for the given Typography to be added to the Text
* component.
*/
- @NonNull
- static SpProp getLineHeightForTypography(@TypographyName int typography) {
+ static @NonNull SpProp getLineHeightForTypography(@TypographyName int typography) {
if (!TYPOGRAPHY_TO_LINE_HEIGHT_SP.containsKey(typography)) {
throw new IllegalArgumentException("Typography " + typography + " doesn't exist.");
}
@@ -232,85 +230,79 @@
}
/** Font style for large display text. */
- @NonNull
- private static FontStyle.Builder display1(boolean isScalable, @NonNull Context context) {
+ private static FontStyle.@NonNull Builder display1(boolean isScalable,
+ @NonNull Context context) {
return createFontStyleBuilder(
40, FONT_WEIGHT_MEDIUM, FONT_VARIANT_TITLE, 0.01f, isScalable, context);
}
/** Font style for medium display text. */
- @NonNull
- private static FontStyle.Builder display2(boolean isScalable, @NonNull Context context) {
+ private static FontStyle.@NonNull Builder display2(boolean isScalable,
+ @NonNull Context context) {
return createFontStyleBuilder(
34, FONT_WEIGHT_MEDIUM, FONT_VARIANT_TITLE, 0.03f, isScalable, context);
}
/** Font style for small display text. */
- @NonNull
- private static FontStyle.Builder display3(boolean isScalable, @NonNull Context context) {
+ private static FontStyle.@NonNull Builder display3(boolean isScalable,
+ @NonNull Context context) {
return createFontStyleBuilder(
30, FONT_WEIGHT_MEDIUM, FONT_VARIANT_TITLE, 0.03f, isScalable, context);
}
/** Font style for large title text. */
- @NonNull
- private static FontStyle.Builder title1(boolean isScalable, @NonNull Context context) {
+ private static FontStyle.@NonNull Builder title1(boolean isScalable, @NonNull Context context) {
return createFontStyleBuilder(
24, FONT_WEIGHT_MEDIUM, FONT_VARIANT_TITLE, 0.008f, isScalable, context);
}
/** Font style for medium title text. */
- @NonNull
- private static FontStyle.Builder title2(boolean isScalable, @NonNull Context context) {
+ private static FontStyle.@NonNull Builder title2(boolean isScalable, @NonNull Context context) {
return createFontStyleBuilder(
20, FONT_WEIGHT_MEDIUM, FONT_VARIANT_TITLE, 0.01f, isScalable, context);
}
/** Font style for small title text. */
- @NonNull
- private static FontStyle.Builder title3(boolean isScalable, @NonNull Context context) {
+ private static FontStyle.@NonNull Builder title3(boolean isScalable, @NonNull Context context) {
return createFontStyleBuilder(
16, FONT_WEIGHT_MEDIUM, FONT_VARIANT_TITLE, 0.01f, isScalable, context);
}
/** Font style for normal body text. */
- @NonNull
- private static FontStyle.Builder body1(boolean isScalable, @NonNull Context context) {
+ private static FontStyle.@NonNull Builder body1(boolean isScalable, @NonNull Context context) {
return createFontStyleBuilder(
16, FONT_WEIGHT_NORMAL, FONT_VARIANT_BODY, 0.01f, isScalable, context);
}
/** Font style for small body text. */
- @NonNull
- private static FontStyle.Builder body2(boolean isScalable, @NonNull Context context) {
+ private static FontStyle.@NonNull Builder body2(boolean isScalable, @NonNull Context context) {
return createFontStyleBuilder(
14, FONT_WEIGHT_NORMAL, FONT_VARIANT_BODY, 0.014f, isScalable, context);
}
/** Font style for bold button text. */
- @NonNull
- private static FontStyle.Builder button(boolean isScalable, @NonNull Context context) {
+ private static FontStyle.@NonNull Builder button(boolean isScalable, @NonNull Context context) {
return createFontStyleBuilder(
15, FONT_WEIGHT_BOLD, FONT_VARIANT_BODY, 0.03f, isScalable, context);
}
/** Font style for large caption text. */
- @NonNull
- private static FontStyle.Builder caption1(boolean isScalable, @NonNull Context context) {
+ private static FontStyle.@NonNull Builder caption1(boolean isScalable,
+ @NonNull Context context) {
return createFontStyleBuilder(
14, FONT_WEIGHT_MEDIUM, FONT_VARIANT_BODY, 0.01f, isScalable, context);
}
/** Font style for medium caption text. */
- @NonNull
- private static FontStyle.Builder caption2(boolean isScalable, @NonNull Context context) {
+ private static FontStyle.@NonNull Builder caption2(boolean isScalable,
+ @NonNull Context context) {
return createFontStyleBuilder(
12, FONT_WEIGHT_MEDIUM, FONT_VARIANT_BODY, 0.01f, isScalable, context);
}
/** Font style for small caption text. */
- @NonNull
- private static FontStyle.Builder caption3(boolean isScalable, @NonNull Context context) {
+ private static FontStyle.@NonNull Builder caption3(boolean isScalable,
+ @NonNull Context context) {
return createFontStyleBuilder(
10, FONT_WEIGHT_MEDIUM, FONT_VARIANT_BODY, 0.01f, isScalable, context);
}
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/EdgeContentLayout.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/EdgeContentLayout.java
index 228e88a..75f9829 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/EdgeContentLayout.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/EdgeContentLayout.java
@@ -42,8 +42,6 @@
import androidx.annotation.Dimension;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters;
@@ -61,6 +59,9 @@
import androidx.wear.protolayout.material.CircularProgressIndicator;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
@@ -160,7 +161,7 @@
})
@interface ContentBits {}
- @NonNull private final Box mImpl;
+ private final @NonNull Box mImpl;
EdgeContentLayout(@NonNull Box layoutElement) {
this.mImpl = layoutElement;
@@ -168,19 +169,18 @@
/** Builder class for {@link EdgeContentLayout}. */
public static final class Builder implements LayoutElement.Builder {
- @NonNull private final DeviceParameters mDeviceParameters;
- @Nullable private LayoutElement mEdgeContent = null;
- @Nullable private LayoutElement mPrimaryLabelText = null;
- @Nullable private LayoutElement mSecondaryLabelText = null;
- @Nullable private LayoutElement mContent = null;
+ private final @NonNull DeviceParameters mDeviceParameters;
+ private @Nullable LayoutElement mEdgeContent = null;
+ private @Nullable LayoutElement mPrimaryLabelText = null;
+ private @Nullable LayoutElement mSecondaryLabelText = null;
+ private @Nullable LayoutElement mContent = null;
private byte mMetadataContentByte = 0;
// Default for non responsive behaviour is false (for backwards compatibility) and for
// responsive behaviour, only true is used.
- @Nullable private Boolean mIsEdgeContentBehind = null;
+ private @Nullable Boolean mIsEdgeContentBehind = null;
private boolean mIsResponsiveInsetEnabled = false;
- @Nullable private Float mEdgeContentThickness = null;
- @NonNull
- private DpProp mVerticalSpacerHeight =
+ private @Nullable Float mEdgeContentThickness = null;
+ private @NonNull DpProp mVerticalSpacerHeight =
DEFAULT_VERTICAL_SPACER_HEIGHT;
/**
@@ -212,8 +212,7 @@
* @throws IllegalStateException if this and
* {@link #setEdgeContentBehindAllOtherContent(boolean)} are used together.
*/
- @NonNull
- public Builder setResponsiveContentInsetEnabled(boolean enabled) {
+ public @NonNull Builder setResponsiveContentInsetEnabled(boolean enabled) {
if (mIsEdgeContentBehind != null && !mIsEdgeContentBehind) {
// We don't allow mixing above content with responsiveness, as content should always
// be behind.
@@ -245,8 +244,7 @@
* <p>Note that, calling this method when responsiveness is not set with
* {@link #setResponsiveContentInsetEnabled}, will be ignored.
*/
- @NonNull
- public Builder setEdgeContentThickness(@Dimension(unit = DP) float thickness) {
+ public @NonNull Builder setEdgeContentThickness(@Dimension(unit = DP) float thickness) {
this.mEdgeContentThickness = thickness;
return this;
}
@@ -257,8 +255,7 @@
* <p>If this content is something other that {@link CircularProgressIndicator}, please add
* its thickness with {@link #setEdgeContentThickness} for best results.
*/
- @NonNull
- public Builder setEdgeContent(@NonNull LayoutElement edgeContent) {
+ public @NonNull Builder setEdgeContent(@NonNull LayoutElement edgeContent) {
this.mEdgeContent = edgeContent;
mMetadataContentByte = (byte) (mMetadataContentByte | EDGE_CONTENT_PRESENT);
return this;
@@ -275,8 +272,8 @@
* - If responsive behaviour is not set or called, label will be above the additional
* content, centered in the remaining space.
*/
- @NonNull
- public Builder setPrimaryLabelTextContent(@NonNull LayoutElement primaryLabelText) {
+ public @NonNull Builder setPrimaryLabelTextContent(
+ @NonNull LayoutElement primaryLabelText) {
this.mPrimaryLabelText = primaryLabelText;
mMetadataContentByte = (byte) (mMetadataContentByte | PRIMARY_LABEL_PRESENT);
return this;
@@ -289,16 +286,15 @@
* <p>Note that when {@link #setResponsiveContentInsetEnabled} is set to {@code true}, the
* label will also have an inset to prevent it from going off the screen.
*/
- @NonNull
- public Builder setSecondaryLabelTextContent(@NonNull LayoutElement secondaryLabelText) {
+ public @NonNull Builder setSecondaryLabelTextContent(
+ @NonNull LayoutElement secondaryLabelText) {
this.mSecondaryLabelText = secondaryLabelText;
mMetadataContentByte = (byte) (mMetadataContentByte | SECONDARY_LABEL_PRESENT);
return this;
}
/** Sets the additional content to this layout, inside of the screen. */
- @NonNull
- public Builder setContent(@NonNull LayoutElement content) {
+ public @NonNull Builder setContent(@NonNull LayoutElement content) {
this.mContent = content;
mMetadataContentByte = (byte) (mMetadataContentByte | CONTENT_PRESENT);
return this;
@@ -313,8 +309,7 @@
* <p>Note that, this method should be used together with
* {@link #setResponsiveContentInsetEnabled}, otherwise it will be ignored.
*/
- @NonNull
- public Builder setContentAndSecondaryLabelSpacing(@NonNull DpProp height) {
+ public @NonNull Builder setContentAndSecondaryLabelSpacing(@NonNull DpProp height) {
this.mVerticalSpacerHeight = height;
return this;
}
@@ -331,8 +326,7 @@
* @throws IllegalStateException if this and {@link #setResponsiveContentInsetEnabled} are
* used together.
*/
- @NonNull
- public Builder setEdgeContentBehindAllOtherContent(boolean isBehind) {
+ public @NonNull Builder setEdgeContentBehindAllOtherContent(boolean isBehind) {
if (mIsResponsiveInsetEnabled && !isBehind) {
// We don't allow mixing this method with responsiveness.
throw new IllegalStateException(
@@ -347,9 +341,8 @@
}
/** Constructs and returns {@link EdgeContentLayout} with the provided content and look. */
- @NonNull
@Override
- public EdgeContentLayout build() {
+ public @NonNull EdgeContentLayout build() {
if (mIsResponsiveInsetEnabled
&& mIsEdgeContentBehind != null
&& !mIsEdgeContentBehind) {
@@ -365,8 +358,7 @@
return mIsResponsiveInsetEnabled ? responsiveLayoutBuild() : legacyLayoutBuild();
}
- @NonNull
- private EdgeContentLayout responsiveLayoutBuild() {
+ private @NonNull EdgeContentLayout responsiveLayoutBuild() {
// Calculate what is the inset box max size, i.e., the size that all content can occupy
// without the edge content.
// Use provided thickness if set. Otherwise, see if we can get it from
@@ -493,8 +485,7 @@
return 2 * (EDGE_CONTENT_LAYOUT_RESPONSIVE_OUTER_MARGIN_DP + edgeContentThickness);
}
- @NonNull
- private EdgeContentLayout legacyLayoutBuild() {
+ private @NonNull EdgeContentLayout legacyLayoutBuild() {
if (mIsEdgeContentBehind == null) {
mIsEdgeContentBehind = false;
}
@@ -604,14 +595,12 @@
}
/** Returns metadata tag set to this EdgeContentLayout. */
- @NonNull
- byte[] getMetadataTag() {
+ byte @NonNull [] getMetadataTag() {
return getMetadataTagBytes(checkNotNull(checkNotNull(mImpl.getModifiers()).getMetadata()));
}
/** Returns the inner content from this layout. */
- @Nullable
- public LayoutElement getContent() {
+ public @Nullable LayoutElement getContent() {
if (!areElementsPresent(CONTENT_PRESENT)) {
return null;
}
@@ -635,8 +624,7 @@
}
/** Get the primary label content from this layout. */
- @Nullable
- public LayoutElement getPrimaryLabelTextContent() {
+ public @Nullable LayoutElement getPrimaryLabelTextContent() {
if (!areElementsPresent(PRIMARY_LABEL_PRESENT)) {
return null;
}
@@ -648,8 +636,7 @@
}
/** Get the secondary label content from this layout. */
- @Nullable
- public LayoutElement getSecondaryLabelTextContent() {
+ public @Nullable LayoutElement getSecondaryLabelTextContent() {
if (!areElementsPresent(SECONDARY_LABEL_PRESENT)) {
return null;
}
@@ -687,8 +674,7 @@
}
/** Returns the edge content from this layout. */
- @Nullable
- public LayoutElement getEdgeContent() {
+ public @Nullable LayoutElement getEdgeContent() {
return areElementsPresent(EDGE_CONTENT_PRESENT)
? mImpl.getContents().get(getEdgeContentPosition()) : null;
}
@@ -744,8 +730,7 @@
* container's content with {@code container.getContents().get(index)}) if that element can be
* converted to EdgeContentLayout. Otherwise, it will return null.
*/
- @Nullable
- public static EdgeContentLayout fromLayoutElement(@NonNull LayoutElement element) {
+ public static @Nullable EdgeContentLayout fromLayoutElement(@NonNull LayoutElement element) {
if (element instanceof EdgeContentLayout) {
return (EdgeContentLayout) element;
}
@@ -760,17 +745,15 @@
return new EdgeContentLayout(boxElement);
}
- @NonNull
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mImpl.toLayoutElementProto();
}
- @Nullable
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mImpl.getFingerprint();
}
}
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/LayoutDefaults.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/LayoutDefaults.java
index af7f33d..0aa7f43 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/LayoutDefaults.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/LayoutDefaults.java
@@ -20,7 +20,6 @@
import static androidx.wear.protolayout.DimensionBuilders.dp;
import androidx.annotation.Dimension;
-import androidx.annotation.NonNull;
import androidx.wear.protolayout.DimensionBuilders.DpProp;
import androidx.wear.protolayout.LayoutElementBuilders.Box;
import androidx.wear.protolayout.LayoutElementBuilders.LayoutElement;
@@ -29,6 +28,7 @@
import androidx.wear.protolayout.material.ButtonDefaults;
import androidx.wear.protolayout.material.ProgressIndicatorDefaults;
+import org.jspecify.annotations.NonNull;
/** Contains the default values used by layout templates for ProtoLayout. */
public class LayoutDefaults {
@@ -60,7 +60,7 @@
* The default spacer above primary label in {@link PrimaryLayout} to make space for Tile icon
* on round devices.
*/
- @NonNull static final DpProp PRIMARY_LAYOUT_PRIMARY_LABEL_SPACER_HEIGHT_ROUND_DP = dp(0);
+ static final @NonNull DpProp PRIMARY_LAYOUT_PRIMARY_LABEL_SPACER_HEIGHT_ROUND_DP = dp(0);
/**
* The default percentage for the horizontal padding for primary or secondary label in the
@@ -72,7 +72,7 @@
* The default spacer above primary label in {@link PrimaryLayout} to make space for Tile icon
* on square devices.
*/
- @NonNull static final DpProp PRIMARY_LAYOUT_PRIMARY_LABEL_SPACER_HEIGHT_SQUARE_DP = dp(4);
+ static final @NonNull DpProp PRIMARY_LAYOUT_PRIMARY_LABEL_SPACER_HEIGHT_SQUARE_DP = dp(4);
/**
* The default percentage for the horizontal margin for primary chip in the {@link
@@ -131,7 +131,7 @@
* The default spacing below primary label in the {@link EdgeContentLayout} to ensure that inner
* content is not too high up and not near the primary label.
*/
- @NonNull static final DpProp EDGE_CONTENT_LAYOUT_RESPONSIVE_PRIMARY_LABEL_SPACING_DP = dp(8);
+ static final @NonNull DpProp EDGE_CONTENT_LAYOUT_RESPONSIVE_PRIMARY_LABEL_SPACING_DP = dp(8);
/**
* The recommended padding that should be above the main content (text) in the {@link
@@ -146,7 +146,7 @@
public static final float EDGE_CONTENT_LAYOUT_PADDING_BELOW_MAIN_CONTENT_DP = 8;
/** The default spacer width for slots in a {@link MultiSlotLayout}. */
- @NonNull public static final DpProp MULTI_SLOT_LAYOUT_HORIZONTAL_SPACER_WIDTH = dp(8);
+ public static final @NonNull DpProp MULTI_SLOT_LAYOUT_HORIZONTAL_SPACER_WIDTH = dp(8);
/**
* The default spacer height that should be between main content and secondary label if set in
@@ -159,7 +159,7 @@
* {@link EdgeContentLayout.Builder#setContentAndSecondaryLabelSpacing} or
* {@link PrimaryLayout.Builder#setVerticalSpacerHeight}.
*/
- @NonNull public static final DpProp DEFAULT_VERTICAL_SPACER_HEIGHT = dp(8);
+ public static final @NonNull DpProp DEFAULT_VERTICAL_SPACER_HEIGHT = dp(8);
/**
* The default spacer height that should be between main content and secondary label if set in
@@ -171,7 +171,7 @@
* {@link EdgeContentLayout.Builder#setContentAndSecondaryLabelSpacing} or
* {@link PrimaryLayout.Builder#setVerticalSpacerHeight}.
*/
- @NonNull public static final DpProp
+ public static final @NonNull DpProp
DEFAULT_LARGE_VERTICAL_SPACER_HEIGHT = dp(12);
@@ -194,37 +194,37 @@
* The default size of button in case when there are 3 or more buttons in the {@link
* MultiButtonLayout}.
*/
- @NonNull public static final DpProp BUTTON_SIZE_FOR_3_PLUS_BUTTONS =
+ public static final @NonNull DpProp BUTTON_SIZE_FOR_3_PLUS_BUTTONS =
ButtonDefaults.DEFAULT_SIZE;
/**
* The default size of button in case when there are 2 buttons in the {@link
* MultiButtonLayout}.
*/
- @NonNull public static final DpProp BUTTON_SIZE_FOR_2_BUTTONS = ButtonDefaults.LARGE_SIZE;
+ public static final @NonNull DpProp BUTTON_SIZE_FOR_2_BUTTONS = ButtonDefaults.LARGE_SIZE;
/**
* The default size of button in case when there is 1 button in the {@link
* MultiButtonLayout}.
*/
- @NonNull public static final DpProp BUTTON_SIZE_FOR_1_BUTTON =
+ public static final @NonNull DpProp BUTTON_SIZE_FOR_1_BUTTON =
ButtonDefaults.EXTRA_LARGE_SIZE;
/**
* The default width for vertical spacer between buttons in the {@link MultiButtonLayout}.
*/
- @NonNull static final DpProp SPACER_WIDTH = dp(6);
+ static final @NonNull DpProp SPACER_WIDTH = dp(6);
/**
* The default height for horizontal spacer between buttons in the {@link
* MultiButtonLayout}.
*/
- @NonNull static final DpProp SPACER_HEIGHT = dp(4);
+ static final @NonNull DpProp SPACER_HEIGHT = dp(4);
}
/** Wraps the given element into a {@link Box} and applies given horizontal padding. */
- @NonNull
- static Box insetElementWithPadding(@NonNull LayoutElement label, float horizontalLabelPadding) {
+ static @NonNull Box insetElementWithPadding(@NonNull LayoutElement label,
+ float horizontalLabelPadding) {
return new Box.Builder()
.addContent(label)
.setModifiers(
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/MultiButtonLayout.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/MultiButtonLayout.java
index 87ad3f6..4d5f9c2 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/MultiButtonLayout.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/MultiButtonLayout.java
@@ -29,8 +29,6 @@
import static androidx.wear.protolayout.materialcore.Helper.getTagBytes;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.DimensionBuilders.DpProp;
@@ -45,6 +43,9 @@
import androidx.wear.protolayout.material.Button;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
@@ -93,7 +94,7 @@
@IntDef({FIVE_BUTTON_DISTRIBUTION_TOP_HEAVY, FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY})
public @interface ButtonDistribution {}
- @NonNull private final Box mElement;
+ private final @NonNull Box mElement;
MultiButtonLayout(@NonNull Box mElement) {
this.mElement = mElement;
@@ -101,7 +102,7 @@
/** Builder class for {@link MultiButtonLayout}. */
public static final class Builder implements LayoutElement.Builder {
- @NonNull private final List<LayoutElement> mButtonsContent = new ArrayList<>();
+ private final @NonNull List<LayoutElement> mButtonsContent = new ArrayList<>();
@ButtonDistribution private int mFiveButtonDistribution =
FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY;
@@ -117,11 +118,10 @@
* optimized for it. Any button added after {@link
* LayoutDefaults.MultiButtonLayoutDefaults#MAX_BUTTONS} is reached will be discarded.
*/
- @NonNull
@SuppressWarnings("MissingGetterMatchingBuilder")
// There is no direct matching getter for this setter, but there is a getter that gets all
// added buttons.
- public Builder addButtonContent(@NonNull LayoutElement buttonContent) {
+ public @NonNull Builder addButtonContent(@NonNull LayoutElement buttonContent) {
mButtonsContent.add(buttonContent);
return this;
}
@@ -131,8 +131,8 @@
* there is 5 buttons in the layout to determine whether the 3 buttons row is at the top or
* bottom.
*/
- @NonNull
- public Builder setFiveButtonDistribution(@ButtonDistribution int fiveButtonDistribution) {
+ public @NonNull Builder setFiveButtonDistribution(
+ @ButtonDistribution int fiveButtonDistribution) {
this.mFiveButtonDistribution = fiveButtonDistribution;
return this;
}
@@ -143,9 +143,8 @@
* @throws IllegalArgumentException if no buttons are added or the number of buttons added
* is larger than {@link LayoutDefaults.MultiButtonLayoutDefaults#MAX_BUTTONS}.
*/
- @NonNull
@Override
- public MultiButtonLayout build() {
+ public @NonNull MultiButtonLayout build() {
int buttonNum = mButtonsContent.size();
if (buttonNum > MAX_BUTTONS) {
throw new IllegalArgumentException(
@@ -170,8 +169,7 @@
return new MultiButtonLayout(elementBuilder.build());
}
- @NonNull
- private LayoutElement buildButtons(int buttonNum) {
+ private @NonNull LayoutElement buildButtons(int buttonNum) {
switch (buttonNum) {
case 1:
return wrapButton(mButtonsContent.get(0), BUTTON_SIZE_FOR_1_BUTTON);
@@ -262,8 +260,7 @@
}
}
- @NonNull
- private Row build3ButtonRow(
+ private @NonNull Row build3ButtonRow(
@NonNull LayoutElement button1,
@NonNull LayoutElement button2,
@NonNull LayoutElement button3) {
@@ -278,8 +275,7 @@
.build();
}
- @NonNull
- private Row build2ButtonRow(
+ private @NonNull Row build2ButtonRow(
@NonNull LayoutElement button1,
@NonNull LayoutElement button2,
@NonNull DpProp size) {
@@ -292,25 +288,21 @@
.build();
}
- @NonNull
- private Spacer buildHorizontalSpacer() {
+ private @NonNull Spacer buildHorizontalSpacer() {
return new Spacer.Builder().setWidth(SPACER_WIDTH).build();
}
- @NonNull
- private Spacer buildVerticalSpacer() {
+ private @NonNull Spacer buildVerticalSpacer() {
return new Spacer.Builder().setHeight(SPACER_HEIGHT).build();
}
- @NonNull
- private Box wrapButton(@NonNull LayoutElement button, @NonNull DpProp size) {
+ private @NonNull Box wrapButton(@NonNull LayoutElement button, @NonNull DpProp size) {
return new Box.Builder().setWidth(size).setHeight(size).addContent(button).build();
}
}
/** Gets the content from this layout, containing all buttons that were added. */
- @NonNull
- public List<LayoutElement> getButtonContents() {
+ public @NonNull List<LayoutElement> getButtonContents() {
List<LayoutElement> buttons = new ArrayList<>();
List<LayoutElement> contents = mElement.getContents();
if (contents.isEmpty()) {
@@ -333,8 +325,7 @@
}
/** Returns metadata tag set to this MultiButtonLayouts. */
- @NonNull
- String getMetadataTag() {
+ @NonNull String getMetadataTag() {
return getMetadataTagName(
checkNotNull(checkNotNull(mElement.getModifiers()).getMetadata()));
}
@@ -376,8 +367,7 @@
* container's content with {@code container.getContents().get(index)}) if that element can be
* converted to MultiButtonLayout. Otherwise, it will return null.
*/
- @Nullable
- public static MultiButtonLayout fromLayoutElement(@NonNull LayoutElement element) {
+ public static @Nullable MultiButtonLayout fromLayoutElement(@NonNull LayoutElement element) {
if (element instanceof MultiButtonLayout) {
return (MultiButtonLayout) element;
}
@@ -392,17 +382,15 @@
return new MultiButtonLayout(boxElement);
}
- @NonNull
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mElement.toLayoutElementProto();
}
- @Nullable
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mElement.getFingerprint();
}
}
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/MultiSlotLayout.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/MultiSlotLayout.java
index de735fb..8e863e2 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/MultiSlotLayout.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/MultiSlotLayout.java
@@ -28,8 +28,6 @@
import android.annotation.SuppressLint;
import androidx.annotation.Dimension;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.DimensionBuilders.DpProp;
@@ -44,6 +42,9 @@
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.List;
@@ -80,7 +81,7 @@
/** Tool tag for Metadata in Modifiers, so we know that Row is actually a MultiSlotLayout. */
static final String METADATA_TAG = "MSL";
- @NonNull private final Row mElement;
+ private final @NonNull Row mElement;
MultiSlotLayout(@NonNull Row mElement) {
this.mElement = mElement;
@@ -89,8 +90,8 @@
/** Builder class for {@link MultiSlotLayout}. */
public static final class Builder implements LayoutElement.Builder {
- @NonNull private final List<LayoutElement> mSlotsContent = new ArrayList<>();
- @NonNull private DpProp mHorizontalSpacerWidth = MULTI_SLOT_LAYOUT_HORIZONTAL_SPACER_WIDTH;
+ private final @NonNull List<LayoutElement> mSlotsContent = new ArrayList<>();
+ private @NonNull DpProp mHorizontalSpacerWidth = MULTI_SLOT_LAYOUT_HORIZONTAL_SPACER_WIDTH;
/**
* Creates a builder for the {@link MultiSlotLayout}. Content inside of it can later be
@@ -99,11 +100,10 @@
public Builder() {}
/** Add one new slot to the layout with the given content inside. */
- @NonNull
@SuppressWarnings("MissingGetterMatchingBuilder")
// There is no direct matching getter for this setter, but there is a getter that gets all
// added slots.
- public Builder addSlotContent(@NonNull LayoutElement slotContent) {
+ public @NonNull Builder addSlotContent(@NonNull LayoutElement slotContent) {
mSlotsContent.add(slotContent);
return this;
}
@@ -113,20 +113,18 @@
* than one slot. If not set, {@link
* LayoutDefaults#MULTI_SLOT_LAYOUT_HORIZONTAL_SPACER_WIDTH} will be used.
*/
- @NonNull
- public Builder setHorizontalSpacerWidth(@Dimension(unit = DP) float width) {
+ public @NonNull Builder setHorizontalSpacerWidth(@Dimension(unit = DP) float width) {
this.mHorizontalSpacerWidth = dp(width);
return this;
}
/** Constructs and returns {@link MultiSlotLayout} with the provided content and look. */
- @NonNull
@Override
// The @Dimension(unit = DP) on mVerticalSpacerHeight.getValue() is seemingly being ignored,
// so lint complains that we're passing PX to something expecting DP. Just suppress the
// warning for now.
@SuppressLint("ResourceType")
- public MultiSlotLayout build() {
+ public @NonNull MultiSlotLayout build() {
Row.Builder rowBuilder =
new Row.Builder()
.setHeight(wrap())
@@ -163,8 +161,7 @@
}
/** Gets the content from this layout, containing all slots that were added. */
- @NonNull
- public List<LayoutElement> getSlotContents() {
+ public @NonNull List<LayoutElement> getSlotContents() {
List<LayoutElement> slots = new ArrayList<>();
for (LayoutElement slot : mElement.getContents()) {
if (slot instanceof Box) {
@@ -193,8 +190,7 @@
}
/** Returns metadata tag set to this MultiSlotLayout. */
- @NonNull
- String getMetadataTag() {
+ @NonNull String getMetadataTag() {
return getMetadataTagName(
checkNotNull(checkNotNull(mElement.getModifiers()).getMetadata()));
}
@@ -204,8 +200,7 @@
* container's content with {@code container.getContents().get(index)}) if that element can be
* converted to MultiSlotLayout. Otherwise, it will return null.
*/
- @Nullable
- public static MultiSlotLayout fromLayoutElement(@NonNull LayoutElement element) {
+ public static @Nullable MultiSlotLayout fromLayoutElement(@NonNull LayoutElement element) {
if (element instanceof MultiSlotLayout) {
return (MultiSlotLayout) element;
}
@@ -220,17 +215,15 @@
return new MultiSlotLayout(rowElement);
}
- @NonNull
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mElement.toLayoutElementProto();
}
- @Nullable
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mElement.getFingerprint();
}
}
diff --git a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/PrimaryLayout.java b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/PrimaryLayout.java
index 6d0ed54..6923cdd 100644
--- a/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/PrimaryLayout.java
+++ b/wear/protolayout/protolayout-material/src/main/java/androidx/wear/protolayout/material/layouts/PrimaryLayout.java
@@ -45,8 +45,6 @@
import androidx.annotation.Dimension;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters;
@@ -64,6 +62,9 @@
import androidx.wear.protolayout.material.CompactChip;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
@@ -167,14 +168,14 @@
})
@interface ContentBits {}
- @NonNull private final Box mImpl;
+ private final @NonNull Box mImpl;
// This contains inner columns and primary chip.
- @NonNull private final List<LayoutElement> mAllContent;
+ private final @NonNull List<LayoutElement> mAllContent;
// This contains primary label content.
- @NonNull private final List<LayoutElement> mPrimaryLabel;
+ private final @NonNull List<LayoutElement> mPrimaryLabel;
// This contains optional labels, spacers and main content.
- @NonNull private final List<LayoutElement> mContentAndSecondaryLabel;
+ private final @NonNull List<LayoutElement> mContentAndSecondaryLabel;
PrimaryLayout(@NonNull Box layoutElement) {
this.mImpl = layoutElement;
@@ -188,13 +189,13 @@
/** Builder class for {@link PrimaryLayout}. */
public static final class Builder implements LayoutElement.Builder {
- @NonNull private final DeviceParameters mDeviceParameters;
- @Nullable private LayoutElement mPrimaryChip = null;
+ private final @NonNull DeviceParameters mDeviceParameters;
+ private @Nullable LayoutElement mPrimaryChip = null;
private boolean mIsResponsiveInsetEnabled = false;
- @Nullable private LayoutElement mPrimaryLabelText = null;
- @Nullable private LayoutElement mSecondaryLabelText = null;
- @NonNull private LayoutElement mContent = new Box.Builder().build();
- @NonNull private DpProp mVerticalSpacerHeight = DEFAULT_VERTICAL_SPACER_HEIGHT;
+ private @Nullable LayoutElement mPrimaryLabelText = null;
+ private @Nullable LayoutElement mSecondaryLabelText = null;
+ private @NonNull LayoutElement mContent = new Box.Builder().build();
+ private @NonNull DpProp mVerticalSpacerHeight = DEFAULT_VERTICAL_SPACER_HEIGHT;
private byte mMetadataContentByte = 0;
/**
@@ -217,8 +218,7 @@
* <p>It is highly recommended to call this method with {@code true} when using this layout
* to optimize it for different screen sizes.
*/
- @NonNull
- public Builder setResponsiveContentInsetEnabled(boolean enabled) {
+ public @NonNull Builder setResponsiveContentInsetEnabled(boolean enabled) {
this.mIsResponsiveInsetEnabled = enabled;
if (enabled) {
mMetadataContentByte = (byte) (mMetadataContentByte | CONTENT_INSET_USED);
@@ -233,16 +233,15 @@
* accepted to pass in any {@link LayoutElement}, but it is strongly recommended to add a
* {@link CompactChip} as the layout is optimized for it.
*/
- @NonNull
- public Builder setPrimaryChipContent(@NonNull LayoutElement compactChip) {
+ public @NonNull Builder setPrimaryChipContent(@NonNull LayoutElement compactChip) {
this.mPrimaryChip = compactChip;
mMetadataContentByte = (byte) (mMetadataContentByte | CHIP_PRESENT);
return this;
}
/** Sets the content in the primary label slot which will be above the main content. */
- @NonNull
- public Builder setPrimaryLabelTextContent(@NonNull LayoutElement primaryLabelText) {
+ public @NonNull Builder setPrimaryLabelTextContent(
+ @NonNull LayoutElement primaryLabelText) {
this.mPrimaryLabelText = primaryLabelText;
mMetadataContentByte = (byte) (mMetadataContentByte | PRIMARY_LABEL_PRESENT);
return this;
@@ -252,8 +251,8 @@
* Sets the content in the primary label slot which will be below the main content. It is
* highly recommended to have primary label set when having secondary label.
*/
- @NonNull
- public Builder setSecondaryLabelTextContent(@NonNull LayoutElement secondaryLabelText) {
+ public @NonNull Builder setSecondaryLabelTextContent(
+ @NonNull LayoutElement secondaryLabelText) {
this.mSecondaryLabelText = secondaryLabelText;
mMetadataContentByte = (byte) (mMetadataContentByte | SECONDARY_LABEL_PRESENT);
return this;
@@ -269,8 +268,7 @@
* set to {@code expand} to use all the available space, rather than an explicit width which
* may lead to clipping.
*/
- @NonNull
- public Builder setContent(@NonNull LayoutElement content) {
+ public @NonNull Builder setContent(@NonNull LayoutElement content) {
this.mContent = content;
mMetadataContentByte = (byte) (mMetadataContentByte | CONTENT_PRESENT);
return this;
@@ -281,11 +279,10 @@
* secondary label if there is any. If not set, {@link
* LayoutDefaults#DEFAULT_VERTICAL_SPACER_HEIGHT} will be used.
*/
- @NonNull
// The @Dimension(unit = DP) on dp() is seemingly being ignored, so lint complains that
// we're passing PX to something expecting DP. Just suppress the warning for now.
@SuppressLint("ResourceType")
- public Builder setVerticalSpacerHeight(@Dimension(unit = DP) float height) {
+ public @NonNull Builder setVerticalSpacerHeight(@Dimension(unit = DP) float height) {
this.mVerticalSpacerHeight = dp(height);
return this;
}
@@ -294,9 +291,8 @@
// The @Dimension(unit = DP) on dp() is seemingly being ignored, so lint complains that
// we're passing DP to something expecting PX. Just suppress the warning for now.
@SuppressLint("ResourceType")
- @NonNull
@Override
- public PrimaryLayout build() {
+ public @NonNull PrimaryLayout build() {
float topPadding = getTopPadding();
float bottomPadding = getBottomPadding();
float horizontalPadding = getHorizontalPadding();
@@ -497,8 +493,7 @@
}
/** Returns the spacer height to be placed above primary label to accommodate Tile icon. */
- @NonNull
- private DpProp getPrimaryLabelTopSpacerHeight() {
+ private @NonNull DpProp getPrimaryLabelTopSpacerHeight() {
return isRoundDevice(mDeviceParameters)
? PRIMARY_LAYOUT_PRIMARY_LABEL_SPACER_HEIGHT_ROUND_DP
: PRIMARY_LAYOUT_PRIMARY_LABEL_SPACER_HEIGHT_SQUARE_DP;
@@ -506,8 +501,7 @@
}
/** Get the primary label content from this layout. */
- @Nullable
- public LayoutElement getPrimaryLabelTextContent() {
+ public @Nullable LayoutElement getPrimaryLabelTextContent() {
if (!areElementsPresent(PRIMARY_LABEL_PRESENT)) {
return null;
}
@@ -519,8 +513,7 @@
}
/** Get the secondary label content from this layout. */
- @Nullable
- public LayoutElement getSecondaryLabelTextContent() {
+ public @Nullable LayoutElement getSecondaryLabelTextContent() {
if (!areElementsPresent(SECONDARY_LABEL_PRESENT)) {
return null;
}
@@ -533,8 +526,7 @@
}
/** Get the inner content from this layout. */
- @Nullable
- public LayoutElement getContent() {
+ public @Nullable LayoutElement getContent() {
if (!areElementsPresent(CONTENT_PRESENT)) {
return null;
}
@@ -542,8 +534,7 @@
}
/** Get the primary chip content from this layout. */
- @Nullable
- public LayoutElement getPrimaryChipContent() {
+ public @Nullable LayoutElement getPrimaryChipContent() {
if (areElementsPresent(CHIP_PRESENT)) {
return ((Box) mAllContent.get(PRIMARY_CHIP_POSITION)).getContents().get(0);
}
@@ -578,8 +569,7 @@
}
/** Returns metadata tag set to this PrimaryLayout. */
- @NonNull
- byte[] getMetadataTag() {
+ byte @NonNull [] getMetadataTag() {
return getMetadataTagBytes(checkNotNull(checkNotNull(mImpl.getModifiers()).getMetadata()));
}
@@ -588,8 +578,7 @@
* container's content with {@code container.getContents().get(index)}) if that element can be
* converted to PrimaryLayout. Otherwise, it will return null.
*/
- @Nullable
- public static PrimaryLayout fromLayoutElement(@NonNull LayoutElement element) {
+ public static @Nullable PrimaryLayout fromLayoutElement(@NonNull LayoutElement element) {
if (element instanceof PrimaryLayout) {
return (PrimaryLayout) element;
}
@@ -604,17 +593,15 @@
return new PrimaryLayout(boxElement);
}
- @NonNull
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mImpl.toLayoutElementProto();
}
- @Nullable
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mImpl.getFingerprint();
}
}
diff --git a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ButtonTest.java b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ButtonTest.java
index 4d87b320..a895895 100644
--- a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ButtonTest.java
+++ b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ButtonTest.java
@@ -32,8 +32,6 @@
import android.content.Context;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.wear.protolayout.ActionBuilders.LaunchAction;
@@ -47,6 +45,8 @@
import androidx.wear.protolayout.TypeBuilders.StringProp;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicString;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.internal.DoNotInstrument;
diff --git a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ChipTest.java b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ChipTest.java
index af82462..471ca21 100644
--- a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ChipTest.java
+++ b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/ChipTest.java
@@ -32,8 +32,6 @@
import android.content.Context;
import android.graphics.Color;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.wear.protolayout.ActionBuilders.LaunchAction;
@@ -51,6 +49,8 @@
import androidx.wear.protolayout.TypeBuilders.StringProp;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicString;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.internal.DoNotInstrument;
diff --git a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/CircularProgressIndicatorTest.java b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/CircularProgressIndicatorTest.java
index 82d87ac..fd783ff 100644
--- a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/CircularProgressIndicatorTest.java
+++ b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/CircularProgressIndicatorTest.java
@@ -27,8 +27,6 @@
import android.graphics.Color;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.wear.protolayout.LayoutElementBuilders.Box;
import androidx.wear.protolayout.LayoutElementBuilders.Column;
@@ -39,6 +37,8 @@
import androidx.wear.protolayout.expression.DynamicBuilders;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicString;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.internal.DoNotInstrument;
diff --git a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/CompactChipTest.java b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/CompactChipTest.java
index f038573..9e2426b 100644
--- a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/CompactChipTest.java
+++ b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/CompactChipTest.java
@@ -27,8 +27,6 @@
import android.content.Context;
import android.graphics.Color;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.wear.protolayout.ActionBuilders.LaunchAction;
@@ -40,6 +38,8 @@
import androidx.wear.protolayout.ModifiersBuilders.ElementMetadata;
import androidx.wear.protolayout.ModifiersBuilders.Modifiers;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.internal.DoNotInstrument;
diff --git a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/TitleChipTest.java b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/TitleChipTest.java
index 2fac6bb..624ff29 100644
--- a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/TitleChipTest.java
+++ b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/TitleChipTest.java
@@ -28,7 +28,6 @@
import android.content.Context;
import android.graphics.Color;
-import androidx.annotation.Nullable;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.wear.protolayout.ActionBuilders.LaunchAction;
@@ -40,6 +39,7 @@
import androidx.wear.protolayout.ModifiersBuilders.ElementMetadata;
import androidx.wear.protolayout.ModifiersBuilders.Modifiers;
+import org.jspecify.annotations.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.internal.DoNotInstrument;
diff --git a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/layouts/EdgeContentLayoutTest.java b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/layouts/EdgeContentLayoutTest.java
index b022419..4286b02 100644
--- a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/layouts/EdgeContentLayoutTest.java
+++ b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/layouts/EdgeContentLayoutTest.java
@@ -24,8 +24,6 @@
import android.content.Context;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters;
@@ -37,6 +35,8 @@
import androidx.wear.protolayout.material.CircularProgressIndicator;
import androidx.wear.protolayout.material.Text;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.internal.DoNotInstrument;
diff --git a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/layouts/PrimaryLayoutTest.java b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/layouts/PrimaryLayoutTest.java
index 8700295..a157857 100644
--- a/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/layouts/PrimaryLayoutTest.java
+++ b/wear/protolayout/protolayout-material/src/test/java/androidx/wear/protolayout/material/layouts/PrimaryLayoutTest.java
@@ -24,8 +24,6 @@
import android.content.Context;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.wear.protolayout.ActionBuilders.LaunchAction;
@@ -39,6 +37,8 @@
import androidx.wear.protolayout.material.CompactChip;
import androidx.wear.protolayout.material.Text;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.internal.DoNotInstrument;
diff --git a/wear/protolayout/protolayout-material3/build.gradle b/wear/protolayout/protolayout-material3/build.gradle
index 3cdcbbd..b90ce81 100644
--- a/wear/protolayout/protolayout-material3/build.gradle
+++ b/wear/protolayout/protolayout-material3/build.gradle
@@ -30,6 +30,7 @@
}
dependencies {
+ api(libs.jspecify)
annotationProcessor(libs.nullaway)
api(project(":wear:protolayout:protolayout"))
api(project(":wear:protolayout:protolayout-expression"))
diff --git a/wear/protolayout/protolayout-material3/src/androidTest/java/androidx/wear/protolayout/material3/test/GoldenTestActivity.java b/wear/protolayout/protolayout-material3/src/androidTest/java/androidx/wear/protolayout/material3/test/GoldenTestActivity.java
index bcf8417..ffeeabc 100644
--- a/wear/protolayout/protolayout-material3/src/androidTest/java/androidx/wear/protolayout/material3/test/GoldenTestActivity.java
+++ b/wear/protolayout/protolayout-material3/src/androidTest/java/androidx/wear/protolayout/material3/test/GoldenTestActivity.java
@@ -32,8 +32,6 @@
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.wear.protolayout.LayoutElementBuilders.Layout;
import androidx.wear.protolayout.ResourceBuilders.AndroidImageResourceByResId;
import androidx.wear.protolayout.ResourceBuilders.ImageResource;
@@ -43,6 +41,9 @@
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Locale;
import java.util.concurrent.ExecutionException;
diff --git a/wear/protolayout/protolayout-material3/src/main/java/androidx/wear/protolayout/material3/tokens/PaletteTokens.java b/wear/protolayout/protolayout-material3/src/main/java/androidx/wear/protolayout/material3/tokens/PaletteTokens.java
index ad55490f..d6d4d2d 100644
--- a/wear/protolayout/protolayout-material3/src/main/java/androidx/wear/protolayout/material3/tokens/PaletteTokens.java
+++ b/wear/protolayout/protolayout-material3/src/main/java/androidx/wear/protolayout/material3/tokens/PaletteTokens.java
@@ -20,6 +20,7 @@
package androidx.wear.protolayout.material3.tokens;
import android.graphics.Color;
+
import androidx.annotation.ColorInt;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
diff --git a/wear/protolayout/protolayout-material3/src/main/java/androidx/wear/protolayout/material3/tokens/ShapeTokens.java b/wear/protolayout/protolayout-material3/src/main/java/androidx/wear/protolayout/material3/tokens/ShapeTokens.java
index d64da97..0a47eb2 100644
--- a/wear/protolayout/protolayout-material3/src/main/java/androidx/wear/protolayout/material3/tokens/ShapeTokens.java
+++ b/wear/protolayout/protolayout-material3/src/main/java/androidx/wear/protolayout/material3/tokens/ShapeTokens.java
@@ -21,33 +21,33 @@
import static androidx.wear.protolayout.DimensionBuilders.dp;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.ModifiersBuilders.Corner;
+import org.jspecify.annotations.NonNull;
+
/** The Material 3 shape system on Wear OS. */
@RestrictTo(Scope.LIBRARY)
public final class ShapeTokens {
- @NonNull public static final Corner CORNER_EXTRA_LARGE = roundedCornerShape(36.0f);
+ public static final @NonNull Corner CORNER_EXTRA_LARGE = roundedCornerShape(36.0f);
- @NonNull public static final Corner CORNER_EXTRA_SMALL = roundedCornerShape(4.0f);
+ public static final @NonNull Corner CORNER_EXTRA_SMALL = roundedCornerShape(4.0f);
// Full corner can be achieved by setting a big radius value, which will be clamped by
// min(halfWidth, halfHeight).
- @NonNull public static final Corner CORNER_FULL = roundedCornerShape(99999.0f);
+ public static final @NonNull Corner CORNER_FULL = roundedCornerShape(99999.0f);
- @NonNull public static final Corner CORNER_LARGE = roundedCornerShape(26.0f);
+ public static final @NonNull Corner CORNER_LARGE = roundedCornerShape(26.0f);
- @NonNull public static final Corner CORNER_MEDIUM = roundedCornerShape(18.0f);
+ public static final @NonNull Corner CORNER_MEDIUM = roundedCornerShape(18.0f);
- @NonNull public static final Corner CORNER_NONE = roundedCornerShape(0.0f);
+ public static final @NonNull Corner CORNER_NONE = roundedCornerShape(0.0f);
- @NonNull public static final Corner CORNER_SMALL = roundedCornerShape(8.0f);
+ public static final @NonNull Corner CORNER_SMALL = roundedCornerShape(8.0f);
- @NonNull
- private static Corner roundedCornerShape(float sizeDp) {
+ private static @NonNull Corner roundedCornerShape(float sizeDp) {
return new Corner.Builder().setRadius(dp(sizeDp)).build();
}
diff --git a/wear/protolayout/protolayout-material3/src/main/java/androidx/wear/protolayout/material3/tokens/TextStyle.java b/wear/protolayout/protolayout-material3/src/main/java/androidx/wear/protolayout/material3/tokens/TextStyle.java
index 22a3d19..298e197 100644
--- a/wear/protolayout/protolayout-material3/src/main/java/androidx/wear/protolayout/material3/tokens/TextStyle.java
+++ b/wear/protolayout/protolayout-material3/src/main/java/androidx/wear/protolayout/material3/tokens/TextStyle.java
@@ -21,12 +21,14 @@
import static androidx.wear.protolayout.DimensionBuilders.sp;
import androidx.annotation.Dimension;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.DimensionBuilders.EmProp;
import androidx.wear.protolayout.DimensionBuilders.SpProp;
import androidx.wear.protolayout.LayoutElementBuilders.FontSetting;
+
+import org.jspecify.annotations.NonNull;
+
import java.util.ArrayList;
import java.util.List;
@@ -34,22 +36,22 @@
@RestrictTo(Scope.LIBRARY)
public class TextStyle {
/** Font family, such as "Roboto". */
- @NonNull public final String fontFamily;
+ public final @NonNull String fontFamily;
/** The size of the font, in scaled pixels. */
- @NonNull public final SpProp size;
+ public final @NonNull SpProp size;
/** The explicit height between lines of text. */
- @NonNull public final SpProp lineHeight;
+ public final @NonNull SpProp lineHeight;
/**
* The text letter spacing. Positive numbers increase the space between letters while negative
* numbers tighten the space.
*/
- @NonNull public final EmProp letterSpacing;
+ public final @NonNull EmProp letterSpacing;
/** List of {@link FontSetting} option for font, such as weight, width. */
- @NonNull public final List<FontSetting> fontSettings;
+ public final @NonNull List<FontSetting> fontSettings;
public TextStyle(
@NonNull String fontFamily,
diff --git a/wear/protolayout/protolayout-material3/src/main/java/androidx/wear/protolayout/material3/tokens/VariableFontSettingsTokens.java b/wear/protolayout/protolayout-material3/src/main/java/androidx/wear/protolayout/material3/tokens/VariableFontSettingsTokens.java
index 37efe70..14018bb 100644
--- a/wear/protolayout/protolayout-material3/src/main/java/androidx/wear/protolayout/material3/tokens/VariableFontSettingsTokens.java
+++ b/wear/protolayout/protolayout-material3/src/main/java/androidx/wear/protolayout/material3/tokens/VariableFontSettingsTokens.java
@@ -22,6 +22,7 @@
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.LayoutElementBuilders.FontSetting;
+
import java.util.List;
/** A list of text style values in Material3 for supporting product needs. */
diff --git a/wear/protolayout/protolayout-renderer/build.gradle b/wear/protolayout/protolayout-renderer/build.gradle
index e1ae6c7..4efa090 100644
--- a/wear/protolayout/protolayout-renderer/build.gradle
+++ b/wear/protolayout/protolayout-renderer/build.gradle
@@ -29,6 +29,7 @@
}
dependencies {
+ api(libs.jspecify)
annotationProcessor(libs.nullaway)
api("androidx.annotation:annotation:1.8.1")
api("androidx.core:core:1.7.0")
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/ProtoLayoutExtensionViewProvider.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/ProtoLayoutExtensionViewProvider.java
index 42df804..97ffa39 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/ProtoLayoutExtensionViewProvider.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/ProtoLayoutExtensionViewProvider.java
@@ -17,11 +17,12 @@
import android.view.View;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* View provider for a View ExtensionLayoutElement. This should check that the given renderer
* extension ID matches the expected renderer extension ID, then return a View based on the given
@@ -36,6 +37,5 @@
*
* <p>Note: The renderer extension must not set the default tag of the returned View object.
*/
- @Nullable
- View provideView(@NonNull byte[] extensionPayload, @NonNull String vendorId);
+ @Nullable View provideView(byte @NonNull [] extensionPayload, @NonNull String vendorId);
}
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/ProtoLayoutTheme.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/ProtoLayoutTheme.java
index 0361d51..a7e3101 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/ProtoLayoutTheme.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/ProtoLayoutTheme.java
@@ -21,10 +21,11 @@
import androidx.annotation.AttrRes;
import androidx.annotation.DrawableRes;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
+import org.jspecify.annotations.NonNull;
+
/** Theme customization for ProtoLayout texts, which includes Font types and variants. */
@RestrictTo(Scope.LIBRARY)
public interface ProtoLayoutTheme {
@@ -38,14 +39,11 @@
/** Holder for different weights of the same font variant. */
interface FontSet {
- @NonNull
- Typeface getNormalFont();
+ @NonNull Typeface getNormalFont();
- @NonNull
- Typeface getMediumFont();
+ @NonNull Typeface getMediumFont();
- @NonNull
- Typeface getBoldFont();
+ @NonNull Typeface getBoldFont();
}
/**
@@ -63,12 +61,10 @@
* @param preferredFontFamilies the ordered list of String values representing the preferred
* font families that should be used.
*/
- @NonNull
- FontSet getFontSet(@NonNull String... preferredFontFamilies);
+ @NonNull FontSet getFontSet(String @NonNull ... preferredFontFamilies);
/** Gets an Android Theme object styled with TextAppearance attributes. */
- @NonNull
- Theme getTheme();
+ @NonNull Theme getTheme();
/**
* Gets an Attribute resource Id for a fallback TextAppearance. The resource with this id should
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/LoggingUtils.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/LoggingUtils.java
index c3e6fa4..0338453 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/LoggingUtils.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/LoggingUtils.java
@@ -1,12 +1,13 @@
package androidx.wear.protolayout.renderer.common;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import com.google.errorprone.annotations.FormatMethod;
import com.google.errorprone.annotations.FormatString;
+import org.jspecify.annotations.NonNull;
+
/**
* Logger used for extensive logging. Note that all logs will contain the component name. To enable
* logs use the following command:
@@ -19,11 +20,11 @@
public interface LoggingUtils {
/** LogD a formatted message. */
- void logD(@NonNull String tag,@NonNull String message);
+ void logD(@NonNull String tag, @NonNull String message);
/** LogD a formatted message. */
@FormatMethod
- void logD(@NonNull String tag, @NonNull @FormatString String format, @NonNull Object... args);
+ void logD(@NonNull String tag, @FormatString @NonNull String format, Object @NonNull ... args);
/**
* Check whether debug logging is allowed or not for the given {@code tag}. This will allow
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/LoggingUtilsImpl.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/LoggingUtilsImpl.java
index 7cd6b42..b2484b8 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/LoggingUtilsImpl.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/LoggingUtilsImpl.java
@@ -3,13 +3,14 @@
import android.content.ComponentName;
import android.util.Log;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import com.google.errorprone.annotations.FormatMethod;
import com.google.errorprone.annotations.FormatString;
+import org.jspecify.annotations.NonNull;
+
/**
* Logger used for extensive logging. Note that all logs will contain the component name. To enable
* logs use the following command:
@@ -21,7 +22,7 @@
@RestrictTo(Scope.LIBRARY_GROUP_PREFIX)
public class LoggingUtilsImpl implements LoggingUtils {
- @NonNull private final ComponentName mComponent;
+ private final @NonNull ComponentName mComponent;
public LoggingUtilsImpl(@NonNull ComponentName component) {
this.mComponent = component;
@@ -36,8 +37,8 @@
@FormatMethod
public void logD(
@NonNull String tag,
- @NonNull @FormatString String format,
- @NonNull Object... args) {
+ @FormatString @NonNull String format,
+ Object @NonNull ... args) {
logD(tag, String.format(format, args));
}
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/NoOpProviderStatsLogger.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/NoOpProviderStatsLogger.java
index f292c98..7ffde68 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/NoOpProviderStatsLogger.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/NoOpProviderStatsLogger.java
@@ -19,11 +19,12 @@
import android.graphics.drawable.Drawable;
import android.util.Log;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.wear.protolayout.proto.StateProto.State;
import androidx.wear.protolayout.renderer.common.Constants.UpdateRequestReason;
+import org.jspecify.annotations.NonNull;
+
/** A No-Op implementation of {@link ProviderStatsLogger}. */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public class NoOpProviderStatsLogger implements ProviderStatsLogger {
@@ -52,8 +53,7 @@
/** No-op method. */
@Override
- @NonNull
- public InflaterStatsLogger createInflaterStatsLogger() {
+ public @NonNull InflaterStatsLogger createInflaterStatsLogger() {
return new NoOpInflaterStatsLogger();
}
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/ProtoLayoutDiffer.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/ProtoLayoutDiffer.java
index 6860d79..06a1c1c 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/ProtoLayoutDiffer.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/ProtoLayoutDiffer.java
@@ -20,8 +20,6 @@
import android.annotation.SuppressLint;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.annotation.VisibleForTesting;
@@ -31,6 +29,9 @@
import androidx.wear.protolayout.proto.LayoutElementProto.Layout;
import androidx.wear.protolayout.proto.LayoutElementProto.LayoutElement;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -39,12 +40,11 @@
@RestrictTo(Scope.LIBRARY_GROUP)
public class ProtoLayoutDiffer {
/** Prefix for all node IDs generated by this differ. */
- @NonNull private static final String NODE_ID_PREFIX = "pT";
+ private static final @NonNull String NODE_ID_PREFIX = "pT";
/** Node ID of the root node. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final String ROOT_NODE_ID = NODE_ID_PREFIX + "1";
+ public static final @NonNull String ROOT_NODE_ID = NODE_ID_PREFIX + "1";
// This must match {@code Fingerprint.DISCARDED_VALUE}
@VisibleForTesting static final int DISCARDED_FINGERPRINT_VALUE = -1;
@@ -77,10 +77,10 @@
/** A node in a layout tree. */
private static final class TreeNode {
- @Nullable final LayoutElement mLayoutElement;
- @Nullable final ArcLayoutElement mArcLayoutElement;
- @NonNull final NodeFingerprint mFingerprint;
- @NonNull final String mPosId;
+ final @Nullable LayoutElement mLayoutElement;
+ final @Nullable ArcLayoutElement mArcLayoutElement;
+ final @NonNull NodeFingerprint mFingerprint;
+ final @NonNull String mPosId;
private TreeNode(
@Nullable LayoutElement layoutElement,
@@ -93,24 +93,21 @@
this.mPosId = posId;
}
- @NonNull
- static TreeNode ofLayoutElement(
+ static @NonNull TreeNode ofLayoutElement(
@NonNull LayoutElement layoutElement,
@NonNull NodeFingerprint fingerprint,
@NonNull String posId) {
return new TreeNode(layoutElement, null, fingerprint, posId);
}
- @NonNull
- static TreeNode ofArcLayoutElement(
+ static @NonNull TreeNode ofArcLayoutElement(
@NonNull ArcLayoutElement arcLayoutElement,
@NonNull NodeFingerprint fingerprint,
@NonNull String id) {
return new TreeNode(null, arcLayoutElement, fingerprint, id);
}
- @NonNull
- TreeNodeWithChange withChange(@NonNull NodeChangeType nodeChangeType) {
+ @NonNull TreeNodeWithChange withChange(@NonNull NodeChangeType nodeChangeType) {
return new TreeNodeWithChange(this, nodeChangeType);
}
}
@@ -118,8 +115,8 @@
/** A node in a layout tree, that has a change compared to a previous version. */
@RestrictTo(Scope.LIBRARY_GROUP)
public static final class TreeNodeWithChange {
- @NonNull private final TreeNode mTreeNode;
- @NonNull private final NodeChangeType mNodeChangeType;
+ private final @NonNull TreeNode mTreeNode;
+ private final @NonNull NodeChangeType mNodeChangeType;
TreeNodeWithChange(@NonNull TreeNode treeNode, @NonNull NodeChangeType nodeChangeType) {
this.mTreeNode = treeNode;
@@ -130,9 +127,8 @@
* Returns the linear {@link LayoutElement} that this node represents, or null if the node
* isn't for a {@link LayoutElement}.
*/
- @Nullable
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElement getLayoutElement() {
+ public @Nullable LayoutElement getLayoutElement() {
return mTreeNode.mLayoutElement;
}
@@ -140,16 +136,14 @@
* Returns the radial {@link ArcLayoutElement} that this node represents, or null if the
* node isn't for a {@link ArcLayoutElement}.
*/
- @Nullable
@RestrictTo(Scope.LIBRARY_GROUP)
- public ArcLayoutElement getArcLayoutElement() {
+ public @Nullable ArcLayoutElement getArcLayoutElement() {
return mTreeNode.mArcLayoutElement;
}
/** Returns the fingerprint for this node. */
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- public NodeFingerprint getFingerprint() {
+ public @NonNull NodeFingerprint getFingerprint() {
return mTreeNode.mFingerprint;
}
@@ -157,9 +151,8 @@
* Returns an ID for this node based on its position in the tree. Only comparable against
* other position IDs that are generated with {@link #createNodePosId}.
*/
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- public String getPosId() {
+ public @NonNull String getPosId() {
return mTreeNode.mPosId;
}
@@ -180,8 +173,7 @@
/** Returns the {@link NodeChangeType} of this {@link TreeNodeWithChange}. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public NodeChangeType getChangeType() {
+ public @NonNull NodeChangeType getChangeType() {
return mNodeChangeType;
}
}
@@ -189,7 +181,7 @@
/** A diff in layout, containing information about the tree nodes that have changed. */
@RestrictTo(Scope.LIBRARY_GROUP)
public static final class LayoutDiff {
- @NonNull private final List<TreeNodeWithChange> mChangedNodes;
+ private final @NonNull List<TreeNodeWithChange> mChangedNodes;
LayoutDiff(@NonNull List<TreeNodeWithChange> changedNodes) {
this.mChangedNodes = changedNodes;
@@ -199,9 +191,8 @@
* An ordered list of nodes that have changed. A changed node always comes before its
* changed descendants in this list.
*/
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- public List<TreeNodeWithChange> getChangedNodes() {
+ public @NonNull List<TreeNodeWithChange> getChangedNodes() {
return mChangedNodes;
}
}
@@ -217,9 +208,8 @@
* #FIRST_CHILD_INDEX}, and increment by one for each.
*/
@SuppressLint("DefaultLocale")
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- public static String createNodePosId(@NonNull String parentPosId, int childIndex) {
+ public static @NonNull String createNodePosId(@NonNull String parentPosId, int childIndex) {
return String.format("%s.%d", parentPosId, childIndex + 1);
}
@@ -230,9 +220,8 @@
* @param posId A position ID for a node.
* @return The position ID of the node's parent or null if the parent ID cannot be generated.
*/
- @Nullable
@RestrictTo(Scope.LIBRARY_GROUP)
- public static String getParentNodePosId(@NonNull String posId) {
+ public static @Nullable String getParentNodePosId(@NonNull String posId) {
if (!posId.startsWith(NODE_ID_PREFIX)) {
return null;
}
@@ -265,9 +254,8 @@
* @return The layout diff or null if the diff cannot be computed, which means the whole layout
* should be refreshed.
*/
- @Nullable
@RestrictTo(Scope.LIBRARY_GROUP)
- public static LayoutDiff getDiff(
+ public static @Nullable LayoutDiff getDiff(
@NonNull TreeFingerprint prevTreeFingerprint, @NonNull Layout layout) {
if (!layout.getFingerprint().hasRoot()) {
return null;
@@ -328,8 +316,7 @@
}
}
- @NonNull
- private static NodeChangeType getChangeType(
+ private static @NonNull NodeChangeType getChangeType(
@NonNull NodeFingerprint prevNode, @Nullable NodeFingerprint node) {
if (node == null) {
return NodeChangeType.CHANGE_IN_SELF_AND_ALL_CHILDREN;
@@ -393,10 +380,9 @@
}
@SuppressWarnings("MixedMutabilityReturnType")
- @NonNull
- private static List<TreeNode> getChildNodes(@NonNull TreeNode node)
+ private static @NonNull List<TreeNode> getChildNodes(@NonNull TreeNode node)
throws InconsistentFingerprintException {
- @Nullable LayoutElement layoutElement = node.mLayoutElement;
+ LayoutElement layoutElement = node.mLayoutElement;
if (layoutElement == null) {
// Only LayoutElement objects (which includes Arc and Span) can have children.
return Collections.emptyList();
@@ -429,8 +415,7 @@
}
@SuppressWarnings("MixedMutabilityReturnType")
- @NonNull
- private static List<TreeNode> getLinearChildNodes(
+ private static @NonNull List<TreeNode> getLinearChildNodes(
@NonNull List<LayoutElement> childElements,
@NonNull List<NodeFingerprint> childElementFingerprints,
@NonNull String parentPosId)
@@ -452,8 +437,7 @@
}
@SuppressWarnings("MixedMutabilityReturnType")
- @NonNull
- private static List<TreeNode> getRadialChildNodes(
+ private static @NonNull List<TreeNode> getRadialChildNodes(
@NonNull List<ArcLayoutElement> childElements,
@NonNull List<NodeFingerprint> childElementFingerprints,
@NonNull String parentPosId)
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/ProviderStatsLogger.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/ProviderStatsLogger.java
index 96a6fb0..7af8f08 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/ProviderStatsLogger.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/ProviderStatsLogger.java
@@ -19,12 +19,13 @@
import android.graphics.drawable.Drawable;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.UiThread;
import androidx.wear.protolayout.proto.StateProto.State;
import androidx.wear.protolayout.renderer.common.Constants.UpdateRequestReason;
+import org.jspecify.annotations.NonNull;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -91,8 +92,7 @@
* logged to statsd only when {@link #logInflationFinished} is called.
*/
@UiThread
- @NonNull
- InflaterStatsLogger createInflaterStatsLogger();
+ @NonNull InflaterStatsLogger createInflaterStatsLogger();
/** Makes the end of inflation and log the inflation results. */
@UiThread
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/RenderingArtifact.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/RenderingArtifact.java
index 8424728..177caf5 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/RenderingArtifact.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/common/RenderingArtifact.java
@@ -16,36 +16,34 @@
package androidx.wear.protolayout.renderer.common;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.renderer.common.ProviderStatsLogger.InflaterStatsLogger;
+import org.jspecify.annotations.NonNull;
+
/** Artifacts resulted from the layout rendering. */
@RestrictTo(Scope.LIBRARY_GROUP)
public interface RenderingArtifact {
/** Creates a {@link RenderingArtifact} instance. */
- @NonNull
- static RenderingArtifact create(@NonNull InflaterStatsLogger inflaterStatsLogger) {
+ static @NonNull RenderingArtifact create(@NonNull InflaterStatsLogger inflaterStatsLogger) {
return new SuccessfulRenderingArtifact(inflaterStatsLogger);
}
/** Creates a {@link RenderingArtifact} instance for a skipped inflation. */
- @NonNull
- static RenderingArtifact skipped() {
+ static @NonNull RenderingArtifact skipped() {
return new SkippedRenderingArtifact();
}
/** Creates a {@link RenderingArtifact} instance for a failed inflation. */
- @NonNull
- static RenderingArtifact failed() {
+ static @NonNull RenderingArtifact failed() {
return new FailedRenderingArtifact();
}
/** Artifacts resulted from a successful layout rendering. */
class SuccessfulRenderingArtifact implements RenderingArtifact {
- @NonNull private final InflaterStatsLogger mInflaterStatsLogger;
+ private final @NonNull InflaterStatsLogger mInflaterStatsLogger;
private SuccessfulRenderingArtifact(@NonNull InflaterStatsLogger inflaterStatsLogger) {
mInflaterStatsLogger = inflaterStatsLogger;
@@ -55,8 +53,7 @@
* Returns the {@link ProviderStatsLogger.InflaterStatsLogger} used log inflation stats.
* This will return {@code null} if the inflation was skipped or failed.
*/
- @NonNull
- public InflaterStatsLogger getInflaterStatsLogger() {
+ public @NonNull InflaterStatsLogger getInflaterStatsLogger() {
return mInflaterStatsLogger;
}
}
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/dynamicdata/NodeInfo.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/dynamicdata/NodeInfo.java
index 6df8a51..34b8343 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/dynamicdata/NodeInfo.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/dynamicdata/NodeInfo.java
@@ -20,8 +20,6 @@
import android.graphics.drawable.AnimatedVectorDrawable;
import android.graphics.drawable.Drawable;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.UiThread;
import androidx.annotation.VisibleForTesting;
@@ -37,6 +35,9 @@
import androidx.wear.protolayout.proto.TriggerProto.Trigger.InnerCase;
import androidx.wear.protolayout.renderer.dynamicdata.PositionIdTree.TreeNode;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -52,25 +53,25 @@
class NodeInfo implements TreeNode {
/** List of active bound dynamic types in the pipeline. */
- @NonNull private final List<BoundDynamicType> mActiveBoundTypes = new ArrayList<>();
+ private final @NonNull List<BoundDynamicType> mActiveBoundTypes = new ArrayList<>();
/** List of bound dynamic types that need to be evaluated. */
- @NonNull private List<BoundDynamicType> mPendingBoundTypes = Collections.emptyList();
+ private @NonNull List<BoundDynamicType> mPendingBoundTypes = Collections.emptyList();
/** List of binding requests that failed to bind. */
- @NonNull
- private final List<DynamicTypeBindingRequest> mFailedBindingRequests = new ArrayList<>();
+ private final @NonNull List<DynamicTypeBindingRequest> mFailedBindingRequests =
+ new ArrayList<>();
- @NonNull private final QuotaManager mAnimationQuotaManager;
+ private final @NonNull QuotaManager mAnimationQuotaManager;
/** Set of animated image resources after they are resolved during inflation. */
- @NonNull private Set<ResolvedAvd> mResolvedAvds = Collections.emptySet();
+ private @NonNull Set<ResolvedAvd> mResolvedAvds = Collections.emptySet();
- @NonNull private Set<ResolvedSeekableAvd> mResolvedSeekableAvds = Collections.emptySet();
+ private @NonNull Set<ResolvedSeekableAvd> mResolvedSeekableAvds = Collections.emptySet();
- @Nullable private AnimatedVisibility mAnimatedVisibility = null;
+ private @Nullable AnimatedVisibility mAnimatedVisibility = null;
- @NonNull private final String mPosId;
+ private final @NonNull String mPosId;
NodeInfo(@NonNull String posId, @NonNull QuotaManager animationQuotaManager) {
this.mPosId = posId;
@@ -118,8 +119,8 @@
return mFailedBindingRequests;
}
- @NonNull
- ResolvedAvd addResolvedAvd(@NonNull AnimatedVectorDrawable drawable, @NonNull Trigger trigger) {
+ @NonNull ResolvedAvd addResolvedAvd(@NonNull AnimatedVectorDrawable drawable,
+ @NonNull Trigger trigger) {
if (mResolvedAvds.isEmpty()) {
mResolvedAvds = new ArraySet<>();
}
@@ -223,8 +224,7 @@
* Returns the total duration in milliseconds of the animated drawable associated with a
* StateSource with the given key name; or null if no such SourceKey exists.
*/
- @Nullable
- Long getSeekableAnimationTotalDurationMillis(@NonNull String sourceKey) {
+ @Nullable Long getSeekableAnimationTotalDurationMillis(@NonNull String sourceKey) {
for (ResolvedSeekableAvd resourceEntry : mResolvedSeekableAvds) {
if (resourceEntry.hasStateSourceKey(sourceKey)) {
return resourceEntry.mDrawable.getTotalDuration();
@@ -266,21 +266,19 @@
* Returns the {@link AnimatedVisibility} associated with this node. Returns null if no enter
* animation is associated with this node.
*/
- @Nullable
- AnimatedVisibility getAnimatedVisibility() {
+ @Nullable AnimatedVisibility getAnimatedVisibility() {
return mAnimatedVisibility;
}
/** Returns the position Id for this node. */
- @NonNull
- String getPosId() {
+ @NonNull String getPosId() {
return mPosId;
}
static class ResolvedAvd {
- @NonNull final AnimatedVectorDrawable mDrawable;
- @NonNull final QuotaReleasingAnimationCallback mCallback;
- @NonNull final Trigger mTrigger;
+ final @NonNull AnimatedVectorDrawable mDrawable;
+ final @NonNull QuotaReleasingAnimationCallback mCallback;
+ final @NonNull Trigger mTrigger;
boolean mPlayedAtLeastOnce;
ResolvedAvd(
@@ -302,8 +300,8 @@
}
static class ResolvedSeekableAvd {
- @NonNull final SeekableAnimatedVectorDrawable mDrawable;
- @NonNull final DynamicFloat mBoundProgress;
+ final @NonNull SeekableAnimatedVectorDrawable mDrawable;
+ final @NonNull DynamicFloat mBoundProgress;
ResolvedSeekableAvd(
@NonNull SeekableAnimatedVectorDrawable drawable,
@@ -319,9 +317,9 @@
/** The callback used for AVD animations to release quota when the animation is finished. */
private static final class QuotaReleasingAnimationCallback extends AnimationCallback {
- @NonNull private final QuotaManager mQuotaManager;
+ private final @NonNull QuotaManager mQuotaManager;
- @NonNull final AtomicBoolean mIsUsingQuota = new AtomicBoolean(false);
+ final @NonNull AtomicBoolean mIsUsingQuota = new AtomicBoolean(false);
QuotaReleasingAnimationCallback(@NonNull QuotaManager quotaManager) {
this.mQuotaManager = quotaManager;
@@ -338,9 +336,8 @@
public void onAnimationStart(@NonNull Drawable drawable) {}
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
return mPosId;
}
}
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/dynamicdata/PositionIdTree.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/dynamicdata/PositionIdTree.java
index ad467e4..8dcf006 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/dynamicdata/PositionIdTree.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/dynamicdata/PositionIdTree.java
@@ -23,12 +23,13 @@
import android.util.ArrayMap;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.renderer.dynamicdata.PositionIdTree.TreeNode;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -55,7 +56,7 @@
void destroy();
}
- @NonNull private final Map<String, T> mPosIdToTreeNode = new ArrayMap<>();
+ private final @NonNull Map<String, T> mPosIdToTreeNode = new ArrayMap<>();
/** Calls {@code action} on all of the tree nodes. */
void forEach(Consumer<T> action) {
@@ -102,14 +103,12 @@
}
/** Returns the node matching the {@code predicate} or an null if there is no match. */
- @Nullable
- T findFirst(@NonNull Predicate<? super T> predicate) {
+ @Nullable T findFirst(@NonNull Predicate<? super T> predicate) {
return mPosIdToTreeNode.values().stream().filter(predicate).findFirst().orElse(null);
}
/** Returns the node with {@code posId} or null if it doesn't exist. */
- @Nullable
- public T get(@NonNull String posId) {
+ public @Nullable T get(@NonNull String posId) {
return mPosIdToTreeNode.get(posId);
}
@@ -117,8 +116,7 @@
* Returns all of the ancestors of the node {@code posId} and value matching the {@code
* predicate}.
*/
- @NonNull
- public List<T> findAncestorsFor(
+ public @NonNull List<T> findAncestorsFor(
@NonNull String posId, @NonNull Predicate<? super T> predicate) {
List<T> result = new ArrayList<>();
for (String id : findAncestorsNodesFor(posId, predicate)) {
@@ -134,8 +132,7 @@
* Returns all of the ancestors' posIds of the node {@code posId} with value matching the {@code
* predicate}.
*/
- @NonNull
- public List<String> findAncestorsNodesFor(
+ public @NonNull List<String> findAncestorsNodesFor(
@NonNull String posId, @NonNull Predicate<? super T> predicate) {
List<String> result = new ArrayList<>();
while (true) {
@@ -153,8 +150,7 @@
}
/** Returns all of the nodes in a subtree under the node with {@code posId}. */
- @NonNull
- List<T> findChildrenFor(@NonNull String posId) {
+ @NonNull List<T> findChildrenFor(@NonNull String posId) {
return findChildrenFor(posId, node -> true);
}
@@ -162,8 +158,8 @@
* Returns all of the nodes in a subtree under the node with {@code posId} matching the {@code
* predicate}.
*/
- @NonNull
- List<T> findChildrenFor(@NonNull String posId, @NonNull Predicate<? super T> predicate) {
+ @NonNull List<T> findChildrenFor(@NonNull String posId,
+ @NonNull Predicate<? super T> predicate) {
List<T> result = new ArrayList<>();
addChildrenFor(posId, predicate, result);
return result;
@@ -187,8 +183,7 @@
}
/** Returns all of the current tree nodes. This is intended to be used only in tests. */
- @NonNull
- Collection<T> getAllNodes() {
+ @NonNull Collection<T> getAllNodes() {
return Collections.unmodifiableCollection(mPosIdToTreeNode.values());
}
}
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/dynamicdata/ProtoLayoutDynamicDataPipeline.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/dynamicdata/ProtoLayoutDynamicDataPipeline.java
index 81dfac5..0b32579 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/dynamicdata/ProtoLayoutDynamicDataPipeline.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/dynamicdata/ProtoLayoutDynamicDataPipeline.java
@@ -32,8 +32,6 @@
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.animation.AnimationSet;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.annotation.UiThread;
@@ -70,6 +68,9 @@
import com.google.common.collect.ImmutableList;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@@ -90,20 +91,19 @@
*/
@RestrictTo(Scope.LIBRARY_GROUP)
public class ProtoLayoutDynamicDataPipeline {
- @NonNull private static final String TAG = "DynamicDataPipeline";
+ private static final @NonNull String TAG = "DynamicDataPipeline";
- @NonNull
- private static final QuotaManager DISABLED_ANIMATIONS_QUOTA_MANAGER =
+ private static final @NonNull QuotaManager DISABLED_ANIMATIONS_QUOTA_MANAGER =
new FixedQuotaManagerImpl(/* quotaCap= */ 0, "disabled animations");
- @NonNull final PositionIdTree<NodeInfo> mPositionIdTree = new PositionIdTree<>();
- @NonNull final List<QuotaAwareAnimationSet> mEnterAnimations = new ArrayList<>();
- @NonNull final List<QuotaAwareAnimationSet> mExitAnimations = new ArrayList<>();
+ final @NonNull PositionIdTree<NodeInfo> mPositionIdTree = new PositionIdTree<>();
+ final @NonNull List<QuotaAwareAnimationSet> mEnterAnimations = new ArrayList<>();
+ final @NonNull List<QuotaAwareAnimationSet> mExitAnimations = new ArrayList<>();
final boolean mEnableAnimations;
boolean mFullyVisible;
- @NonNull final QuotaManager mAnimationQuotaManager;
- @NonNull private final DynamicTypeEvaluator mEvaluator;
- @NonNull private final PlatformTimeUpdateNotifierImpl mTimeNotifier;
+ final @NonNull QuotaManager mAnimationQuotaManager;
+ private final @NonNull DynamicTypeEvaluator mEvaluator;
+ private final @NonNull PlatformTimeUpdateNotifierImpl mTimeNotifier;
/** Creates a {@link ProtoLayoutDynamicDataPipeline} without animation support. */
@RestrictTo(Scope.LIBRARY_GROUP)
@@ -183,9 +183,8 @@
}
/** Build {@link PipelineMaker}. */
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- public PipelineMaker newPipelineMaker(
+ public @NonNull PipelineMaker newPipelineMaker(
@NonNull BiFunction<EnterTransition, View, AnimationSet> enterAnimationInflator,
@NonNull BiFunction<ExitTransition, View, AnimationSet> exitAnimationInflator) {
return new PipelineMaker(this, enterAnimationInflator, exitAnimationInflator, mEvaluator);
@@ -196,8 +195,7 @@
* inflators.
*/
@VisibleForTesting
- @NonNull
- public PipelineMaker newPipelineMaker() {
+ public @NonNull PipelineMaker newPipelineMaker() {
return newPipelineMaker(
(enterTransition, view) -> new AnimationSet(/* shareInterpolator= */ false),
(exitTransition, view) -> new AnimationSet(/* shareInterpolator= */ false));
@@ -235,20 +233,20 @@
*/
@RestrictTo(Scope.LIBRARY_GROUP)
public static final class PipelineMaker {
- @NonNull private final ProtoLayoutDynamicDataPipeline mPipeline;
+ private final @NonNull ProtoLayoutDynamicDataPipeline mPipeline;
- @NonNull
- private final BiFunction<EnterTransition, View, AnimationSet> mEnterAnimationInflator;
+ private final @NonNull BiFunction<EnterTransition, View, AnimationSet>
+ mEnterAnimationInflator;
- @NonNull
- private final BiFunction<ExitTransition, View, AnimationSet> mExitAnimationInflator;
+ private final @NonNull BiFunction<ExitTransition, View, AnimationSet>
+ mExitAnimationInflator;
// Stores pending nodes that are committed to the pipeline after a successful layout update.
- @NonNull private final Map<String, NodeInfo> mPosIdToNodeInfo = new ArrayMap<>();
- @NonNull private final List<String> mNodesPendingChildrenRemoval = new ArrayList<>();
- @NonNull private final Set<String> mChangedNodes = new ArraySet<>();
- @NonNull private final Set<String> mParentsOfChangedNodes = new ArraySet<>();
- @NonNull private final DynamicTypeEvaluator mEvaluator;
+ private final @NonNull Map<String, NodeInfo> mPosIdToNodeInfo = new ArrayMap<>();
+ private final @NonNull List<String> mNodesPendingChildrenRemoval = new ArrayList<>();
+ private final @NonNull Set<String> mChangedNodes = new ArraySet<>();
+ private final @NonNull Set<String> mParentsOfChangedNodes = new ArraySet<>();
+ private final @NonNull DynamicTypeEvaluator mEvaluator;
private int mExitAnimationsCounter = 0;
PipelineMaker(
@@ -502,8 +500,7 @@
}
}
- @NonNull
- private NodeInfo getNodeInfo(@NonNull String posId) {
+ private @NonNull NodeInfo getNodeInfo(@NonNull String posId) {
return mPosIdToNodeInfo.computeIfAbsent(
posId, k -> new NodeInfo(posId, mPipeline.mAnimationQuotaManager));
}
@@ -514,8 +511,7 @@
*/
@RestrictTo(Scope.LIBRARY_GROUP)
@SuppressWarnings("RestrictTo")
- @NonNull
- public PipelineMaker addPipelineFor(
+ public @NonNull PipelineMaker addPipelineFor(
@NonNull DynamicString stringSource,
@NonNull Locale locale,
@NonNull String posId,
@@ -533,8 +529,7 @@
*/
@RestrictTo(Scope.LIBRARY_GROUP)
@SuppressWarnings("RestrictTo")
- @NonNull
- public PipelineMaker addPipelineFor(
+ public @NonNull PipelineMaker addPipelineFor(
@NonNull DynamicInt32 int32Source,
@NonNull String posId,
@NonNull DynamicTypeValueReceiver<Integer> consumer) {
@@ -550,8 +545,7 @@
*/
@RestrictTo(Scope.LIBRARY_GROUP)
@SuppressWarnings("RestrictTo")
- @NonNull
- public PipelineMaker addPipelineFor(
+ public @NonNull PipelineMaker addPipelineFor(
@NonNull DynamicString stringSource,
@NonNull String invalidData,
@NonNull Locale locale,
@@ -567,8 +561,7 @@
*/
@RestrictTo(Scope.LIBRARY_GROUP)
@SuppressWarnings("RestrictTo")
- @NonNull
- public PipelineMaker addPipelineFor(
+ public @NonNull PipelineMaker addPipelineFor(
@NonNull DynamicFloat floatSource,
@NonNull String posId,
@NonNull DynamicTypeValueReceiver<Float> consumer) {
@@ -584,8 +577,7 @@
*/
@RestrictTo(Scope.LIBRARY_GROUP)
@SuppressWarnings("RestrictTo")
- @NonNull
- public PipelineMaker addPipelineFor(
+ public @NonNull PipelineMaker addPipelineFor(
@NonNull DynamicFloat floatSource,
float invalidData,
@NonNull String posId,
@@ -600,8 +592,7 @@
*/
@RestrictTo(Scope.LIBRARY_GROUP)
@SuppressWarnings("RestrictTo")
- @NonNull
- public PipelineMaker addPipelineFor(
+ public @NonNull PipelineMaker addPipelineFor(
@NonNull DynamicColor colorSource,
@NonNull String posId,
@NonNull DynamicTypeValueReceiver<Integer> consumer) {
@@ -616,8 +607,7 @@
* {@link PipelineMaker} is committed with {@link PipelineMaker#commit}.
*/
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public PipelineMaker addPipelineFor(
+ public @NonNull PipelineMaker addPipelineFor(
@NonNull DynamicBool boolSource,
@NonNull String posId,
@NonNull Runnable triggerAnimationRunnable) {
@@ -633,8 +623,7 @@
*/
@RestrictTo(Scope.LIBRARY_GROUP)
@SuppressWarnings("RestrictTo")
- @NonNull
- public PipelineMaker addPipelineFor(
+ public @NonNull PipelineMaker addPipelineFor(
@NonNull DynamicBool boolSource,
@NonNull String posId,
@NonNull DynamicTypeValueReceiver<Boolean> consumer) {
@@ -650,8 +639,7 @@
*/
@RestrictTo(Scope.LIBRARY_GROUP)
@SuppressWarnings("RestrictTo")
- @NonNull
- public PipelineMaker addPipelineFor(
+ public @NonNull PipelineMaker addPipelineFor(
@NonNull DynamicBool boolSource,
boolean invalidData,
@NonNull String posId,
@@ -664,9 +652,8 @@
* Add the given source to the pipeline for future evaluation. Evaluation will start when
* {@link PipelineMaker} is committed with {@link PipelineMaker#commit}.
*/
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- public PipelineMaker addPipelineFor(
+ public @NonNull PipelineMaker addPipelineFor(
@NonNull DpProp dpProp,
@NonNull String posId,
@NonNull DynamicTypeValueReceiver<Float> consumer) {
@@ -683,8 +670,7 @@
*/
@RestrictTo(Scope.LIBRARY_GROUP)
@SuppressWarnings("RestrictTo")
- @NonNull
- public PipelineMaker addPipelineFor(
+ public @NonNull PipelineMaker addPipelineFor(
@NonNull DegreesProp degreesProp,
@NonNull String posId,
@NonNull DynamicTypeValueReceiver<Float> consumer) {
@@ -701,8 +687,7 @@
*/
@RestrictTo(Scope.LIBRARY_GROUP)
@SuppressWarnings("RestrictTo")
- @NonNull
- public PipelineMaker addPipelineFor(
+ public @NonNull PipelineMaker addPipelineFor(
@NonNull ColorProp colorProp,
@NonNull String posId,
@NonNull DynamicTypeValueReceiver<Integer> consumer) {
@@ -719,8 +704,7 @@
*/
@RestrictTo(Scope.LIBRARY_GROUP)
@SuppressWarnings("RestrictTo")
- @NonNull
- public PipelineMaker addPipelineFor(
+ public @NonNull PipelineMaker addPipelineFor(
@NonNull BoolProp boolProp,
@NonNull String posId,
@NonNull DynamicTypeValueReceiver<Boolean> consumer) {
@@ -737,8 +721,7 @@
*/
@RestrictTo(Scope.LIBRARY_GROUP)
@SuppressWarnings("RestrictTo")
- @NonNull
- public PipelineMaker addPipelineFor(
+ public @NonNull PipelineMaker addPipelineFor(
@NonNull DpProp dpProp,
float invalidData,
@NonNull String posId,
@@ -752,8 +735,7 @@
*/
@RestrictTo(Scope.LIBRARY_GROUP)
@SuppressWarnings("RestrictTo")
- @NonNull
- public PipelineMaker addPipelineFor(
+ public @NonNull PipelineMaker addPipelineFor(
@NonNull DegreesProp degreesProp,
float invalidData,
@NonNull String posId,
@@ -768,8 +750,7 @@
*/
@RestrictTo(Scope.LIBRARY_GROUP)
@SuppressWarnings("RestrictTo")
- @NonNull
- public PipelineMaker addPipelineFor(
+ public @NonNull PipelineMaker addPipelineFor(
@NonNull ColorProp colorProp,
int invalidData,
@NonNull String posId,
@@ -784,8 +765,7 @@
*/
@RestrictTo(Scope.LIBRARY_GROUP)
@SuppressWarnings("RestrictTo")
- @NonNull
- public PipelineMaker addPipelineFor(
+ public @NonNull PipelineMaker addPipelineFor(
@NonNull BoolProp boolProp,
boolean invalidData,
@NonNull String posId,
@@ -810,8 +790,7 @@
/** This store method shall be called during the layout inflation in a background thread. */
@RestrictTo(Scope.LIBRARY_GROUP)
@SuppressLint("CheckReturnValue") // (b/247804720)
- @NonNull
- public PipelineMaker addResolvedAnimatedImage(
+ public @NonNull PipelineMaker addResolvedAnimatedImage(
@NonNull AnimatedVectorDrawable drawable,
@NonNull Trigger trigger,
@NonNull String posId) {
@@ -829,8 +808,7 @@
* adds given {@link DynamicBool} to the pipeline too.
*/
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public PipelineMaker addResolvedAnimatedImageWithBoolTrigger(
+ public @NonNull PipelineMaker addResolvedAnimatedImageWithBoolTrigger(
@NonNull AnimatedVectorDrawable drawable,
@NonNull Trigger trigger,
@NonNull String posId,
@@ -851,9 +829,8 @@
}
/** This store method shall be called during the layout inflation in a background thread. */
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- public PipelineMaker addResolvedSeekableAnimatedImage(
+ public @NonNull PipelineMaker addResolvedSeekableAnimatedImage(
@NonNull SeekableAnimatedVectorDrawable seekableDrawable,
@NonNull DynamicFloat boundProgress,
@NonNull String posId) {
@@ -879,9 +856,8 @@
}
/** Stores the {@link AnimatedVisibility} associated with the {@code posId}. */
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- public PipelineMaker storeAnimatedVisibilityFor(
+ public @NonNull PipelineMaker storeAnimatedVisibilityFor(
@NonNull String posId, @NonNull AnimatedVisibility animatedVisibility) {
if (!mPipeline.mEnableAnimations) {
Log.w(TAG, "Can't use AnimatedVisibility; animations are disabled.");
@@ -900,8 +876,7 @@
* as changed too. This is used for triggering Exit animations.
*/
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public PipelineMaker markNodeAsChanged(
+ public @NonNull PipelineMaker markNodeAsChanged(
@NonNull String posId, boolean includePreviousChildren) {
if (mPipeline.mEnableAnimations) {
mChangedNodes.add(posId);
@@ -910,9 +885,10 @@
return this;
}
- @NonNull
- private static DynamicTypeValueReceiver<Boolean> buildBooleanConditionTriggerCallback(
- @NonNull Runnable triggerAnimationRunnable, @NonNull QuotaManager quotaManager) {
+ private static @NonNull DynamicTypeValueReceiver<Boolean>
+ buildBooleanConditionTriggerCallback(
+ @NonNull Runnable triggerAnimationRunnable,
+ @NonNull QuotaManager quotaManager) {
return new DynamicTypeValueReceiver<Boolean>() {
private boolean mCurrent;
@@ -930,8 +906,7 @@
};
}
- @NonNull
- private <T> DynamicTypeValueReceiver<T> buildStateUpdateCallback(
+ private <T> @NonNull DynamicTypeValueReceiver<T> buildStateUpdateCallback(
@NonNull T invalidData, @NonNull Consumer<T> consumer) {
return new DynamicTypeValueReceiver<T>() {
@Override
@@ -950,17 +925,15 @@
* Add the given source to the pipeline for future evaluation. Evaluation will start when
* {@link PipelineMaker} is committed with {@link PipelineMaker#commit}.
*/
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- public PipelineMaker markForChildRemoval(@NonNull String nodePosId) {
+ public @NonNull PipelineMaker markForChildRemoval(@NonNull String nodePosId) {
mNodesPendingChildrenRemoval.add(nodePosId);
return this;
}
/** Stores a node if doesn't exist. Otherwise does nothing. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public PipelineMaker rememberNode(@NonNull String nodePosId) {
+ public @NonNull PipelineMaker rememberNode(@NonNull String nodePosId) {
NodeInfo ignored = getNodeInfo(nodePosId);
return this;
}
@@ -1016,7 +989,7 @@
/** Play the animation with the given trigger type. */
@RestrictTo(Scope.LIBRARY_GROUP)
@VisibleForTesting
- public void playAvdAnimations(@NonNull Trigger.InnerCase triggerCase) {
+ public void playAvdAnimations(Trigger.@NonNull InnerCase triggerCase) {
mPositionIdTree.forEach(info -> info.playAvdAnimations(triggerCase));
}
@@ -1030,7 +1003,7 @@
@UiThread
@VisibleForTesting
@RestrictTo(Scope.LIBRARY_GROUP)
- public void resetAvdAnimations(@NonNull Trigger.InnerCase triggerCase) {
+ public void resetAvdAnimations(Trigger.@NonNull InnerCase triggerCase) {
mPositionIdTree.forEach(info -> info.resetAvdAnimations(triggerCase));
}
@@ -1038,7 +1011,7 @@
@UiThread
@VisibleForTesting
@RestrictTo(Scope.LIBRARY_GROUP)
- public void stopAvdAnimations(@NonNull Trigger.InnerCase triggerCase) {
+ public void stopAvdAnimations(Trigger.@NonNull InnerCase triggerCase) {
mPositionIdTree.forEach(info -> info.stopAvdAnimations(triggerCase));
}
@@ -1087,8 +1060,7 @@
* StateSource with the given key name; or null if no such SourceKey exists.
*/
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Long getSeekableAnimationTotalDurationMillis(@NonNull String sourceKey) {
+ public @Nullable Long getSeekableAnimationTotalDurationMillis(@NonNull String sourceKey) {
NodeInfo node =
mPositionIdTree.findFirst(
nodeInfo ->
@@ -1105,8 +1077,7 @@
* {@code posId}
*/
@UiThread
- @NonNull
- List<NodeInfo> getNodesAffectedBy(
+ @NonNull List<NodeInfo> getNodesAffectedBy(
@NonNull String posId, @NonNull Predicate<NodeInfo> predicate) {
List<NodeInfo> affectedNodes = mPositionIdTree.findAncestorsFor(posId, predicate);
NodeInfo currentNode = mPositionIdTree.get(posId);
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/dynamicdata/QuotaAwareAnimationSet.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/dynamicdata/QuotaAwareAnimationSet.java
index af2d843..50506d9 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/dynamicdata/QuotaAwareAnimationSet.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/dynamicdata/QuotaAwareAnimationSet.java
@@ -23,12 +23,13 @@
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationSet;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.core.os.HandlerCompat;
import androidx.wear.protolayout.expression.pipeline.QuotaManager;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.concurrent.atomic.AtomicBoolean;
/**
@@ -36,21 +37,20 @@
* manager allows. Any existing listeners on wrapped {@link AnimationSet} will be replaced.
*/
final class QuotaAwareAnimationSet {
- @NonNull private final AnimationSet mAnimationSet;
- @NonNull private final QuotaManager mQuotaManager;
+ private final @NonNull AnimationSet mAnimationSet;
+ private final @NonNull QuotaManager mQuotaManager;
- @NonNull private final View mAssociatedView;
- @NonNull private final QuotaReleasingAnimationListener mListener;
+ private final @NonNull View mAssociatedView;
+ private final @NonNull QuotaReleasingAnimationListener mListener;
- @Nullable private final Runnable mOnAnimationEnd;
+ private final @Nullable Runnable mOnAnimationEnd;
private final long mCommonDelay;
- @NonNull private final Handler mUiHandler;
+ private final @NonNull Handler mUiHandler;
// Suppress initialization warnings here. These are only used inside of methods, and this class
// is final, so these cannot actually be referenced while the class is under initialization.
@SuppressWarnings("methodref.receiver.bound")
- @NonNull
- private final Runnable mTryAcquireQuotaAndStartAnimation =
+ private final @NonNull Runnable mTryAcquireQuotaAndStartAnimation =
this::tryAcquireQuotaAndStartAnimation;
QuotaAwareAnimationSet(
@@ -153,10 +153,10 @@
private static final class QuotaReleasingAnimationListener implements AnimationListener {
- @Nullable private final Runnable mOnAnimationEnd;
- @NonNull private final QuotaManager mQuotaManager;
+ private final @Nullable Runnable mOnAnimationEnd;
+ private final @NonNull QuotaManager mQuotaManager;
private final int mAnimationNum;
- @NonNull final AtomicBoolean mIsUsingQuota = new AtomicBoolean(false);
+ final @NonNull AtomicBoolean mIsUsingQuota = new AtomicBoolean(false);
QuotaReleasingAnimationListener(
@NonNull QuotaManager mQuotaManager,
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/impl/ProtoLayoutViewInstance.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/impl/ProtoLayoutViewInstance.java
index 0274630..0bad993 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/impl/ProtoLayoutViewInstance.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/impl/ProtoLayoutViewInstance.java
@@ -37,8 +37,6 @@
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.annotation.UiThread;
@@ -85,6 +83,9 @@
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.SettableFuture;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -126,21 +127,21 @@
private static final int DEFAULT_MAX_CONCURRENT_RUNNING_ANIMATIONS = 4;
static final int MAX_LAYOUT_ELEMENT_DEPTH = 30;
- @NonNull private static final String TAG = "ProtoLayoutViewInstance";
+ private static final @NonNull String TAG = "ProtoLayoutViewInstance";
- @NonNull private final Context mUiContext;
- @NonNull private final Resources mRendererResources;
- @NonNull private final ResourceResolversProvider mResourceResolversProvider;
- @NonNull private final ProtoLayoutTheme mProtoLayoutTheme;
- @Nullable private final ProtoLayoutDynamicDataPipeline mDataPipeline;
- @NonNull private final LoadActionListener mLoadActionListener;
- @NonNull private final ListeningExecutorService mUiExecutorService;
- @NonNull private final ListeningExecutorService mBgExecutorService;
- @NonNull private final String mClickableIdExtra;
- @NonNull private final ProviderStatsLogger mProviderStatsLogger;
- @Nullable private final LoggingUtils mLoggingUtils;
+ private final @NonNull Context mUiContext;
+ private final @NonNull Resources mRendererResources;
+ private final @NonNull ResourceResolversProvider mResourceResolversProvider;
+ private final @NonNull ProtoLayoutTheme mProtoLayoutTheme;
+ private final @Nullable ProtoLayoutDynamicDataPipeline mDataPipeline;
+ private final @NonNull LoadActionListener mLoadActionListener;
+ private final @NonNull ListeningExecutorService mUiExecutorService;
+ private final @NonNull ListeningExecutorService mBgExecutorService;
+ private final @NonNull String mClickableIdExtra;
+ private final @NonNull ProviderStatsLogger mProviderStatsLogger;
+ private final @Nullable LoggingUtils mLoggingUtils;
- @Nullable private final ProtoLayoutExtensionViewProvider mExtensionViewProvider;
+ private final @Nullable ProtoLayoutExtensionViewProvider mExtensionViewProvider;
private final boolean mAnimationEnabled;
@@ -149,7 +150,7 @@
private final boolean mAllowLayoutChangingBindsWithoutDefault;
/** This keeps track of the current inflated parent for the layout. */
- @Nullable private ViewGroup mInflateParent = null;
+ private @Nullable ViewGroup mInflateParent = null;
/**
* This is simply a reference to the current parent for this layout instance (i.e. the last
@@ -164,13 +165,13 @@
*
* <p>This field should only ever be accessed from the UI thread.
*/
- @Nullable private ViewGroup mAttachParent = null;
+ private @Nullable ViewGroup mAttachParent = null;
/**
* This field is used to avoid unnecessary rendering when dealing with non-interactive layouts.
* For interactive layouts, the diffing should already handle this.
*/
- @Nullable private Layout mPrevLayout = null;
+ private @Nullable Layout mPrevLayout = null;
/**
* This field is used to avoid unnecessarily checking layout depth if the layout was previously
@@ -183,7 +184,7 @@
* could result in the resource change not getting reflected with diff rendering (if the layout
* pointing to that resource hasn't changed)
*/
- @Nullable private String mPrevResourcesVersion = null;
+ private @Nullable String mPrevResourcesVersion = null;
/**
* This is used as the Future for the currently running inflation session. The first time
@@ -211,17 +212,16 @@
public interface ResourceResolversProvider {
/** Provide a {@link ResourceResolvers} instance */
- @Nullable
- ResourceResolvers getResourceResolvers(
+ @Nullable ResourceResolvers getResourceResolvers(
@NonNull Context context,
- @NonNull ResourceProto.Resources resources,
+ ResourceProto.@NonNull Resources resources,
@NonNull ListeningExecutorService listeningExecutorService,
boolean animationEnabled);
}
/** Data about a parent that a layout has been inflated into. */
static final class InflateParentData {
- @Nullable final InflateResult mInflateResult;
+ final @Nullable InflateResult mInflateResult;
InflateParentData(@Nullable InflateResult inflateResult) {
this.mInflateResult = inflateResult;
@@ -242,8 +242,7 @@
* transition animations.
*/
@UiThread
- @NonNull
- ListenableFuture<RenderingArtifact> postInflate(
+ @NonNull ListenableFuture<RenderingArtifact> postInflate(
@NonNull ViewGroup attachParent,
@Nullable ViewGroup prevInflateParent,
boolean isReattaching,
@@ -257,9 +256,8 @@
return false;
}
- @NonNull
@Override
- public ListenableFuture<RenderingArtifact> postInflate(
+ public @NonNull ListenableFuture<RenderingArtifact> postInflate(
@NonNull ViewGroup attachParent,
@Nullable ViewGroup prevInflateParent,
boolean isReattaching,
@@ -275,9 +273,8 @@
return false;
}
- @NonNull
@Override
- public ListenableFuture<RenderingArtifact> postInflate(
+ public @NonNull ListenableFuture<RenderingArtifact> postInflate(
@NonNull ViewGroup attachParent,
@Nullable ViewGroup prevInflateParent,
boolean isReattaching,
@@ -291,7 +288,7 @@
* new parent.
*/
static final class InflatedIntoNewParentRenderResult implements RenderResult {
- @NonNull final InflateParentData mNewInflateParentData;
+ final @NonNull InflateParentData mNewInflateParentData;
InflatedIntoNewParentRenderResult(@NonNull InflateParentData newInflateParentData) {
this.mNewInflateParentData = newInflateParentData;
@@ -302,10 +299,9 @@
return true;
}
- @NonNull
@Override
@UiThread
- public ListenableFuture<RenderingArtifact> postInflate(
+ public @NonNull ListenableFuture<RenderingArtifact> postInflate(
@NonNull ViewGroup attachParent,
@Nullable ViewGroup prevInflateParent,
boolean isReattaching,
@@ -329,8 +325,8 @@
* needs to be applied to the previous parent.
*/
static final class ApplyToPrevParentRenderResult implements RenderResult {
- @NonNull final ProtoLayoutInflater mInflater;
- @NonNull final ViewGroupMutation mMutation;
+ final @NonNull ProtoLayoutInflater mInflater;
+ final @NonNull ViewGroupMutation mMutation;
ApplyToPrevParentRenderResult(
@NonNull ProtoLayoutInflater inflater, @NonNull ViewGroupMutation mutation) {
@@ -343,10 +339,9 @@
return false;
}
- @NonNull
@Override
@UiThread
- public ListenableFuture<RenderingArtifact> postInflate(
+ public @NonNull ListenableFuture<RenderingArtifact> postInflate(
@NonNull ViewGroup attachParent,
@Nullable ViewGroup prevInflateParent,
boolean isReattaching,
@@ -358,23 +353,23 @@
/** Config class for {@link ProtoLayoutViewInstance}. */
@RestrictTo(Scope.LIBRARY_GROUP_PREFIX)
public static final class Config {
- @NonNull private final Context mUiContext;
- @NonNull private final Resources mRendererResources;
- @NonNull private final ResourceResolversProvider mResourceResolversProvider;
- @NonNull private final ProtoLayoutTheme mProtoLayoutTheme;
+ private final @NonNull Context mUiContext;
+ private final @NonNull Resources mRendererResources;
+ private final @NonNull ResourceResolversProvider mResourceResolversProvider;
+ private final @NonNull ProtoLayoutTheme mProtoLayoutTheme;
- @NonNull
- private final Map<PlatformDataProvider, Set<PlatformDataKey<?>>> mPlatformDataProviders;
+ private final @NonNull Map<PlatformDataProvider, Set<PlatformDataKey<?>>>
+ mPlatformDataProviders;
- @Nullable private final StateStore mStateStore;
- @NonNull private final LoadActionListener mLoadActionListener;
- @NonNull private final ListeningExecutorService mUiExecutorService;
- @NonNull private final ListeningExecutorService mBgExecutorService;
- @Nullable private final ProtoLayoutExtensionViewProvider mExtensionViewProvider;
- @NonNull private final String mClickableIdExtra;
+ private final @Nullable StateStore mStateStore;
+ private final @NonNull LoadActionListener mLoadActionListener;
+ private final @NonNull ListeningExecutorService mUiExecutorService;
+ private final @NonNull ListeningExecutorService mBgExecutorService;
+ private final @Nullable ProtoLayoutExtensionViewProvider mExtensionViewProvider;
+ private final @NonNull String mClickableIdExtra;
- @Nullable private final LoggingUtils mLoggingUtils;
- @NonNull private final ProviderStatsLogger mProviderStatsLogger;
+ private final @Nullable LoggingUtils mLoggingUtils;
+ private final @NonNull ProviderStatsLogger mProviderStatsLogger;
private final boolean mAnimationEnabled;
private final int mRunningAnimationsLimit;
@@ -425,85 +420,73 @@
}
/** Returns UI Context used for interacting with the UI. */
- @NonNull
- public Context getUiContext() {
+ public @NonNull Context getUiContext() {
return mUiContext;
}
/** Returns the Android Resources object for the renderer package. */
@RestrictTo(Scope.LIBRARY)
- @NonNull
- public Resources getRendererResources() {
+ public @NonNull Resources getRendererResources() {
return mRendererResources;
}
/** Returns provider for resolving resources. */
@RestrictTo(Scope.LIBRARY)
- @NonNull
- public ResourceResolversProvider getResourceResolversProvider() {
+ public @NonNull ResourceResolversProvider getResourceResolversProvider() {
return mResourceResolversProvider;
}
/** Returns theme used for this instance. */
- @NonNull
@RestrictTo(Scope.LIBRARY)
- public ProtoLayoutTheme getProtoLayoutTheme() {
+ public @NonNull ProtoLayoutTheme getProtoLayoutTheme() {
return mProtoLayoutTheme;
}
/** Returns the registered platform data providers. */
- @NonNull
- public Map<PlatformDataProvider, Set<PlatformDataKey<?>>> getPlatformDataProviders() {
+ public @NonNull Map<PlatformDataProvider, Set<PlatformDataKey<?>>>
+ getPlatformDataProviders() {
return mPlatformDataProviders;
}
/** Returns state store. */
- @Nullable
- public StateStore getStateStore() {
+ public @Nullable StateStore getStateStore() {
return mStateStore;
}
/** Returns listener for load actions. */
- @NonNull
- public LoadActionListener getLoadActionListener() {
+ public @NonNull LoadActionListener getLoadActionListener() {
return mLoadActionListener;
}
/** Returns ExecutorService for UI tasks. */
- @NonNull
- public ListeningExecutorService getUiExecutorService() {
+ public @NonNull ListeningExecutorService getUiExecutorService() {
return mUiExecutorService;
}
/** Returns ExecutorService for background tasks. */
- @NonNull
- public ListeningExecutorService getBgExecutorService() {
+ public @NonNull ListeningExecutorService getBgExecutorService() {
return mBgExecutorService;
}
/** Returns provider for renderer extension. */
@RestrictTo(Scope.LIBRARY)
- @Nullable
- public ProtoLayoutExtensionViewProvider getExtensionViewProvider() {
+ public @Nullable ProtoLayoutExtensionViewProvider getExtensionViewProvider() {
return mExtensionViewProvider;
}
/** Returns extra used for storing clickable id. */
- @NonNull
- public String getClickableIdExtra() {
+ public @NonNull String getClickableIdExtra() {
return mClickableIdExtra;
}
/** Returns the debug logger. */
- @Nullable
- public LoggingUtils getLoggingUtils() {
+ public @Nullable LoggingUtils getLoggingUtils() {
return mLoggingUtils;
}
/** Returns the provider stats logger used for telemetry. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ProviderStatsLogger getProviderStatsLogger() {
+ public @NonNull ProviderStatsLogger getProviderStatsLogger() {
return mProviderStatsLogger;
}
@@ -552,23 +535,22 @@
/** Builder for {@link Config}. */
@RestrictTo(Scope.LIBRARY_GROUP_PREFIX)
public static final class Builder {
- @NonNull private final Context mUiContext;
- @Nullable private Resources mRendererResources;
- @Nullable private ResourceResolversProvider mResourceResolversProvider;
- @Nullable private ProtoLayoutTheme mProtoLayoutTheme;
+ private final @NonNull Context mUiContext;
+ private @Nullable Resources mRendererResources;
+ private @Nullable ResourceResolversProvider mResourceResolversProvider;
+ private @Nullable ProtoLayoutTheme mProtoLayoutTheme;
- @NonNull
- private final Map<PlatformDataProvider, Set<PlatformDataKey<?>>>
+ private final @NonNull Map<PlatformDataProvider, Set<PlatformDataKey<?>>>
mPlatformDataProviders = new ArrayMap<>();
- @Nullable private StateStore mStateStore;
- @Nullable private LoadActionListener mLoadActionListener;
- @NonNull private final ListeningExecutorService mUiExecutorService;
- @NonNull private final ListeningExecutorService mBgExecutorService;
- @Nullable private ProtoLayoutExtensionViewProvider mExtensionViewProvider;
- @NonNull private final String mClickableIdExtra;
- @Nullable private LoggingUtils mLoggingUtils;
- @Nullable private ProviderStatsLogger mProviderStatsLogger;
+ private @Nullable StateStore mStateStore;
+ private @Nullable LoadActionListener mLoadActionListener;
+ private final @NonNull ListeningExecutorService mUiExecutorService;
+ private final @NonNull ListeningExecutorService mBgExecutorService;
+ private @Nullable ProtoLayoutExtensionViewProvider mExtensionViewProvider;
+ private final @NonNull String mClickableIdExtra;
+ private @Nullable LoggingUtils mLoggingUtils;
+ private @Nullable ProviderStatsLogger mProviderStatsLogger;
private boolean mAnimationEnabled = true;
private int mRunningAnimationsLimit = DEFAULT_MAX_CONCURRENT_RUNNING_ANIMATIONS;
@@ -597,9 +579,8 @@
}
/** Sets provider for resolving resources. */
- @NonNull
@RestrictTo(Scope.LIBRARY)
- public Builder setResourceResolverProvider(
+ public @NonNull Builder setResourceResolverProvider(
@NonNull ResourceResolversProvider resourceResolversProvider) {
this.mResourceResolversProvider = resourceResolversProvider;
return this;
@@ -611,9 +592,8 @@
* android.content.pm.PackageManager#getResourcesForApplication(String)}. If not
* specified, this is retrieved from the Ui Context.
*/
- @NonNull
@RestrictTo(Scope.LIBRARY)
- public Builder setRendererResources(@NonNull Resources rendererResources) {
+ public @NonNull Builder setRendererResources(@NonNull Resources rendererResources) {
this.mRendererResources = rendererResources;
return this;
}
@@ -622,25 +602,23 @@
* Sets theme for this ProtoLayout instance. If not set, default theme would be used.
*/
@RestrictTo(Scope.LIBRARY)
- @NonNull
- public Builder setProtoLayoutTheme(@NonNull ProtoLayoutTheme protoLayoutTheme) {
+ public @NonNull Builder setProtoLayoutTheme(
+ @NonNull ProtoLayoutTheme protoLayoutTheme) {
this.mProtoLayoutTheme = protoLayoutTheme;
return this;
}
/** Adds a {@link PlatformDataProvider} for accessing {@code supportedKeys}. */
- @NonNull
- public Builder addPlatformDataProvider(
+ public @NonNull Builder addPlatformDataProvider(
@NonNull PlatformDataProvider platformDataProvider,
- @NonNull PlatformDataKey<?>... supportedKeys) {
+ PlatformDataKey<?> @NonNull ... supportedKeys) {
this.mPlatformDataProviders.put(
platformDataProvider, ImmutableSet.copyOf(supportedKeys));
return this;
}
/** Sets the storage for state updates. */
- @NonNull
- public Builder setStateStore(@NonNull StateStore stateStore) {
+ public @NonNull Builder setStateStore(@NonNull StateStore stateStore) {
this.mStateStore = stateStore;
return this;
}
@@ -649,16 +627,15 @@
* Sets the listener for clicks that will cause contents to be reloaded. Defaults to
* no-op.
*/
- @NonNull
- public Builder setLoadActionListener(@NonNull LoadActionListener loadActionListener) {
+ public @NonNull Builder setLoadActionListener(
+ @NonNull LoadActionListener loadActionListener) {
this.mLoadActionListener = loadActionListener;
return this;
}
/** Sets provider for the renderer extension. */
@RestrictTo(Scope.LIBRARY)
- @NonNull
- public Builder setExtensionViewProvider(
+ public @NonNull Builder setExtensionViewProvider(
@NonNull ProtoLayoutExtensionViewProvider extensionViewProvider) {
this.mExtensionViewProvider = extensionViewProvider;
return this;
@@ -666,16 +643,14 @@
/** Sets the debug logger. */
@RestrictTo(Scope.LIBRARY)
- @NonNull
- public Builder setLoggingUtils(@NonNull LoggingUtils loggingUitls) {
+ public @NonNull Builder setLoggingUtils(@NonNull LoggingUtils loggingUitls) {
this.mLoggingUtils = loggingUitls;
return this;
}
/** Sets the provider stats logger used for telemetry. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public Builder setProviderStatsLogger(
+ public @NonNull Builder setProviderStatsLogger(
@NonNull ProviderStatsLogger providerStatsLogger) {
this.mProviderStatsLogger = providerStatsLogger;
return this;
@@ -686,40 +661,36 @@
* played.
*/
@RestrictTo(Scope.LIBRARY)
- @NonNull
- public Builder setAnimationEnabled(boolean animationEnabled) {
+ public @NonNull Builder setAnimationEnabled(boolean animationEnabled) {
this.mAnimationEnabled = animationEnabled;
return this;
}
/** Sets the limit to how much concurrently running animations are allowed. */
@RestrictTo(Scope.LIBRARY)
- @NonNull
- public Builder setRunningAnimationsLimit(int runningAnimationsLimit) {
+ public @NonNull Builder setRunningAnimationsLimit(int runningAnimationsLimit) {
this.mRunningAnimationsLimit = runningAnimationsLimit;
return this;
}
/** Sets whether sending updates is enabled. */
@RestrictTo(Scope.LIBRARY)
- @NonNull
- public Builder setUpdatesEnabled(boolean updatesEnabled) {
+ public @NonNull Builder setUpdatesEnabled(boolean updatesEnabled) {
this.mUpdatesEnabled = updatesEnabled;
return this;
}
/** Sets whether adaptive updates rates is enabled. */
@RestrictTo(Scope.LIBRARY)
- @NonNull
- public Builder setAdaptiveUpdateRatesEnabled(boolean adaptiveUpdateRatesEnabled) {
+ public @NonNull Builder setAdaptiveUpdateRatesEnabled(
+ boolean adaptiveUpdateRatesEnabled) {
this.mAdaptiveUpdateRatesEnabled = adaptiveUpdateRatesEnabled;
return this;
}
/** Sets whether the view is fully visible. */
@RestrictTo(Scope.LIBRARY)
- @NonNull
- public Builder setIsViewFullyVisible(boolean isViewFullyVisible) {
+ public @NonNull Builder setIsViewFullyVisible(boolean isViewFullyVisible) {
this.mIsViewFullyVisible = isViewFullyVisible;
return this;
}
@@ -733,8 +704,7 @@
* support was built.
*/
@RestrictTo(Scope.LIBRARY)
- @NonNull
- public Builder setAllowLayoutChangingBindsWithoutDefault(
+ public @NonNull Builder setAllowLayoutChangingBindsWithoutDefault(
boolean allowLayoutChangingBindsWithoutDefault) {
this.mAllowLayoutChangingBindsWithoutDefault =
allowLayoutChangingBindsWithoutDefault;
@@ -742,8 +712,7 @@
}
/** Builds {@link Config} object. */
- @NonNull
- public Config build() {
+ public @NonNull Config build() {
LoadActionListener loadActionListener = mLoadActionListener;
if (loadActionListener == null) {
loadActionListener = p -> {};
@@ -858,10 +827,9 @@
}
@WorkerThread
- @NonNull
- private RenderResult renderOrComputeMutations(
+ private @NonNull RenderResult renderOrComputeMutations(
@NonNull Layout layout,
- @NonNull ResourceProto.Resources resources,
+ ResourceProto.@NonNull Resources resources,
@Nullable RenderedMetadata prevRenderedMetadata,
@NonNull ViewProperties parentViewProp,
@NonNull InflaterStatsLogger inflaterStatsLogger) {
@@ -916,7 +884,7 @@
ProtoLayoutInflater inflater = new ProtoLayoutInflater(inflaterConfigBuilder.build());
// mark the view and skip doing diff update (to avoid doubling the work each time).
- @Nullable ViewGroupMutation mutation = null;
+ ViewGroupMutation mutation = null;
if (mAdaptiveUpdateRatesEnabled && prevRenderedMetadata != null) {
// Compute the mutation here, but if there is a change, apply it in the UI thread.
try {
@@ -947,8 +915,7 @@
// setLayoutParams.
@SuppressWarnings({"nullness:dereference.of.nullable", "nullness:argument"})
@WorkerThread
- @NonNull
- private InflateParentData inflateIntoNewParent(
+ private @NonNull InflateParentData inflateIntoNewParent(
@NonNull Context uiContext, @NonNull ProtoLayoutInflater inflater) {
FrameLayout inflateParent;
int gravity;
@@ -973,10 +940,9 @@
@UiThread
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
- @NonNull
- public ListenableFuture<RenderingArtifact> renderLayoutAndAttach(
+ public @NonNull ListenableFuture<RenderingArtifact> renderLayoutAndAttach(
@NonNull Layout layout,
- @NonNull ResourceProto.Resources resources,
+ ResourceProto.@NonNull Resources resources,
@NonNull ViewGroup attachParent) {
return renderAndAttach(
@@ -1003,10 +969,9 @@
"ReferenceEquality",
"ExecutorTaskName",
}) // layout == prevLayout is intentional (and enough in this case)
- @NonNull
- public ListenableFuture<Void> renderAndAttach(
+ public @NonNull ListenableFuture<Void> renderAndAttach(
@NonNull Layout layout,
- @NonNull ResourceProto.Resources resources,
+ ResourceProto.@NonNull Resources resources,
@NonNull ViewGroup attachParent) {
SettableFuture<Void> result = SettableFuture.create();
ListenableFuture<RenderingArtifact> future =
@@ -1043,10 +1008,9 @@
"ReferenceEquality",
"ExecutorTaskName",
}) // layout == prevLayout is intentional (and enough in this case)
- @NonNull
- private ListenableFuture<RenderingArtifact> renderAndAttach(
+ private @NonNull ListenableFuture<RenderingArtifact> renderAndAttach(
@NonNull Layout layout,
- @NonNull ResourceProto.Resources resources,
+ ResourceProto.@NonNull Resources resources,
@NonNull ViewGroup attachParent,
@NonNull InflaterStatsLogger inflaterStatsLogger) {
if (mLoggingUtils != null && mLoggingUtils.canLogD(TAG)) {
@@ -1086,7 +1050,7 @@
}
}
- @Nullable ViewGroup prevInflateParent = getOnlyChildViewGroup(attachParent);
+ ViewGroup prevInflateParent = getOnlyChildViewGroup(attachParent);
if (mRenderFuture == null) {
if (prevInflateParent != null
@@ -1096,8 +1060,7 @@
ProtoLayoutInflater.clearRenderedMetadata(checkNotNull(prevInflateParent));
}
- @Nullable
- RenderedMetadata prevRenderedMetadata =
+ RenderedMetadata prevRenderedMetadata =
prevInflateParent != null
? ProtoLayoutInflater.getRenderedMetadata(prevInflateParent)
: null;
@@ -1213,8 +1176,7 @@
}
}
- @Nullable
- private static ViewGroup getOnlyChildViewGroup(@NonNull ViewGroup parent) {
+ private static @Nullable ViewGroup getOnlyChildViewGroup(@NonNull ViewGroup parent) {
if (parent.getChildCount() == 1) {
View child = parent.getChildAt(0);
if (child instanceof ViewGroup) {
@@ -1226,14 +1188,13 @@
@UiThread
@SuppressWarnings("ExecutorTaskName")
- @NonNull
- private ListenableFuture<RenderingArtifact> postInflate(
+ private @NonNull ListenableFuture<RenderingArtifact> postInflate(
@NonNull ViewGroup attachParent,
@Nullable ViewGroup prevInflateParent,
@NonNull RenderResult renderResult,
boolean isReattaching,
@NonNull Layout layout,
- @NonNull ResourceProto.Resources resources,
+ ResourceProto.@NonNull Resources resources,
InflaterStatsLogger inflaterStatsLogger) {
mCanReattachWithoutRendering = renderResult.canReattachWithoutRendering();
@@ -1288,11 +1249,10 @@
@UiThread
@SuppressWarnings("ReferenceEquality") // layout == prevLayout is intentional
- @NonNull
- private ListenableFuture<RenderingArtifact> handlePostInflateFailure(
+ private @NonNull ListenableFuture<RenderingArtifact> handlePostInflateFailure(
@NonNull Throwable error,
@NonNull Layout layout,
- @NonNull ResourceProto.Resources resources,
+ ResourceProto.@NonNull Resources resources,
@Nullable ViewGroup prevInflateParent,
@NonNull ViewGroup parent,
InflaterStatsLogger inflaterStatsLogger) {
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ContentUriValidator.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ContentUriValidator.java
index 39c4ea6..d902048 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ContentUriValidator.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ContentUriValidator.java
@@ -23,14 +23,15 @@
import android.net.Uri;
import android.os.Process;
-import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
+import org.jspecify.annotations.NonNull;
+
class ContentUriValidator {
- @NonNull final Context mAppContext;
- @NonNull private final PackageManager mPackageManager;
- @NonNull private final String mAllowedPackageName;
- @NonNull private final UriPermissionValidator mUriPermissionValidator;
+ final @NonNull Context mAppContext;
+ private final @NonNull PackageManager mPackageManager;
+ private final @NonNull String mAllowedPackageName;
+ private final @NonNull UriPermissionValidator mUriPermissionValidator;
public ContentUriValidator(@NonNull Context appContext, @NonNull String allowedPackageName) {
this.mAppContext = appContext;
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/CustomTypefaceSpan.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/CustomTypefaceSpan.java
index 35b3215..e2395fe 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/CustomTypefaceSpan.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/CustomTypefaceSpan.java
@@ -20,14 +20,14 @@
import android.text.TextPaint;
import android.text.style.MetricAffectingSpan;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* Stripped down version of TypefaceSpan, which can accept a Typeface argument on API levels under
* 28.
*/
public class CustomTypefaceSpan extends MetricAffectingSpan {
- @NonNull private final Typeface mTypeface;
+ private final @NonNull Typeface mTypeface;
public CustomTypefaceSpan(@NonNull Typeface typeface) {
mTypeface = typeface;
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultAndroidAnimatedImageResourceByResIdResolver.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultAndroidAnimatedImageResourceByResIdResolver.java
index 5b2fd8e..79b7f28 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultAndroidAnimatedImageResourceByResIdResolver.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultAndroidAnimatedImageResourceByResIdResolver.java
@@ -19,17 +19,18 @@
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
-import androidx.annotation.NonNull;
import androidx.wear.protolayout.proto.ResourceProto.AndroidAnimatedImageResourceByResId;
import androidx.wear.protolayout.proto.ResourceProto.AnimatedImageFormat;
import androidx.wear.protolayout.renderer.inflater.ResourceResolvers.AndroidAnimatedImageResourceByResIdResolver;
import androidx.wear.protolayout.renderer.inflater.ResourceResolvers.ResourceAccessException;
+import org.jspecify.annotations.NonNull;
+
/** Resource resolver for Android animated resources. */
public class DefaultAndroidAnimatedImageResourceByResIdResolver
implements AndroidAnimatedImageResourceByResIdResolver {
- @NonNull private final Resources mAndroidResources;
+ private final @NonNull Resources mAndroidResources;
/**
* Constructor.
@@ -41,10 +42,9 @@
this.mAndroidResources = androidResources;
}
- @NonNull
@Override
- public Drawable getDrawableOrThrow(@NonNull AndroidAnimatedImageResourceByResId resource)
- throws ResourceAccessException {
+ public @NonNull Drawable getDrawableOrThrow(
+ @NonNull AndroidAnimatedImageResourceByResId resource) throws ResourceAccessException {
if (resource.getAnimatedImageFormat() == AnimatedImageFormat.ANIMATED_IMAGE_FORMAT_AVD) {
return mAndroidResources.getDrawable(resource.getResourceId(), /* theme= */ null);
}
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultAndroidImageResourceByContentUriResolver.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultAndroidImageResourceByContentUriResolver.java
index 14e2fa6..efae366 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultAndroidImageResourceByContentUriResolver.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultAndroidImageResourceByContentUriResolver.java
@@ -24,7 +24,6 @@
import android.graphics.drawable.Drawable;
import android.net.Uri;
-import androidx.annotation.NonNull;
import androidx.concurrent.futures.ResolvableFuture;
import androidx.wear.protolayout.proto.ResourceProto.AndroidImageResourceByContentUri;
import androidx.wear.protolayout.renderer.inflater.ResourceResolvers.AndroidImageResourceByContentUriResolver;
@@ -32,6 +31,8 @@
import com.google.common.util.concurrent.ListenableFuture;
+import org.jspecify.annotations.NonNull;
+
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@@ -40,12 +41,12 @@
/** Resource resolver for Android resources, accessed by Content URI. */
public class DefaultAndroidImageResourceByContentUriResolver
implements AndroidImageResourceByContentUriResolver {
- @NonNull private static final String TAG = "AndroidContentUriResolver";
+ private static final @NonNull String TAG = "AndroidContentUriResolver";
- @NonNull private final ContentUriValidator mContentUriValidator;
- @NonNull private final Resources mPackageResources;
- @NonNull private final ContentResolver mContentResolver;
- @NonNull private final Executor mLoadExecutor;
+ private final @NonNull ContentUriValidator mContentUriValidator;
+ private final @NonNull Resources mPackageResources;
+ private final @NonNull ContentResolver mContentResolver;
+ private final @NonNull Executor mLoadExecutor;
public DefaultAndroidImageResourceByContentUriResolver(
@NonNull Context appContext,
@@ -59,9 +60,8 @@
this.mLoadExecutor = loadExecutor;
}
- @NonNull
- private Drawable getDrawableBlocking(@NonNull AndroidImageResourceByContentUri resource)
- throws ResourceAccessException {
+ private @NonNull Drawable getDrawableBlocking(
+ @NonNull AndroidImageResourceByContentUri resource) throws ResourceAccessException {
Uri resourceUri = Uri.parse(resource.getContentUri());
if (!mContentUriValidator.validateUri(resourceUri)) {
throw new IllegalArgumentException(
@@ -84,9 +84,8 @@
}
}
- @NonNull
@Override
- public ListenableFuture<Drawable> getDrawable(
+ public @NonNull ListenableFuture<Drawable> getDrawable(
@NonNull AndroidImageResourceByContentUri resource) {
ResolvableFuture<Drawable> resolvableFuture = ResolvableFuture.create();
mLoadExecutor.execute(
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultAndroidImageResourceByResIdResolver.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultAndroidImageResourceByResIdResolver.java
index 0989b25..2637180 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultAndroidImageResourceByResIdResolver.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultAndroidImageResourceByResIdResolver.java
@@ -20,15 +20,16 @@
import android.content.res.Resources.NotFoundException;
import android.graphics.drawable.Drawable;
-import androidx.annotation.NonNull;
import androidx.wear.protolayout.proto.ResourceProto.AndroidImageResourceByResId;
import androidx.wear.protolayout.renderer.inflater.ResourceResolvers.AndroidImageResourceByResIdResolver;
import androidx.wear.protolayout.renderer.inflater.ResourceResolvers.ResourceAccessException;
+import org.jspecify.annotations.NonNull;
+
/** Resource resolver for Android resources. */
public class DefaultAndroidImageResourceByResIdResolver
implements AndroidImageResourceByResIdResolver {
- @NonNull private final Resources mAndroidResources;
+ private final @NonNull Resources mAndroidResources;
/**
* Constructor.
@@ -40,9 +41,8 @@
this.mAndroidResources = androidResources;
}
- @NonNull
@Override
- public Drawable getDrawableOrThrow(@NonNull AndroidImageResourceByResId resource)
+ public @NonNull Drawable getDrawableOrThrow(@NonNull AndroidImageResourceByResId resource)
throws ResourceAccessException {
try {
return mAndroidResources.getDrawable(resource.getResourceId(), /* theme= */ null);
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultAndroidSeekableAnimatedImageResourceByResIdResolver.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultAndroidSeekableAnimatedImageResourceByResIdResolver.java
index eed00eb..8d0d95b 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultAndroidSeekableAnimatedImageResourceByResIdResolver.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultAndroidSeekableAnimatedImageResourceByResIdResolver.java
@@ -22,13 +22,13 @@
import android.util.Log;
import android.util.Xml;
-import androidx.annotation.NonNull;
import androidx.vectordrawable.graphics.drawable.SeekableAnimatedVectorDrawable;
import androidx.wear.protolayout.proto.ResourceProto.AndroidSeekableAnimatedImageResourceByResId;
import androidx.wear.protolayout.proto.ResourceProto.AnimatedImageFormat;
import androidx.wear.protolayout.renderer.inflater.ResourceResolvers.AndroidSeekableAnimatedImageResourceByResIdResolver;
import androidx.wear.protolayout.renderer.inflater.ResourceResolvers.ResourceAccessException;
+import org.jspecify.annotations.NonNull;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -38,7 +38,7 @@
public class DefaultAndroidSeekableAnimatedImageResourceByResIdResolver
implements AndroidSeekableAnimatedImageResourceByResIdResolver {
- @NonNull private final Resources mAndroidResources;
+ private final @NonNull Resources mAndroidResources;
/**
* Constructor.
@@ -51,9 +51,8 @@
this.mAndroidResources = androidResources;
}
- @NonNull
@Override
- public Drawable getDrawableOrThrow(
+ public @NonNull Drawable getDrawableOrThrow(
@NonNull AndroidSeekableAnimatedImageResourceByResId resource)
throws ResourceAccessException {
if (resource.getAnimatedImageFormat() == AnimatedImageFormat.ANIMATED_IMAGE_FORMAT_AVD) {
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultInlineImageResourceResolver.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultInlineImageResourceResolver.java
index b5714cc..1e3c440 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultInlineImageResourceResolver.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/DefaultInlineImageResourceResolver.java
@@ -24,31 +24,31 @@
import android.graphics.drawable.Drawable;
import android.util.Log;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.wear.protolayout.proto.ResourceProto.ImageFormat;
import androidx.wear.protolayout.proto.ResourceProto.InlineImageResource;
import androidx.wear.protolayout.renderer.inflater.ResourceResolvers.InlineImageResourceResolver;
import androidx.wear.protolayout.renderer.inflater.ResourceResolvers.ResourceAccessException;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.nio.ByteBuffer;
/** Resource resolver for inline resources. */
public class DefaultInlineImageResourceResolver implements InlineImageResourceResolver {
private static final String TAG = "InlineImageResolver";
- @NonNull private final Context mAppContext;
+ private final @NonNull Context mAppContext;
/** Constructor. */
public DefaultInlineImageResourceResolver(@NonNull Context appContext) {
this.mAppContext = appContext;
}
- @NonNull
@Override
- public Drawable getDrawableOrThrow(@NonNull InlineImageResource inlineImage)
+ public @NonNull Drawable getDrawableOrThrow(@NonNull InlineImageResource inlineImage)
throws ResourceAccessException {
- @Nullable Bitmap bitmap = null;
+ Bitmap bitmap = null;
if (inlineImage.getFormat() == ImageFormat.IMAGE_FORMAT_RGB_565
|| inlineImage.getFormat() == ImageFormat.IMAGE_FORMAT_ARGB_8888) {
@@ -66,8 +66,7 @@
return new BitmapDrawable(mAppContext.getResources(), bitmap);
}
- @Nullable
- private static Config imageFormatToBitmapConfig(ImageFormat imageFormat) {
+ private static @Nullable Config imageFormatToBitmapConfig(ImageFormat imageFormat) {
switch (imageFormat) {
case IMAGE_FORMAT_RGB_565:
return Config.RGB_565;
@@ -89,8 +88,7 @@
return -1;
}
- @NonNull
- private Bitmap loadRawBitmap(@NonNull InlineImageResource inlineImage)
+ private @NonNull Bitmap loadRawBitmap(@NonNull InlineImageResource inlineImage)
throws ResourceAccessException {
Config config = imageFormatToBitmapConfig(inlineImage.getFormat());
@@ -114,8 +112,7 @@
return bitmap;
}
- @Nullable
- private Bitmap loadStructuredBitmap(@NonNull InlineImageResource inlineImage) {
+ private @Nullable Bitmap loadStructuredBitmap(@NonNull InlineImageResource inlineImage) {
Bitmap bitmap =
BitmapFactory.decodeByteArray(
inlineImage.getData().toByteArray(), 0, inlineImage.getData().size());
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/FixedImageSpan.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/FixedImageSpan.java
index 37e0979..64861e9 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/FixedImageSpan.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/FixedImageSpan.java
@@ -4,9 +4,12 @@
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.text.style.ImageSpan;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+
import androidx.annotation.VisibleForTesting;
+
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.ref.WeakReference;
// Android's normal ImageSpan (well, DynamicDrawableSpan) applies baseline alignment incorrectly
@@ -15,7 +18,7 @@
// hold. Instead, the "y" parameter is the Y coordinate of the baseline, so base the baseline
// alignment on that rather than "bottom".
class FixedImageSpan extends ImageSpan {
- @Nullable private WeakReference<Drawable> mDrawableRef;
+ private @Nullable WeakReference<Drawable> mDrawableRef;
FixedImageSpan(@NonNull Drawable drawable) {
super(drawable);
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ImageViewWithoutIntrinsicSizes.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ImageViewWithoutIntrinsicSizes.java
index b52958a..246abac 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ImageViewWithoutIntrinsicSizes.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ImageViewWithoutIntrinsicSizes.java
@@ -21,8 +21,8 @@
import android.util.AttributeSet;
import android.widget.ImageView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* Fixed version of ImageView which doesn't ever use the intrinsic size of its drawables.
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/LetterSpacingSpan.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/LetterSpacingSpan.java
index fc685cc..bf4c617 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/LetterSpacingSpan.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/LetterSpacingSpan.java
@@ -19,7 +19,7 @@
import android.text.TextPaint;
import android.text.style.MetricAffectingSpan;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/** LetterSpacingSpan class used to apply custom spacing between letters. */
public class LetterSpacingSpan extends MetricAffectingSpan {
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/OneOffPreDrawListener.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/OneOffPreDrawListener.java
index ebf6b23..5ea9abb 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/OneOffPreDrawListener.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/OneOffPreDrawListener.java
@@ -21,8 +21,8 @@
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnPreDrawListener;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.util.function.Supplier;
@@ -35,9 +35,9 @@
*/
class OneOffPreDrawListener implements OnPreDrawListener, OnAttachStateChangeListener {
- @NonNull private final View mView;
- @Nullable private ViewTreeObserver mViewTreeObserver;
- @NonNull private final Supplier<Boolean> mSupplier;
+ private final @NonNull View mView;
+ private @Nullable ViewTreeObserver mViewTreeObserver;
+ private final @NonNull Supplier<Boolean> mSupplier;
private boolean mIsAttached = false;
private OneOffPreDrawListener(@NonNull View view, @NonNull Supplier<Boolean> supplier) {
@@ -53,8 +53,7 @@
* @param supplier The Supplier to execute in the OnPreDraw (once). This Supplier should return
* false if the current drawing pass that was called for needs to be cancelled.
*/
- @NonNull
- public static OneOffPreDrawListener add(
+ public static @NonNull OneOffPreDrawListener add(
@NonNull View view, @NonNull Supplier<Boolean> supplier) {
OneOffPreDrawListener listener = new OneOffPreDrawListener(view, supplier);
// OnPreDraw listener will be added only after this View was attached.
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ProtoLayoutInflater.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ProtoLayoutInflater.java
index 014578f..8e799ce 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ProtoLayoutInflater.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ProtoLayoutInflater.java
@@ -84,8 +84,6 @@
import android.widget.Space;
import android.widget.TextView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.annotation.VisibleForTesting;
import androidx.core.content.ContextCompat;
@@ -108,8 +106,8 @@
import androidx.wear.protolayout.proto.AlignmentProto.VerticalAlignment;
import androidx.wear.protolayout.proto.AlignmentProto.VerticalAlignmentProp;
import androidx.wear.protolayout.proto.ColorProto.ColorProp;
-import androidx.wear.protolayout.proto.DimensionProto.ArcLineLength;
import androidx.wear.protolayout.proto.DimensionProto.AngularDimension;
+import androidx.wear.protolayout.proto.DimensionProto.ArcLineLength;
import androidx.wear.protolayout.proto.DimensionProto.ContainerDimension;
import androidx.wear.protolayout.proto.DimensionProto.ContainerDimension.InnerCase;
import androidx.wear.protolayout.proto.DimensionProto.DegreesProp;
@@ -206,6 +204,9 @@
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
@@ -275,7 +276,7 @@
// This is pretty badly named; TruncateAt specifies where to place the ellipsis (or whether to
// marquee). Disabling truncation with null actually disables the _ellipsis_, but text will
// still be truncated.
- @Nullable private static final TruncateAt TEXT_OVERFLOW_DEFAULT = null;
+ private static final @Nullable TruncateAt TEXT_OVERFLOW_DEFAULT = null;
private static final int TEXT_COLOR_DEFAULT = 0xFFFFFFFF;
private static final int TEXT_MAX_LINES_DEFAULT = 1;
@@ -307,14 +308,14 @@
private final Optional<ProtoLayoutDynamicDataPipeline> mDataPipeline;
- @Nullable private final ProtoLayoutExtensionViewProvider mExtensionViewProvider;
+ private final @Nullable ProtoLayoutExtensionViewProvider mExtensionViewProvider;
private final boolean mAllowLayoutChangingBindsWithoutDefault;
final String mClickableIdExtra;
- @Nullable private final LoggingUtils mLoggingUtils;
- @NonNull private final InflaterStatsLogger mInflaterStatsLogger;
- @Nullable final Executor mLoadActionExecutor;
+ private final @Nullable LoggingUtils mLoggingUtils;
+ private final @NonNull InflaterStatsLogger mInflaterStatsLogger;
+ final @Nullable Executor mLoadActionExecutor;
final LoadActionListener mLoadActionListener;
final boolean mAnimationEnabled;
@@ -478,8 +479,7 @@
return true;
}
- @Nullable
- String getTag() {
+ @Nullable String getTag() {
return (String) mView.getTag();
}
}
@@ -489,7 +489,7 @@
* the renderer.
*/
private static final class ParentViewWrapper {
- @Nullable private final ViewGroup mParent;
+ private final @Nullable ViewGroup mParent;
private final ViewProperties mParentProps;
ParentViewWrapper(ViewGroup parent, LayoutParams parentLayoutParams) {
@@ -536,19 +536,19 @@
public static final class Config {
public static final String DEFAULT_CLICKABLE_ID_EXTRA =
"androidx.wear.protolayout.extra.CLICKABLE_ID";
- @NonNull private final Context mUiContext;
- @NonNull private final Layout mLayout;
- @NonNull private final ResourceResolvers mLayoutResourceResolvers;
- @Nullable private final Executor mLoadActionExecutor;
- @NonNull private final LoadActionListener mLoadActionListener;
- @NonNull private final Resources mRendererResources;
- @NonNull private final ProtoLayoutTheme mProtoLayoutTheme;
- @Nullable private final ProtoLayoutDynamicDataPipeline mDataPipeline;
- @NonNull private final String mClickableIdExtra;
+ private final @NonNull Context mUiContext;
+ private final @NonNull Layout mLayout;
+ private final @NonNull ResourceResolvers mLayoutResourceResolvers;
+ private final @Nullable Executor mLoadActionExecutor;
+ private final @NonNull LoadActionListener mLoadActionListener;
+ private final @NonNull Resources mRendererResources;
+ private final @NonNull ProtoLayoutTheme mProtoLayoutTheme;
+ private final @Nullable ProtoLayoutDynamicDataPipeline mDataPipeline;
+ private final @NonNull String mClickableIdExtra;
- @Nullable private final LoggingUtils mLoggingUtils;
- @NonNull private final InflaterStatsLogger mInflaterStatsLogger;
- @Nullable private final ProtoLayoutExtensionViewProvider mExtensionViewProvider;
+ private final @Nullable LoggingUtils mLoggingUtils;
+ private final @NonNull InflaterStatsLogger mInflaterStatsLogger;
+ private final @Nullable ProtoLayoutExtensionViewProvider mExtensionViewProvider;
private final boolean mAnimationEnabled;
private final boolean mAllowLayoutChangingBindsWithoutDefault;
@@ -589,32 +589,27 @@
}
/** A {@link Context} suitable for interacting with UI. */
- @NonNull
- public Context getUiContext() {
+ public @NonNull Context getUiContext() {
return mUiContext;
}
/** The layout to be rendered. */
- @NonNull
- public Layout getLayout() {
+ public @NonNull Layout getLayout() {
return mLayout;
}
/** Resolvers for the resources used for rendering this layout. */
- @NonNull
- public ResourceResolvers getLayoutResourceResolvers() {
+ public @NonNull ResourceResolvers getLayoutResourceResolvers() {
return mLayoutResourceResolvers;
}
/** Executor to dispatch loadActionListener on. */
- @Nullable
- public Executor getLoadActionExecutor() {
+ public @Nullable Executor getLoadActionExecutor() {
return mLoadActionExecutor;
}
/** Listener for clicks that will cause contents to be reloaded. */
- @NonNull
- public LoadActionListener getLoadActionListener() {
+ public @NonNull LoadActionListener getLoadActionListener() {
return mLoadActionListener;
}
@@ -622,8 +617,7 @@
* Renderer internal resources. This Resources object can be used to resolve Renderer's
* resources.
*/
- @NonNull
- public Resources getRendererResources() {
+ public @NonNull Resources getRendererResources() {
return mRendererResources;
}
@@ -631,8 +625,7 @@
* Theme to use for this ProtoLayoutInflater instance. This can be used to customise things
* like the default font family.
*/
- @NonNull
- public ProtoLayoutTheme getProtoLayoutTheme() {
+ public @NonNull ProtoLayoutTheme getProtoLayoutTheme() {
return mProtoLayoutTheme;
}
@@ -640,8 +633,7 @@
* Pipeline for dynamic data. If null, the dynamic properties would not be registered for
* update.
*/
- @Nullable
- public ProtoLayoutDynamicDataPipeline getDynamicDataPipeline() {
+ public @Nullable ProtoLayoutDynamicDataPipeline getDynamicDataPipeline() {
return mDataPipeline;
}
@@ -649,26 +641,22 @@
* ID for the Intent extra containing the ID of a Clickable. Defaults to {@link
* Config#DEFAULT_CLICKABLE_ID_EXTRA} if not specified.
*/
- @NonNull
- public String getClickableIdExtra() {
+ public @NonNull String getClickableIdExtra() {
return mClickableIdExtra;
}
/** Debug logger used to log debug messages. */
- @Nullable
- public LoggingUtils getLoggingUtils() {
+ public @Nullable LoggingUtils getLoggingUtils() {
return mLoggingUtils;
}
/** Stats logger used for telemetry. */
- @NonNull
- public InflaterStatsLogger getInflaterStatsLogger() {
+ public @NonNull InflaterStatsLogger getInflaterStatsLogger() {
return mInflaterStatsLogger;
}
/** View provider for the renderer extension. */
- @Nullable
- public ProtoLayoutExtensionViewProvider getExtensionViewProvider() {
+ public @Nullable ProtoLayoutExtensionViewProvider getExtensionViewProvider() {
return mExtensionViewProvider;
}
@@ -693,22 +681,22 @@
/** Builder for the Config class. */
public static final class Builder {
- @NonNull private final Context mUiContext;
- @NonNull private final Layout mLayout;
- @NonNull private final ResourceResolvers mLayoutResourceResolvers;
- @Nullable private Executor mLoadActionExecutor;
- @Nullable private LoadActionListener mLoadActionListener;
- @NonNull private Resources mRendererResources;
- @Nullable private ProtoLayoutTheme mProtoLayoutTheme;
- @Nullable private ProtoLayoutDynamicDataPipeline mDataPipeline = null;
+ private final @NonNull Context mUiContext;
+ private final @NonNull Layout mLayout;
+ private final @NonNull ResourceResolvers mLayoutResourceResolvers;
+ private @Nullable Executor mLoadActionExecutor;
+ private @Nullable LoadActionListener mLoadActionListener;
+ private @NonNull Resources mRendererResources;
+ private @Nullable ProtoLayoutTheme mProtoLayoutTheme;
+ private @Nullable ProtoLayoutDynamicDataPipeline mDataPipeline = null;
private boolean mAnimationEnabled = true;
private boolean mAllowLayoutChangingBindsWithoutDefault = false;
- @Nullable private String mClickableIdExtra;
+ private @Nullable String mClickableIdExtra;
- @Nullable private LoggingUtils mLoggingUtils;
- @Nullable private InflaterStatsLogger mInflaterStatsLogger;
+ private @Nullable LoggingUtils mLoggingUtils;
+ private @Nullable InflaterStatsLogger mInflaterStatsLogger;
- @Nullable private ProtoLayoutExtensionViewProvider mExtensionViewProvider = null;
+ private @Nullable ProtoLayoutExtensionViewProvider mExtensionViewProvider = null;
private boolean mApplyFontVariantBodyAsDefault = false;
@@ -732,8 +720,7 @@
* Sets the Executor to dispatch loadActionListener on. This is required when setting
* {@link Builder#setLoadActionListener}.
*/
- @NonNull
- public Builder setLoadActionExecutor(@NonNull Executor loadActionExecutor) {
+ public @NonNull Builder setLoadActionExecutor(@NonNull Executor loadActionExecutor) {
this.mLoadActionExecutor = loadActionExecutor;
return this;
}
@@ -743,8 +730,8 @@
* no-op. This is required if the given layout contains a load action. When this is set,
* it's also required to set an executor with {@link Builder#setLoadActionExecutor}.
*/
- @NonNull
- public Builder setLoadActionListener(@NonNull LoadActionListener loadActionListener) {
+ public @NonNull Builder setLoadActionListener(
+ @NonNull LoadActionListener loadActionListener) {
this.mLoadActionListener = loadActionListener;
return this;
}
@@ -755,8 +742,7 @@
* android.content.pm.PackageManager#getResourcesForApplication(String)}. If not
* specified, this is retrieved from the Ui Context.
*/
- @NonNull
- public Builder setRendererResources(@NonNull Resources rendererResources) {
+ public @NonNull Builder setRendererResources(@NonNull Resources rendererResources) {
this.mRendererResources = rendererResources;
return this;
}
@@ -765,8 +751,8 @@
* Sets the theme to use for this ProtoLayoutInflater instance. This can be used to
* customise things like the default font family. If not set, the default theme is used.
*/
- @NonNull
- public Builder setProtoLayoutTheme(@NonNull ProtoLayoutTheme protoLayoutTheme) {
+ public @NonNull Builder setProtoLayoutTheme(
+ @NonNull ProtoLayoutTheme protoLayoutTheme) {
this.mProtoLayoutTheme = protoLayoutTheme;
return this;
}
@@ -775,16 +761,14 @@
* Sets the pipeline for dynamic data. If null, the dynamic properties would not be
* registered for update.
*/
- @NonNull
- public Builder setDynamicDataPipeline(
+ public @NonNull Builder setDynamicDataPipeline(
@NonNull ProtoLayoutDynamicDataPipeline dataPipeline) {
this.mDataPipeline = dataPipeline;
return this;
}
/** Sets the view provider for the renderer extension. */
- @NonNull
- public Builder setExtensionViewProvider(
+ public @NonNull Builder setExtensionViewProvider(
@NonNull ProtoLayoutExtensionViewProvider extensionViewProvider) {
this.mExtensionViewProvider = extensionViewProvider;
return this;
@@ -794,8 +778,7 @@
* Sets whether animation is enabled, which decides whether to load
* contentUpdateAnimations. Defaults to true.
*/
- @NonNull
- public Builder setAnimationEnabled(boolean animationEnabled) {
+ public @NonNull Builder setAnimationEnabled(boolean animationEnabled) {
this.mAnimationEnabled = animationEnabled;
return this;
}
@@ -804,22 +787,19 @@
* Sets the ID for the Intent extra containing the ID of a Clickable. Defaults to {@link
* Config#DEFAULT_CLICKABLE_ID_EXTRA} if not specified.
*/
- @NonNull
- public Builder setClickableIdExtra(@NonNull String clickableIdExtra) {
+ public @NonNull Builder setClickableIdExtra(@NonNull String clickableIdExtra) {
this.mClickableIdExtra = clickableIdExtra;
return this;
}
/** Sets the debug logger used for extensive logging. */
- @NonNull
- public Builder setLoggingUtils(@NonNull LoggingUtils loggingUtils) {
+ public @NonNull Builder setLoggingUtils(@NonNull LoggingUtils loggingUtils) {
this.mLoggingUtils = loggingUtils;
return this;
}
/** Sets the stats logger used for telemetry. */
- @NonNull
- public Builder setInflaterStatsLogger(
+ public @NonNull Builder setInflaterStatsLogger(
@NonNull InflaterStatsLogger inflaterStatsLogger) {
this.mInflaterStatsLogger = inflaterStatsLogger;
return this;
@@ -833,8 +813,7 @@
* <p>This is to support legacy apps which use layout-changing data bind before the full
* support was built.
*/
- @NonNull
- public Builder setAllowLayoutChangingBindsWithoutDefault(
+ public @NonNull Builder setAllowLayoutChangingBindsWithoutDefault(
boolean allowLayoutChangingBindsWithoutDefault) {
this.mAllowLayoutChangingBindsWithoutDefault =
allowLayoutChangingBindsWithoutDefault;
@@ -842,15 +821,14 @@
}
/** Apply FONT_VARIANT_BODY as default variant. */
- @NonNull
- public Builder setApplyFontVariantBodyAsDefault(boolean applyFontVariantBodyAsDefault) {
+ public @NonNull Builder setApplyFontVariantBodyAsDefault(
+ boolean applyFontVariantBodyAsDefault) {
this.mApplyFontVariantBodyAsDefault = applyFontVariantBodyAsDefault;
return this;
}
/** Builds a Config instance. */
- @NonNull
- public Config build() {
+ public @NonNull Config build() {
if (mLoadActionListener != null && mLoadActionExecutor == null) {
throw new IllegalArgumentException(
"A loadActionExecutor should always be set if setting a"
@@ -932,8 +910,7 @@
return safeDpToPx(dpProp.getValue());
}
- @Nullable
- private static Float safeAspectRatioOrNull(
+ private static @Nullable Float safeAspectRatioOrNull(
ProportionalDimensionProp proportionalDimensionProp) {
final int dividend = proportionalDimensionProp.getAspectRatioWidth();
final int divisor = proportionalDimensionProp.getAspectRatioHeight();
@@ -1395,8 +1372,7 @@
}
/** Given the integer representation of 4 characters ASCII code, returns the String of it. */
- @NonNull
- private static String toTagString(int tagCode) {
+ private static @NonNull String toTagString(int tagCode) {
return new String(ByteBuffer.allocate(4).putInt(tagCode).array(), US_ASCII);
}
@@ -2199,8 +2175,7 @@
return TEXT_ALIGN_DEFAULT;
}
- @Nullable
- private static TruncateAt textTruncationToEllipsize(TextOverflow overflowValue) {
+ private static @Nullable TruncateAt textTruncationToEllipsize(TextOverflow overflowValue) {
switch (overflowValue) {
case TEXT_OVERFLOW_TRUNCATE:
// A null TruncateAt disables adding an ellipsis.
@@ -2279,8 +2254,7 @@
* Returns an Android {@link Intent} that can perform the action defined in the given layout
* {@link LaunchAction}.
*/
- @Nullable
- public static Intent buildLaunchActionIntent(
+ public static @Nullable Intent buildLaunchActionIntent(
@NonNull LaunchAction launchAction,
@NonNull String clickableId,
@NonNull String clickableIdExtra) {
@@ -2319,8 +2293,7 @@
return loadAction.getRequestState().toBuilder().setLastClickableId(clickableId).build();
}
- @Nullable
- private InflatedView inflateColumn(
+ private @Nullable InflatedView inflateColumn(
ParentViewWrapper parentViewWrapper,
Column column,
String columnPosId,
@@ -2380,8 +2353,7 @@
numMissingChildren);
}
- @Nullable
- private InflatedView inflateRow(
+ private @Nullable InflatedView inflateRow(
ParentViewWrapper parentViewWrapper,
Row row,
String rowPosId,
@@ -2440,8 +2412,7 @@
// dereference of possibly-null reference lp
@SuppressWarnings("nullness:dereference.of.nullable")
- @Nullable
- private InflatedView inflateBox(
+ private @Nullable InflatedView inflateBox(
ParentViewWrapper parentViewWrapper,
Box box,
String boxPosId,
@@ -2534,8 +2505,7 @@
numMissingChildren);
}
- @Nullable
- private InflatedView inflateSpacer(
+ private @Nullable InflatedView inflateSpacer(
ParentViewWrapper parentViewWrapper,
Spacer spacer,
String posId,
@@ -2554,8 +2524,8 @@
// Initialize the size wrapper here, if needed. This simplifies the logic below when
// creating the actual Spacer and adding it to its parent...
FrameLayout sizeWrapper = null;
- @Nullable Float widthForLayoutDp = resolveSizeForLayoutIfNeeded(spacer.getWidth());
- @Nullable Float heightForLayoutDp = resolveSizeForLayoutIfNeeded(spacer.getHeight());
+ Float widthForLayoutDp = resolveSizeForLayoutIfNeeded(spacer.getWidth());
+ Float heightForLayoutDp = resolveSizeForLayoutIfNeeded(spacer.getHeight());
// Handling dynamic width/height for the spacer.
if (widthForLayoutDp != null || heightForLayoutDp != null) {
@@ -2743,8 +2713,7 @@
});
}
- @Nullable
- private InflatedView inflateArcSpacer(
+ private @Nullable InflatedView inflateArcSpacer(
ParentViewWrapper parentViewWrapper,
ArcSpacer spacer,
String posId,
@@ -2870,7 +2839,7 @@
textView.setGravity(textAlignToAndroidGravity(text.getMultilineAlignment().getValue()));
- @Nullable String valueForLayout = resolveValueForLayoutIfNeeded(text.getText());
+ String valueForLayout = resolveValueForLayoutIfNeeded(text.getText());
// Use valueForLayout as a proxy for "has a dynamic size". If there's a dynamic binding for
// the text element, then it can only have a single line of text.
@@ -3124,8 +3093,7 @@
}
@SuppressWarnings("ExecutorTaskName")
- @Nullable
- private InflatedView inflateImage(
+ private @Nullable InflatedView inflateImage(
ParentViewWrapper parentViewWrapper,
Image image,
String posId,
@@ -3155,7 +3123,7 @@
}
// Pull the ratio for the RatioViewWrapper. Was either argument a proportional dimension?
- @Nullable Float ratio = RatioViewWrapper.UNDEFINED_ASPECT_RATIO;
+ Float ratio = RatioViewWrapper.UNDEFINED_ASPECT_RATIO;
if (image.getWidth().getInnerCase() == ImageDimension.InnerCase.PROPORTIONAL_DIMENSION) {
ratio = safeAspectRatioOrNull(image.getWidth().getProportionalDimension());
@@ -3322,8 +3290,7 @@
* @return Returns the drawable if it is successfully retrieved from the drawable future and set
* to the image view; otherwise returns null to indicate the failure of setting drawable.
*/
- @Nullable
- private Drawable setImageDrawable(
+ private @Nullable Drawable setImageDrawable(
ImageView imageView, Future<Drawable> drawableFuture, String protoResId) {
try {
return setImageDrawable(imageView, drawableFuture.get(), protoResId);
@@ -3339,8 +3306,8 @@
* @return Returns the drawable if it is successfully set to the image view; otherwise returns
* null to indicate the failure of setting drawable.
*/
- @Nullable
- private Drawable setImageDrawable(ImageView imageView, Drawable drawable, String protoResId) {
+ private @Nullable Drawable setImageDrawable(ImageView imageView, Drawable drawable,
+ String protoResId) {
if (drawable != null) {
mInflaterStatsLogger.logDrawableUsage(drawable);
}
@@ -3354,8 +3321,7 @@
return drawable;
}
- @Nullable
- private InflatedView inflateArcLine(
+ private @Nullable InflatedView inflateArcLine(
ParentViewWrapper parentViewWrapper,
ArcLine line,
String posId,
@@ -3465,7 +3431,7 @@
SizedArcContainer.LayoutParams sizedLp =
new SizedArcContainer.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
- @Nullable Float sizeForLayout = resolveSizeForLayoutIfNeeded(length);
+ Float sizeForLayout = resolveSizeForLayoutIfNeeded(length);
if (sizeForLayout != null) {
sizeWrapper = new SizedArcContainer(mUiContext);
sizeWrapper.setArcDirection(arcLineDirection);
@@ -3511,8 +3477,7 @@
// dereference of possibly-null reference childLayoutParams
@SuppressWarnings("nullness:dereference.of.nullable")
- @Nullable
- private InflatedView inflateArc(
+ private @Nullable InflatedView inflateArc(
ParentViewWrapper parentViewWrapper,
Arc arc,
String arcPosId,
@@ -3571,8 +3536,7 @@
int index = FIRST_CHILD_INDEX;
for (ArcLayoutElement child : arc.getContentsList()) {
String childPosId = ProtoLayoutDiffer.createNodePosId(arcPosId, index++);
- @Nullable
- InflatedView childView =
+ InflatedView childView =
inflateArcLayoutElement(
new ParentViewWrapper(arcLayout, layoutParams),
child,
@@ -3710,7 +3674,7 @@
}
} else {
// If the future is not done, add an empty drawable to builder as a placeholder.
- @Nullable Drawable placeholderDrawable = null;
+ Drawable placeholderDrawable = null;
try {
if (mLayoutResourceResolvers.hasPlaceholderDrawable(protoResId)) {
@@ -3914,8 +3878,7 @@
.applyPendingChildLayoutParams(layoutParams));
}
- @Nullable
- private InflatedView inflateArcLayoutElement(
+ private @Nullable InflatedView inflateArcLayoutElement(
ParentViewWrapper parentViewWrapper,
ArcLayoutElement element,
String nodePosId,
@@ -4032,8 +3995,7 @@
return false;
}
- @Nullable
- private InflatedView inflateLayoutElement(
+ private @Nullable InflatedView inflateLayoutElement(
ParentViewWrapper parentViewWrapper,
LayoutElement element,
String nodePosId,
@@ -4138,8 +4100,7 @@
return inflatedView;
}
- @Nullable
- private InflatedView inflateExtension(
+ private @Nullable InflatedView inflateExtension(
ParentViewWrapper parentViewWrapper, ExtensionLayoutElement element) {
int widthPx = safeDpToPx(element.getWidth().getLinearDimension());
int heightPx = safeDpToPx(element.getHeight().getLinearDimension());
@@ -4338,8 +4299,7 @@
* Resolves the value for layout to be used in a Size Wrapper for elements containing dynamic
* values. Returns null if no size wrapper is needed.
*/
- @Nullable
- private String resolveValueForLayoutIfNeeded(StringProp stringProp) {
+ private @Nullable String resolveValueForLayoutIfNeeded(StringProp stringProp) {
if (!stringProp.hasDynamicValue() || !mDataPipeline.isPresent()) {
return null;
}
@@ -4356,8 +4316,7 @@
* Resolves the value for layout to be used in a Size Wrapper for elements containing dynamic
* values. Returns null if no size wrapper is needed.
*/
- @Nullable
- private Float resolveSizeForLayoutIfNeeded(SpacerDimension spacerDimension) {
+ private @Nullable Float resolveSizeForLayoutIfNeeded(SpacerDimension spacerDimension) {
DpProp dimension = spacerDimension.getLinearDimension();
if (!dimension.hasDynamicValue() || !mDataPipeline.isPresent()) {
return null;
@@ -4374,8 +4333,7 @@
* Resolves the value for layout to be used in a Size Wrapper for elements containing dynamic
* values. Returns null if no size wrapper is needed.
*/
- @Nullable
- private Float resolveSizeForLayoutIfNeeded(DegreesProp degreesProp) {
+ private @Nullable Float resolveSizeForLayoutIfNeeded(DegreesProp degreesProp) {
if (!degreesProp.hasDynamicValue() || !mDataPipeline.isPresent()) {
return null;
}
@@ -4565,8 +4523,7 @@
* <p>This may be null if the proto is empty the top-level LayoutElement has no inner set,
* or the top-level LayoutElement contains an unsupported inner type.
*/
- @Nullable
- public InflateResult inflate(@NonNull ViewGroup inflateParent) {
+ public @Nullable InflateResult inflate(@NonNull ViewGroup inflateParent) {
// This is a full re-inflation, so we don't need any previous rendering information.
LayoutInfo.Builder layoutInfoBuilder =
@@ -4617,8 +4574,7 @@
* @param targetLayout The target layout that the mutation should result in.
* @return The mutation that will produce the target layout.
*/
- @Nullable
- public ViewGroupMutation computeMutation(
+ public @Nullable ViewGroupMutation computeMutation(
@NonNull RenderedMetadata prevRenderedMetadata,
@NonNull Layout targetLayout,
@NonNull ViewProperties parentViewProp) {
@@ -4626,8 +4582,7 @@
Log.w(TAG, "No previous fingerprint available.");
return null;
}
- @Nullable
- LayoutDiff diff =
+ LayoutDiff diff =
ProtoLayoutDiffer.getDiff(prevRenderedMetadata.getTreeFingerprint(), targetLayout);
if (diff == null) {
Log.w(TAG, "getDiff failed");
@@ -4665,8 +4620,7 @@
}
// The parent node might also have been updated.
- @Nullable
- ViewProperties possibleUpdatedParentInfo =
+ ViewProperties possibleUpdatedParentInfo =
layoutInfoBuilder.getViewPropertiesFor(parentNodePosId);
parentInfo =
possibleUpdatedParentInfo != null
@@ -4675,8 +4629,8 @@
prevLayoutInfo.getViewPropertiesFor(parentNodePosId));
}
InflatedView inflatedView = null;
- @Nullable LayoutElement updatedLayoutElement = changedNode.getLayoutElement();
- @Nullable ArcLayoutElement updatedArcLayoutElement = changedNode.getArcLayoutElement();
+ LayoutElement updatedLayoutElement = changedNode.getLayoutElement();
+ ArcLayoutElement updatedArcLayoutElement = changedNode.getArcLayoutElement();
if (updatedLayoutElement != null) {
inflatedView =
inflateLayoutElement(
@@ -4724,8 +4678,7 @@
/** Apply the mutation that was previously computed with {@link #computeMutation}. */
@UiThread
- @NonNull
- public ListenableFuture<RenderingArtifact> applyMutation(
+ public @NonNull ListenableFuture<RenderingArtifact> applyMutation(
@NonNull ViewGroup prevInflatedParent, @NonNull ViewGroupMutation groupMutation) {
RenderedMetadata prevRenderedMetadata = getRenderedMetadata(prevInflatedParent);
if (prevRenderedMetadata != null
@@ -4836,8 +4789,7 @@
/** Returns the {@link RenderedMetadata} attached to {@code inflateParent}. */
@UiThread
- @Nullable
- public static RenderedMetadata getRenderedMetadata(@NonNull ViewGroup inflateParent) {
+ public static @Nullable RenderedMetadata getRenderedMetadata(@NonNull ViewGroup inflateParent) {
Object prevMetadataObject = inflateParent.getTag(R.id.rendered_metadata_tag);
if (prevMetadataObject instanceof RenderedMetadata) {
return (RenderedMetadata) prevMetadataObject;
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ProtoLayoutThemeImpl.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ProtoLayoutThemeImpl.java
index c1c0e22..2df4eef 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ProtoLayoutThemeImpl.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ProtoLayoutThemeImpl.java
@@ -29,7 +29,6 @@
import androidx.annotation.AttrRes;
import androidx.annotation.DrawableRes;
-import androidx.annotation.NonNull;
import androidx.annotation.StyleRes;
import androidx.annotation.StyleableRes;
import androidx.collection.ArrayMap;
@@ -38,6 +37,8 @@
import com.google.common.collect.ImmutableSet;
+import org.jspecify.annotations.NonNull;
+
import java.util.Map;
/** Theme customization for ProtoLayout texts, which includes Font types and variants. */
@@ -82,20 +83,17 @@
}
@Override
- @NonNull
- public Typeface getNormalFont() {
+ public @NonNull Typeface getNormalFont() {
return mNormalFont;
}
@Override
- @NonNull
- public Typeface getMediumFont() {
+ public @NonNull Typeface getMediumFont() {
return mMediumFont;
}
@Override
- @NonNull
- public Typeface getBoldFont() {
+ public @NonNull Typeface getBoldFont() {
return mBoldFont;
}
}
@@ -104,8 +102,7 @@
* Creates a ProtoLayoutTheme for the default theme, based on R.style.ProtoLayoutBaseTheme and
* R.attr.protoLayoutFallbackAppearance from the local package.
*/
- @NonNull
- public static ProtoLayoutTheme defaultTheme(@NonNull Context context) {
+ public static @NonNull ProtoLayoutTheme defaultTheme(@NonNull Context context) {
return new ProtoLayoutThemeImpl(context.getResources(), R.style.ProtoLayoutBaseTheme);
}
@@ -203,9 +200,8 @@
* @param preferredFontFamilies the prioritized list of String values representing the preferred
* font families that should be used.
*/
- @NonNull
@Override
- public FontSet getFontSet(@NonNull String... preferredFontFamilies) {
+ public @NonNull FontSet getFontSet(String @NonNull ... preferredFontFamilies) {
String acceptedFontFamily =
stream(preferredFontFamilies)
.filter(SUPPORTED_FONT_FAMILIES::contains)
@@ -218,8 +214,7 @@
/** Gets an Android Theme object styled with TextAppearance attributes. */
@Override
- @NonNull
- public Theme getTheme() {
+ public @NonNull Theme getTheme() {
return mTheme;
}
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/RatioViewWrapper.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/RatioViewWrapper.java
index 1a4b550..61823f4 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/RatioViewWrapper.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/RatioViewWrapper.java
@@ -22,10 +22,11 @@
import android.view.ViewGroup;
import androidx.annotation.AttrRes;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* A wrapper for a view, which enforces that its dimensions adhere to a set ratio if possible. Note
* that while multiple children can be added, only the first child will be measured, laid out, and
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/RenderedMetadata.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/RenderedMetadata.java
index 0ea9eff..9d0b5e2 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/RenderedMetadata.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/RenderedMetadata.java
@@ -24,45 +24,43 @@
import android.widget.FrameLayout;
import android.widget.LinearLayout;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.collection.ArrayMap;
import androidx.wear.protolayout.proto.FingerprintProto.TreeFingerprint;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.Map;
/** Additional metadata associated with a rendered layout. */
public final class RenderedMetadata {
- @NonNull private final TreeFingerprint mTreeFingerprint;
- @NonNull private final LayoutInfo mLayoutInfo;
+ private final @NonNull TreeFingerprint mTreeFingerprint;
+ private final @NonNull LayoutInfo mLayoutInfo;
RenderedMetadata(@NonNull TreeFingerprint treeFingerprint, @NonNull LayoutInfo layoutInfo) {
this.mTreeFingerprint = treeFingerprint;
this.mLayoutInfo = layoutInfo;
}
- @NonNull
- public TreeFingerprint getTreeFingerprint() {
+ public @NonNull TreeFingerprint getTreeFingerprint() {
return mTreeFingerprint;
}
- @NonNull
- LayoutInfo getLayoutInfo() {
+ @NonNull LayoutInfo getLayoutInfo() {
return mLayoutInfo;
}
/** This will hold information needed from an attached view while rendering in background. */
static final class LayoutInfo {
static final class Builder {
- @NonNull
- private final Map<String, ViewProperties> mPositionIdToViewProperties =
+ private final @NonNull Map<String, ViewProperties> mPositionIdToViewProperties =
new ArrayMap<>();
- @NonNull
- private final ArrayList<String> mSubtreePosIdPendingRemoval = new ArrayList<>();
+ private final @NonNull ArrayList<String> mSubtreePosIdPendingRemoval =
+ new ArrayList<>();
- @Nullable private final LayoutInfo mPreviousLayoutInfo;
+ private final @Nullable LayoutInfo mPreviousLayoutInfo;
Builder(@Nullable LayoutInfo previousLayoutInfo) {
this.mPreviousLayoutInfo = previousLayoutInfo;
@@ -72,8 +70,7 @@
mPositionIdToViewProperties.put(positionId, viewProperties);
}
- @Nullable
- ViewProperties getViewPropertiesFor(@NonNull String posId) {
+ @Nullable ViewProperties getViewPropertiesFor(@NonNull String posId) {
return mPositionIdToViewProperties.get(posId);
}
@@ -99,7 +96,7 @@
}
}
- @NonNull final Map<String, ViewProperties> mPositionIdToLayoutInfo;
+ final @NonNull Map<String, ViewProperties> mPositionIdToLayoutInfo;
LayoutInfo(@NonNull Map<String, ViewProperties> positionIdToLayoutInfo) {
this.mPositionIdToLayoutInfo = positionIdToLayoutInfo;
@@ -109,8 +106,7 @@
return mPositionIdToLayoutInfo.containsKey(positionId);
}
- @Nullable
- ViewProperties getViewPropertiesFor(@NonNull String positionId) {
+ @Nullable ViewProperties getViewPropertiesFor(@NonNull String positionId) {
return mPositionIdToLayoutInfo.get(positionId);
}
}
@@ -123,8 +119,7 @@
* Apply the additional fields from this class to the {@code layoutParams}. This might lead
* to creating a new instance of a subclass of {@link LayoutParams}
*/
- @NonNull
- LayoutParams apply(@NonNull LayoutParams layoutParams);
+ @NonNull LayoutParams apply(@NonNull LayoutParams layoutParams);
}
/** Additional pending layout params for layout elements inside a {@link FrameLayout}. */
@@ -136,8 +131,7 @@
}
@Override
- @NonNull
- public LayoutParams apply(@NonNull LayoutParams layoutParams) {
+ public @NonNull LayoutParams apply(@NonNull LayoutParams layoutParams) {
FrameLayout.LayoutParams frameLayoutParams;
// Note: These conversions reflect the procedure in FrameLayout#generateLayoutParams
// which applies to a View when it's attached to a FrameLayout container.
@@ -155,15 +149,14 @@
/** Holds properties of any container that are needed for background rendering. */
public static class ViewProperties {
- @NonNull public static final ViewProperties EMPTY = new ViewProperties();
+ public static final @NonNull ViewProperties EMPTY = new ViewProperties();
/**
* Creates a {@link ViewProperties} from any {@link ViewGroup} container. Note that {@code
* rawLayoutParams} doesn't need to be a container-specific variant. But the {@code
* childLayoutParams} should be of a container specific instance (if provided).
*/
- @NonNull
- public static ViewProperties fromViewGroup(
+ public static @NonNull ViewProperties fromViewGroup(
@NonNull ViewGroup viewGroup,
@NonNull LayoutParams rawLayoutParams,
@NonNull PendingLayoutParams childLayoutParams) {
@@ -177,8 +170,7 @@
return EMPTY;
}
- @NonNull
- LayoutParams applyPendingChildLayoutParams(@NonNull LayoutParams layoutParams) {
+ @NonNull LayoutParams applyPendingChildLayoutParams(@NonNull LayoutParams layoutParams) {
// Do nothing.
return layoutParams;
}
@@ -190,7 +182,7 @@
*/
static final class LinearLayoutProperties extends ViewProperties {
private final int mOrientation;
- @NonNull private final LayoutParams mRawLayoutParams;
+ private final @NonNull LayoutParams mRawLayoutParams;
LinearLayoutProperties(int orientation, @NonNull LayoutParams rawLayoutParams) {
this.mOrientation = orientation;
@@ -205,8 +197,7 @@
* Returns the non-container specific {@link LayoutParams} for this object. Note that
* down-casting this to {@link LinearLayout.LayoutParams} can fail.
*/
- @NonNull
- LayoutParams getRawLayoutParams() {
+ @NonNull LayoutParams getRawLayoutParams() {
return mRawLayoutParams;
}
}
@@ -215,15 +206,14 @@
* Holds properties of a {@link FrameLayout} container that are needed for background rendering.
*/
static final class FrameLayoutProperties extends ViewProperties {
- @NonNull private final PendingLayoutParams mChildLayoutParams;
+ private final @NonNull PendingLayoutParams mChildLayoutParams;
FrameLayoutProperties(@NonNull PendingLayoutParams childLayoutParams) {
this.mChildLayoutParams = childLayoutParams;
}
@Override
- @NonNull
- LayoutParams applyPendingChildLayoutParams(@NonNull LayoutParams layoutParams) {
+ @NonNull LayoutParams applyPendingChildLayoutParams(@NonNull LayoutParams layoutParams) {
return mChildLayoutParams.apply(layoutParams);
}
}
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ResourceResolvers.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ResourceResolvers.java
index 2434d9c..e3ae3e4 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ResourceResolvers.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/ResourceResolvers.java
@@ -19,8 +19,6 @@
import android.annotation.SuppressLint;
import android.graphics.drawable.Drawable;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.wear.protolayout.expression.proto.DynamicProto.DynamicFloat;
import androidx.wear.protolayout.proto.ResourceProto;
import androidx.wear.protolayout.proto.ResourceProto.AndroidAnimatedImageResourceByResId;
@@ -33,39 +31,37 @@
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Class for resolving resources. Delegates the actual work to different types of resolver classes,
* and allows each type of resolver to be configured individually, as well as instantiation from
* common resolver implementations.
*/
public class ResourceResolvers {
- @NonNull private final ResourceProto.Resources mProtoResources;
+ private final ResourceProto.@NonNull Resources mProtoResources;
- @Nullable
- private final AndroidImageResourceByResIdResolver mAndroidImageResourceByResIdResolver;
+ private final @Nullable AndroidImageResourceByResIdResolver
+ mAndroidImageResourceByResIdResolver;
- @Nullable
- private final AndroidAnimatedImageResourceByResIdResolver
+ private final @Nullable AndroidAnimatedImageResourceByResIdResolver
mAndroidAnimatedImageResourceByResIdResolver;
- @Nullable
- private final AndroidSeekableAnimatedImageResourceByResIdResolver
+ private final @Nullable AndroidSeekableAnimatedImageResourceByResIdResolver
mAndroidSeekableAnimatedImageResourceByResIdResolver;
- @Nullable private final InlineImageResourceResolver mInlineImageResourceResolver;
+ private final @Nullable InlineImageResourceResolver mInlineImageResourceResolver;
- @Nullable
- private final AndroidImageResourceByContentUriResolver
+ private final @Nullable AndroidImageResourceByContentUriResolver
mAndroidImageResourceByContentUriResolver;
ResourceResolvers(
- @NonNull ResourceProto.Resources protoResources,
+ ResourceProto.@NonNull Resources protoResources,
@Nullable AndroidImageResourceByResIdResolver androidImageResourceByResIdResolver,
- @Nullable
- AndroidAnimatedImageResourceByResIdResolver
+ @Nullable AndroidAnimatedImageResourceByResIdResolver
androidAnimatedImageResourceByResIdResolver,
- @Nullable
- AndroidSeekableAnimatedImageResourceByResIdResolver
+ @Nullable AndroidSeekableAnimatedImageResourceByResIdResolver
androidSeekableAnimatedImageResourceByResIdResolver,
@Nullable InlineImageResourceResolver inlineImageResourceResolver,
@Nullable AndroidImageResourceByContentUriResolver androidContentUriResolver) {
@@ -97,8 +93,7 @@
*
* @throws ResourceAccessException If the drawable cannot be found
*/
- @NonNull
- Drawable getDrawableOrThrow(@NonNull AndroidImageResourceByResId resource)
+ @NonNull Drawable getDrawableOrThrow(@NonNull AndroidImageResourceByResId resource)
throws ResourceAccessException;
}
@@ -109,8 +104,7 @@
*
* @throws ResourceAccessException If the drawable cannot be found.
*/
- @NonNull
- Drawable getDrawableOrThrow(@NonNull AndroidAnimatedImageResourceByResId resource)
+ @NonNull Drawable getDrawableOrThrow(@NonNull AndroidAnimatedImageResourceByResId resource)
throws ResourceAccessException;
}
@@ -121,8 +115,7 @@
*
* @throws ResourceAccessException If the drawable cannot be found.
*/
- @NonNull
- Drawable getDrawableOrThrow(@NonNull AndroidSeekableAnimatedImageResourceByResId resource)
+ @NonNull Drawable getDrawableOrThrow(@NonNull AndroidSeekableAnimatedImageResourceByResId resource)
throws ResourceAccessException;
}
@@ -133,21 +126,18 @@
*
* @throws ResourceAccessException If the drawable cannot be found,.
*/
- @NonNull
- Drawable getDrawableOrThrow(@NonNull InlineImageResource resource)
+ @NonNull Drawable getDrawableOrThrow(@NonNull InlineImageResource resource)
throws ResourceAccessException;
}
/** Interface that can provide a Drawable for an AndroidContentUriResource. */
public interface AndroidImageResourceByContentUriResolver {
/** Get the drawable as specified by {@code resource}, to be loaded asynchronously. */
- @NonNull
- ListenableFuture<Drawable> getDrawable(@NonNull AndroidImageResourceByContentUri resource);
+ @NonNull ListenableFuture<Drawable> getDrawable(@NonNull AndroidImageResourceByContentUri resource);
}
/** Get an empty builder to build {@link ResourceResolvers} with. */
- @NonNull
- public static Builder builder(@NonNull ResourceProto.Resources protoResources) {
+ public static @NonNull Builder builder(ResourceProto.@NonNull Resources protoResources) {
return new Builder(protoResources);
}
@@ -168,8 +158,7 @@
* exist.
* @see ResourceResolvers#hasPlaceholderDrawable(String)
*/
- @NonNull
- public Drawable getPlaceholderDrawableOrThrow(@NonNull String protoResourceId)
+ public @NonNull Drawable getPlaceholderDrawableOrThrow(@NonNull String protoResourceId)
throws ResourceAccessException {
String placeholderResourceId = getPlaceholderResourceId(protoResourceId);
@@ -200,8 +189,7 @@
}
/** Get the drawable corresponding to the given resource ID. */
- @NonNull
- public ListenableFuture<Drawable> getDrawable(@NonNull String protoResourceId) {
+ public @NonNull ListenableFuture<Drawable> getDrawable(@NonNull String protoResourceId) {
ResourceProto.ImageResource imageResource =
mProtoResources.getIdToImageMap().get(protoResourceId);
@@ -211,8 +199,7 @@
"Resource " + protoResourceId + " is not defined in resources bundle"));
}
- @Nullable
- ListenableFuture<Drawable> drawableFutureOrNull =
+ ListenableFuture<Drawable> drawableFutureOrNull =
getDrawableForImageResource(imageResource);
if (drawableFutureOrNull == null) {
return Futures.immediateFailedFuture(
@@ -227,8 +214,7 @@
*
* @throws IllegalArgumentException If the resource is not an animated resource.
*/
- @Nullable
- public Trigger getAnimationTrigger(@NonNull String protoResourceId) {
+ public @Nullable Trigger getAnimationTrigger(@NonNull String protoResourceId) {
ResourceProto.ImageResource imageResource =
mProtoResources.getIdToImageMap().get(protoResourceId);
if (imageResource != null && imageResource.hasAndroidAnimatedResourceByResId()) {
@@ -245,8 +231,7 @@
*
* @throws IllegalArgumentException If the resource is not a seekable animated resource.
*/
- @Nullable
- public DynamicFloat getBoundProgress(@NonNull String protoResourceId) {
+ public @Nullable DynamicFloat getBoundProgress(@NonNull String protoResourceId) {
ResourceProto.ImageResource imageResource =
mProtoResources.getIdToImageMap().get(protoResourceId);
if (imageResource != null && imageResource.hasAndroidSeekableAnimatedResourceByResId()) {
@@ -259,9 +244,8 @@
+ " DynamicFloat");
}
- @Nullable
- Drawable getDrawableForImageResourceSynchronously(
- @NonNull ResourceProto.ImageResource imageResource) throws ResourceAccessException {
+ @Nullable Drawable getDrawableForImageResourceSynchronously(
+ ResourceProto.@NonNull ImageResource imageResource) throws ResourceAccessException {
if (imageResource.hasAndroidAnimatedResourceByResId()
&& mAndroidAnimatedImageResourceByResIdResolver != null) {
AndroidAnimatedImageResourceByResIdResolver resolver =
@@ -295,9 +279,8 @@
* Get the drawable for the known ImageResource. Can return null if there's no resolver for the
* image resource.
*/
- @Nullable
- protected ListenableFuture<Drawable> getDrawableForImageResource(
- @NonNull ResourceProto.ImageResource imageResource) {
+ protected @Nullable ListenableFuture<Drawable> getDrawableForImageResource(
+ ResourceProto.@NonNull ImageResource imageResource) {
try {
Drawable drawable = getDrawableForImageResourceSynchronously(imageResource);
if (drawable != null) {
@@ -338,8 +321,7 @@
return false;
}
- @Nullable
- protected String getPlaceholderResourceId(@NonNull String originalResourceId) {
+ protected @Nullable String getPlaceholderResourceId(@NonNull String originalResourceId) {
ResourceProto.ImageResource imageResource =
mProtoResources.getIdToImageMap().get(originalResourceId);
@@ -353,30 +335,27 @@
/** Builder for ResourceResolvers */
public static final class Builder {
- @NonNull private final ResourceProto.Resources mProtoResources;
- @Nullable private AndroidImageResourceByResIdResolver mAndroidImageResourceByResIdResolver;
+ private final ResourceProto.@NonNull Resources mProtoResources;
+ private @Nullable AndroidImageResourceByResIdResolver mAndroidImageResourceByResIdResolver;
- @Nullable
- private AndroidAnimatedImageResourceByResIdResolver
+ private @Nullable AndroidAnimatedImageResourceByResIdResolver
mAndroidAnimatedImageResourceByResIdResolver;
- @Nullable
- private AndroidSeekableAnimatedImageResourceByResIdResolver
+ private @Nullable AndroidSeekableAnimatedImageResourceByResIdResolver
mAndroidSeekableAnimatedImageResourceByResIdResolver;
- @Nullable private InlineImageResourceResolver mInlineImageResourceResolver;
+ private @Nullable InlineImageResourceResolver mInlineImageResourceResolver;
- @Nullable
- private AndroidImageResourceByContentUriResolver mAndroidImageResourceByContentUriResolver;
+ private @Nullable AndroidImageResourceByContentUriResolver
+ mAndroidImageResourceByContentUriResolver;
- Builder(@NonNull ResourceProto.Resources protoResources) {
+ Builder(ResourceProto.@NonNull Resources protoResources) {
this.mProtoResources = protoResources;
}
/** Set the resource loader for {@link AndroidImageResourceByResIdResolver} resources. */
- @NonNull
@SuppressLint("MissingGetterMatchingBuilder")
- public Builder setAndroidImageResourceByResIdResolver(
+ public @NonNull Builder setAndroidImageResourceByResIdResolver(
@NonNull AndroidImageResourceByResIdResolver resolver) {
mAndroidImageResourceByResIdResolver = resolver;
return this;
@@ -386,9 +365,8 @@
* Set the resource loader for {@link AndroidAnimatedImageResourceByResIdResolver}
* resources.
*/
- @NonNull
@SuppressLint("MissingGetterMatchingBuilder")
- public Builder setAndroidAnimatedImageResourceByResIdResolver(
+ public @NonNull Builder setAndroidAnimatedImageResourceByResIdResolver(
@NonNull AndroidAnimatedImageResourceByResIdResolver resolver) {
mAndroidAnimatedImageResourceByResIdResolver = resolver;
return this;
@@ -398,34 +376,30 @@
* Set the resource loader for {@link AndroidSeekableAnimatedImageResourceByResIdResolver}
* resources.
*/
- @NonNull
@SuppressLint("MissingGetterMatchingBuilder")
- public Builder setAndroidSeekableAnimatedImageResourceByResIdResolver(
+ public @NonNull Builder setAndroidSeekableAnimatedImageResourceByResIdResolver(
@NonNull AndroidSeekableAnimatedImageResourceByResIdResolver resolver) {
mAndroidSeekableAnimatedImageResourceByResIdResolver = resolver;
return this;
}
/** Set the resource loader for {@link InlineImageResourceResolver} resources. */
- @NonNull
@SuppressLint("MissingGetterMatchingBuilder")
- public Builder setInlineImageResourceResolver(
+ public @NonNull Builder setInlineImageResourceResolver(
@NonNull InlineImageResourceResolver resolver) {
mInlineImageResourceResolver = resolver;
return this;
}
- @NonNull
@SuppressLint("MissingGetterMatchingBuilder")
- public Builder setAndroidImageResourceByContentUriResolver(
+ public @NonNull Builder setAndroidImageResourceByContentUriResolver(
@NonNull AndroidImageResourceByContentUriResolver resolver) {
mAndroidImageResourceByContentUriResolver = resolver;
return this;
}
/** Build a {@link ResourceResolvers} instance. */
- @NonNull
- public ResourceResolvers build() {
+ public @NonNull ResourceResolvers build() {
return new ResourceResolvers(
mProtoResources,
mAndroidImageResourceByResIdResolver,
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/SizedArcContainer.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/SizedArcContainer.java
index ccdb6db..b0f4843 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/SizedArcContainer.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/SizedArcContainer.java
@@ -26,14 +26,15 @@
import android.view.ViewGroup;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.proto.LayoutElementProto.ArcDirection;
import androidx.wear.protolayout.renderer.R;
import androidx.wear.widget.ArcLayout;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -45,7 +46,7 @@
*/
class SizedArcContainer extends ViewGroup implements ArcLayout.Widget {
private static final float DEFAULT_SWEEP_ANGLE_DEGREES = 0;
- @NonNull private ArcDirection mArcDirection = ArcDirection.ARC_DIRECTION_CLOCKWISE;
+ private @NonNull ArcDirection mArcDirection = ArcDirection.ARC_DIRECTION_CLOCKWISE;
private float mSweepAngleDegrees;
@@ -80,7 +81,7 @@
super(width, height);
}
- LayoutParams(@NonNull ViewGroup.LayoutParams source) {
+ LayoutParams(ViewGroup.@NonNull LayoutParams source) {
super(source);
}
@@ -157,7 +158,7 @@
@Override
public void addView(
- @NonNull View child, int index, @NonNull ViewGroup.LayoutParams layoutParams) {
+ @NonNull View child, int index, ViewGroup.@NonNull LayoutParams layoutParams) {
if (!(child instanceof ArcLayout.Widget)) {
throw new IllegalArgumentException(
"SizedArcContainer can only contain instances of ArcLayout.Widget");
@@ -171,13 +172,13 @@
}
@Override
- protected boolean checkLayoutParams(@NonNull ViewGroup.LayoutParams p) {
+ protected boolean checkLayoutParams(ViewGroup.@NonNull LayoutParams p) {
return p instanceof LayoutParams;
}
@Override
- @NonNull
- protected ViewGroup.LayoutParams generateLayoutParams(@NonNull ViewGroup.LayoutParams p) {
+ protected ViewGroup.@NonNull LayoutParams generateLayoutParams(
+ ViewGroup.@NonNull LayoutParams p) {
return new LayoutParams(p);
}
@@ -212,8 +213,7 @@
}
}
- @Nullable
- private ArcLayout.Widget getChild() {
+ private ArcLayout.@Nullable Widget getChild() {
if (getChildCount() == 0) {
return null;
}
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/StandardLineHeightSpan.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/StandardLineHeightSpan.java
index 4b0f602..3d531a3 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/StandardLineHeightSpan.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/StandardLineHeightSpan.java
@@ -19,9 +19,10 @@
import android.graphics.Paint.FontMetricsInt;
import android.text.style.LineHeightSpan;
-import androidx.annotation.NonNull;
import androidx.annotation.Px;
+import org.jspecify.annotations.NonNull;
+
// LineHeightSpan.Standard is only available on API 29+, but the implementation is trivial. Just
// re-implement it here.
class StandardLineHeightSpan implements LineHeightSpan {
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/StandardResourceResolvers.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/StandardResourceResolvers.java
index 467af71..bd66164 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/StandardResourceResolvers.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/StandardResourceResolvers.java
@@ -20,9 +20,10 @@
import android.content.Context;
import android.content.res.Resources;
-import androidx.annotation.NonNull;
import androidx.wear.protolayout.proto.ResourceProto;
+import org.jspecify.annotations.NonNull;
+
import java.util.concurrent.Executor;
/** Utility class to get {@link ResourceResolvers} populated with standard options. */
@@ -39,9 +40,8 @@
* @param asyncLoadExecutor The executor to use to load any async resources (e.g. Content URI).
*/
@SuppressLint("CheckResult")
- @NonNull
- public static ResourceResolvers.Builder forLocalApp(
- @NonNull ResourceProto.Resources protoResources,
+ public static ResourceResolvers.@NonNull Builder forLocalApp(
+ ResourceProto.@NonNull Resources protoResources,
@NonNull Context appContext,
@NonNull Executor asyncLoadExecutor,
boolean animationEnabled) {
@@ -103,9 +103,8 @@
* resources.
*/
@SuppressLint("CheckResult")
- @NonNull
- public static ResourceResolvers.Builder forRemoteService(
- @NonNull ResourceProto.Resources protoResources,
+ public static ResourceResolvers.@NonNull Builder forRemoteService(
+ ResourceProto.@NonNull Resources protoResources,
@NonNull String servicePackageName,
@NonNull Resources serviceAndroidResources,
@NonNull Context hostAppContext,
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/TouchDelegateComposite.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/TouchDelegateComposite.java
index 6184ac8..dd5da33 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/TouchDelegateComposite.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/TouchDelegateComposite.java
@@ -32,9 +32,10 @@
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo.TouchDelegateInfo;
-import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
+import org.jspecify.annotations.NonNull;
+
import java.util.Map;
import java.util.WeakHashMap;
@@ -50,7 +51,7 @@
*/
class TouchDelegateComposite extends TouchDelegate {
- @NonNull private final WeakHashMap<View, DelegateInfo> mDelegates = new WeakHashMap<>();
+ private final @NonNull WeakHashMap<View, DelegateInfo> mDelegates = new WeakHashMap<>();
/**
* Constructor
@@ -127,8 +128,7 @@
@SuppressLint("ClassVerificationFailure")
@Override
- @NonNull
- public AccessibilityNodeInfo.TouchDelegateInfo getTouchDelegateInfo() {
+ public AccessibilityNodeInfo.@NonNull TouchDelegateInfo getTouchDelegateInfo() {
if (VERSION.SDK_INT >= VERSION_CODES.Q && !mDelegates.isEmpty()) {
Map<Region, View> targetMap = new ArrayMap<>(mDelegates.size());
for (Map.Entry<View, DelegateInfo> entry : mDelegates.entrySet()) {
@@ -152,9 +152,9 @@
}
private static final class DelegateInfo {
- @NonNull final Rect mActualBounds;
- @NonNull final Rect mExtendedBounds;
- @NonNull final TouchDelegate mTouchDelegate;
+ final @NonNull Rect mActualBounds;
+ final @NonNull Rect mExtendedBounds;
+ final @NonNull TouchDelegate mTouchDelegate;
DelegateInfo(
@NonNull View delegateView,
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/WearCurvedLineView.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/WearCurvedLineView.java
index 5729186..bb019b0 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/WearCurvedLineView.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/WearCurvedLineView.java
@@ -39,8 +39,6 @@
import android.view.View;
import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.wear.protolayout.proto.ColorProto;
import androidx.wear.protolayout.proto.LayoutElementProto.ArcDirection;
@@ -50,6 +48,9 @@
import com.google.common.primitives.Floats;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -89,13 +90,13 @@
private float mMaxSweepAngleDegrees;
private float mLineSweepAngleDegrees;
- @Nullable @VisibleForTesting SweepGradientHelper mSweepGradientHelper;
+ @VisibleForTesting @Nullable SweepGradientHelper mSweepGradientHelper;
- @Nullable private ArcDrawable mArcDrawable;
- @Nullable private StrokeCapShadow mCapShadow;
+ private @Nullable ArcDrawable mArcDrawable;
+ private @Nullable StrokeCapShadow mCapShadow;
/** Base paint used for drawing. This paint doesn't include any gradient definition. */
- @NonNull private final Paint mBasePaint;
+ private final @NonNull Paint mBasePaint;
private boolean updatesEnabled = true;
@@ -292,7 +293,7 @@
}
/** Sets a brush to be used to draw this arc. */
- public void setBrush(@NonNull ColorProto.Brush brushProto) {
+ public void setBrush(ColorProto.@NonNull Brush brushProto) {
if (!brushProto.hasSweepGradient()) {
Log.e(TAG, "Only SweepGradient is currently supported in ArcLine.");
return;
@@ -306,8 +307,7 @@
}
/** Returns the strokeCap of this arc. */
- @NonNull
- public Cap getStrokeCap() {
+ public @NonNull Cap getStrokeCap() {
return mBasePaint.getStrokeCap();
}
@@ -390,10 +390,10 @@
*/
private static final float CAP_COLOR_SHADER_OFFSET_SIZE = 0.25f;
- @NonNull private final List<AngularColorStop> colorStops;
+ private final @NonNull List<AngularColorStop> colorStops;
/** Constructor. All colors will have their alpha channel set to 0xFF (opaque). */
- SweepGradientHelper(@NonNull ColorProto.SweepGradient sweepGradProto) {
+ SweepGradientHelper(ColorProto.@NonNull SweepGradient sweepGradProto) {
int numColors = sweepGradProto.getColorStopsCount();
if (numColors < MIN_COLOR_STOPS || numColors > MAX_COLOR_STOPS) {
throw new IllegalArgumentException(
@@ -506,8 +506,7 @@
* color
* @param capPosition the position of the stroke cap.
*/
- @NonNull
- Shader getShader(
+ @NonNull Shader getShader(
@NonNull RectF bounds,
float gradStartAngle,
float gradEndAngle,
@@ -599,14 +598,14 @@
/** The angle span of the sector that is clipped out. */
private static final float CLIP_OUT_PATH_SPAN_DEGREES = 90f;
- @NonNull private final Paint mPaint;
- @NonNull private final Path mPath;
+ private final @NonNull Paint mPaint;
+ private final @NonNull Path mPath;
/** A region to be clipped out when drawing, in order to exclude one of the stroke caps. */
- @Nullable private Path mExcludedCapRegion = null;
+ private @Nullable Path mExcludedCapRegion = null;
/** A region to be clipped in when drawing, in order to only include this region. */
- @Nullable private Path mMaskRegion = null;
+ private @Nullable Path mMaskRegion = null;
/**
* Creates a segment that draws perpendicular to the arc, covering a length equivalent to
@@ -759,7 +758,7 @@
static class ArcDrawableImpl implements ArcDrawable {
// The list of segments that compose the ArcDrawable, in the order that they should be
// drawn.
- @NonNull private final List<ArcSegment> mSegments = new ArrayList<>();
+ private final @NonNull List<ArcSegment> mSegments = new ArrayList<>();
ArcDrawableImpl(
@NonNull RectF bounds,
@@ -796,7 +795,7 @@
float segmentSweep = topLayerLength / 2f;
- @Nullable Paint shadowPaint = null;
+ Paint shadowPaint = null;
if (strokeCapShadow != null) {
shadowPaint = new Paint(basePaint);
shadowPaint.setColor(Color.TRANSPARENT);
@@ -888,8 +887,8 @@
/** Legacy LinePath, which supports drawing the line as a single Path. */
private static class ArcDrawableLegacy implements ArcDrawable {
- @NonNull private final Paint mPaint;
- @NonNull private final Path mPath = new Path();
+ private final @NonNull Paint mPaint;
+ private final @NonNull Path mPath = new Path();
ArcDrawableLegacy(@NonNull RectF bounds, float clampedLineLength, @NonNull Paint paint) {
this.mPaint = paint;
diff --git a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/WearCurvedSpacer.java b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/WearCurvedSpacer.java
index c4d1eb3..1dcc99f 100644
--- a/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/WearCurvedSpacer.java
+++ b/wear/protolayout/protolayout-renderer/src/main/java/androidx/wear/protolayout/renderer/inflater/WearCurvedSpacer.java
@@ -21,11 +21,12 @@
import android.util.AttributeSet;
import android.view.View;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.wear.protolayout.renderer.R;
import androidx.wear.widget.ArcLayout;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* A lightweight curved widget that represents space between elements inside an Arc. This does no
* rendering; it simply causes the parent {@link ArcLayout} to advance by {@code sweepAngleDegrees}.
diff --git a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/dynamicdata/AddToListCallback.java b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/dynamicdata/AddToListCallback.java
index ed282b8..165f9c8 100644
--- a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/dynamicdata/AddToListCallback.java
+++ b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/dynamicdata/AddToListCallback.java
@@ -16,15 +16,16 @@
package androidx.wear.protolayout.renderer.dynamicdata;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.wear.protolayout.expression.pipeline.DynamicTypeValueReceiver;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
public class AddToListCallback<T> implements DynamicTypeValueReceiver<T> {
private final List<T> mListToUpdate;
- @Nullable private final List<Boolean> mInvalidListToUpdate;
+ private final @Nullable List<Boolean> mInvalidListToUpdate;
public AddToListCallback(List<T> list) {
this.mListToUpdate = list;
diff --git a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/dynamicdata/ProtoLayoutDynamicDataPipelineTest.java b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/dynamicdata/ProtoLayoutDynamicDataPipelineTest.java
index 3a049d2..b387e84 100644
--- a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/dynamicdata/ProtoLayoutDynamicDataPipelineTest.java
+++ b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/dynamicdata/ProtoLayoutDynamicDataPipelineTest.java
@@ -37,8 +37,6 @@
import android.graphics.drawable.Drawable;
import android.widget.FrameLayout;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.vectordrawable.graphics.drawable.SeekableAnimatedVectorDrawable;
@@ -93,6 +91,8 @@
import com.google.common.collect.Range;
import com.google.common.truth.Expect;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -1050,16 +1050,14 @@
expect.that(quotaManager.isAllQuotaReleased()).isTrue();
}
- @NonNull
- private static Trigger conditionTrigger(DynamicBool dynamicBool) {
+ private static @NonNull Trigger conditionTrigger(DynamicBool dynamicBool) {
return Trigger.newBuilder()
.setOnConditionMetTrigger(
OnConditionMetTrigger.newBuilder().setCondition(dynamicBool).build())
.build();
}
- @NonNull
- private static DynamicBool dynamicBool(String boolStateKey) {
+ private static @NonNull DynamicBool dynamicBool(String boolStateKey) {
return DynamicBool.newBuilder()
.setStateSource(StateBoolSource.newBuilder().setSourceKey(boolStateKey).build())
.build();
@@ -1691,16 +1689,15 @@
expect.that(quotaManager.isAllQuotaReleased()).isTrue();
}
- @NonNull
- private DynamicFloat animatableFixedFloat(float from, float to) {
+ private @NonNull DynamicFloat animatableFixedFloat(float from, float to) {
return DynamicFloat.newBuilder()
.setAnimatableFixed(
AnimatableFixedFloat.newBuilder().setFromValue(from).setToValue(to))
.build();
}
- @NonNull
- private DynamicFloat animatableFixedFloat(float from, float to, int duration, int delay) {
+ private @NonNull DynamicFloat animatableFixedFloat(float from, float to, int duration,
+ int delay) {
return DynamicFloat.newBuilder()
.setAnimatableFixed(
AnimatableFixedFloat.newBuilder()
@@ -1717,8 +1714,7 @@
.build();
}
- @NonNull
- private DynamicFloat animatableFixedFloat(
+ private @NonNull DynamicFloat animatableFixedFloat(
float from, float to, int duration, int delay, int repeatDelay, int iterations) {
AnimationParameters alternateParameters =
AnimationParameters.newBuilder().setDelayMillis(repeatDelay).build();
@@ -1749,16 +1745,14 @@
.build();
}
- @NonNull
- private DynamicColor animatableFixedColor(int from, int to) {
+ private @NonNull DynamicColor animatableFixedColor(int from, int to) {
return DynamicColor.newBuilder()
.setAnimatableFixed(
AnimatableFixedColor.newBuilder().setFromArgb(from).setToArgb(to).build())
.build();
}
- @NonNull
- private ProtoLayoutDynamicDataPipeline initPipelineWithAllAnimations(
+ private @NonNull ProtoLayoutDynamicDataPipeline initPipelineWithAllAnimations(
List<DynamicFloat> dynamicFloats,
@Nullable DynamicFloat boundProgress,
@Nullable SeekableAnimatedVectorDrawable seekableDrawable,
@@ -1773,8 +1767,7 @@
/* results= */ new ArrayList<>());
}
- @NonNull
- private ProtoLayoutDynamicDataPipeline initPipelineWithAllAnimations(
+ private @NonNull ProtoLayoutDynamicDataPipeline initPipelineWithAllAnimations(
@NonNull List<DynamicFloat> dynamicFloats,
@Nullable DynamicFloat boundProgress,
@Nullable SeekableAnimatedVectorDrawable seekableDrawable,
diff --git a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/dynamicdata/TestAnimatedVectorDrawable.java b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/dynamicdata/TestAnimatedVectorDrawable.java
index 3bb97b4..b4d82f2 100644
--- a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/dynamicdata/TestAnimatedVectorDrawable.java
+++ b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/dynamicdata/TestAnimatedVectorDrawable.java
@@ -18,7 +18,7 @@
import android.graphics.drawable.AnimatedVectorDrawable;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
import java.util.ArrayList;
import java.util.List;
diff --git a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/helper/TestDsl.java b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/helper/TestDsl.java
index 520b0b4..d5033d3 100644
--- a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/helper/TestDsl.java
+++ b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/helper/TestDsl.java
@@ -19,7 +19,6 @@
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.toList;
-import androidx.annotation.Nullable;
import androidx.wear.protolayout.expression.proto.DynamicProto.DynamicString;
import androidx.wear.protolayout.expression.proto.FixedProto.FixedString;
import androidx.wear.protolayout.proto.AlignmentProto.HorizontalAlignment;
@@ -56,6 +55,8 @@
import androidx.wear.protolayout.proto.TypesProto.Int32Prop;
import androidx.wear.protolayout.proto.TypesProto.StringProp;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
diff --git a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/helper/TestFingerprinter.java b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/helper/TestFingerprinter.java
index 0f8d2d3..2b5a765 100644
--- a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/helper/TestFingerprinter.java
+++ b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/helper/TestFingerprinter.java
@@ -18,7 +18,6 @@
import static androidx.wear.protolayout.proto.LayoutElementProto.ArcLayoutElement.InnerCase.ADAPTER;
-import androidx.annotation.Nullable;
import androidx.wear.protolayout.proto.FingerprintProto.NodeFingerprint;
import androidx.wear.protolayout.proto.FingerprintProto.TreeFingerprint;
import androidx.wear.protolayout.proto.LayoutElementProto;
@@ -26,6 +25,8 @@
import androidx.wear.protolayout.proto.LayoutElementProto.LayoutElement;
import androidx.wear.protolayout.proto.LayoutElementProto.LayoutElement.InnerCase;
+import org.jspecify.annotations.Nullable;
+
import java.util.Collections;
import java.util.List;
@@ -87,7 +88,7 @@
private NodeFingerprint addNodeToParent(
LayoutElementProto.LayoutElement element,
- @Nullable NodeFingerprint.Builder parentFingerprintBuilder) {
+ NodeFingerprint.@Nullable Builder parentFingerprintBuilder) {
NodeFingerprint.Builder currentFingerprintBuilder =
NodeFingerprint.newBuilder()
.setSelfTypeValue(getSelfTypeFingerprint(element))
diff --git a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/impl/ProtoLayoutViewInstanceTest.java b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/impl/ProtoLayoutViewInstanceTest.java
index d095d58..61d9e5c 100644
--- a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/impl/ProtoLayoutViewInstanceTest.java
+++ b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/impl/ProtoLayoutViewInstanceTest.java
@@ -48,7 +48,6 @@
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
-import androidx.annotation.NonNull;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.wear.protolayout.expression.pipeline.StateStore;
import androidx.wear.protolayout.proto.LayoutElementProto.Layout;
@@ -63,6 +62,7 @@
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
+import org.jspecify.annotations.NonNull;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -680,8 +680,7 @@
mInstanceUnderTest = new ProtoLayoutViewInstance(config);
}
- @NonNull
- private Config.Builder createInstanceConfig(boolean adaptiveUpdateRatesEnabled) {
+ private Config.@NonNull Builder createInstanceConfig(boolean adaptiveUpdateRatesEnabled) {
FakeExecutorService uiThreadExecutor =
new FakeExecutorService(new Handler(Looper.getMainLooper()));
ListeningExecutorService listeningExecutorService =
diff --git a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/ProtoLayoutInflaterTest.java b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/ProtoLayoutInflaterTest.java
index f041417..e4712f9 100644
--- a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/ProtoLayoutInflaterTest.java
+++ b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/ProtoLayoutInflaterTest.java
@@ -79,8 +79,6 @@
import android.widget.Space;
import android.widget.TextView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.test.ext.junit.runners.AndroidJUnit4;
@@ -129,8 +127,8 @@
import androidx.wear.protolayout.proto.ColorProto.ColorStop;
import androidx.wear.protolayout.proto.ColorProto.SweepGradient;
import androidx.wear.protolayout.proto.DimensionProto;
-import androidx.wear.protolayout.proto.DimensionProto.ArcLineLength;
import androidx.wear.protolayout.proto.DimensionProto.AngularDimension;
+import androidx.wear.protolayout.proto.DimensionProto.ArcLineLength;
import androidx.wear.protolayout.proto.DimensionProto.BoundingBoxRatio;
import androidx.wear.protolayout.proto.DimensionProto.ContainerDimension;
import androidx.wear.protolayout.proto.DimensionProto.DegreesProp;
@@ -223,6 +221,8 @@
import com.google.common.truth.Expect;
import com.google.common.util.concurrent.ListenableFuture;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@@ -2400,8 +2400,8 @@
assertThat(line.getSweepAngleDegrees()).isEqualTo(60f);
}
- @NonNull
- private static ArcLayoutElement.Builder arcLayoutElement(ArcSpacer.Builder setAngularLength) {
+ private static ArcLayoutElement.@NonNull Builder arcLayoutElement(
+ ArcSpacer.Builder setAngularLength) {
return ArcLayoutElement.newBuilder().setSpacer(setAngularLength.setThickness(dp(20)));
}
@@ -3002,8 +3002,7 @@
assertThat(hasFiredList).hasSize(1);
}
- @NonNull
- private static SpanModifiers.Builder spanClickMod() {
+ private static SpanModifiers.@NonNull Builder spanClickMod() {
return SpanModifiers.newBuilder()
.setClickable(
Clickable.newBuilder()
@@ -3528,13 +3527,11 @@
expect.that(image2.getHeight()).isEqualTo(24);
}
- @NonNull
- private static ImageDimension.Builder linImageDim(DpProp.Builder builderForValue) {
+ private static ImageDimension.@NonNull Builder linImageDim(DpProp.Builder builderForValue) {
return ImageDimension.newBuilder().setLinearDimension(builderForValue);
}
- @NonNull
- private static ContainerDimension.Builder wrap() {
+ private static ContainerDimension.@NonNull Builder wrap() {
return ContainerDimension.newBuilder()
.setWrappedDimension(WrappedDimensionProp.getDefaultInstance());
}
@@ -3775,13 +3772,11 @@
assertThat(line.getMaxSweepAngleDegrees()).isEqualTo(0);
}
- @NonNull
- private static DegreesProp.Builder degreesDynamic(DynamicFloat arcLength) {
+ private static DegreesProp.@NonNull Builder degreesDynamic(DynamicFloat arcLength) {
return DegreesProp.newBuilder().setDynamicValue(arcLength);
}
- @NonNull
- private static DegreesProp.Builder degreesDynamic(
+ private static DegreesProp.@NonNull Builder degreesDynamic(
DynamicFloat arcLength, float valueForLayout) {
return DegreesProp.newBuilder()
.setValueForLayout(valueForLayout)
@@ -5061,15 +5056,13 @@
.build();
}
- @NonNull
- private static Trigger onVisibleTrigger() {
+ private static @NonNull Trigger onVisibleTrigger() {
return Trigger.newBuilder()
.setOnVisibleTrigger(OnVisibleTrigger.getDefaultInstance())
.build();
}
- @NonNull
- private static AnimatableDynamicFloat.Builder stateDynamicFloat() {
+ private static AnimatableDynamicFloat.@NonNull Builder stateDynamicFloat() {
return AnimatableDynamicFloat.newBuilder()
.setInput(
DynamicFloat.newBuilder()
@@ -5111,8 +5104,7 @@
expect.that(linearLayoutParams.weight).isEqualTo(10.0f);
}
- @NonNull
- private static ContainerDimension expandWeight() {
+ private static @NonNull ContainerDimension expandWeight() {
return ContainerDimension.newBuilder()
.setExpandedDimension(
ExpandedDimensionProp.newBuilder()
@@ -6233,13 +6225,11 @@
.build();
}
- @NonNull
- private static EnterTransition.Builder enterFadeIn(int delay) {
+ private static EnterTransition.@NonNull Builder enterFadeIn(int delay) {
return EnterTransition.newBuilder().setFadeIn(fadeIn(delay));
}
- @NonNull
- private static FadeInTransition.Builder fadeIn(int delay) {
+ private static FadeInTransition.@NonNull Builder fadeIn(int delay) {
return FadeInTransition.newBuilder()
.setAnimationSpec(
AnimationSpec.newBuilder()
@@ -6330,15 +6320,15 @@
.build();
}
- @NonNull
- private Text.Builder textAnimVisibility(AnimatedVisibility.Builder snapTo, String text) {
+ private Text.@NonNull Builder textAnimVisibility(AnimatedVisibility.Builder snapTo,
+ String text) {
return Text.newBuilder()
.setModifiers(Modifiers.newBuilder().setContentUpdateAnimation(snapTo.build()))
.setText(string(text).build());
}
- @NonNull
- private Text.Builder dynamicTextAnimVisibility(AnimatedVisibility.Builder snapTo, String text) {
+ private Text.@NonNull Builder dynamicTextAnimVisibility(AnimatedVisibility.Builder snapTo,
+ String text) {
return Text.newBuilder()
.setModifiers(Modifiers.newBuilder().setContentUpdateAnimation(snapTo.build()))
.setText(
@@ -6369,66 +6359,54 @@
.build()));
}
- @NonNull
- private static DpProp.Builder dp(float value) {
+ private static DpProp.@NonNull Builder dp(float value) {
return DpProp.newBuilder().setValue(value);
}
- @NonNull
- private static DpProp.Builder dynamicDp(DynamicFloat value, float valueForLayout) {
+ private static DpProp.@NonNull Builder dynamicDp(DynamicFloat value, float valueForLayout) {
return DpProp.newBuilder().setDynamicValue(value).setValueForLayout(valueForLayout);
}
- @NonNull
- private static DimensionProto.SpProp sp(float value) {
+ private static DimensionProto.@NonNull SpProp sp(float value) {
return DimensionProto.SpProp.newBuilder().setValue(value).build();
}
- @NonNull
- private static ContainerDimension.Builder expand() {
+ private static ContainerDimension.@NonNull Builder expand() {
return ContainerDimension.newBuilder()
.setExpandedDimension(ExpandedDimensionProp.getDefaultInstance());
}
- @NonNull
- private static StrokeCapProp.Builder strokeCapButt() {
+ private static StrokeCapProp.@NonNull Builder strokeCapButt() {
return StrokeCapProp.newBuilder().setValue(LayoutElementProto.StrokeCap.STROKE_CAP_BUTT);
}
- @NonNull
- private static DegreesProp.Builder degrees(int value) {
+ private static DegreesProp.@NonNull Builder degrees(int value) {
return DegreesProp.newBuilder().setValue(value);
}
- @NonNull
- private static ColorStop.Builder colorStop(int color, float offset) {
+ private static ColorStop.@NonNull Builder colorStop(int color, float offset) {
return colorStop(color).setOffset(FloatProp.newBuilder().setValue(offset));
}
- @NonNull
- private static ColorStop.Builder colorStop(int color) {
+ private static ColorStop.@NonNull Builder colorStop(int color) {
return ColorStop.newBuilder().setColor(argb(color));
}
- @NonNull
- private static ColorProp.Builder argb(int value) {
+ private static ColorProp.@NonNull Builder argb(int value) {
return ColorProp.newBuilder().setArgb(value);
}
- @NonNull
- private static ExpandedAngularDimensionProp expandAngular(float value) {
+ private static @NonNull ExpandedAngularDimensionProp expandAngular(float value) {
return ExpandedAngularDimensionProp.newBuilder()
.setLayoutWeight(FloatProp.newBuilder().setValue(value).build())
.build();
}
- @NonNull
- private static StringProp.Builder string(String value) {
+ private static StringProp.@NonNull Builder string(String value) {
return StringProp.newBuilder().setValue(value);
}
- @NonNull
- private static StringProp.Builder dynamicString(String value) {
+ private static StringProp.@NonNull Builder dynamicString(String value) {
return StringProp.newBuilder()
.setValue(value)
.setDynamicValue(
@@ -6436,14 +6414,12 @@
.setFixed(FixedString.newBuilder().setValue(value)));
}
- @NonNull
- private static ImageDimension.Builder expandImage() {
+ private static ImageDimension.@NonNull Builder expandImage() {
return ImageDimension.newBuilder()
.setExpandedDimension(ExpandedDimensionProp.getDefaultInstance());
}
- @NonNull
- private static List<DimensionProto.SpProp> buildSizesList(int[] presetSizes) {
+ private static @NonNull List<DimensionProto.SpProp> buildSizesList(int[] presetSizes) {
List<DimensionProto.SpProp> sizes = new ArrayList<>(3);
for (int s : presetSizes) {
sizes.add(sp(s));
@@ -6501,7 +6477,7 @@
/** Builds a wrapper Box that contains Spacer with the given parameters. */
private static Layout layoutBoxWithSpacer(
- int width, int height, @Nullable Modifiers.Builder modifiers) {
+ int width, int height, Modifiers.@Nullable Builder modifiers) {
Spacer.Builder spacer =
Spacer.newBuilder()
.setWidth(SpacerDimension.newBuilder().setLinearDimension(dp(width)))
diff --git a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/ResourceResolversTest.java b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/ResourceResolversTest.java
index 54685fd..083af9f 100644
--- a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/ResourceResolversTest.java
+++ b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/ResourceResolversTest.java
@@ -27,7 +27,6 @@
import android.graphics.drawable.Drawable;
import android.graphics.drawable.VectorDrawable;
-import androidx.annotation.Nullable;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.wear.protolayout.expression.proto.DynamicProto.DynamicFloat;
import androidx.wear.protolayout.expression.proto.FixedProto.FixedFloat;
@@ -52,6 +51,7 @@
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import org.jspecify.annotations.Nullable;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/WearCurvedLineViewTest.java b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/WearCurvedLineViewTest.java
index 532bb8e..ba96678 100644
--- a/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/WearCurvedLineViewTest.java
+++ b/wear/protolayout/protolayout-renderer/src/test/java/androidx/wear/protolayout/renderer/inflater/WearCurvedLineViewTest.java
@@ -9,7 +9,6 @@
import android.graphics.RectF;
import android.graphics.Shader;
-import androidx.annotation.NonNull;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.wear.protolayout.proto.ColorProto.ColorProp;
import androidx.wear.protolayout.proto.ColorProto.ColorStop;
@@ -21,6 +20,7 @@
import com.google.common.truth.Expect;
+import org.jspecify.annotations.NonNull;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
diff --git a/wear/protolayout/protolayout/build.gradle b/wear/protolayout/protolayout/build.gradle
index 7b0f17a..77b4b24 100644
--- a/wear/protolayout/protolayout/build.gradle
+++ b/wear/protolayout/protolayout/build.gradle
@@ -30,6 +30,7 @@
}
dependencies {
+ api(libs.jspecify)
annotationProcessor(libs.nullaway)
api("androidx.annotation:annotation:1.8.1")
api(project(":wear:protolayout:protolayout-expression"))
diff --git a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/ActionBuilders.java b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/ActionBuilders.java
index 84c192e..620b21d 100644
--- a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/ActionBuilders.java
+++ b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/ActionBuilders.java
@@ -21,8 +21,6 @@
import android.annotation.SuppressLint;
import android.content.ComponentName;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.StateBuilders.State;
@@ -30,6 +28,9 @@
import androidx.wear.protolayout.expression.RequiresSchemaVersion;
import androidx.wear.protolayout.proto.ActionProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -40,38 +41,32 @@
private ActionBuilders() {}
/** Shortcut for building an {@link AndroidStringExtra}. */
- @NonNull
- public static AndroidStringExtra stringExtra(@NonNull String value) {
+ public static @NonNull AndroidStringExtra stringExtra(@NonNull String value) {
return new AndroidStringExtra.Builder().setValue(value).build();
}
/** Shortcut for building an {@link AndroidIntExtra}. */
- @NonNull
- public static AndroidIntExtra intExtra(int value) {
+ public static @NonNull AndroidIntExtra intExtra(int value) {
return new AndroidIntExtra.Builder().setValue(value).build();
}
/** Shortcut for building an {@link AndroidLongExtra}. */
- @NonNull
- public static AndroidLongExtra longExtra(long value) {
+ public static @NonNull AndroidLongExtra longExtra(long value) {
return new AndroidLongExtra.Builder().setValue(value).build();
}
/** Shortcut for building an {@link AndroidDoubleExtra}. */
- @NonNull
- public static AndroidDoubleExtra doubleExtra(double value) {
+ public static @NonNull AndroidDoubleExtra doubleExtra(double value) {
return new AndroidDoubleExtra.Builder().setValue(value).build();
}
/** Shortcut for building an {@link AndroidBooleanExtra}. */
- @NonNull
- public static AndroidBooleanExtra booleanExtra(boolean value) {
+ public static @NonNull AndroidBooleanExtra booleanExtra(boolean value) {
return new AndroidBooleanExtra.Builder().setValue(value).build();
}
/** Shortcut for building a {@link LaunchAction}. */
- @NonNull
- public static LaunchAction launchAction(@NonNull ComponentName activityComponentName) {
+ public static @NonNull LaunchAction launchAction(@NonNull ComponentName activityComponentName) {
return new LaunchAction.Builder()
.setAndroidActivity(
new AndroidActivity.Builder()
@@ -82,8 +77,7 @@
}
/** Shortcut for building a {@link LaunchAction} with extras in the launch intent. */
- @NonNull
- public static LaunchAction launchAction(
+ public static @NonNull LaunchAction launchAction(
@NonNull ComponentName activityComponentName,
@NonNull Map<String, AndroidExtra> intentExtras) {
AndroidActivity.Builder builder = new AndroidActivity.Builder();
@@ -102,7 +96,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class AndroidStringExtra implements AndroidExtra {
private final ActionProto.AndroidStringExtra mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AndroidStringExtra(ActionProto.AndroidStringExtra impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -110,48 +104,42 @@
}
/** Gets the value. */
- @NonNull
- public String getValue() {
+ public @NonNull String getValue() {
return mImpl.getValue();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AndroidStringExtra fromProto(
- @NonNull ActionProto.AndroidStringExtra proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull AndroidStringExtra fromProto(
+ ActionProto.@NonNull AndroidStringExtra proto, @Nullable Fingerprint fingerprint) {
return new AndroidStringExtra(proto, fingerprint);
}
- @NonNull
- static AndroidStringExtra fromProto(@NonNull ActionProto.AndroidStringExtra proto) {
+ static @NonNull AndroidStringExtra fromProto(
+ ActionProto.@NonNull AndroidStringExtra proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- ActionProto.AndroidStringExtra toProto() {
+ ActionProto.@NonNull AndroidStringExtra toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ActionProto.AndroidExtra toAndroidExtraProto() {
+ public ActionProto.@NonNull AndroidExtra toAndroidExtraProto() {
return ActionProto.AndroidExtra.newBuilder().setStringVal(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AndroidStringExtra{" + "value=" + getValue() + "}";
}
@@ -167,8 +155,7 @@
/** Sets the value. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(@NonNull String value) {
+ public @NonNull Builder setValue(@NonNull String value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, value.hashCode());
return this;
@@ -176,8 +163,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public AndroidStringExtra build() {
+ public @NonNull AndroidStringExtra build() {
return new AndroidStringExtra(mImpl.build(), mFingerprint);
}
}
@@ -187,7 +173,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class AndroidIntExtra implements AndroidExtra {
private final ActionProto.AndroidIntExtra mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AndroidIntExtra(ActionProto.AndroidIntExtra impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -201,40 +187,34 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AndroidIntExtra fromProto(
- @NonNull ActionProto.AndroidIntExtra proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull AndroidIntExtra fromProto(
+ ActionProto.@NonNull AndroidIntExtra proto, @Nullable Fingerprint fingerprint) {
return new AndroidIntExtra(proto, fingerprint);
}
- @NonNull
- static AndroidIntExtra fromProto(@NonNull ActionProto.AndroidIntExtra proto) {
+ static @NonNull AndroidIntExtra fromProto(ActionProto.@NonNull AndroidIntExtra proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- ActionProto.AndroidIntExtra toProto() {
+ ActionProto.@NonNull AndroidIntExtra toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ActionProto.AndroidExtra toAndroidExtraProto() {
+ public ActionProto.@NonNull AndroidExtra toAndroidExtraProto() {
return ActionProto.AndroidExtra.newBuilder().setIntVal(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AndroidIntExtra{" + "value=" + getValue() + "}";
}
@@ -250,8 +230,7 @@
/** Sets the value. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(int value) {
+ public @NonNull Builder setValue(int value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, value);
return this;
@@ -259,8 +238,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public AndroidIntExtra build() {
+ public @NonNull AndroidIntExtra build() {
return new AndroidIntExtra(mImpl.build(), mFingerprint);
}
}
@@ -270,7 +248,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class AndroidLongExtra implements AndroidExtra {
private final ActionProto.AndroidLongExtra mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AndroidLongExtra(ActionProto.AndroidLongExtra impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -284,40 +262,34 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AndroidLongExtra fromProto(
- @NonNull ActionProto.AndroidLongExtra proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull AndroidLongExtra fromProto(
+ ActionProto.@NonNull AndroidLongExtra proto, @Nullable Fingerprint fingerprint) {
return new AndroidLongExtra(proto, fingerprint);
}
- @NonNull
- static AndroidLongExtra fromProto(@NonNull ActionProto.AndroidLongExtra proto) {
+ static @NonNull AndroidLongExtra fromProto(ActionProto.@NonNull AndroidLongExtra proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- ActionProto.AndroidLongExtra toProto() {
+ ActionProto.@NonNull AndroidLongExtra toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ActionProto.AndroidExtra toAndroidExtraProto() {
+ public ActionProto.@NonNull AndroidExtra toAndroidExtraProto() {
return ActionProto.AndroidExtra.newBuilder().setLongVal(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AndroidLongExtra{" + "value=" + getValue() + "}";
}
@@ -333,8 +305,7 @@
/** Sets the value. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(long value) {
+ public @NonNull Builder setValue(long value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, Long.hashCode(value));
return this;
@@ -342,8 +313,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public AndroidLongExtra build() {
+ public @NonNull AndroidLongExtra build() {
return new AndroidLongExtra(mImpl.build(), mFingerprint);
}
}
@@ -353,7 +323,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class AndroidDoubleExtra implements AndroidExtra {
private final ActionProto.AndroidDoubleExtra mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AndroidDoubleExtra(ActionProto.AndroidDoubleExtra impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -367,40 +337,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AndroidDoubleExtra fromProto(
- @NonNull ActionProto.AndroidDoubleExtra proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull AndroidDoubleExtra fromProto(
+ ActionProto.@NonNull AndroidDoubleExtra proto, @Nullable Fingerprint fingerprint) {
return new AndroidDoubleExtra(proto, fingerprint);
}
- @NonNull
- static AndroidDoubleExtra fromProto(@NonNull ActionProto.AndroidDoubleExtra proto) {
+ static @NonNull AndroidDoubleExtra fromProto(
+ ActionProto.@NonNull AndroidDoubleExtra proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- ActionProto.AndroidDoubleExtra toProto() {
+ ActionProto.@NonNull AndroidDoubleExtra toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ActionProto.AndroidExtra toAndroidExtraProto() {
+ public ActionProto.@NonNull AndroidExtra toAndroidExtraProto() {
return ActionProto.AndroidExtra.newBuilder().setDoubleVal(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AndroidDoubleExtra{" + "value=" + getValue() + "}";
}
@@ -416,8 +381,7 @@
/** Sets the value. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(double value) {
+ public @NonNull Builder setValue(double value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, Double.hashCode(value));
return this;
@@ -425,8 +389,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public AndroidDoubleExtra build() {
+ public @NonNull AndroidDoubleExtra build() {
return new AndroidDoubleExtra(mImpl.build(), mFingerprint);
}
}
@@ -436,7 +399,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class AndroidBooleanExtra implements AndroidExtra {
private final ActionProto.AndroidBooleanExtra mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AndroidBooleanExtra(
ActionProto.AndroidBooleanExtra impl, @Nullable Fingerprint fingerprint) {
@@ -451,41 +414,36 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AndroidBooleanExtra fromProto(
- @NonNull ActionProto.AndroidBooleanExtra proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull AndroidBooleanExtra fromProto(
+ ActionProto.@NonNull AndroidBooleanExtra proto, @Nullable Fingerprint fingerprint) {
return new AndroidBooleanExtra(proto, fingerprint);
}
- @NonNull
- static AndroidBooleanExtra fromProto(@NonNull ActionProto.AndroidBooleanExtra proto) {
+ static @NonNull AndroidBooleanExtra fromProto(
+ ActionProto.@NonNull AndroidBooleanExtra proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- ActionProto.AndroidBooleanExtra toProto() {
+ ActionProto.@NonNull AndroidBooleanExtra toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ActionProto.AndroidExtra toAndroidExtraProto() {
+ public ActionProto.@NonNull AndroidExtra toAndroidExtraProto() {
return ActionProto.AndroidExtra.newBuilder().setBooleanVal(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AndroidBooleanExtra{" + "value=" + getValue() + "}";
}
@@ -502,8 +460,7 @@
/** Sets the value. */
@RequiresSchemaVersion(major = 1, minor = 0)
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setValue(boolean value) {
+ public @NonNull Builder setValue(boolean value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, Boolean.hashCode(value));
return this;
@@ -511,8 +468,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public AndroidBooleanExtra build() {
+ public @NonNull AndroidBooleanExtra build() {
return new AndroidBooleanExtra(mImpl.build(), mFingerprint);
}
}
@@ -526,29 +482,25 @@
public interface AndroidExtra {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- ActionProto.AndroidExtra toAndroidExtraProto();
+ ActionProto.@NonNull AndroidExtra toAndroidExtraProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link AndroidExtra} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- AndroidExtra build();
+ @NonNull AndroidExtra build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AndroidExtra androidExtraFromProto(
- @NonNull ActionProto.AndroidExtra proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull AndroidExtra androidExtraFromProto(
+ ActionProto.@NonNull AndroidExtra proto, @Nullable Fingerprint fingerprint) {
if (proto.hasStringVal()) {
return AndroidStringExtra.fromProto(proto.getStringVal(), fingerprint);
}
@@ -567,8 +519,7 @@
throw new IllegalStateException("Proto was not a recognised instance of AndroidExtra");
}
- @NonNull
- static AndroidExtra androidExtraFromProto(@NonNull ActionProto.AndroidExtra proto) {
+ static @NonNull AndroidExtra androidExtraFromProto(ActionProto.@NonNull AndroidExtra proto) {
return androidExtraFromProto(proto, null);
}
@@ -576,7 +527,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class AndroidActivity {
private final ActionProto.AndroidActivity mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AndroidActivity(ActionProto.AndroidActivity impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -584,8 +535,7 @@
}
/** Gets the package name to send the intent to, for example, "com.example.weather". */
- @NonNull
- public String getPackageName() {
+ public @NonNull String getPackageName() {
return mImpl.getPackageName();
}
@@ -593,14 +543,12 @@
* Gets the fully qualified class name (including the package) to send the intent to, for
* example, "com.example.weather.WeatherOverviewActivity".
*/
- @NonNull
- public String getClassName() {
+ public @NonNull String getClassName() {
return mImpl.getClassName();
}
/** Gets the extras to be included in the intent. */
- @NonNull
- public Map<String, AndroidExtra> getKeyToExtraMapping() {
+ public @NonNull Map<String, AndroidExtra> getKeyToExtraMapping() {
Map<String, AndroidExtra> map = new HashMap<>();
for (Entry<String, ActionProto.AndroidExtra> entry :
mImpl.getKeyToExtraMap().entrySet()) {
@@ -611,34 +559,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AndroidActivity fromProto(
- @NonNull ActionProto.AndroidActivity proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull AndroidActivity fromProto(
+ ActionProto.@NonNull AndroidActivity proto, @Nullable Fingerprint fingerprint) {
return new AndroidActivity(proto, fingerprint);
}
- @NonNull
- static AndroidActivity fromProto(@NonNull ActionProto.AndroidActivity proto) {
+ static @NonNull AndroidActivity fromProto(ActionProto.@NonNull AndroidActivity proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ActionProto.AndroidActivity toProto() {
+ public ActionProto.@NonNull AndroidActivity toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AndroidActivity{"
+ "packageName="
+ getPackageName()
@@ -660,8 +603,7 @@
/** Sets the package name to send the intent to, for example, "com.example.weather". */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setPackageName(@NonNull String packageName) {
+ public @NonNull Builder setPackageName(@NonNull String packageName) {
mImpl.setPackageName(packageName);
mFingerprint.recordPropertyUpdate(1, packageName.hashCode());
return this;
@@ -672,8 +614,7 @@
* for example, "com.example.weather.WeatherOverviewActivity".
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setClassName(@NonNull String className) {
+ public @NonNull Builder setClassName(@NonNull String className) {
mImpl.setClassName(className);
mFingerprint.recordPropertyUpdate(2, className.hashCode());
return this;
@@ -682,8 +623,8 @@
/** Adds an entry into the extras to be included in the intent. */
@RequiresSchemaVersion(major = 1, minor = 0)
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addKeyToExtraMapping(@NonNull String key, @NonNull AndroidExtra extra) {
+ public @NonNull Builder addKeyToExtraMapping(@NonNull String key,
+ @NonNull AndroidExtra extra) {
mImpl.putKeyToExtra(key, extra.toAndroidExtraProto());
mFingerprint.recordPropertyUpdate(
key.hashCode(), checkNotNull(extra.getFingerprint()).aggregateValueAsInt());
@@ -691,8 +632,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public AndroidActivity build() {
+ public @NonNull AndroidActivity build() {
return new AndroidActivity(mImpl.build(), mFingerprint);
}
}
@@ -706,7 +646,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class LaunchAction implements Action {
private final ActionProto.LaunchAction mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
LaunchAction(ActionProto.LaunchAction impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -714,8 +654,7 @@
}
/** Gets an action to launch an Android activity. */
- @Nullable
- public AndroidActivity getAndroidActivity() {
+ public @Nullable AndroidActivity getAndroidActivity() {
if (mImpl.hasAndroidActivity()) {
return AndroidActivity.fromProto(mImpl.getAndroidActivity());
} else {
@@ -725,41 +664,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static LaunchAction fromProto(
- @NonNull ActionProto.LaunchAction proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull LaunchAction fromProto(
+ ActionProto.@NonNull LaunchAction proto, @Nullable Fingerprint fingerprint) {
return new LaunchAction(proto, fingerprint);
}
- @NonNull
- static LaunchAction fromProto(@NonNull ActionProto.LaunchAction proto) {
+ static @NonNull LaunchAction fromProto(ActionProto.@NonNull LaunchAction proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- ActionProto.LaunchAction toProto() {
+ ActionProto.@NonNull LaunchAction toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ActionProto.Action toActionProto() {
+ public ActionProto.@NonNull Action toActionProto() {
return ActionProto.Action.newBuilder().setLaunchAction(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "LaunchAction{" + "androidActivity=" + getAndroidActivity() + "}";
}
@@ -775,8 +708,7 @@
/** Sets an action to launch an Android activity. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setAndroidActivity(@NonNull AndroidActivity androidActivity) {
+ public @NonNull Builder setAndroidActivity(@NonNull AndroidActivity androidActivity) {
mImpl.setAndroidActivity(androidActivity.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(androidActivity.getFingerprint()).aggregateValueAsInt());
@@ -785,8 +717,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public LaunchAction build() {
+ public @NonNull LaunchAction build() {
return new LaunchAction(mImpl.build(), mFingerprint);
}
}
@@ -796,7 +727,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class LoadAction implements Action {
private final ActionProto.LoadAction mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
LoadAction(ActionProto.LoadAction impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -808,8 +739,7 @@
* sent after this action is invoked by a {@link
* androidx.wear.protolayout.ModifiersBuilders.Clickable}.
*/
- @Nullable
- public State getRequestState() {
+ public @Nullable State getRequestState() {
if (mImpl.hasRequestState()) {
return State.fromProto(mImpl.getRequestState());
} else {
@@ -819,40 +749,34 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static LoadAction fromProto(
- @NonNull ActionProto.LoadAction proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull LoadAction fromProto(
+ ActionProto.@NonNull LoadAction proto, @Nullable Fingerprint fingerprint) {
return new LoadAction(proto, fingerprint);
}
- @NonNull
- static LoadAction fromProto(@NonNull ActionProto.LoadAction proto) {
+ static @NonNull LoadAction fromProto(ActionProto.@NonNull LoadAction proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- ActionProto.LoadAction toProto() {
+ ActionProto.@NonNull LoadAction toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ActionProto.Action toActionProto() {
+ public ActionProto.@NonNull Action toActionProto() {
return ActionProto.Action.newBuilder().setLoadAction(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "LoadAction{" + "requestState=" + getRequestState() + "}";
}
@@ -872,8 +796,7 @@
* androidx.wear.protolayout.ModifiersBuilders.Clickable}.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setRequestState(@NonNull State requestState) {
+ public @NonNull Builder setRequestState(@NonNull State requestState) {
mImpl.setRequestState(requestState.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(requestState.getFingerprint()).aggregateValueAsInt());
@@ -882,8 +805,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public LoadAction build() {
+ public @NonNull LoadAction build() {
return new LoadAction(mImpl.build(), mFingerprint);
}
}
@@ -894,29 +816,25 @@
public interface Action {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- ActionProto.Action toActionProto();
+ ActionProto.@NonNull Action toActionProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link Action} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- Action build();
+ @NonNull Action build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Action actionFromProto(
- @NonNull ActionProto.Action proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Action actionFromProto(
+ ActionProto.@NonNull Action proto, @Nullable Fingerprint fingerprint) {
if (proto.hasLaunchAction()) {
return LaunchAction.fromProto(proto.getLaunchAction(), fingerprint);
}
@@ -926,8 +844,7 @@
throw new IllegalStateException("Proto was not a recognised instance of Action");
}
- @NonNull
- static Action actionFromProto(@NonNull ActionProto.Action proto) {
+ static @NonNull Action actionFromProto(ActionProto.@NonNull Action proto) {
return actionFromProto(proto, null);
}
}
diff --git a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/ColorBuilders.java b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/ColorBuilders.java
index 8c116f0..077c910 100644
--- a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/ColorBuilders.java
+++ b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/ColorBuilders.java
@@ -21,8 +21,6 @@
import android.graphics.Color;
import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.DimensionBuilders.DegreesProp;
@@ -33,6 +31,9 @@
import androidx.wear.protolayout.expression.RequiresSchemaVersion;
import androidx.wear.protolayout.proto.ColorProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -43,8 +44,7 @@
/** Shortcut for building a {@link ColorProp} using an ARGB value. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public static ColorProp argb(@ColorInt int colorArgb) {
+ public static @NonNull ColorProp argb(@ColorInt int colorArgb) {
return new ColorProp.Builder(colorArgb).build();
}
@@ -52,7 +52,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class ColorProp {
private final ColorProto.ColorProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ColorProp(ColorProto.ColorProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -75,8 +75,7 @@
* required to be set to support older renderers that only read the static value. If {@code
* dynamicValue} has an invalid result, the provided static value will be used instead.
*/
- @Nullable
- public DynamicColor getDynamicValue() {
+ public @Nullable DynamicColor getDynamicValue() {
if (mImpl.hasDynamicValue()) {
return DynamicBuilders.dynamicColorFromProto(mImpl.getDynamicValue());
} else {
@@ -86,34 +85,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ColorProp fromProto(
- @NonNull ColorProto.ColorProp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ColorProp fromProto(
+ ColorProto.@NonNull ColorProp proto, @Nullable Fingerprint fingerprint) {
return new ColorProp(proto, fingerprint);
}
- @NonNull
- static ColorProp fromProto(@NonNull ColorProto.ColorProp proto) {
+ static @NonNull ColorProp fromProto(ColorProto.@NonNull ColorProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ColorProto.ColorProp toProto() {
+ public ColorProto.@NonNull ColorProp toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ColorProp{" + "argb=" + getArgb() + ", dynamicValue=" + getDynamicValue() + "}";
}
@@ -145,8 +139,7 @@
* Color#TRANSPARENT}) will be used instead.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setArgb(@ColorInt int argb) {
+ public @NonNull Builder setArgb(@ColorInt int argb) {
mImpl.setArgb(argb);
mFingerprint.recordPropertyUpdate(1, argb);
return this;
@@ -159,8 +152,7 @@
* instead.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setDynamicValue(@NonNull DynamicColor dynamicValue) {
+ public @NonNull Builder setDynamicValue(@NonNull DynamicColor dynamicValue) {
mImpl.setDynamicValue(dynamicValue.toDynamicColorProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(dynamicValue.getFingerprint()).aggregateValueAsInt());
@@ -174,8 +166,7 @@
* #setDynamicValue(DynamicColor)} but neither {@link #Builder(int)} nor {@link
* #setArgb(int)} is used to provide a static value.
*/
- @NonNull
- public ColorProp build() {
+ public @NonNull ColorProp build() {
if (mImpl.hasDynamicValue() && !mImpl.hasArgb()) {
throw new IllegalStateException("Static value is missing.");
}
@@ -188,7 +179,7 @@
@RequiresSchemaVersion(major = 1, minor = 300)
public static final class ColorStop {
private final ColorProto.ColorStop mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ColorStop(ColorProto.ColorStop impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -199,8 +190,7 @@
* Gets the color for this stop. Only opaque colors are supported. Any transparent colors
* will have their alpha component set to 0xFF (opaque).
*/
- @NonNull
- public ColorProp getColor() {
+ public @NonNull ColorProp getColor() {
return ColorProp.fromProto(mImpl.getColor());
}
@@ -208,8 +198,7 @@
* Gets the relative offset for this color, between 0 and 1. This determines where the color
* is positioned relative to a gradient space.
*/
- @Nullable
- public FloatProp getOffset() {
+ public @Nullable FloatProp getOffset() {
if (mImpl.hasOffset()) {
return FloatProp.fromProto(mImpl.getOffset());
} else {
@@ -219,34 +208,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ColorStop fromProto(
- @NonNull ColorProto.ColorStop proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ColorStop fromProto(
+ ColorProto.@NonNull ColorStop proto, @Nullable Fingerprint fingerprint) {
return new ColorStop(proto, fingerprint);
}
- @NonNull
- static ColorStop fromProto(@NonNull ColorProto.ColorStop proto) {
+ static @NonNull ColorStop fromProto(ColorProto.@NonNull ColorStop proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ColorProto.ColorStop toProto() {
+ public ColorProto.@NonNull ColorStop toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ColorStop{" + "color=" + getColor() + ", offset=" + getOffset() + "}";
}
@@ -262,8 +246,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- Builder setColor(@NonNull ColorProp color) {
+ @NonNull Builder setColor(@NonNull ColorProp color) {
if (color.getDynamicValue() != null) {
throw new IllegalArgumentException(
"ColorStop.Builder.setColor doesn't support dynamic values.");
@@ -283,8 +266,7 @@
* @throws IllegalArgumentException if the offset value is outside of range [0,1].
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- Builder setOffset(@NonNull FloatProp offset) {
+ @NonNull Builder setOffset(@NonNull FloatProp offset) {
if (offset.getDynamicValue() != null) {
throw new IllegalArgumentException(
"ColorStop.Builder.setOffset doesn't support dynamic values.");
@@ -320,8 +302,7 @@
Builder() {}
/** Builds an instance from accumulated values. */
- @NonNull
- public ColorStop build() {
+ public @NonNull ColorStop build() {
return new ColorStop(mImpl.build(), mFingerprint);
}
}
@@ -337,7 +318,7 @@
@RequiresSchemaVersion(major = 1, minor = 300)
public static final class SweepGradient implements Brush {
private final ColorProto.SweepGradient mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
SweepGradient(ColorProto.SweepGradient impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -357,8 +338,7 @@
*
* <p>If offset values are not set, the colors are evenly distributed in the gradient.
*/
- @NonNull
- public List<ColorStop> getColorStops() {
+ public @NonNull List<ColorStop> getColorStops() {
List<ColorStop> list = new ArrayList<>();
for (ColorProto.ColorStop item : mImpl.getColorStopsList()) {
list.add(ColorStop.fromProto(item));
@@ -375,8 +355,7 @@
* length span. Values greater than 360 degrees correspond to upper layers of the arc line
* as it wraps over itself.
*/
- @NonNull
- public DegreesProp getStartAngle() {
+ public @NonNull DegreesProp getStartAngle() {
if (mImpl.hasStartAngle()) {
return DegreesProp.fromProto(mImpl.getStartAngle());
} else {
@@ -393,8 +372,7 @@
* length span. Values greater than 360 degrees correspond to upper layers of the arc line
* as it wraps over itself.
*/
- @NonNull
- public DegreesProp getEndAngle() {
+ public @NonNull DegreesProp getEndAngle() {
if (mImpl.hasEndAngle()) {
return DegreesProp.fromProto(mImpl.getEndAngle());
} else {
@@ -404,40 +382,34 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static SweepGradient fromProto(
- @NonNull ColorProto.SweepGradient proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull SweepGradient fromProto(
+ ColorProto.@NonNull SweepGradient proto, @Nullable Fingerprint fingerprint) {
return new SweepGradient(proto, fingerprint);
}
- @NonNull
- static SweepGradient fromProto(@NonNull ColorProto.SweepGradient proto) {
+ static @NonNull SweepGradient fromProto(ColorProto.@NonNull SweepGradient proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- ColorProto.SweepGradient toProto() {
+ ColorProto.@NonNull SweepGradient toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ColorProto.Brush toBrushProto() {
+ public ColorProto.@NonNull Brush toBrushProto() {
return ColorProto.Brush.newBuilder().setSweepGradient(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "SweepGradient{"
+ "colorStops="
+ getColorStops()
@@ -469,8 +441,7 @@
* <p>If offset values are not set, the colors are evenly distributed in the gradient.
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- private Builder addColorStop(@NonNull ColorStop colorStop) {
+ private @NonNull Builder addColorStop(@NonNull ColorStop colorStop) {
mImpl.addColorStops(colorStop.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(colorStop.getFingerprint()).aggregateValueAsInt());
@@ -489,8 +460,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setStartAngle(@NonNull DegreesProp startAngle) {
+ public @NonNull Builder setStartAngle(@NonNull DegreesProp startAngle) {
if (startAngle.getDynamicValue() != null) {
throw new IllegalArgumentException(
"SweepGradient.Builder.setStartAngle doesn't support dynamic values.");
@@ -513,8 +483,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setEndAngle(@NonNull DegreesProp endAngle) {
+ public @NonNull Builder setEndAngle(@NonNull DegreesProp endAngle) {
if (endAngle.getDynamicValue() != null) {
throw new IllegalArgumentException(
"SweepGradient.Builder.setEndAngle doesn't support dynamic values.");
@@ -538,7 +507,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 300)
@SafeVarargs
- public Builder(@NonNull ColorStop... colorStops) {
+ public Builder(ColorStop @NonNull ... colorStops) {
if (colorStops.length < 2 || colorStops.length > 10) {
throw new IllegalArgumentException(
"Size of colorStops must not be less than 2 or greater than 10. Got "
@@ -562,7 +531,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 300)
@SafeVarargs
- public Builder(@NonNull ColorProp... colors) {
+ public Builder(ColorProp @NonNull ... colors) {
if (colors.length < 2 || colors.length > 10) {
throw new IllegalArgumentException(
"Size of colors must not be less than 2 or greater than 10. Got "
@@ -581,8 +550,7 @@
* 10.
*/
@Override
- @NonNull
- public SweepGradient build() {
+ public @NonNull SweepGradient build() {
int colorStopsCount = mImpl.getColorStopsCount();
if (colorStopsCount < 2 || colorStopsCount > 10) {
throw new IllegalStateException(
@@ -601,37 +569,32 @@
public interface Brush {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- ColorProto.Brush toBrushProto();
+ ColorProto.@NonNull Brush toBrushProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link Brush} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- Brush build();
+ @NonNull Brush build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Brush brushFromProto(
- @NonNull ColorProto.Brush proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Brush brushFromProto(
+ ColorProto.@NonNull Brush proto, @Nullable Fingerprint fingerprint) {
if (proto.hasSweepGradient()) {
return SweepGradient.fromProto(proto.getSweepGradient(), fingerprint);
}
throw new IllegalStateException("Proto was not a recognised instance of Brush");
}
- @NonNull
- static Brush brushFromProto(@NonNull ColorProto.Brush proto) {
+ static @NonNull Brush brushFromProto(ColorProto.@NonNull Brush proto) {
return brushFromProto(proto, null);
}
}
diff --git a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/DeviceParametersBuilders.java b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/DeviceParametersBuilders.java
index c844392..ab4c9e1 100644
--- a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/DeviceParametersBuilders.java
+++ b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/DeviceParametersBuilders.java
@@ -21,8 +21,6 @@
import androidx.annotation.Dimension;
import androidx.annotation.FloatRange;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.OptIn;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
@@ -31,6 +29,9 @@
import androidx.wear.protolayout.expression.VersionBuilders.VersionInfo;
import androidx.wear.protolayout.proto.DeviceParametersProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -131,8 +132,7 @@
* that uses features not available on schema version 1.0 , this can be used to
* conditionally choose which feature to use.
*/
- @NonNull
- public VersionInfo getRendererSchemaVersion() {
+ public @NonNull VersionInfo getRendererSchemaVersion() {
if (mImpl.hasRendererSchemaVersion()) {
return VersionInfo.fromProto(mImpl.getRendererSchemaVersion());
} else {
@@ -142,8 +142,7 @@
/** Gets renderer supported {@link Capabilities}. */
@ProtoLayoutExperimental
- @Nullable
- public Capabilities getCapabilities() {
+ public @Nullable Capabilities getCapabilities() {
if (mImpl.hasCapabilities()) {
return Capabilities.fromProto(mImpl.getCapabilities());
} else {
@@ -153,23 +152,20 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DeviceParameters fromProto(
- @NonNull DeviceParametersProto.DeviceParameters proto) {
+ public static @NonNull DeviceParameters fromProto(
+ DeviceParametersProto.@NonNull DeviceParameters proto) {
return new DeviceParameters(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DeviceParametersProto.DeviceParameters toProto() {
+ public DeviceParametersProto.@NonNull DeviceParameters toProto() {
return mImpl;
}
@Override
@OptIn(markerClass = ProtoLayoutExperimental.class)
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "DeviceParameters{"
+ "screenWidthDp="
+ getScreenWidthDp()
@@ -200,16 +196,14 @@
/** Sets width of the device's screen in DP. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setScreenWidthDp(@Dimension(unit = DP) int screenWidthDp) {
+ public @NonNull Builder setScreenWidthDp(@Dimension(unit = DP) int screenWidthDp) {
mImpl.setScreenWidthDp(screenWidthDp);
return this;
}
/** Sets height of the device's screen in DP. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setScreenHeightDp(@Dimension(unit = DP) int screenHeightDp) {
+ public @NonNull Builder setScreenHeightDp(@Dimension(unit = DP) int screenHeightDp) {
mImpl.setScreenHeightDp(screenHeightDp);
return this;
}
@@ -219,8 +213,7 @@
* Pixels (px = dp * density).
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setScreenDensity(
+ public @NonNull Builder setScreenDensity(
@FloatRange(from = 0.0, fromInclusive = false, toInclusive = false)
float screenDensity) {
mImpl.setScreenDensity(screenDensity);
@@ -232,8 +225,7 @@
* display. This value is used to get from SP to DP (dp = sp * font_scale).
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setFontScale(
+ public @NonNull Builder setFontScale(
@FloatRange(from = 0.0, fromInclusive = false, toInclusive = false)
float fontScale) {
mImpl.setFontScale(fontScale);
@@ -242,8 +234,7 @@
/** Sets the platform of the device. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setDevicePlatform(@DevicePlatform int devicePlatform) {
+ public @NonNull Builder setDevicePlatform(@DevicePlatform int devicePlatform) {
mImpl.setDevicePlatform(
DeviceParametersProto.DevicePlatform.forNumber(devicePlatform));
return this;
@@ -251,8 +242,7 @@
/** Sets the shape of the device's screen. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setScreenShape(@ScreenShape int screenShape) {
+ public @NonNull Builder setScreenShape(@ScreenShape int screenShape) {
mImpl.setScreenShape(DeviceParametersProto.ScreenShape.forNumber(screenShape));
return this;
}
@@ -263,8 +253,8 @@
* conditionally choose which feature to use.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setRendererSchemaVersion(@NonNull VersionInfo rendererSchemaVersion) {
+ public @NonNull Builder setRendererSchemaVersion(
+ @NonNull VersionInfo rendererSchemaVersion) {
mImpl.setRendererSchemaVersion(rendererSchemaVersion.toProto());
return this;
}
@@ -272,15 +262,13 @@
/** Sets renderer supported {@link Capabilities}. */
@RequiresSchemaVersion(major = 1, minor = 200)
@ProtoLayoutExperimental
- @NonNull
- public Builder setCapabilities(@NonNull Capabilities capabilities) {
+ public @NonNull Builder setCapabilities(@NonNull Capabilities capabilities) {
mImpl.setCapabilities(capabilities.toProto());
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public DeviceParameters build() {
+ public @NonNull DeviceParameters build() {
return DeviceParameters.fromProto(mImpl.build());
}
}
@@ -312,21 +300,19 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Capabilities fromProto(@NonNull DeviceParametersProto.Capabilities proto) {
+ public static @NonNull Capabilities fromProto(
+ DeviceParametersProto.@NonNull Capabilities proto) {
return new Capabilities(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DeviceParametersProto.Capabilities toProto() {
+ public DeviceParametersProto.@NonNull Capabilities toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Capabilities{"
+ "minimumFreshnessLimitMillis="
+ getMinimumFreshnessLimitMillis()
@@ -348,15 +334,14 @@
* in unknown.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setMinimumFreshnessLimitMillis(long minimumFreshnessLimitMillis) {
+ public @NonNull Builder setMinimumFreshnessLimitMillis(
+ long minimumFreshnessLimitMillis) {
mImpl.setMinimumFreshnessLimitMillis(minimumFreshnessLimitMillis);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Capabilities build() {
+ public @NonNull Capabilities build() {
return Capabilities.fromProto(mImpl.build());
}
}
diff --git a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/DimensionBuilders.java b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/DimensionBuilders.java
index b5fbe82..597e950 100644
--- a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/DimensionBuilders.java
+++ b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/DimensionBuilders.java
@@ -23,8 +23,6 @@
import androidx.annotation.Dimension;
import androidx.annotation.FloatRange;
import androidx.annotation.IntRange;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.OptIn;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
@@ -36,6 +34,9 @@
import androidx.wear.protolayout.expression.RequiresSchemaVersion;
import androidx.wear.protolayout.proto.DimensionProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/** Builders for dimensions for layout elements. */
public final class DimensionBuilders {
private DimensionBuilders() {}
@@ -45,36 +46,31 @@
/** Shortcut for building a {@link DpProp} using a measurement in DP. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public static DpProp dp(@Dimension(unit = DP) float valueDp) {
+ public static @NonNull DpProp dp(@Dimension(unit = DP) float valueDp) {
return new DpProp.Builder(valueDp).build();
}
/** Shortcut for building a {@link SpProp} using a measurement in SP. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public static SpProp sp(@Dimension(unit = SP) float valueSp) {
+ public static @NonNull SpProp sp(@Dimension(unit = SP) float valueSp) {
return new SpProp.Builder().setValue(valueSp).build();
}
/** Shortcut for building a {@link EmProp} using a measurement in EM. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public static EmProp em(int valueEm) {
+ public static @NonNull EmProp em(int valueEm) {
return new EmProp.Builder().setValue(valueEm).build();
}
/** Shortcut for building a {@link EmProp} using a measurement in EM. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public static EmProp em(float valueEm) {
+ public static @NonNull EmProp em(float valueEm) {
return new EmProp.Builder().setValue(valueEm).build();
}
/** Shortcut for building an {@link DegreesProp} using a measurement in degrees. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public static DegreesProp degrees(float valueDegrees) {
+ public static @NonNull DegreesProp degrees(float valueDegrees) {
return new DegreesProp.Builder(valueDegrees).build();
}
@@ -83,8 +79,7 @@
* parent.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public static ExpandedDimensionProp expand() {
+ public static @NonNull ExpandedDimensionProp expand() {
return EXPAND;
}
@@ -102,8 +97,7 @@
* they are expanded, defaults to 1.
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public static ExpandedDimensionProp weight(@FloatRange(from = 0.0) float weight) {
+ public static @NonNull ExpandedDimensionProp weight(@FloatRange(from = 0.0) float weight) {
return new ExpandedDimensionProp.Builder()
.setLayoutWeight(new FloatProp.Builder(weight).build())
.build();
@@ -114,8 +108,7 @@
* children.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public static WrappedDimensionProp wrap() {
+ public static @NonNull WrappedDimensionProp wrap() {
return WRAP;
}
@@ -130,7 +123,7 @@
ExtensionDimension,
PivotDimension {
private final DimensionProto.DpProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
DpProp(DimensionProto.DpProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -153,8 +146,7 @@
* {@code dynamicValue} has an invalid result, the provided static value will be used
* instead.
*/
- @Nullable
- public DynamicFloat getDynamicValue() {
+ public @Nullable DynamicFloat getDynamicValue() {
if (mImpl.hasDynamicValue()) {
return DynamicBuilders.dynamicFloatFromProto(mImpl.getDynamicValue());
} else {
@@ -164,77 +156,66 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DpProp fromProto(
- @NonNull DimensionProto.DpProp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull DpProp fromProto(
+ DimensionProto.@NonNull DpProp proto, @Nullable Fingerprint fingerprint) {
return new DpProp(proto, fingerprint);
}
- @NonNull
- static DpProp fromProto(@NonNull DimensionProto.DpProp proto) {
+ static @NonNull DpProp fromProto(DimensionProto.@NonNull DpProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DimensionProto.DpProp toProto() {
+ DimensionProto.@NonNull DpProp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.AngularDimension toAngularDimensionProto() {
+ public DimensionProto.@NonNull AngularDimension toAngularDimensionProto() {
return DimensionProto.AngularDimension.newBuilder().setDp(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.ContainerDimension toContainerDimensionProto() {
+ public DimensionProto.@NonNull ContainerDimension toContainerDimensionProto() {
return DimensionProto.ContainerDimension.newBuilder().setLinearDimension(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.ImageDimension toImageDimensionProto() {
+ public DimensionProto.@NonNull ImageDimension toImageDimensionProto() {
return DimensionProto.ImageDimension.newBuilder().setLinearDimension(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.SpacerDimension toSpacerDimensionProto() {
+ public DimensionProto.@NonNull SpacerDimension toSpacerDimensionProto() {
return DimensionProto.SpacerDimension.newBuilder().setLinearDimension(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
@ExperimentalProtoLayoutExtensionApi
- public DimensionProto.ExtensionDimension toExtensionDimensionProto() {
+ public DimensionProto.@NonNull ExtensionDimension toExtensionDimensionProto() {
return DimensionProto.ExtensionDimension.newBuilder().setLinearDimension(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.PivotDimension toPivotDimensionProto() {
+ public DimensionProto.@NonNull PivotDimension toPivotDimensionProto() {
return DimensionProto.PivotDimension.newBuilder().setOffsetDp(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "DpProp{" + "value=" + getValue() + ", dynamicValue=" + getDynamicValue() + "}";
}
@@ -272,8 +253,7 @@
* ignored. If the static value is not specified, zero will be used instead.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(@Dimension(unit = DP) float value) {
+ public @NonNull Builder setValue(@Dimension(unit = DP) float value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, Float.floatToIntBits(value));
return this;
@@ -286,8 +266,7 @@
* instead.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setDynamicValue(@NonNull DynamicFloat dynamicValue) {
+ public @NonNull Builder setDynamicValue(@NonNull DynamicFloat dynamicValue) {
mImpl.setDynamicValue(dynamicValue.toDynamicFloatProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(dynamicValue.getFingerprint()).aggregateValueAsInt());
@@ -302,8 +281,7 @@
* #setValue(float)} is used to provide a static value.
*/
@Override
- @NonNull
- public DpProp build() {
+ public @NonNull DpProp build() {
if (mImpl.hasDynamicValue() && !mImpl.hasValue()) {
throw new IllegalStateException("Static value is missing.");
}
@@ -314,7 +292,7 @@
private static class DpPropLayoutConstraint {
protected final DimensionProto.DpProp mImpl;
- @Nullable protected final Fingerprint mFingerprint;
+ protected final @Nullable Fingerprint mFingerprint;
protected DpPropLayoutConstraint(
DimensionProto.DpProp impl, @Nullable Fingerprint fingerprint) {
@@ -335,15 +313,13 @@
@SuppressWarnings("Unused")
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
@SuppressWarnings("Unused")
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.SpacerDimension toSpacerDimensionProto() {
+ public DimensionProto.@NonNull SpacerDimension toSpacerDimensionProto() {
return DimensionProto.SpacerDimension.newBuilder().setLinearDimension(mImpl).build();
}
@@ -371,8 +347,7 @@
* of the dynamic value that is being provided.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- private Builder setValue(@Dimension(unit = DP) float value) {
+ private @NonNull Builder setValue(@Dimension(unit = DP) float value) {
mImpl.setValueForLayout(value);
mFingerprint.recordPropertyUpdate(3, Float.floatToIntBits(value));
return this;
@@ -399,8 +374,7 @@
return mImpl.getHorizontalAlignmentForLayoutValue();
}
- @NonNull
- static HorizontalLayoutConstraint fromProto(@NonNull DimensionProto.DpProp proto) {
+ static @NonNull HorizontalLayoutConstraint fromProto(DimensionProto.@NonNull DpProp proto) {
return new HorizontalLayoutConstraint(proto, null);
}
@@ -423,8 +397,7 @@
* value. If not specified, defaults to center alignment.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setHorizontalAlignment(
+ public @NonNull Builder setHorizontalAlignment(
@LayoutElementBuilders.HorizontalAlignment int horizontalAlignment) {
mImpl.setHorizontalAlignmentForLayoutValue(horizontalAlignment);
mFingerprint.recordPropertyUpdate(5, horizontalAlignment);
@@ -432,8 +405,7 @@
}
/** Builds an instance of {@link HorizontalLayoutConstraint}. */
- @NonNull
- public HorizontalLayoutConstraint build() {
+ public @NonNull HorizontalLayoutConstraint build() {
return new HorizontalLayoutConstraint(mImpl.build(), mFingerprint);
}
}
@@ -456,8 +428,7 @@
return mImpl.getVerticalAlignmentForLayoutValue();
}
- @NonNull
- static VerticalLayoutConstraint fromProto(@NonNull DimensionProto.DpProp proto) {
+ static @NonNull VerticalLayoutConstraint fromProto(DimensionProto.@NonNull DpProp proto) {
return new VerticalLayoutConstraint(proto, null);
}
@@ -480,8 +451,7 @@
* If not specified, defaults to center alignment.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setVerticalAlignment(
+ public @NonNull Builder setVerticalAlignment(
@LayoutElementBuilders.VerticalAlignment int verticalAlignment) {
mImpl.setVerticalAlignmentForLayoutValue(verticalAlignment);
mFingerprint.recordPropertyUpdate(4, verticalAlignment);
@@ -489,8 +459,7 @@
}
/** Builds an instance of {@link VerticalLayoutConstraint}. */
- @NonNull
- public VerticalLayoutConstraint build() {
+ public @NonNull VerticalLayoutConstraint build() {
return new VerticalLayoutConstraint(mImpl.build(), mFingerprint);
}
}
@@ -500,7 +469,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class SpProp {
private final DimensionProto.SpProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
SpProp(DimensionProto.SpProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -515,34 +484,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static SpProp fromProto(
- @NonNull DimensionProto.SpProp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull SpProp fromProto(
+ DimensionProto.@NonNull SpProp proto, @Nullable Fingerprint fingerprint) {
return new SpProp(proto, fingerprint);
}
- @NonNull
- static SpProp fromProto(@NonNull DimensionProto.SpProp proto) {
+ static @NonNull SpProp fromProto(DimensionProto.@NonNull SpProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.SpProp toProto() {
+ public DimensionProto.@NonNull SpProp toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "SpProp{" + "value=" + getValue() + "}";
}
@@ -556,16 +520,14 @@
/** Sets the value, in sp. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(@Dimension(unit = SP) float value) {
+ public @NonNull Builder setValue(@Dimension(unit = SP) float value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(2, Float.floatToIntBits(value));
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public SpProp build() {
+ public @NonNull SpProp build() {
return new SpProp(mImpl.build(), mFingerprint);
}
}
@@ -575,7 +537,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class EmProp {
private final DimensionProto.EmProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
EmProp(DimensionProto.EmProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -589,34 +551,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static EmProp fromProto(
- @NonNull DimensionProto.EmProp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull EmProp fromProto(
+ DimensionProto.@NonNull EmProp proto, @Nullable Fingerprint fingerprint) {
return new EmProp(proto, fingerprint);
}
- @NonNull
- static EmProp fromProto(@NonNull DimensionProto.EmProp proto) {
+ static @NonNull EmProp fromProto(DimensionProto.@NonNull EmProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.EmProp toProto() {
+ public DimensionProto.@NonNull EmProp toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "EmProp{" + "value=" + getValue() + "}";
}
@@ -630,16 +587,14 @@
/** Sets the value, in em. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(float value) {
+ public @NonNull Builder setValue(float value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, Float.floatToIntBits(value));
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public EmProp build() {
+ public @NonNull EmProp build() {
return new EmProp(mImpl.build(), mFingerprint);
}
}
@@ -652,29 +607,25 @@
public interface AngularDimension {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DimensionProto.AngularDimension toAngularDimensionProto();
+ DimensionProto.@NonNull AngularDimension toAngularDimensionProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link AngularDimension} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- AngularDimension build();
+ @NonNull AngularDimension build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AngularDimension angularDimensionFromProto(
- @NonNull DimensionProto.AngularDimension proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull AngularDimension angularDimensionFromProto(
+ DimensionProto.@NonNull AngularDimension proto, @Nullable Fingerprint fingerprint) {
if (proto.hasDegrees()) {
return DegreesProp.fromProto(proto.getDegrees(), fingerprint);
}
@@ -684,9 +635,8 @@
throw new IllegalStateException("Proto was not a recognised instance of AngularDimension");
}
- @NonNull
- static AngularDimension angularDimensionFromProto(
- @NonNull DimensionProto.AngularDimension proto) {
+ static @NonNull AngularDimension angularDimensionFromProto(
+ DimensionProto.@NonNull AngularDimension proto) {
return angularDimensionFromProto(proto, null);
}
@@ -694,7 +644,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class DegreesProp implements AngularDimension{
private final DimensionProto.DegreesProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
DegreesProp(DimensionProto.DegreesProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -716,8 +666,7 @@
* If {@code dynamicValue} has an invalid result, the provided static value will be used
* instead.
*/
- @Nullable
- public DynamicFloat getDynamicValue() {
+ public @Nullable DynamicFloat getDynamicValue() {
if (mImpl.hasDynamicValue()) {
return DynamicBuilders.dynamicFloatFromProto(mImpl.getDynamicValue());
} else {
@@ -728,40 +677,34 @@
/** Get the fingerprint for this object, or null if unknown. */
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DegreesProp fromProto(
- @NonNull DimensionProto.DegreesProp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull DegreesProp fromProto(
+ DimensionProto.@NonNull DegreesProp proto, @Nullable Fingerprint fingerprint) {
return new DegreesProp(proto, fingerprint);
}
- @NonNull
- static DegreesProp fromProto(@NonNull DimensionProto.DegreesProp proto) {
+ static @NonNull DegreesProp fromProto(DimensionProto.@NonNull DegreesProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DimensionProto.DegreesProp toProto() {
+ DimensionProto.@NonNull DegreesProp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.AngularDimension toAngularDimensionProto() {
+ public DimensionProto.@NonNull AngularDimension toAngularDimensionProto() {
return DimensionProto.AngularDimension.newBuilder().setDegrees(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "DegreesProp{"
+ "value="
+ getValue()
@@ -799,8 +742,7 @@
* ignored. If the static value is not specified, zero will be used instead.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(float value) {
+ public @NonNull Builder setValue(float value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, Float.floatToIntBits(value));
return this;
@@ -813,8 +755,7 @@
* value will be used instead.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setDynamicValue(@NonNull DynamicFloat dynamicValue) {
+ public @NonNull Builder setDynamicValue(@NonNull DynamicFloat dynamicValue) {
mImpl.setDynamicValue(dynamicValue.toDynamicFloatProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(dynamicValue.getFingerprint()).aggregateValueAsInt());
@@ -829,8 +770,7 @@
* #setValue(float)} is used to provide a static value.
*/
@Override
- @NonNull
- public DegreesProp build() {
+ public @NonNull DegreesProp build() {
if (mImpl.hasDynamicValue() && !mImpl.hasValue()) {
throw new IllegalStateException("Static value is missing.");
}
@@ -846,7 +786,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
public static final class AngularLayoutConstraint {
private final DimensionProto.DegreesProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AngularLayoutConstraint(
DimensionProto.DegreesProp impl, @Nullable Fingerprint fingerprint) {
@@ -870,19 +810,17 @@
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.DegreesProp toProto() {
+ public DimensionProto.@NonNull DegreesProp toProto() {
return mImpl;
}
- @NonNull
- static AngularLayoutConstraint fromProto(@NonNull DimensionProto.DegreesProp proto) {
+ static @NonNull AngularLayoutConstraint fromProto(
+ DimensionProto.@NonNull DegreesProp proto) {
return new AngularLayoutConstraint(proto, null);
}
@@ -907,8 +845,7 @@
* Sets the fixed value to reserve the space when used on a layout-changing data bind.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- private Builder setValue(@Dimension(unit = DP) float value) {
+ private @NonNull Builder setValue(@Dimension(unit = DP) float value) {
mImpl.setValueForLayout(value);
mFingerprint.recordPropertyUpdate(3, Float.floatToIntBits(value));
return this;
@@ -919,8 +856,7 @@
* not specified, defaults to center alignment.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setAngularAlignment(
+ public @NonNull Builder setAngularAlignment(
@LayoutElementBuilders.AngularAlignment int angularAlignment) {
mImpl.setAngularAlignmentForLayoutValue(angularAlignment);
mFingerprint.recordPropertyUpdate(4, angularAlignment);
@@ -928,8 +864,7 @@
}
/** Builds an instance of {@link AngularLayoutConstraint}. */
- @NonNull
- public AngularLayoutConstraint build() {
+ public @NonNull AngularLayoutConstraint build() {
return new AngularLayoutConstraint(mImpl.build(), mFingerprint);
}
}
@@ -943,7 +878,7 @@
public static final class ExpandedDimensionProp
implements ContainerDimension, ImageDimension, SpacerDimension {
private final DimensionProto.ExpandedDimensionProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ExpandedDimensionProp(
DimensionProto.ExpandedDimensionProp impl, @Nullable Fingerprint fingerprint) {
@@ -961,8 +896,7 @@
*
* <p>Note that negative values are not supported and it can lead to unexpected behaviour.
*/
- @Nullable
- public FloatProp getLayoutWeight() {
+ public @Nullable FloatProp getLayoutWeight() {
if (mImpl.hasLayoutWeight()) {
return FloatProp.fromProto(mImpl.getLayoutWeight());
} else {
@@ -972,37 +906,32 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ExpandedDimensionProp fromProto(
- @NonNull DimensionProto.ExpandedDimensionProp proto,
+ public static @NonNull ExpandedDimensionProp fromProto(
+ DimensionProto.@NonNull ExpandedDimensionProp proto,
@Nullable Fingerprint fingerprint) {
return new ExpandedDimensionProp(proto, fingerprint);
}
- @NonNull
- static ExpandedDimensionProp fromProto(
- @NonNull DimensionProto.ExpandedDimensionProp proto) {
+ static @NonNull ExpandedDimensionProp fromProto(
+ DimensionProto.@NonNull ExpandedDimensionProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DimensionProto.ExpandedDimensionProp toProto() {
+ DimensionProto.@NonNull ExpandedDimensionProp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.ContainerDimension toContainerDimensionProto() {
+ public DimensionProto.@NonNull ContainerDimension toContainerDimensionProto() {
return DimensionProto.ContainerDimension.newBuilder()
.setExpandedDimension(mImpl)
.build();
@@ -1010,21 +939,18 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.ImageDimension toImageDimensionProto() {
+ public DimensionProto.@NonNull ImageDimension toImageDimensionProto() {
return DimensionProto.ImageDimension.newBuilder().setExpandedDimension(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.SpacerDimension toSpacerDimensionProto() {
+ public DimensionProto.@NonNull SpacerDimension toSpacerDimensionProto() {
return DimensionProto.SpacerDimension.newBuilder().setExpandedDimension(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ExpandedDimensionProp{" + "layoutWeight=" + getLayoutWeight() + "}";
}
@@ -1055,8 +981,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setLayoutWeight(@NonNull FloatProp layoutWeight) {
+ public @NonNull Builder setLayoutWeight(@NonNull FloatProp layoutWeight) {
if (layoutWeight.getDynamicValue() != null) {
throw new IllegalArgumentException(
"ExpandedDimensionProp.Builder.setLayoutWeight doesn't support dynamic"
@@ -1070,8 +995,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public ExpandedDimensionProp build() {
+ public @NonNull ExpandedDimensionProp build() {
return new ExpandedDimensionProp(mImpl.build(), mFingerprint);
}
}
@@ -1084,7 +1008,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class WrappedDimensionProp implements ContainerDimension {
private final DimensionProto.WrappedDimensionProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
WrappedDimensionProp(
DimensionProto.WrappedDimensionProp impl, @Nullable Fingerprint fingerprint) {
@@ -1093,8 +1017,7 @@
}
/** Gets the minimum size of this dimension. If not set, then there is no minimum size. */
- @Nullable
- public DpProp getMinimumSize() {
+ public @Nullable DpProp getMinimumSize() {
if (mImpl.hasMinimumSize()) {
return DpProp.fromProto(mImpl.getMinimumSize());
} else {
@@ -1104,44 +1027,39 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static WrappedDimensionProp fromProto(
- @NonNull DimensionProto.WrappedDimensionProp proto,
+ public static @NonNull WrappedDimensionProp fromProto(
+ DimensionProto.@NonNull WrappedDimensionProp proto,
@Nullable Fingerprint fingerprint) {
return new WrappedDimensionProp(proto, fingerprint);
}
- @NonNull
- static WrappedDimensionProp fromProto(@NonNull DimensionProto.WrappedDimensionProp proto) {
+ static @NonNull WrappedDimensionProp fromProto(
+ DimensionProto.@NonNull WrappedDimensionProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DimensionProto.WrappedDimensionProp toProto() {
+ DimensionProto.@NonNull WrappedDimensionProp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.ContainerDimension toContainerDimensionProto() {
+ public DimensionProto.@NonNull ContainerDimension toContainerDimensionProto() {
return DimensionProto.ContainerDimension.newBuilder()
.setWrappedDimension(mImpl)
.build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "WrappedDimensionProp{" + "minimumSize=" + getMinimumSize() + "}";
}
@@ -1161,8 +1079,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setMinimumSize(@NonNull DpProp minimumSize) {
+ public @NonNull Builder setMinimumSize(@NonNull DpProp minimumSize) {
if (minimumSize.getDynamicValue() != null) {
throw new IllegalArgumentException(
"WrappedDimensionProp.Builder.setMinimumSize doesn't support dynamic"
@@ -1176,8 +1093,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public WrappedDimensionProp build() {
+ public @NonNull WrappedDimensionProp build() {
return new WrappedDimensionProp(mImpl.build(), mFingerprint);
}
}
@@ -1195,7 +1111,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class ProportionalDimensionProp implements ImageDimension {
private final DimensionProto.ProportionalDimensionProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ProportionalDimensionProp(
DimensionProto.ProportionalDimensionProp impl, @Nullable Fingerprint fingerprint) {
@@ -1217,45 +1133,39 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ProportionalDimensionProp fromProto(
- @NonNull DimensionProto.ProportionalDimensionProp proto,
+ public static @NonNull ProportionalDimensionProp fromProto(
+ DimensionProto.@NonNull ProportionalDimensionProp proto,
@Nullable Fingerprint fingerprint) {
return new ProportionalDimensionProp(proto, fingerprint);
}
- @NonNull
- static ProportionalDimensionProp fromProto(
- @NonNull DimensionProto.ProportionalDimensionProp proto) {
+ static @NonNull ProportionalDimensionProp fromProto(
+ DimensionProto.@NonNull ProportionalDimensionProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DimensionProto.ProportionalDimensionProp toProto() {
+ DimensionProto.@NonNull ProportionalDimensionProp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.ImageDimension toImageDimensionProto() {
+ public DimensionProto.@NonNull ImageDimension toImageDimensionProto() {
return DimensionProto.ImageDimension.newBuilder()
.setProportionalDimension(mImpl)
.build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ProportionalDimensionProp{"
+ "aspectRatioWidth="
+ getAspectRatioWidth()
@@ -1276,8 +1186,7 @@
/** Sets the width to be used when calculating the aspect ratio to preserve. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setAspectRatioWidth(@IntRange(from = 0) int aspectRatioWidth) {
+ public @NonNull Builder setAspectRatioWidth(@IntRange(from = 0) int aspectRatioWidth) {
mImpl.setAspectRatioWidth(aspectRatioWidth);
mFingerprint.recordPropertyUpdate(1, aspectRatioWidth);
return this;
@@ -1285,8 +1194,8 @@
/** Sets the height to be used when calculating the aspect ratio ratio to preserve. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setAspectRatioHeight(@IntRange(from = 0) int aspectRatioHeight) {
+ public @NonNull Builder setAspectRatioHeight(
+ @IntRange(from = 0) int aspectRatioHeight) {
mImpl.setAspectRatioHeight(aspectRatioHeight);
mFingerprint.recordPropertyUpdate(2, aspectRatioHeight);
return this;
@@ -1294,8 +1203,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public ProportionalDimensionProp build() {
+ public @NonNull ProportionalDimensionProp build() {
return new ProportionalDimensionProp(mImpl.build(), mFingerprint);
}
}
@@ -1306,29 +1214,25 @@
public interface ContainerDimension {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DimensionProto.ContainerDimension toContainerDimensionProto();
+ DimensionProto.@NonNull ContainerDimension toContainerDimensionProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link ContainerDimension} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- ContainerDimension build();
+ @NonNull ContainerDimension build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ContainerDimension containerDimensionFromProto(
- @NonNull DimensionProto.ContainerDimension proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ContainerDimension containerDimensionFromProto(
+ DimensionProto.@NonNull ContainerDimension proto, @Nullable Fingerprint fingerprint) {
if (proto.hasLinearDimension()) {
return DpProp.fromProto(proto.getLinearDimension(), fingerprint);
}
@@ -1342,9 +1246,8 @@
"Proto was not a recognised instance of ContainerDimension");
}
- @NonNull
- static ContainerDimension containerDimensionFromProto(
- @NonNull DimensionProto.ContainerDimension proto) {
+ static @NonNull ContainerDimension containerDimensionFromProto(
+ DimensionProto.@NonNull ContainerDimension proto) {
return containerDimensionFromProto(proto, null);
}
@@ -1353,29 +1256,25 @@
public interface ImageDimension {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DimensionProto.ImageDimension toImageDimensionProto();
+ DimensionProto.@NonNull ImageDimension toImageDimensionProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link ImageDimension} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- ImageDimension build();
+ @NonNull ImageDimension build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ImageDimension imageDimensionFromProto(
- @NonNull DimensionProto.ImageDimension proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ImageDimension imageDimensionFromProto(
+ DimensionProto.@NonNull ImageDimension proto, @Nullable Fingerprint fingerprint) {
if (proto.hasLinearDimension()) {
return DpProp.fromProto(proto.getLinearDimension(), fingerprint);
}
@@ -1389,8 +1288,8 @@
throw new IllegalStateException("Proto was not a recognised instance of ImageDimension");
}
- @NonNull
- static ImageDimension imageDimensionFromProto(@NonNull DimensionProto.ImageDimension proto) {
+ static @NonNull ImageDimension imageDimensionFromProto(
+ DimensionProto.@NonNull ImageDimension proto) {
return imageDimensionFromProto(proto, null);
}
@@ -1399,29 +1298,25 @@
public interface SpacerDimension {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DimensionProto.SpacerDimension toSpacerDimensionProto();
+ DimensionProto.@NonNull SpacerDimension toSpacerDimensionProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link SpacerDimension} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- SpacerDimension build();
+ @NonNull SpacerDimension build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static SpacerDimension spacerDimensionFromProto(
- @NonNull DimensionProto.SpacerDimension proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull SpacerDimension spacerDimensionFromProto(
+ DimensionProto.@NonNull SpacerDimension proto, @Nullable Fingerprint fingerprint) {
if (proto.hasLinearDimension()) {
return DpProp.fromProto(proto.getLinearDimension(), fingerprint);
}
@@ -1431,8 +1326,8 @@
throw new IllegalStateException("Proto was not a recognised instance of SpacerDimension");
}
- @NonNull
- static SpacerDimension spacerDimensionFromProto(@NonNull DimensionProto.SpacerDimension proto) {
+ static @NonNull SpacerDimension spacerDimensionFromProto(
+ DimensionProto.@NonNull SpacerDimension proto) {
return spacerDimensionFromProto(proto, null);
}
@@ -1445,29 +1340,25 @@
public interface ExtensionDimension {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DimensionProto.ExtensionDimension toExtensionDimensionProto();
+ DimensionProto.@NonNull ExtensionDimension toExtensionDimensionProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link ExtensionDimension} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- ExtensionDimension build();
+ @NonNull ExtensionDimension build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ExtensionDimension extensionDimensionFromProto(
- @NonNull DimensionProto.ExtensionDimension proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ExtensionDimension extensionDimensionFromProto(
+ DimensionProto.@NonNull ExtensionDimension proto, @Nullable Fingerprint fingerprint) {
if (proto.hasLinearDimension()) {
return DpProp.fromProto(proto.getLinearDimension(), fingerprint);
}
@@ -1475,9 +1366,8 @@
"Proto was not a recognised instance of ExtensionDimension");
}
- @NonNull
- static ExtensionDimension extensionDimensionFromProto(
- @NonNull DimensionProto.ExtensionDimension proto) {
+ static @NonNull ExtensionDimension extensionDimensionFromProto(
+ DimensionProto.@NonNull ExtensionDimension proto) {
return extensionDimensionFromProto(proto, null);
}
@@ -1485,7 +1375,7 @@
@RequiresSchemaVersion(major = 1, minor = 400)
public static final class BoundingBoxRatio implements PivotDimension {
private final DimensionProto.BoundingBoxRatio mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
BoundingBoxRatio(DimensionProto.BoundingBoxRatio impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -1498,8 +1388,7 @@
* bottom / end of the bounding box. Its default value 0.5 represents the middle of the
* bounding box. Values outside [0, 1] are also valid. Dynamic value is supported.
*/
- @NonNull
- public FloatProp getRatio() {
+ public @NonNull FloatProp getRatio() {
if (mImpl.hasRatio()) {
return FloatProp.fromProto(mImpl.getRatio());
} else {
@@ -1509,40 +1398,34 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static BoundingBoxRatio fromProto(
- @NonNull DimensionProto.BoundingBoxRatio proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull BoundingBoxRatio fromProto(
+ DimensionProto.@NonNull BoundingBoxRatio proto, @Nullable Fingerprint fingerprint) {
return new BoundingBoxRatio(proto, fingerprint);
}
- @NonNull
- static BoundingBoxRatio fromProto(@NonNull DimensionProto.BoundingBoxRatio proto) {
+ static @NonNull BoundingBoxRatio fromProto(DimensionProto.@NonNull BoundingBoxRatio proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- DimensionProto.BoundingBoxRatio toProto() {
+ DimensionProto.@NonNull BoundingBoxRatio toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.PivotDimension toPivotDimensionProto() {
+ public DimensionProto.@NonNull PivotDimension toPivotDimensionProto() {
return DimensionProto.PivotDimension.newBuilder().setLocationRatio(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "BoundingBoxRatio{" + "ratio=" + getRatio() + "}";
}
@@ -1573,8 +1456,7 @@
* of the bounding box. Values outside [0, 1] are also valid. Dynamic value is
* supported.
*/
- @NonNull
- private Builder setRatio(@NonNull FloatProp ratio) {
+ private @NonNull Builder setRatio(@NonNull FloatProp ratio) {
mImpl.setRatio(ratio.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(ratio.getFingerprint()).aggregateValueAsInt());
@@ -1583,8 +1465,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public BoundingBoxRatio build() {
+ public @NonNull BoundingBoxRatio build() {
return new BoundingBoxRatio(mImpl.build(), mFingerprint);
}
}
@@ -1598,29 +1479,25 @@
public interface PivotDimension {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DimensionProto.PivotDimension toPivotDimensionProto();
+ DimensionProto.@NonNull PivotDimension toPivotDimensionProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link PivotDimension} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- PivotDimension build();
+ @NonNull PivotDimension build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static PivotDimension pivotDimensionFromProto(
- @NonNull DimensionProto.PivotDimension proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull PivotDimension pivotDimensionFromProto(
+ DimensionProto.@NonNull PivotDimension proto, @Nullable Fingerprint fingerprint) {
if (proto.hasOffsetDp()) {
return DpProp.fromProto(proto.getOffsetDp(), fingerprint);
}
@@ -1630,8 +1507,8 @@
throw new IllegalStateException("Proto was not a recognised instance of PivotDimension");
}
- @NonNull
- static PivotDimension pivotDimensionFromProto(@NonNull DimensionProto.PivotDimension proto) {
+ static @NonNull PivotDimension pivotDimensionFromProto(
+ DimensionProto.@NonNull PivotDimension proto) {
return pivotDimensionFromProto(proto, null);
}
}
diff --git a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/LayoutElementBuilders.java b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/LayoutElementBuilders.java
index d09517e..7fba5d7 100644
--- a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/LayoutElementBuilders.java
+++ b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/LayoutElementBuilders.java
@@ -32,8 +32,6 @@
import androidx.annotation.FloatRange;
import androidx.annotation.IntDef;
import androidx.annotation.IntRange;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.OptIn;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
@@ -42,8 +40,8 @@
import androidx.wear.protolayout.ColorBuilders.Brush;
import androidx.wear.protolayout.ColorBuilders.ColorProp;
import androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters;
-import androidx.wear.protolayout.DimensionBuilders.AngularLayoutConstraint;
import androidx.wear.protolayout.DimensionBuilders.AngularDimension;
+import androidx.wear.protolayout.DimensionBuilders.AngularLayoutConstraint;
import androidx.wear.protolayout.DimensionBuilders.ContainerDimension;
import androidx.wear.protolayout.DimensionBuilders.DegreesProp;
import androidx.wear.protolayout.DimensionBuilders.DpProp;
@@ -76,6 +74,9 @@
import androidx.wear.protolayout.protobuf.ByteString;
import androidx.wear.protolayout.protobuf.InvalidProtocolBufferException;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.nio.ByteBuffer;
@@ -348,7 +349,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class FontWeightProp {
private final LayoutElementProto.FontWeightProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FontWeightProp(LayoutElementProto.FontWeightProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -363,35 +364,30 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static FontWeightProp fromProto(
- @NonNull LayoutElementProto.FontWeightProp proto,
+ public static @NonNull FontWeightProp fromProto(
+ LayoutElementProto.@NonNull FontWeightProp proto,
@Nullable Fingerprint fingerprint) {
return new FontWeightProp(proto, fingerprint);
}
- @NonNull
- static FontWeightProp fromProto(@NonNull LayoutElementProto.FontWeightProp proto) {
+ static @NonNull FontWeightProp fromProto(LayoutElementProto.@NonNull FontWeightProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.FontWeightProp toProto() {
+ public LayoutElementProto.@NonNull FontWeightProp toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "FontWeightProp{" + "value=" + getValue() + "}";
}
@@ -406,16 +402,14 @@
/** Sets the value. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(@FontWeight int value) {
+ public @NonNull Builder setValue(@FontWeight int value) {
mImpl.setValue(LayoutElementProto.FontWeight.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public FontWeightProp build() {
+ public @NonNull FontWeightProp build() {
return new FontWeightProp(mImpl.build(), mFingerprint);
}
}
@@ -426,7 +420,7 @@
@ProtoLayoutExperimental
public static final class FontVariantProp {
private final LayoutElementProto.FontVariantProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FontVariantProp(
LayoutElementProto.FontVariantProp impl, @Nullable Fingerprint fingerprint) {
@@ -442,35 +436,31 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static FontVariantProp fromProto(
- @NonNull LayoutElementProto.FontVariantProp proto,
+ public static @NonNull FontVariantProp fromProto(
+ LayoutElementProto.@NonNull FontVariantProp proto,
@Nullable Fingerprint fingerprint) {
return new FontVariantProp(proto, fingerprint);
}
- @NonNull
- static FontVariantProp fromProto(@NonNull LayoutElementProto.FontVariantProp proto) {
+ static @NonNull FontVariantProp fromProto(
+ LayoutElementProto.@NonNull FontVariantProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.FontVariantProp toProto() {
+ public LayoutElementProto.@NonNull FontVariantProp toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "FontVariantProp{" + "value=" + getValue() + "}";
}
@@ -485,16 +475,14 @@
/** Sets the value. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(@FontVariant int value) {
+ public @NonNull Builder setValue(@FontVariant int value) {
mImpl.setValue(LayoutElementProto.FontVariant.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public FontVariantProp build() {
+ public @NonNull FontVariantProp build() {
return new FontVariantProp(mImpl.build(), mFingerprint);
}
}
@@ -504,7 +492,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class SpanVerticalAlignmentProp {
private final LayoutElementProto.SpanVerticalAlignmentProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
SpanVerticalAlignmentProp(
LayoutElementProto.SpanVerticalAlignmentProp impl,
@@ -521,36 +509,31 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static SpanVerticalAlignmentProp fromProto(
- @NonNull LayoutElementProto.SpanVerticalAlignmentProp proto,
+ public static @NonNull SpanVerticalAlignmentProp fromProto(
+ LayoutElementProto.@NonNull SpanVerticalAlignmentProp proto,
@Nullable Fingerprint fingerprint) {
return new SpanVerticalAlignmentProp(proto, fingerprint);
}
- @NonNull
- static SpanVerticalAlignmentProp fromProto(
- @NonNull LayoutElementProto.SpanVerticalAlignmentProp proto) {
+ static @NonNull SpanVerticalAlignmentProp fromProto(
+ LayoutElementProto.@NonNull SpanVerticalAlignmentProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.SpanVerticalAlignmentProp toProto() {
+ public LayoutElementProto.@NonNull SpanVerticalAlignmentProp toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "SpanVerticalAlignmentProp{" + "value=" + getValue() + "}";
}
@@ -565,16 +548,14 @@
/** Sets the value. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(@SpanVerticalAlignment int value) {
+ public @NonNull Builder setValue(@SpanVerticalAlignment int value) {
mImpl.setValue(LayoutElementProto.SpanVerticalAlignment.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public SpanVerticalAlignmentProp build() {
+ public @NonNull SpanVerticalAlignmentProp build() {
return new SpanVerticalAlignmentProp(mImpl.build(), mFingerprint);
}
}
@@ -584,7 +565,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class FontStyle {
private final LayoutElementProto.FontStyle mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FontStyle(LayoutElementProto.FontStyle impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -595,8 +576,7 @@
* Gets whether the text should be rendered in a italic typeface. If not specified, defaults
* to "false".
*/
- @Nullable
- private BoolProp isItalic() {
+ private @Nullable BoolProp isItalic() {
if (mImpl.hasItalic()) {
return BoolProp.fromProto(mImpl.getItalic());
} else {
@@ -608,8 +588,7 @@
* Gets whether the text should be rendered with an underline. If not specified, defaults to
* "false".
*/
- @Nullable
- private BoolProp isUnderline() {
+ private @Nullable BoolProp isUnderline() {
if (mImpl.hasUnderline()) {
return BoolProp.fromProto(mImpl.getUnderline());
} else {
@@ -623,8 +602,7 @@
* <p>While this field is statically accessible from 1.0, it's only bindable since version
* 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
- @Nullable
- public ColorProp getColor() {
+ public @Nullable ColorProp getColor() {
if (mImpl.hasColor()) {
return ColorProp.fromProto(mImpl.getColor());
} else {
@@ -637,8 +615,7 @@
* nearest supported value will be used. If not defined, or when set to an invalid value,
* defaults to "normal".
*/
- @Nullable
- public FontWeightProp getWeight() {
+ public @Nullable FontWeightProp getWeight() {
if (mImpl.hasWeight()) {
return FontWeightProp.fromProto(mImpl.getWeight());
} else {
@@ -650,8 +627,7 @@
* Gets the text letter-spacing. Positive numbers increase the space between letters while
* negative numbers tighten the space. If not specified, defaults to 0.
*/
- @Nullable
- public EmProp getLetterSpacing() {
+ public @Nullable EmProp getLetterSpacing() {
if (mImpl.hasLetterSpacing()) {
return EmProp.fromProto(mImpl.getLetterSpacing());
} else {
@@ -664,8 +640,7 @@
* text, which can be selected using this field. If not specified, defaults to "body".
*/
@ProtoLayoutExperimental
- @Nullable
- public FontVariantProp getVariant() {
+ public @Nullable FontVariantProp getVariant() {
if (mImpl.hasVariant()) {
return FontVariantProp.fromProto(mImpl.getVariant());
} else {
@@ -678,8 +653,7 @@
*
* <p>Supported settings depend on the font used and renderer version.
*/
- @NonNull
- public List<FontSetting> getSettings() {
+ public @NonNull List<FontSetting> getSettings() {
List<FontSetting> list = new ArrayList<>();
for (LayoutElementProto.FontSetting item : mImpl.getSettingsList()) {
list.add(LayoutElementBuilders.fontSettingFromProto(item));
@@ -693,8 +667,7 @@
* preferring default system variable font with default non variable system font as a
* fallback.
*/
- @NonNull
- public List<String> getPreferredFontFamilies() {
+ public @NonNull List<String> getPreferredFontFamilies() {
return mImpl.getPreferredFontFamiliesList();
}
@@ -702,16 +675,14 @@
* Gets the size of the font, in scaled pixels (sp). If more than one size was originally
* added, it will return the last one.
*/
- @Nullable
- public SpProp getSize() {
+ public @Nullable SpProp getSize() {
List<DimensionProto.SpProp> sizes = mImpl.getSizeList();
return !sizes.isEmpty() ? SpProp.fromProto(sizes.get(sizes.size() - 1)) : null;
}
/** Gets the available sizes of the font, in scaled pixels (sp). */
- @NonNull
@ProtoLayoutExperimental
- public List<SpProp> getSizes() {
+ public @NonNull List<SpProp> getSizes() {
List<SpProp> list = new ArrayList<>();
for (DimensionProto.SpProp item : mImpl.getSizeList()) {
list.add(SpProp.fromProto(item));
@@ -724,8 +695,7 @@
* Gets whether the text should be rendered in a italic typeface. If not specified, defaults to
* "false".
*/
- @Nullable
- public BoolProp getItalic() {
+ public @Nullable BoolProp getItalic() {
return isItalic();
}
@@ -733,8 +703,7 @@
* Gets whether the text should be rendered with an underline. If not specified, defaults to
* "false".
*/
- @Nullable
- public BoolProp getUnderline() {
+ public @Nullable BoolProp getUnderline() {
return isUnderline();
}
@@ -763,35 +732,30 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static FontStyle fromProto(
- @NonNull LayoutElementProto.FontStyle proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull FontStyle fromProto(
+ LayoutElementProto.@NonNull FontStyle proto, @Nullable Fingerprint fingerprint) {
return new FontStyle(proto, fingerprint);
}
- @NonNull
- static FontStyle fromProto(@NonNull LayoutElementProto.FontStyle proto) {
+ static @NonNull FontStyle fromProto(LayoutElementProto.@NonNull FontStyle proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.FontStyle toProto() {
+ public LayoutElementProto.@NonNull FontStyle toProto() {
return mImpl;
}
@Override
@OptIn(markerClass = ProtoLayoutExperimental.class)
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "FontStyle{"
+ "size="
+ getSize()
@@ -830,8 +794,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setItalic(@NonNull BoolProp italic) {
+ public @NonNull Builder setItalic(@NonNull BoolProp italic) {
if (italic.getDynamicValue() != null) {
throw new IllegalArgumentException(
"FontStyle.Builder.setItalic doesn't support dynamic values.");
@@ -848,8 +811,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 0)
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setItalic(boolean italic) {
+ public @NonNull Builder setItalic(boolean italic) {
return setItalic(new BoolProp.Builder(italic).build());
}
@@ -860,8 +822,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setUnderline(@NonNull BoolProp underline) {
+ public @NonNull Builder setUnderline(@NonNull BoolProp underline) {
if (underline.getDynamicValue() != null) {
throw new IllegalArgumentException(
"FontStyle.Builder.setUnderline doesn't support dynamic values.");
@@ -878,8 +839,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 0)
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setUnderline(boolean underline) {
+ public @NonNull Builder setUnderline(boolean underline) {
return setUnderline(new BoolProp.Builder(underline).build());
}
@@ -890,8 +850,7 @@
* version 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setColor(@NonNull ColorProp color) {
+ public @NonNull Builder setColor(@NonNull ColorProp color) {
mImpl.setColor(color.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(color.getFingerprint()).aggregateValueAsInt());
@@ -904,8 +863,7 @@
* value, defaults to "normal".
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setWeight(@NonNull FontWeightProp weight) {
+ public @NonNull Builder setWeight(@NonNull FontWeightProp weight) {
mImpl.setWeight(weight.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(weight.getFingerprint()).aggregateValueAsInt());
@@ -918,8 +876,7 @@
* value, defaults to "normal".
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setWeight(@FontWeight int weight) {
+ public @NonNull Builder setWeight(@FontWeight int weight) {
return setWeight(new FontWeightProp.Builder().setValue(weight).build());
}
@@ -928,8 +885,7 @@
* while negative numbers tighten the space. If not specified, defaults to 0.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setLetterSpacing(@NonNull EmProp letterSpacing) {
+ public @NonNull Builder setLetterSpacing(@NonNull EmProp letterSpacing) {
mImpl.setLetterSpacing(letterSpacing.toProto());
mFingerprint.recordPropertyUpdate(
6, checkNotNull(letterSpacing.getFingerprint()).aggregateValueAsInt());
@@ -942,8 +898,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 0)
@ProtoLayoutExperimental
- @NonNull
- public Builder setVariant(@NonNull FontVariantProp variant) {
+ public @NonNull Builder setVariant(@NonNull FontVariantProp variant) {
mImpl.setVariant(variant.toProto());
mFingerprint.recordPropertyUpdate(
7, checkNotNull(variant.getFingerprint()).aggregateValueAsInt());
@@ -956,8 +911,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 0)
@ProtoLayoutExperimental
- @NonNull
- public Builder setVariant(@FontVariant int variant) {
+ public @NonNull Builder setVariant(@FontVariant int variant) {
mImpl.setVariant(
LayoutElementProto.FontVariantProp.newBuilder()
.setValue(LayoutElementProto.FontVariant.forNumber(variant)));
@@ -973,8 +927,7 @@
* always available.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- private Builder addSetting(@NonNull FontSetting setting) {
+ private @NonNull Builder addSetting(@NonNull FontSetting setting) {
mImpl.addSettings(setting.toFontSettingProto());
mFingerprint.recordPropertyUpdate(
8, checkNotNull(setting.getFingerprint()).aggregateValueAsInt());
@@ -988,8 +941,7 @@
* variable system font as a fallback. If not set, defaults to system font.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- private Builder addPreferredFontFamily(@NonNull String preferredFontFamily) {
+ private @NonNull Builder addPreferredFontFamily(@NonNull String preferredFontFamily) {
mImpl.addPreferredFontFamilies(preferredFontFamily);
mFingerprint.recordPropertyUpdate(9, preferredFontFamily.hashCode());
return this;
@@ -1027,11 +979,10 @@
* @throws IllegalArgumentException if the number of available sizes is larger than 10
* or one of the sizes is not a positive value.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 300)
@ProtoLayoutExperimental
- public Builder setSizes(
- @NonNull @IntRange(from = 1) @Dimension(unit = Dimension.SP) int... sizes) {
+ public @NonNull Builder setSizes(
+ @IntRange(from = 1) @Dimension(unit = Dimension.SP) int @NonNull ... sizes) {
if (sizes.length > TEXT_SIZES_LIMIT) {
throw new IllegalArgumentException(
"Number of available sizes of the font style can't be larger than 10.");
@@ -1061,8 +1012,7 @@
* <p>Any previously added values with this method or {@link #setSizes} will be cleared.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setSize(@NonNull SpProp size) {
+ public @NonNull Builder setSize(@NonNull SpProp size) {
mImpl.clearSize();
mImpl.addSize(size.toProto());
mFingerprint.recordPropertyUpdate(
@@ -1089,9 +1039,8 @@
* preferred font family is not available.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setPreferredFontFamilies(
- @NonNull @FontFamilyName String fontFamily, @NonNull String... fallbacks) {
+ public @NonNull Builder setPreferredFontFamilies(
+ @FontFamilyName @NonNull String fontFamily, String @NonNull ... fallbacks) {
addPreferredFontFamily(fontFamily);
for (String fallback : fallbacks) {
addPreferredFontFamily(fallback);
@@ -1115,8 +1064,7 @@
* 10.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setSettings(@NonNull FontSetting... settings) {
+ public @NonNull Builder setSettings(FontSetting @NonNull ... settings) {
if (settings.length > SETTINGS_LIMIT) {
throw new IllegalArgumentException(
"Number of given FontSetting can't be larger than " + SETTINGS_LIMIT
@@ -1156,8 +1104,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public FontStyle build() {
+ public @NonNull FontStyle build() {
return new FontStyle(mImpl.build(), mFingerprint);
}
}
@@ -1168,8 +1115,7 @@
public interface FontSetting {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.FontSetting toFontSettingProto();
+ LayoutElementProto.@NonNull FontSetting toFontSettingProto();
/**
* {@link FontSetting} option for custom weight for font. Similar to the {@link
@@ -1182,9 +1128,8 @@
* @param value weight, usually in 1..1000, but actual range can be smaller, depending on
* the font used
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 400)
- static FontSetting weight(@IntRange(from = 1, to = 1000) int value) {
+ static @NonNull FontSetting weight(@IntRange(from = 1, to = 1000) int value) {
return new FontVariationSetting.Builder(WEIGHT_AXIS_TAG, value).build();
}
@@ -1194,9 +1139,8 @@
*
* @param value width, usually in 25..200, but actual range can depend on the font used
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 400)
- static FontSetting width(@FloatRange(from = 25, to = 200) float value) {
+ static @NonNull FontSetting width(@FloatRange(from = 25, to = 200) float value) {
return new FontVariationSetting.Builder(WIDTH_AXIS_TAG, value).build();
}
@@ -1209,32 +1153,28 @@
* families, some of them like Roboto automatically space out numeral characters to have the
* same width, while other characters will have their own width.
*/
- @NonNull
@RequiresSchemaVersion(major = 1, minor = 400)
- static FontSetting tabularNum() {
+ static @NonNull FontSetting tabularNum() {
return new FontFeatureSetting.Builder(TABULAR_OPTION_TAG).build();
}
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link FontSetting} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- FontSetting build();
+ @NonNull FontSetting build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static FontSetting fontSettingFromProto(
- @NonNull LayoutElementProto.FontSetting proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull FontSetting fontSettingFromProto(
+ LayoutElementProto.@NonNull FontSetting proto, @Nullable Fingerprint fingerprint) {
if (proto.hasVariation()) {
return FontVariationSetting.fromProto(proto.getVariation(), fingerprint);
}
@@ -1244,8 +1184,8 @@
throw new IllegalStateException("Proto was not a recognised instance of FontSetting");
}
- @NonNull
- static FontSetting fontSettingFromProto(@NonNull LayoutElementProto.FontSetting proto) {
+ static @NonNull FontSetting fontSettingFromProto(
+ LayoutElementProto.@NonNull FontSetting proto) {
return fontSettingFromProto(proto, null);
}
@@ -1253,7 +1193,7 @@
@RequiresSchemaVersion(major = 1, minor = 400)
static final class FontVariationSetting implements FontSetting {
private final LayoutElementProto.FontVariationSetting mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FontVariationSetting(
LayoutElementProto.FontVariationSetting impl, @Nullable Fingerprint fingerprint) {
@@ -1267,9 +1207,8 @@
}
/** Gets the axis tag for this font setting. This represents a 4 ASCII characters tag. */
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- public String getAxisTag() {
+ public @NonNull String getAxisTag() {
return new String(ByteBuffer.allocate(4).putInt(mImpl.getAxisTag()).array(), US_ASCII);
}
@@ -1295,42 +1234,36 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static FontVariationSetting fromProto(
- @NonNull LayoutElementProto.FontVariationSetting proto,
+ public static @NonNull FontVariationSetting fromProto(
+ LayoutElementProto.@NonNull FontVariationSetting proto,
@Nullable Fingerprint fingerprint) {
return new FontVariationSetting(proto, fingerprint);
}
- @NonNull
- static FontVariationSetting fromProto(
- @NonNull LayoutElementProto.FontVariationSetting proto) {
+ static @NonNull FontVariationSetting fromProto(
+ LayoutElementProto.@NonNull FontVariationSetting proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- LayoutElementProto.FontVariationSetting toProto() {
+ LayoutElementProto.@NonNull FontVariationSetting toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.FontSetting toFontSettingProto() {
+ public LayoutElementProto.@NonNull FontSetting toFontSettingProto() {
return LayoutElementProto.FontSetting.newBuilder().setVariation(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "FontVariationSetting{" + "value=" + getValue() + "}";
}
@@ -1343,8 +1276,7 @@
/** Sets the value for this setting. */
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- Builder setValue(float value) {
+ @NonNull Builder setValue(float value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(2, Float.floatToIntBits(value));
return this;
@@ -1367,8 +1299,7 @@
* Sets the axis tag for this font setting. This represents a 4 ASCII characters tag.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- Builder setAxisTag(@NonNull String axisTag) {
+ @NonNull Builder setAxisTag(@NonNull String axisTag) {
int axisTagInt = ByteBuffer.wrap(axisTag.getBytes()).getInt();
mImpl.setAxisTag(axisTagInt);
mFingerprint.recordPropertyUpdate(1, axisTagInt);
@@ -1377,8 +1308,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public FontVariationSetting build() {
+ public @NonNull FontVariationSetting build() {
return new FontVariationSetting(mImpl.build(), mFingerprint);
}
}
@@ -1388,7 +1318,7 @@
@RequiresSchemaVersion(major = 1, minor = 400)
static final class FontFeatureSetting implements FontSetting {
private final LayoutElementProto.FontFeatureSetting mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FontFeatureSetting(
LayoutElementProto.FontFeatureSetting impl, @Nullable Fingerprint fingerprint) {
@@ -1397,9 +1327,8 @@
}
/** Gets the feature tag. This represents a 4 ASCII characters tag. */
- @NonNull
@RestrictTo(Scope.LIBRARY_GROUP)
- public String getTag() {
+ public @NonNull String getTag() {
return new String(
ByteBuffer.allocate(4).putInt(mImpl.getTag()).array(),
StandardCharsets.US_ASCII);
@@ -1426,41 +1355,36 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static FontFeatureSetting fromProto(
- @NonNull LayoutElementProto.FontFeatureSetting proto,
+ public static @NonNull FontFeatureSetting fromProto(
+ LayoutElementProto.@NonNull FontFeatureSetting proto,
@Nullable Fingerprint fingerprint) {
return new FontFeatureSetting(proto, fingerprint);
}
- @NonNull
- static FontFeatureSetting fromProto(@NonNull LayoutElementProto.FontFeatureSetting proto) {
+ static @NonNull FontFeatureSetting fromProto(
+ LayoutElementProto.@NonNull FontFeatureSetting proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- LayoutElementProto.FontFeatureSetting toProto() {
+ LayoutElementProto.@NonNull FontFeatureSetting toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.FontSetting toFontSettingProto() {
+ public LayoutElementProto.@NonNull FontSetting toFontSettingProto() {
return LayoutElementProto.FontSetting.newBuilder().setFeature(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "FontFeatureSetting";
}
@@ -1483,8 +1407,7 @@
/** Sets the feature tag. This represents a 4 ASCII characters tag. */
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- Builder setTag(@NonNull String tag) {
+ @NonNull Builder setTag(@NonNull String tag) {
int tagInt = ByteBuffer.wrap(tag.getBytes()).getInt();
mImpl.setTag(tagInt);
mFingerprint.recordPropertyUpdate(1, tagInt);
@@ -1493,8 +1416,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public FontFeatureSetting build() {
+ public @NonNull FontFeatureSetting build() {
return new FontFeatureSetting(mImpl.build(), mFingerprint);
}
}
@@ -1504,7 +1426,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class TextOverflowProp {
private final LayoutElementProto.TextOverflowProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
TextOverflowProp(
LayoutElementProto.TextOverflowProp impl, @Nullable Fingerprint fingerprint) {
@@ -1520,35 +1442,31 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static TextOverflowProp fromProto(
- @NonNull LayoutElementProto.TextOverflowProp proto,
+ public static @NonNull TextOverflowProp fromProto(
+ LayoutElementProto.@NonNull TextOverflowProp proto,
@Nullable Fingerprint fingerprint) {
return new TextOverflowProp(proto, fingerprint);
}
- @NonNull
- static TextOverflowProp fromProto(@NonNull LayoutElementProto.TextOverflowProp proto) {
+ static @NonNull TextOverflowProp fromProto(
+ LayoutElementProto.@NonNull TextOverflowProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.TextOverflowProp toProto() {
+ public LayoutElementProto.@NonNull TextOverflowProp toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "TextOverflowProp{" + "value=" + getValue() + "}";
}
@@ -1563,16 +1481,14 @@
/** Sets the value. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(@TextOverflow int value) {
+ public @NonNull Builder setValue(@TextOverflow int value) {
mImpl.setValue(LayoutElementProto.TextOverflow.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public TextOverflowProp build() {
+ public @NonNull TextOverflowProp build() {
return new TextOverflowProp(mImpl.build(), mFingerprint);
}
}
@@ -1583,7 +1499,7 @@
@ProtoLayoutExperimental
static final class MarqueeParameters {
private final LayoutElementProto.MarqueeParameters mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
MarqueeParameters(
LayoutElementProto.MarqueeParameters impl, @Nullable Fingerprint fingerprint) {
@@ -1602,35 +1518,31 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static MarqueeParameters fromProto(
- @NonNull LayoutElementProto.MarqueeParameters proto,
+ public static @NonNull MarqueeParameters fromProto(
+ LayoutElementProto.@NonNull MarqueeParameters proto,
@Nullable Fingerprint fingerprint) {
return new MarqueeParameters(proto, fingerprint);
}
- @NonNull
- static MarqueeParameters fromProto(@NonNull LayoutElementProto.MarqueeParameters proto) {
+ static @NonNull MarqueeParameters fromProto(
+ LayoutElementProto.@NonNull MarqueeParameters proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.MarqueeParameters toProto() {
+ public LayoutElementProto.@NonNull MarqueeParameters toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "MarqueeParameters{" + "iterations=" + getIterations() + "}";
}
@@ -1650,16 +1562,14 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@ProtoLayoutExperimental
- @NonNull
- public Builder setIterations(int iterations) {
+ public @NonNull Builder setIterations(int iterations) {
mImpl.setIterations(iterations);
mFingerprint.recordPropertyUpdate(1, iterations);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public MarqueeParameters build() {
+ public @NonNull MarqueeParameters build() {
return new MarqueeParameters(mImpl.build(), mFingerprint);
}
}
@@ -1669,7 +1579,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class Text implements LayoutElement {
private final LayoutElementProto.Text mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Text(LayoutElementProto.Text impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -1687,8 +1597,7 @@
* {@code setLayoutConstraintsForDynamicText(StringLayoutConstraint)} otherwise
* {@code build()} fails.
*/
- @Nullable
- public StringProp getText() {
+ public @Nullable StringProp getText() {
if (mImpl.hasText()) {
return StringProp.fromProto(mImpl.getText());
} else {
@@ -1700,8 +1609,7 @@
* Gets the style of font to use (size, bold etc). If not specified, defaults to the
* platform's default body font.
*/
- @Nullable
- public FontStyle getFontStyle() {
+ public @Nullable FontStyle getFontStyle() {
if (mImpl.hasFontStyle()) {
return FontStyle.fromProto(mImpl.getFontStyle());
} else {
@@ -1710,8 +1618,7 @@
}
/** Gets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element. */
- @Nullable
- public Modifiers getModifiers() {
+ public @Nullable Modifiers getModifiers() {
if (mImpl.hasModifiers()) {
return Modifiers.fromProto(mImpl.getModifiers());
} else {
@@ -1723,8 +1630,7 @@
* Gets the maximum number of lines that can be represented by the {@link Text} element. If
* not defined, the {@link Text} element will be treated as a single-line element.
*/
- @Nullable
- public Int32Prop getMaxLines() {
+ public @Nullable Int32Prop getMaxLines() {
if (mImpl.hasMaxLines()) {
return Int32Prop.fromProto(mImpl.getMaxLines());
} else {
@@ -1739,8 +1645,7 @@
* the alignment of lines relative to the {@link Text} element bounds. If not defined,
* defaults to TEXT_ALIGN_CENTER.
*/
- @Nullable
- public TextAlignmentProp getMultilineAlignment() {
+ public @Nullable TextAlignmentProp getMultilineAlignment() {
if (mImpl.hasMultilineAlignment()) {
return TextAlignmentProp.fromProto(mImpl.getMultilineAlignment());
} else {
@@ -1755,8 +1660,7 @@
* which cannot fit inside its container will be truncated. If not defined, defaults to
* TEXT_OVERFLOW_TRUNCATE.
*/
- @Nullable
- public TextOverflowProp getOverflow() {
+ public @Nullable TextOverflowProp getOverflow() {
if (mImpl.hasOverflow()) {
return TextOverflowProp.fromProto(mImpl.getOverflow());
} else {
@@ -1769,8 +1673,7 @@
* distance between subsequent baselines. If not specified, defaults the font's recommended
* interline spacing.
*/
- @Nullable
- public SpProp getLineHeight() {
+ public @Nullable SpProp getLineHeight() {
if (mImpl.hasLineHeight()) {
return SpProp.fromProto(mImpl.getLineHeight());
} else {
@@ -1792,8 +1695,7 @@
* Gets the bounding constraints for the layout affected by the dynamic value from {@link
* #getText()}.
*/
- @Nullable
- public StringLayoutConstraint getLayoutConstraintsForDynamicText() {
+ public @Nullable StringLayoutConstraint getLayoutConstraintsForDynamicText() {
if (mImpl.hasText()) {
return StringLayoutConstraint.fromProto(mImpl.getText());
} else {
@@ -1803,42 +1705,36 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Text fromProto(
- @NonNull LayoutElementProto.Text proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Text fromProto(
+ LayoutElementProto.@NonNull Text proto, @Nullable Fingerprint fingerprint) {
return new Text(proto, fingerprint);
}
- @NonNull
- static Text fromProto(@NonNull LayoutElementProto.Text proto) {
+ static @NonNull Text fromProto(LayoutElementProto.@NonNull Text proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.Text toProto() {
+ LayoutElementProto.@NonNull Text toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return LayoutElementProto.LayoutElement.newBuilder().setText(mImpl).build();
}
@Override
@OptIn(markerClass = ProtoLayoutExperimental.class)
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Text{"
+ "text="
+ getText()
@@ -1883,8 +1779,7 @@
* fails.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setText(@NonNull StringProp text) {
+ public @NonNull Builder setText(@NonNull StringProp text) {
mImpl.mergeText(text.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(text.getFingerprint()).aggregateValueAsInt());
@@ -1896,8 +1791,7 @@
* platform's default body font.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setFontStyle(@NonNull FontStyle fontStyle) {
+ public @NonNull Builder setFontStyle(@NonNull FontStyle fontStyle) {
mImpl.setFontStyle(fontStyle.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(fontStyle.getFingerprint()).aggregateValueAsInt());
@@ -1908,8 +1802,7 @@
* Sets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setModifiers(@NonNull Modifiers modifiers) {
+ public @NonNull Builder setModifiers(@NonNull Modifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -1921,8 +1814,7 @@
* If not defined, the {@link Text} element will be treated as a single-line element.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setMaxLines(@NonNull Int32Prop maxLines) {
+ public @NonNull Builder setMaxLines(@NonNull Int32Prop maxLines) {
mImpl.setMaxLines(maxLines.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(maxLines.getFingerprint()).aggregateValueAsInt());
@@ -1933,8 +1825,7 @@
* Sets the maximum number of lines that can be represented by the {@link Text} element.
* If not defined, the {@link Text} element will be treated as a single-line element.
*/
- @NonNull
- public Builder setMaxLines(@IntRange(from = 1) int maxLines) {
+ public @NonNull Builder setMaxLines(@IntRange(from = 1) int maxLines) {
return setMaxLines(new Int32Prop.Builder().setValue(maxLines).build());
}
@@ -1946,8 +1837,8 @@
* defined, defaults to TEXT_ALIGN_CENTER.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setMultilineAlignment(@NonNull TextAlignmentProp multilineAlignment) {
+ public @NonNull Builder setMultilineAlignment(
+ @NonNull TextAlignmentProp multilineAlignment) {
mImpl.setMultilineAlignment(multilineAlignment.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(multilineAlignment.getFingerprint()).aggregateValueAsInt());
@@ -1962,8 +1853,7 @@
* defined, defaults to TEXT_ALIGN_CENTER.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setMultilineAlignment(@TextAlignment int multilineAlignment) {
+ public @NonNull Builder setMultilineAlignment(@TextAlignment int multilineAlignment) {
return setMultilineAlignment(
new TextAlignmentProp.Builder().setValue(multilineAlignment).build());
}
@@ -1976,8 +1866,7 @@
* defined, defaults to TEXT_OVERFLOW_TRUNCATE.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setOverflow(@NonNull TextOverflowProp overflow) {
+ public @NonNull Builder setOverflow(@NonNull TextOverflowProp overflow) {
mImpl.setOverflow(overflow.toProto());
mFingerprint.recordPropertyUpdate(
6, checkNotNull(overflow.getFingerprint()).aggregateValueAsInt());
@@ -1992,8 +1881,7 @@
* defined, defaults to TEXT_OVERFLOW_TRUNCATE.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setOverflow(@TextOverflow int overflow) {
+ public @NonNull Builder setOverflow(@TextOverflow int overflow) {
return setOverflow(new TextOverflowProp.Builder().setValue(overflow).build());
}
@@ -2003,8 +1891,7 @@
* recommended interline spacing.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setLineHeight(@NonNull SpProp lineHeight) {
+ public @NonNull Builder setLineHeight(@NonNull SpProp lineHeight) {
mImpl.setLineHeight(lineHeight.toProto());
mFingerprint.recordPropertyUpdate(
7, checkNotNull(lineHeight.getFingerprint()).aggregateValueAsInt());
@@ -2018,8 +1905,8 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@ProtoLayoutExperimental
- @NonNull
- public Builder setMarqueeIterations(@IntRange(from = -1) int marqueeIterations) {
+ public @NonNull Builder setMarqueeIterations(
+ @IntRange(from = -1) int marqueeIterations) {
mImpl.setMarqueeParameters(
LayoutElementProto.MarqueeParameters.newBuilder()
.setIterations(marqueeIterations));
@@ -2032,8 +1919,7 @@
* {@link #setText(StringProp)}}.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setLayoutConstraintsForDynamicText(
+ public @NonNull Builder setLayoutConstraintsForDynamicText(
@NonNull StringLayoutConstraint stringLayoutConstraint) {
mImpl.mergeText(stringLayoutConstraint.toProto());
mFingerprint.recordPropertyUpdate(
@@ -2045,14 +1931,12 @@
/** Sets the static text to render. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setText(@NonNull String text) {
+ public @NonNull Builder setText(@NonNull String text) {
return setText(new StringProp.Builder(text).build());
}
@Override
- @NonNull
- public Text build() {
+ public @NonNull Text build() {
TypesProto.StringProp text = mImpl.getText();
if (text.hasDynamicValue() && !text.hasValueForLayout()) {
throw new IllegalStateException(
@@ -2068,7 +1952,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class ContentScaleModeProp {
private final LayoutElementProto.ContentScaleModeProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ContentScaleModeProp(
LayoutElementProto.ContentScaleModeProp impl, @Nullable Fingerprint fingerprint) {
@@ -2084,36 +1968,31 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ContentScaleModeProp fromProto(
- @NonNull LayoutElementProto.ContentScaleModeProp proto,
+ public static @NonNull ContentScaleModeProp fromProto(
+ LayoutElementProto.@NonNull ContentScaleModeProp proto,
@Nullable Fingerprint fingerprint) {
return new ContentScaleModeProp(proto, fingerprint);
}
- @NonNull
- static ContentScaleModeProp fromProto(
- @NonNull LayoutElementProto.ContentScaleModeProp proto) {
+ static @NonNull ContentScaleModeProp fromProto(
+ LayoutElementProto.@NonNull ContentScaleModeProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.ContentScaleModeProp toProto() {
+ public LayoutElementProto.@NonNull ContentScaleModeProp toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ContentScaleModeProp{" + "value=" + getValue() + "}";
}
@@ -2128,16 +2007,14 @@
/** Sets the value. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(@ContentScaleMode int value) {
+ public @NonNull Builder setValue(@ContentScaleMode int value) {
mImpl.setValue(LayoutElementProto.ContentScaleMode.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public ContentScaleModeProp build() {
+ public @NonNull ContentScaleModeProp build() {
return new ContentScaleModeProp(mImpl.build(), mFingerprint);
}
}
@@ -2147,7 +2024,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class ColorFilter {
private final LayoutElementProto.ColorFilter mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ColorFilter(LayoutElementProto.ColorFilter impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -2165,8 +2042,7 @@
* <p>While this field is statically accessible from 1.0, it's only bindable since version
* 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
- @Nullable
- public ColorProp getTint() {
+ public @Nullable ColorProp getTint() {
if (mImpl.hasTint()) {
return ColorProp.fromProto(mImpl.getTint());
} else {
@@ -2176,34 +2052,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ColorFilter fromProto(
- @NonNull LayoutElementProto.ColorFilter proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ColorFilter fromProto(
+ LayoutElementProto.@NonNull ColorFilter proto, @Nullable Fingerprint fingerprint) {
return new ColorFilter(proto, fingerprint);
}
- @NonNull
- static ColorFilter fromProto(@NonNull LayoutElementProto.ColorFilter proto) {
+ static @NonNull ColorFilter fromProto(LayoutElementProto.@NonNull ColorFilter proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.ColorFilter toProto() {
+ public LayoutElementProto.@NonNull ColorFilter toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ColorFilter{" + "tint=" + getTint() + "}";
}
@@ -2228,8 +2099,7 @@
* version 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setTint(@NonNull ColorProp tint) {
+ public @NonNull Builder setTint(@NonNull ColorProp tint) {
mImpl.setTint(tint.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(tint.getFingerprint()).aggregateValueAsInt());
@@ -2237,8 +2107,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public ColorFilter build() {
+ public @NonNull ColorFilter build() {
return new ColorFilter(mImpl.build(), mFingerprint);
}
}
@@ -2254,7 +2123,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class Image implements LayoutElement {
private final LayoutElementProto.Image mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Image(LayoutElementProto.Image impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -2265,8 +2134,7 @@
* Gets the resource_id of the image to render. This must exist in the supplied resource
* bundle.
*/
- @Nullable
- public StringProp getResourceId() {
+ public @Nullable StringProp getResourceId() {
if (mImpl.hasResourceId()) {
return StringProp.fromProto(mImpl.getResourceId());
} else {
@@ -2275,8 +2143,7 @@
}
/** Gets the width of this image. If not defined, the image will not be rendered. */
- @Nullable
- public ImageDimension getWidth() {
+ public @Nullable ImageDimension getWidth() {
if (mImpl.hasWidth()) {
return DimensionBuilders.imageDimensionFromProto(mImpl.getWidth());
} else {
@@ -2285,8 +2152,7 @@
}
/** Gets the height of this image. If not defined, the image will not be rendered. */
- @Nullable
- public ImageDimension getHeight() {
+ public @Nullable ImageDimension getHeight() {
if (mImpl.hasHeight()) {
return DimensionBuilders.imageDimensionFromProto(mImpl.getHeight());
} else {
@@ -2298,8 +2164,7 @@
* Gets how to scale the image resource inside the bounds specified by width/height if its
* size does not match those bounds. Defaults to CONTENT_SCALE_MODE_FIT.
*/
- @Nullable
- public ContentScaleModeProp getContentScaleMode() {
+ public @Nullable ContentScaleModeProp getContentScaleMode() {
if (mImpl.hasContentScaleMode()) {
return ContentScaleModeProp.fromProto(mImpl.getContentScaleMode());
} else {
@@ -2308,8 +2173,7 @@
}
/** Gets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element. */
- @Nullable
- public Modifiers getModifiers() {
+ public @Nullable Modifiers getModifiers() {
if (mImpl.hasModifiers()) {
return Modifiers.fromProto(mImpl.getModifiers());
} else {
@@ -2318,8 +2182,7 @@
}
/** Gets filtering parameters for this image. If not specified, defaults to no filtering. */
- @Nullable
- public ColorFilter getColorFilter() {
+ public @Nullable ColorFilter getColorFilter() {
if (mImpl.hasColorFilter()) {
return ColorFilter.fromProto(mImpl.getColorFilter());
} else {
@@ -2329,41 +2192,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Image fromProto(
- @NonNull LayoutElementProto.Image proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Image fromProto(
+ LayoutElementProto.@NonNull Image proto, @Nullable Fingerprint fingerprint) {
return new Image(proto, fingerprint);
}
- @NonNull
- static Image fromProto(@NonNull LayoutElementProto.Image proto) {
+ static @NonNull Image fromProto(LayoutElementProto.@NonNull Image proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.Image toProto() {
+ LayoutElementProto.@NonNull Image toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return LayoutElementProto.LayoutElement.newBuilder().setImage(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Image{"
+ "resourceId="
+ getResourceId()
@@ -2397,8 +2254,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setResourceId(@NonNull StringProp resourceId) {
+ public @NonNull Builder setResourceId(@NonNull StringProp resourceId) {
if (resourceId.getDynamicValue() != null) {
throw new IllegalArgumentException(
"Image.Builder.setResourceId doesn't support dynamic values.");
@@ -2414,15 +2270,13 @@
* bundle.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setResourceId(@NonNull String resourceId) {
+ public @NonNull Builder setResourceId(@NonNull String resourceId) {
return setResourceId(new StringProp.Builder(resourceId).build());
}
/** Sets the width of this image. If not defined, the image will not be rendered. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setWidth(@NonNull ImageDimension width) {
+ public @NonNull Builder setWidth(@NonNull ImageDimension width) {
mImpl.setWidth(width.toImageDimensionProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(width.getFingerprint()).aggregateValueAsInt());
@@ -2431,8 +2285,7 @@
/** Sets the height of this image. If not defined, the image will not be rendered. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setHeight(@NonNull ImageDimension height) {
+ public @NonNull Builder setHeight(@NonNull ImageDimension height) {
mImpl.setHeight(height.toImageDimensionProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(height.getFingerprint()).aggregateValueAsInt());
@@ -2444,8 +2297,8 @@
* its size does not match those bounds. Defaults to CONTENT_SCALE_MODE_FIT.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setContentScaleMode(@NonNull ContentScaleModeProp contentScaleMode) {
+ public @NonNull Builder setContentScaleMode(
+ @NonNull ContentScaleModeProp contentScaleMode) {
mImpl.setContentScaleMode(contentScaleMode.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(contentScaleMode.getFingerprint()).aggregateValueAsInt());
@@ -2457,8 +2310,7 @@
* its size does not match those bounds. Defaults to CONTENT_SCALE_MODE_FIT.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setContentScaleMode(@ContentScaleMode int contentScaleMode) {
+ public @NonNull Builder setContentScaleMode(@ContentScaleMode int contentScaleMode) {
return setContentScaleMode(
new ContentScaleModeProp.Builder().setValue(contentScaleMode).build());
}
@@ -2467,8 +2319,7 @@
* Sets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setModifiers(@NonNull Modifiers modifiers) {
+ public @NonNull Builder setModifiers(@NonNull Modifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -2479,8 +2330,7 @@
* Sets filtering parameters for this image. If not specified, defaults to no filtering.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setColorFilter(@NonNull ColorFilter colorFilter) {
+ public @NonNull Builder setColorFilter(@NonNull ColorFilter colorFilter) {
mImpl.setColorFilter(colorFilter.toProto());
mFingerprint.recordPropertyUpdate(
6, checkNotNull(colorFilter.getFingerprint()).aggregateValueAsInt());
@@ -2488,8 +2338,7 @@
}
@Override
- @NonNull
- public Image build() {
+ public @NonNull Image build() {
return new Image(mImpl.build(), mFingerprint);
}
}
@@ -2499,7 +2348,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class Spacer implements LayoutElement {
private final LayoutElementProto.Spacer mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Spacer(LayoutElementProto.Spacer impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -2519,8 +2368,7 @@
* setLayoutConstraintsForDynamicWidth(HorizontalLayoutConstraint)} otherwise {@code
* build()} fails.
*/
- @Nullable
- public SpacerDimension getWidth() {
+ public @Nullable SpacerDimension getWidth() {
if (mImpl.hasWidth()) {
return DimensionBuilders.spacerDimensionFromProto(mImpl.getWidth());
} else {
@@ -2539,8 +2387,7 @@
* setLayoutConstraintsForDynamicWidth(HorizontalLayoutConstraint)} otherwise {@code
* build()} fails.
*/
- @Nullable
- public SpacerDimension getHeight() {
+ public @Nullable SpacerDimension getHeight() {
if (mImpl.hasHeight()) {
return DimensionBuilders.spacerDimensionFromProto(mImpl.getHeight());
} else {
@@ -2549,8 +2396,7 @@
}
/** Gets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element. */
- @Nullable
- public Modifiers getModifiers() {
+ public @Nullable Modifiers getModifiers() {
if (mImpl.hasModifiers()) {
return Modifiers.fromProto(mImpl.getModifiers());
} else {
@@ -2562,8 +2408,7 @@
* Gets the bounding constraints for the layout affected by the dynamic value from {@link
* #getWidth()}.
*/
- @Nullable
- public HorizontalLayoutConstraint getLayoutConstraintsForDynamicWidth() {
+ public @Nullable HorizontalLayoutConstraint getLayoutConstraintsForDynamicWidth() {
if (mImpl.getWidth().hasLinearDimension()) {
return HorizontalLayoutConstraint.fromProto(mImpl.getWidth().getLinearDimension());
} else {
@@ -2575,8 +2420,7 @@
* Gets the bounding constraints for the layout affected by the dynamic value from {@link
* #getHeight()}.
*/
- @Nullable
- public VerticalLayoutConstraint getLayoutConstraintsForDynamicHeight() {
+ public @Nullable VerticalLayoutConstraint getLayoutConstraintsForDynamicHeight() {
if (mImpl.getHeight().hasLinearDimension()) {
return VerticalLayoutConstraint.fromProto(mImpl.getHeight().getLinearDimension());
} else {
@@ -2586,41 +2430,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Spacer fromProto(
- @NonNull LayoutElementProto.Spacer proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Spacer fromProto(
+ LayoutElementProto.@NonNull Spacer proto, @Nullable Fingerprint fingerprint) {
return new Spacer(proto, fingerprint);
}
- @NonNull
- static Spacer fromProto(@NonNull LayoutElementProto.Spacer proto) {
+ static @NonNull Spacer fromProto(LayoutElementProto.@NonNull Spacer proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.Spacer toProto() {
+ LayoutElementProto.@NonNull Spacer toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return LayoutElementProto.LayoutElement.newBuilder().setSpacer(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Spacer{"
+ "width="
+ getWidth()
@@ -2655,8 +2493,7 @@
* build()} fails.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setWidth(@NonNull SpacerDimension width) {
+ public @NonNull Builder setWidth(@NonNull SpacerDimension width) {
mImpl.mergeWidth(width.toSpacerDimensionProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(width.getFingerprint()).aggregateValueAsInt());
@@ -2669,8 +2506,7 @@
* dynamic value, this will be ignored.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setLayoutConstraintsForDynamicWidth(
+ public @NonNull Builder setLayoutConstraintsForDynamicWidth(
@NonNull HorizontalLayoutConstraint horizontalLayoutConstraint) {
switch (mImpl.getWidth().getInnerCase()) {
case INNER_NOT_SET:
@@ -2698,8 +2534,7 @@
* build()} fails.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setHeight(@NonNull SpacerDimension height) {
+ public @NonNull Builder setHeight(@NonNull SpacerDimension height) {
mImpl.setHeight(height.toSpacerDimensionProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(height.getFingerprint()).aggregateValueAsInt());
@@ -2712,8 +2547,7 @@
* dynamic value, this will be ignored.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setLayoutConstraintsForDynamicHeight(
+ public @NonNull Builder setLayoutConstraintsForDynamicHeight(
@NonNull VerticalLayoutConstraint verticalLayoutConstraint) {
switch (mImpl.getHeight().getInnerCase()) {
case INNER_NOT_SET:
@@ -2733,8 +2567,7 @@
* Sets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setModifiers(@NonNull Modifiers modifiers) {
+ public @NonNull Builder setModifiers(@NonNull Modifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -2742,8 +2575,7 @@
}
@Override
- @NonNull
- public Spacer build() {
+ public @NonNull Spacer build() {
DimensionProto.DpProp width = mImpl.getWidth().getLinearDimension();
if (width.hasDynamicValue() && !width.hasValueForLayout()) {
throw new IllegalStateException(
@@ -2768,7 +2600,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class Box implements LayoutElement {
private final LayoutElementProto.Box mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Box(LayoutElementProto.Box impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -2776,8 +2608,7 @@
}
/** Gets the child element(s) to wrap. */
- @NonNull
- public List<LayoutElement> getContents() {
+ public @NonNull List<LayoutElement> getContents() {
List<LayoutElement> list = new ArrayList<>();
for (LayoutElementProto.LayoutElement item : mImpl.getContentsList()) {
list.add(LayoutElementBuilders.layoutElementFromProto(item));
@@ -2789,8 +2620,7 @@
* Gets the height of this {@link Box}. If not defined, this will size itself to fit all of
* its children (i.e. a WrappedDimension).
*/
- @Nullable
- public ContainerDimension getHeight() {
+ public @Nullable ContainerDimension getHeight() {
if (mImpl.hasHeight()) {
return DimensionBuilders.containerDimensionFromProto(mImpl.getHeight());
} else {
@@ -2802,8 +2632,7 @@
* Gets the width of this {@link Box}. If not defined, this will size itself to fit all of
* its children (i.e. a WrappedDimension).
*/
- @Nullable
- public ContainerDimension getWidth() {
+ public @Nullable ContainerDimension getWidth() {
if (mImpl.hasWidth()) {
return DimensionBuilders.containerDimensionFromProto(mImpl.getWidth());
} else {
@@ -2815,8 +2644,7 @@
* Gets the horizontal alignment of the element inside this {@link Box}. If not defined,
* defaults to HORIZONTAL_ALIGN_CENTER.
*/
- @Nullable
- public HorizontalAlignmentProp getHorizontalAlignment() {
+ public @Nullable HorizontalAlignmentProp getHorizontalAlignment() {
if (mImpl.hasHorizontalAlignment()) {
return HorizontalAlignmentProp.fromProto(mImpl.getHorizontalAlignment());
} else {
@@ -2828,8 +2656,7 @@
* Gets the vertical alignment of the element inside this {@link Box}. If not defined,
* defaults to VERTICAL_ALIGN_CENTER.
*/
- @Nullable
- public VerticalAlignmentProp getVerticalAlignment() {
+ public @Nullable VerticalAlignmentProp getVerticalAlignment() {
if (mImpl.hasVerticalAlignment()) {
return VerticalAlignmentProp.fromProto(mImpl.getVerticalAlignment());
} else {
@@ -2838,8 +2665,7 @@
}
/** Gets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element. */
- @Nullable
- public Modifiers getModifiers() {
+ public @Nullable Modifiers getModifiers() {
if (mImpl.hasModifiers()) {
return Modifiers.fromProto(mImpl.getModifiers());
} else {
@@ -2849,41 +2675,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Box fromProto(
- @NonNull LayoutElementProto.Box proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Box fromProto(
+ LayoutElementProto.@NonNull Box proto, @Nullable Fingerprint fingerprint) {
return new Box(proto, fingerprint);
}
- @NonNull
- static Box fromProto(@NonNull LayoutElementProto.Box proto) {
+ static @NonNull Box fromProto(LayoutElementProto.@NonNull Box proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.Box toProto() {
+ LayoutElementProto.@NonNull Box toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return LayoutElementProto.LayoutElement.newBuilder().setBox(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Box{"
+ "contents="
+ getContents()
@@ -2912,8 +2732,7 @@
/** Adds one item to the child element(s) to wrap. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder addContent(@NonNull LayoutElement content) {
+ public @NonNull Builder addContent(@NonNull LayoutElement content) {
mImpl.addContents(content.toLayoutElementProto());
mFingerprint.addChildNode(checkNotNull(content.getFingerprint()));
return this;
@@ -2924,8 +2743,7 @@
* of its children (i.e. a WrappedDimension).
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setHeight(@NonNull ContainerDimension height) {
+ public @NonNull Builder setHeight(@NonNull ContainerDimension height) {
mImpl.setHeight(height.toContainerDimensionProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(height.getFingerprint()).aggregateValueAsInt());
@@ -2937,8 +2755,7 @@
* of its children (i.e. a WrappedDimension).
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setWidth(@NonNull ContainerDimension width) {
+ public @NonNull Builder setWidth(@NonNull ContainerDimension width) {
mImpl.setWidth(width.toContainerDimensionProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(width.getFingerprint()).aggregateValueAsInt());
@@ -2950,8 +2767,7 @@
* defaults to HORIZONTAL_ALIGN_CENTER.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setHorizontalAlignment(
+ public @NonNull Builder setHorizontalAlignment(
@NonNull HorizontalAlignmentProp horizontalAlignment) {
mImpl.setHorizontalAlignment(horizontalAlignment.toProto());
mFingerprint.recordPropertyUpdate(
@@ -2965,8 +2781,8 @@
* defaults to HORIZONTAL_ALIGN_CENTER.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setHorizontalAlignment(@HorizontalAlignment int horizontalAlignment) {
+ public @NonNull Builder setHorizontalAlignment(
+ @HorizontalAlignment int horizontalAlignment) {
return setHorizontalAlignment(
new HorizontalAlignmentProp.Builder()
.setValue(horizontalAlignment)
@@ -2978,8 +2794,8 @@
* defaults to VERTICAL_ALIGN_CENTER.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setVerticalAlignment(@NonNull VerticalAlignmentProp verticalAlignment) {
+ public @NonNull Builder setVerticalAlignment(
+ @NonNull VerticalAlignmentProp verticalAlignment) {
mImpl.setVerticalAlignment(verticalAlignment.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(verticalAlignment.getFingerprint()).aggregateValueAsInt());
@@ -2991,8 +2807,7 @@
* defaults to VERTICAL_ALIGN_CENTER.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setVerticalAlignment(@VerticalAlignment int verticalAlignment) {
+ public @NonNull Builder setVerticalAlignment(@VerticalAlignment int verticalAlignment) {
return setVerticalAlignment(
new VerticalAlignmentProp.Builder().setValue(verticalAlignment).build());
}
@@ -3001,8 +2816,7 @@
* Sets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setModifiers(@NonNull Modifiers modifiers) {
+ public @NonNull Builder setModifiers(@NonNull Modifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
6, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -3011,8 +2825,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public Box build() {
+ public @NonNull Box build() {
return new Box(mImpl.build(), mFingerprint);
}
}
@@ -3026,7 +2839,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class SpanText implements Span {
private final LayoutElementProto.SpanText mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
SpanText(LayoutElementProto.SpanText impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -3034,8 +2847,7 @@
}
/** Gets the text to render. */
- @Nullable
- public StringProp getText() {
+ public @Nullable StringProp getText() {
if (mImpl.hasText()) {
return StringProp.fromProto(mImpl.getText());
} else {
@@ -3047,8 +2859,7 @@
* Gets the style of font to use (size, bold etc). If not specified, defaults to the
* platform's default body font.
*/
- @Nullable
- public FontStyle getFontStyle() {
+ public @Nullable FontStyle getFontStyle() {
if (mImpl.hasFontStyle()) {
return FontStyle.fromProto(mImpl.getFontStyle());
} else {
@@ -3057,8 +2868,7 @@
}
/** Gets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element. */
- @Nullable
- public SpanModifiers getModifiers() {
+ public @Nullable SpanModifiers getModifiers() {
if (mImpl.hasModifiers()) {
return SpanModifiers.fromProto(mImpl.getModifiers());
} else {
@@ -3068,42 +2878,36 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static SpanText fromProto(
- @NonNull LayoutElementProto.SpanText proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull SpanText fromProto(
+ LayoutElementProto.@NonNull SpanText proto, @Nullable Fingerprint fingerprint) {
return new SpanText(proto, fingerprint);
}
- @NonNull
- static SpanText fromProto(@NonNull LayoutElementProto.SpanText proto) {
+ static @NonNull SpanText fromProto(LayoutElementProto.@NonNull SpanText proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.SpanText toProto() {
+ LayoutElementProto.@NonNull SpanText toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.Span toSpanProto() {
+ public LayoutElementProto.@NonNull Span toSpanProto() {
return LayoutElementProto.Span.newBuilder().setText(mImpl).build();
}
@Override
@OptIn(markerClass = ProtoLayoutExperimental.class)
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "SpanText{"
+ "text="
+ getText()
@@ -3134,8 +2938,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setText(@NonNull StringProp text) {
+ public @NonNull Builder setText(@NonNull StringProp text) {
if (text.getDynamicValue() != null) {
throw new IllegalArgumentException("SpanText.Builder.setText doesn't support dynamic values.");
}
@@ -3147,8 +2950,7 @@
/** Sets the text to render. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setText(@NonNull String text) {
+ public @NonNull Builder setText(@NonNull String text) {
return setText(new StringProp.Builder(text).build());
}
@@ -3159,8 +2961,7 @@
* <p>DynamicColor is not supported for SpanText.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setFontStyle(@NonNull FontStyle fontStyle) {
+ public @NonNull Builder setFontStyle(@NonNull FontStyle fontStyle) {
ColorProp colorProp = fontStyle.getColor();
if (colorProp != null && colorProp.getDynamicValue() != null) {
throw new IllegalArgumentException("SpanText does not support DynamicColor.");
@@ -3175,8 +2976,7 @@
* Sets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setModifiers(@NonNull SpanModifiers modifiers) {
+ public @NonNull Builder setModifiers(@NonNull SpanModifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -3185,8 +2985,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public SpanText build() {
+ public @NonNull SpanText build() {
return new SpanText(mImpl.build(), mFingerprint);
}
}
@@ -3196,7 +2995,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class SpanImage implements Span {
private final LayoutElementProto.SpanImage mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
SpanImage(LayoutElementProto.SpanImage impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -3207,8 +3006,7 @@
* Gets the resource_id of the image to render. This must exist in the supplied resource
* bundle.
*/
- @Nullable
- public StringProp getResourceId() {
+ public @Nullable StringProp getResourceId() {
if (mImpl.hasResourceId()) {
return StringProp.fromProto(mImpl.getResourceId());
} else {
@@ -3217,8 +3015,7 @@
}
/** Gets the width of this image. If not defined, the image will not be rendered. */
- @Nullable
- public DpProp getWidth() {
+ public @Nullable DpProp getWidth() {
if (mImpl.hasWidth()) {
return DpProp.fromProto(mImpl.getWidth());
} else {
@@ -3227,8 +3024,7 @@
}
/** Gets the height of this image. If not defined, the image will not be rendered. */
- @Nullable
- public DpProp getHeight() {
+ public @Nullable DpProp getHeight() {
if (mImpl.hasHeight()) {
return DpProp.fromProto(mImpl.getHeight());
} else {
@@ -3237,8 +3033,7 @@
}
/** Gets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element. */
- @Nullable
- public SpanModifiers getModifiers() {
+ public @Nullable SpanModifiers getModifiers() {
if (mImpl.hasModifiers()) {
return SpanModifiers.fromProto(mImpl.getModifiers());
} else {
@@ -3250,8 +3045,7 @@
* Gets alignment of this image within the line height of the surrounding {@link Spannable}.
* If undefined, defaults to SPAN_VERTICAL_ALIGN_BOTTOM.
*/
- @Nullable
- public SpanVerticalAlignmentProp getAlignment() {
+ public @Nullable SpanVerticalAlignmentProp getAlignment() {
if (mImpl.hasAlignment()) {
return SpanVerticalAlignmentProp.fromProto(mImpl.getAlignment());
} else {
@@ -3261,41 +3055,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static SpanImage fromProto(
- @NonNull LayoutElementProto.SpanImage proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull SpanImage fromProto(
+ LayoutElementProto.@NonNull SpanImage proto, @Nullable Fingerprint fingerprint) {
return new SpanImage(proto, fingerprint);
}
- @NonNull
- static SpanImage fromProto(@NonNull LayoutElementProto.SpanImage proto) {
+ static @NonNull SpanImage fromProto(LayoutElementProto.@NonNull SpanImage proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.SpanImage toProto() {
+ LayoutElementProto.@NonNull SpanImage toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.Span toSpanProto() {
+ public LayoutElementProto.@NonNull Span toSpanProto() {
return LayoutElementProto.Span.newBuilder().setImage(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "SpanImage{"
+ "resourceId="
+ getResourceId()
@@ -3327,8 +3115,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setResourceId(@NonNull StringProp resourceId) {
+ public @NonNull Builder setResourceId(@NonNull StringProp resourceId) {
if (resourceId.getDynamicValue() != null) {
throw new IllegalArgumentException(
"SpanImage.Builder.setResourceId doesn't support dynamic values.");
@@ -3344,8 +3131,7 @@
* bundle.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setResourceId(@NonNull String resourceId) {
+ public @NonNull Builder setResourceId(@NonNull String resourceId) {
return setResourceId(new StringProp.Builder(resourceId).build());
}
@@ -3355,8 +3141,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setWidth(@NonNull DpProp width) {
+ public @NonNull Builder setWidth(@NonNull DpProp width) {
if (width.getDynamicValue() != null) {
throw new IllegalArgumentException(
"SpanImage.Builder.setWidth doesn't support dynamic values.");
@@ -3373,8 +3158,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setHeight(@NonNull DpProp height) {
+ public @NonNull Builder setHeight(@NonNull DpProp height) {
if (height.getDynamicValue() != null) {
throw new IllegalArgumentException(
"SpanImage.Builder.setHeight doesn't support dynamic values.");
@@ -3389,8 +3173,7 @@
* Sets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setModifiers(@NonNull SpanModifiers modifiers) {
+ public @NonNull Builder setModifiers(@NonNull SpanModifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -3402,8 +3185,7 @@
* Spannable}. If undefined, defaults to SPAN_VERTICAL_ALIGN_BOTTOM.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setAlignment(@NonNull SpanVerticalAlignmentProp alignment) {
+ public @NonNull Builder setAlignment(@NonNull SpanVerticalAlignmentProp alignment) {
mImpl.setAlignment(alignment.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(alignment.getFingerprint()).aggregateValueAsInt());
@@ -3415,15 +3197,13 @@
* Spannable}. If undefined, defaults to SPAN_VERTICAL_ALIGN_BOTTOM.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setAlignment(@SpanVerticalAlignment int alignment) {
+ public @NonNull Builder setAlignment(@SpanVerticalAlignment int alignment) {
return setAlignment(
new SpanVerticalAlignmentProp.Builder().setValue(alignment).build());
}
@Override
- @NonNull
- public SpanImage build() {
+ public @NonNull SpanImage build() {
return new SpanImage(mImpl.build(), mFingerprint);
}
}
@@ -3438,29 +3218,25 @@
public interface Span {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.Span toSpanProto();
+ LayoutElementProto.@NonNull Span toSpanProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link Span} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- Span build();
+ @NonNull Span build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Span spanFromProto(
- @NonNull LayoutElementProto.Span proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Span spanFromProto(
+ LayoutElementProto.@NonNull Span proto, @Nullable Fingerprint fingerprint) {
if (proto.hasText()) {
return SpanText.fromProto(proto.getText(), fingerprint);
}
@@ -3470,8 +3246,7 @@
throw new IllegalStateException("Proto was not a recognised instance of Span");
}
- @NonNull
- static Span spanFromProto(@NonNull LayoutElementProto.Span proto) {
+ static @NonNull Span spanFromProto(LayoutElementProto.@NonNull Span proto) {
return spanFromProto(proto, null);
}
@@ -3484,7 +3259,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class Spannable implements LayoutElement {
private final LayoutElementProto.Spannable mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Spannable(LayoutElementProto.Spannable impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -3492,8 +3267,7 @@
}
/** Gets the {@link Span} elements that form this {@link Spannable}. */
- @NonNull
- public List<Span> getSpans() {
+ public @NonNull List<Span> getSpans() {
List<Span> list = new ArrayList<>();
for (LayoutElementProto.Span item : mImpl.getSpansList()) {
list.add(LayoutElementBuilders.spanFromProto(item));
@@ -3502,8 +3276,7 @@
}
/** Gets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element. */
- @Nullable
- public Modifiers getModifiers() {
+ public @Nullable Modifiers getModifiers() {
if (mImpl.hasModifiers()) {
return Modifiers.fromProto(mImpl.getModifiers());
} else {
@@ -3516,8 +3289,7 @@
* element. If not defined, the {@link Spannable} element will be treated as a single-line
* element.
*/
- @Nullable
- public Int32Prop getMaxLines() {
+ public @Nullable Int32Prop getMaxLines() {
if (mImpl.hasMaxLines()) {
return Int32Prop.fromProto(mImpl.getMaxLines());
} else {
@@ -3532,8 +3304,7 @@
* content, however, this will set the alignment of lines relative to the {@link Spannable}
* element bounds. If not defined, defaults to TEXT_ALIGN_CENTER.
*/
- @Nullable
- public HorizontalAlignmentProp getMultilineAlignment() {
+ public @Nullable HorizontalAlignmentProp getMultilineAlignment() {
if (mImpl.hasMultilineAlignment()) {
return HorizontalAlignmentProp.fromProto(mImpl.getMultilineAlignment());
} else {
@@ -3548,8 +3319,7 @@
* content, the content which cannot fit inside its container will be truncated. If not
* defined, defaults to TEXT_OVERFLOW_TRUNCATE.
*/
- @Nullable
- public TextOverflowProp getOverflow() {
+ public @Nullable TextOverflowProp getOverflow() {
if (mImpl.hasOverflow()) {
return TextOverflowProp.fromProto(mImpl.getOverflow());
} else {
@@ -3562,8 +3332,7 @@
* distance between subsequent baselines. If not specified, defaults the font's recommended
* interline spacing.
*/
- @Nullable
- public SpProp getLineHeight() {
+ public @Nullable SpProp getLineHeight() {
if (mImpl.hasLineHeight()) {
return SpProp.fromProto(mImpl.getLineHeight());
} else {
@@ -3583,41 +3352,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Spannable fromProto(
- @NonNull LayoutElementProto.Spannable proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Spannable fromProto(
+ LayoutElementProto.@NonNull Spannable proto, @Nullable Fingerprint fingerprint) {
return new Spannable(proto, fingerprint);
}
- @NonNull
- static Spannable fromProto(@NonNull LayoutElementProto.Spannable proto) {
+ static @NonNull Spannable fromProto(LayoutElementProto.@NonNull Spannable proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.Spannable toProto() {
+ LayoutElementProto.@NonNull Spannable toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return LayoutElementProto.LayoutElement.newBuilder().setSpannable(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Spannable{"
+ "spans="
+ getSpans()
@@ -3646,8 +3409,7 @@
/** Adds one item to the {@link Span} elements that form this {@link Spannable}. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder addSpan(@NonNull Span span) {
+ public @NonNull Builder addSpan(@NonNull Span span) {
mImpl.addSpans(span.toSpanProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(span.getFingerprint()).aggregateValueAsInt());
@@ -3658,8 +3420,7 @@
* Sets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setModifiers(@NonNull Modifiers modifiers) {
+ public @NonNull Builder setModifiers(@NonNull Modifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -3672,8 +3433,7 @@
* single-line element.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setMaxLines(@NonNull Int32Prop maxLines) {
+ public @NonNull Builder setMaxLines(@NonNull Int32Prop maxLines) {
mImpl.setMaxLines(maxLines.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(maxLines.getFingerprint()).aggregateValueAsInt());
@@ -3685,8 +3445,7 @@
* element. If not defined, the {@link Spannable} element will be treated as a
* single-line element.
*/
- @NonNull
- public Builder setMaxLines(@IntRange(from = 1) int maxLines) {
+ public @NonNull Builder setMaxLines(@IntRange(from = 1) int maxLines) {
return setMaxLines(new Int32Prop.Builder().setValue(maxLines).build());
}
@@ -3698,8 +3457,7 @@
* {@link Spannable} element bounds. If not defined, defaults to TEXT_ALIGN_CENTER.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setMultilineAlignment(
+ public @NonNull Builder setMultilineAlignment(
@NonNull HorizontalAlignmentProp multilineAlignment) {
mImpl.setMultilineAlignment(multilineAlignment.toProto());
mFingerprint.recordPropertyUpdate(
@@ -3715,8 +3473,8 @@
* {@link Spannable} element bounds. If not defined, defaults to TEXT_ALIGN_CENTER.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setMultilineAlignment(@HorizontalAlignment int multilineAlignment) {
+ public @NonNull Builder setMultilineAlignment(
+ @HorizontalAlignment int multilineAlignment) {
return setMultilineAlignment(
new HorizontalAlignmentProp.Builder().setValue(multilineAlignment).build());
}
@@ -3729,8 +3487,7 @@
* truncated. If not defined, defaults to TEXT_OVERFLOW_TRUNCATE.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setOverflow(@NonNull TextOverflowProp overflow) {
+ public @NonNull Builder setOverflow(@NonNull TextOverflowProp overflow) {
mImpl.setOverflow(overflow.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(overflow.getFingerprint()).aggregateValueAsInt());
@@ -3745,8 +3502,7 @@
* truncated. If not defined, defaults to TEXT_OVERFLOW_TRUNCATE.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setOverflow(@TextOverflow int overflow) {
+ public @NonNull Builder setOverflow(@TextOverflow int overflow) {
return setOverflow(new TextOverflowProp.Builder().setValue(overflow).build());
}
@@ -3756,8 +3512,7 @@
* recommended interline spacing.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setLineHeight(@NonNull SpProp lineHeight) {
+ public @NonNull Builder setLineHeight(@NonNull SpProp lineHeight) {
mImpl.setLineHeight(lineHeight.toProto());
mFingerprint.recordPropertyUpdate(
7, checkNotNull(lineHeight.getFingerprint()).aggregateValueAsInt());
@@ -3771,8 +3526,8 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@ProtoLayoutExperimental
- @NonNull
- public Builder setMarqueeIterations(@IntRange(from = -1) int marqueeIterations) {
+ public @NonNull Builder setMarqueeIterations(
+ @IntRange(from = -1) int marqueeIterations) {
mImpl.setMarqueeParameters(
LayoutElementProto.MarqueeParameters.newBuilder()
.setIterations(marqueeIterations));
@@ -3781,8 +3536,7 @@
}
@Override
- @NonNull
- public Spannable build() {
+ public @NonNull Spannable build() {
return new Spannable(mImpl.build(), mFingerprint);
}
}
@@ -3801,7 +3555,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class Column implements LayoutElement {
private final LayoutElementProto.Column mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Column(LayoutElementProto.Column impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -3809,8 +3563,7 @@
}
/** Gets the list of child elements to place inside this {@link Column}. */
- @NonNull
- public List<LayoutElement> getContents() {
+ public @NonNull List<LayoutElement> getContents() {
List<LayoutElement> list = new ArrayList<>();
for (LayoutElementProto.LayoutElement item : mImpl.getContentsList()) {
list.add(LayoutElementBuilders.layoutElementFromProto(item));
@@ -3822,8 +3575,7 @@
* Gets the horizontal alignment of elements inside this column, if they are narrower than
* the resulting width of the column. If not defined, defaults to HORIZONTAL_ALIGN_CENTER.
*/
- @Nullable
- public HorizontalAlignmentProp getHorizontalAlignment() {
+ public @Nullable HorizontalAlignmentProp getHorizontalAlignment() {
if (mImpl.hasHorizontalAlignment()) {
return HorizontalAlignmentProp.fromProto(mImpl.getHorizontalAlignment());
} else {
@@ -3835,8 +3587,7 @@
* Gets the width of this column. If not defined, this will size itself to fit all of its
* children (i.e. a WrappedDimension).
*/
- @Nullable
- public ContainerDimension getWidth() {
+ public @Nullable ContainerDimension getWidth() {
if (mImpl.hasWidth()) {
return DimensionBuilders.containerDimensionFromProto(mImpl.getWidth());
} else {
@@ -3848,8 +3599,7 @@
* Gets the height of this column. If not defined, this will size itself to fit all of its
* children (i.e. a WrappedDimension).
*/
- @Nullable
- public ContainerDimension getHeight() {
+ public @Nullable ContainerDimension getHeight() {
if (mImpl.hasHeight()) {
return DimensionBuilders.containerDimensionFromProto(mImpl.getHeight());
} else {
@@ -3858,8 +3608,7 @@
}
/** Gets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element. */
- @Nullable
- public Modifiers getModifiers() {
+ public @Nullable Modifiers getModifiers() {
if (mImpl.hasModifiers()) {
return Modifiers.fromProto(mImpl.getModifiers());
} else {
@@ -3869,41 +3618,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Column fromProto(
- @NonNull LayoutElementProto.Column proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Column fromProto(
+ LayoutElementProto.@NonNull Column proto, @Nullable Fingerprint fingerprint) {
return new Column(proto, fingerprint);
}
- @NonNull
- static Column fromProto(@NonNull LayoutElementProto.Column proto) {
+ static @NonNull Column fromProto(LayoutElementProto.@NonNull Column proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.Column toProto() {
+ LayoutElementProto.@NonNull Column toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return LayoutElementProto.LayoutElement.newBuilder().setColumn(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Column{"
+ "contents="
+ getContents()
@@ -3930,8 +3673,7 @@
/** Adds one item to the list of child elements to place inside this {@link Column}. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder addContent(@NonNull LayoutElement content) {
+ public @NonNull Builder addContent(@NonNull LayoutElement content) {
mImpl.addContents(content.toLayoutElementProto());
mFingerprint.addChildNode(checkNotNull(content.getFingerprint()));
return this;
@@ -3943,8 +3685,7 @@
* HORIZONTAL_ALIGN_CENTER.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setHorizontalAlignment(
+ public @NonNull Builder setHorizontalAlignment(
@NonNull HorizontalAlignmentProp horizontalAlignment) {
mImpl.setHorizontalAlignment(horizontalAlignment.toProto());
mFingerprint.recordPropertyUpdate(
@@ -3959,8 +3700,8 @@
* HORIZONTAL_ALIGN_CENTER.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setHorizontalAlignment(@HorizontalAlignment int horizontalAlignment) {
+ public @NonNull Builder setHorizontalAlignment(
+ @HorizontalAlignment int horizontalAlignment) {
return setHorizontalAlignment(
new HorizontalAlignmentProp.Builder()
.setValue(horizontalAlignment)
@@ -3972,8 +3713,7 @@
* its children (i.e. a WrappedDimension).
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setWidth(@NonNull ContainerDimension width) {
+ public @NonNull Builder setWidth(@NonNull ContainerDimension width) {
mImpl.setWidth(width.toContainerDimensionProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(width.getFingerprint()).aggregateValueAsInt());
@@ -3985,8 +3725,7 @@
* its children (i.e. a WrappedDimension).
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setHeight(@NonNull ContainerDimension height) {
+ public @NonNull Builder setHeight(@NonNull ContainerDimension height) {
mImpl.setHeight(height.toContainerDimensionProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(height.getFingerprint()).aggregateValueAsInt());
@@ -3997,8 +3736,7 @@
* Sets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setModifiers(@NonNull Modifiers modifiers) {
+ public @NonNull Builder setModifiers(@NonNull Modifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -4007,8 +3745,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public Column build() {
+ public @NonNull Column build() {
return new Column(mImpl.build(), mFingerprint);
}
}
@@ -4027,7 +3764,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class Row implements LayoutElement {
private final LayoutElementProto.Row mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Row(LayoutElementProto.Row impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -4035,8 +3772,7 @@
}
/** Gets the list of child elements to place inside this {@link Row}. */
- @NonNull
- public List<LayoutElement> getContents() {
+ public @NonNull List<LayoutElement> getContents() {
List<LayoutElement> list = new ArrayList<>();
for (LayoutElementProto.LayoutElement item : mImpl.getContentsList()) {
list.add(LayoutElementBuilders.layoutElementFromProto(item));
@@ -4048,8 +3784,7 @@
* Gets the vertical alignment of elements inside this row, if they are narrower than the
* resulting height of the row. If not defined, defaults to VERTICAL_ALIGN_CENTER.
*/
- @Nullable
- public VerticalAlignmentProp getVerticalAlignment() {
+ public @Nullable VerticalAlignmentProp getVerticalAlignment() {
if (mImpl.hasVerticalAlignment()) {
return VerticalAlignmentProp.fromProto(mImpl.getVerticalAlignment());
} else {
@@ -4061,8 +3796,7 @@
* Gets the width of this row. If not defined, this will size itself to fit all of its
* children (i.e. a WrappedDimension).
*/
- @Nullable
- public ContainerDimension getWidth() {
+ public @Nullable ContainerDimension getWidth() {
if (mImpl.hasWidth()) {
return DimensionBuilders.containerDimensionFromProto(mImpl.getWidth());
} else {
@@ -4074,8 +3808,7 @@
* Gets the height of this row. If not defined, this will size itself to fit all of its
* children (i.e. a WrappedDimension).
*/
- @Nullable
- public ContainerDimension getHeight() {
+ public @Nullable ContainerDimension getHeight() {
if (mImpl.hasHeight()) {
return DimensionBuilders.containerDimensionFromProto(mImpl.getHeight());
} else {
@@ -4084,8 +3817,7 @@
}
/** Gets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element. */
- @Nullable
- public Modifiers getModifiers() {
+ public @Nullable Modifiers getModifiers() {
if (mImpl.hasModifiers()) {
return Modifiers.fromProto(mImpl.getModifiers());
} else {
@@ -4095,41 +3827,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Row fromProto(
- @NonNull LayoutElementProto.Row proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Row fromProto(
+ LayoutElementProto.@NonNull Row proto, @Nullable Fingerprint fingerprint) {
return new Row(proto, fingerprint);
}
- @NonNull
- static Row fromProto(@NonNull LayoutElementProto.Row proto) {
+ static @NonNull Row fromProto(LayoutElementProto.@NonNull Row proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.Row toProto() {
+ LayoutElementProto.@NonNull Row toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return LayoutElementProto.LayoutElement.newBuilder().setRow(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Row{"
+ "contents="
+ getContents()
@@ -4156,8 +3882,7 @@
/** Adds one item to the list of child elements to place inside this {@link Row}. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder addContent(@NonNull LayoutElement content) {
+ public @NonNull Builder addContent(@NonNull LayoutElement content) {
mImpl.addContents(content.toLayoutElementProto());
mFingerprint.addChildNode(checkNotNull(content.getFingerprint()));
return this;
@@ -4168,8 +3893,8 @@
* the resulting height of the row. If not defined, defaults to VERTICAL_ALIGN_CENTER.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setVerticalAlignment(@NonNull VerticalAlignmentProp verticalAlignment) {
+ public @NonNull Builder setVerticalAlignment(
+ @NonNull VerticalAlignmentProp verticalAlignment) {
mImpl.setVerticalAlignment(verticalAlignment.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(verticalAlignment.getFingerprint()).aggregateValueAsInt());
@@ -4181,8 +3906,7 @@
* the resulting height of the row. If not defined, defaults to VERTICAL_ALIGN_CENTER.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setVerticalAlignment(@VerticalAlignment int verticalAlignment) {
+ public @NonNull Builder setVerticalAlignment(@VerticalAlignment int verticalAlignment) {
return setVerticalAlignment(
new VerticalAlignmentProp.Builder().setValue(verticalAlignment).build());
}
@@ -4192,8 +3916,7 @@
* children (i.e. a WrappedDimension).
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setWidth(@NonNull ContainerDimension width) {
+ public @NonNull Builder setWidth(@NonNull ContainerDimension width) {
mImpl.setWidth(width.toContainerDimensionProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(width.getFingerprint()).aggregateValueAsInt());
@@ -4205,8 +3928,7 @@
* children (i.e. a WrappedDimension).
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setHeight(@NonNull ContainerDimension height) {
+ public @NonNull Builder setHeight(@NonNull ContainerDimension height) {
mImpl.setHeight(height.toContainerDimensionProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(height.getFingerprint()).aggregateValueAsInt());
@@ -4217,8 +3939,7 @@
* Sets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setModifiers(@NonNull Modifiers modifiers) {
+ public @NonNull Builder setModifiers(@NonNull Modifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -4227,8 +3948,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public Row build() {
+ public @NonNull Row build() {
return new Row(mImpl.build(), mFingerprint);
}
}
@@ -4246,7 +3966,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class Arc implements LayoutElement {
private final LayoutElementProto.Arc mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Arc(LayoutElementProto.Arc impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -4254,8 +3974,7 @@
}
/** Gets contents of this container. */
- @NonNull
- public List<ArcLayoutElement> getContents() {
+ public @NonNull List<ArcLayoutElement> getContents() {
List<ArcLayoutElement> list = new ArrayList<>();
for (LayoutElementProto.ArcLayoutElement item : mImpl.getContentsList()) {
list.add(LayoutElementBuilders.arcLayoutElementFromProto(item));
@@ -4275,8 +3994,7 @@
* <p>While this field is statically accessible from 1.0, it's only bindable since version
* 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
- @Nullable
- public DegreesProp getAnchorAngle() {
+ public @Nullable DegreesProp getAnchorAngle() {
if (mImpl.hasAnchorAngle()) {
return DegreesProp.fromProto(mImpl.getAnchorAngle());
} else {
@@ -4288,8 +4006,7 @@
* Gets how to align the contents of this container relative to anchor_angle. If not
* defined, defaults to ARC_ANCHOR_CENTER.
*/
- @Nullable
- public ArcAnchorTypeProp getAnchorType() {
+ public @Nullable ArcAnchorTypeProp getAnchorType() {
if (mImpl.hasAnchorType()) {
return ArcAnchorTypeProp.fromProto(mImpl.getAnchorType());
} else {
@@ -4303,8 +4020,7 @@
* should be drawn towards the inner or outer edge of the arc, or drawn in the center. If
* not defined, defaults to VERTICAL_ALIGN_CENTER.
*/
- @Nullable
- public VerticalAlignmentProp getVerticalAlign() {
+ public @Nullable VerticalAlignmentProp getVerticalAlign() {
if (mImpl.hasVerticalAlign()) {
return VerticalAlignmentProp.fromProto(mImpl.getVerticalAlign());
} else {
@@ -4313,8 +4029,7 @@
}
/** Gets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element. */
- @Nullable
- public Modifiers getModifiers() {
+ public @Nullable Modifiers getModifiers() {
if (mImpl.hasModifiers()) {
return Modifiers.fromProto(mImpl.getModifiers());
} else {
@@ -4323,8 +4038,7 @@
}
/** Gets defines the direction in which child elements are laid out. */
- @Nullable
- public ArcDirectionProp getArcDirection() {
+ public @Nullable ArcDirectionProp getArcDirection() {
if (mImpl.hasArcDirection()) {
return ArcDirectionProp.fromProto(mImpl.getArcDirection());
} else {
@@ -4334,41 +4048,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Arc fromProto(
- @NonNull LayoutElementProto.Arc proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Arc fromProto(
+ LayoutElementProto.@NonNull Arc proto, @Nullable Fingerprint fingerprint) {
return new Arc(proto, fingerprint);
}
- @NonNull
- static Arc fromProto(@NonNull LayoutElementProto.Arc proto) {
+ static @NonNull Arc fromProto(LayoutElementProto.@NonNull Arc proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.Arc toProto() {
+ LayoutElementProto.@NonNull Arc toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return LayoutElementProto.LayoutElement.newBuilder().setArc(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Arc{"
+ "contents="
+ getContents()
@@ -4397,8 +4105,7 @@
/** Adds one item to contents of this container. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder addContent(@NonNull ArcLayoutElement content) {
+ public @NonNull Builder addContent(@NonNull ArcLayoutElement content) {
mImpl.addContents(content.toArcLayoutElementProto());
mFingerprint.addChildNode(checkNotNull(content.getFingerprint()));
return this;
@@ -4417,8 +4124,7 @@
* version 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setAnchorAngle(@NonNull DegreesProp anchorAngle) {
+ public @NonNull Builder setAnchorAngle(@NonNull DegreesProp anchorAngle) {
mImpl.setAnchorAngle(anchorAngle.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(anchorAngle.getFingerprint()).aggregateValueAsInt());
@@ -4430,8 +4136,7 @@
* defined, defaults to ARC_ANCHOR_CENTER.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setAnchorType(@NonNull ArcAnchorTypeProp anchorType) {
+ public @NonNull Builder setAnchorType(@NonNull ArcAnchorTypeProp anchorType) {
mImpl.setAnchorType(anchorType.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(anchorType.getFingerprint()).aggregateValueAsInt());
@@ -4443,8 +4148,7 @@
* defined, defaults to ARC_ANCHOR_CENTER.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setAnchorType(@ArcAnchorType int anchorType) {
+ public @NonNull Builder setAnchorType(@ArcAnchorType int anchorType) {
return setAnchorType(new ArcAnchorTypeProp.Builder().setValue(anchorType).build());
}
@@ -4455,8 +4159,7 @@
* center. If not defined, defaults to VERTICAL_ALIGN_CENTER.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setVerticalAlign(@NonNull VerticalAlignmentProp verticalAlign) {
+ public @NonNull Builder setVerticalAlign(@NonNull VerticalAlignmentProp verticalAlign) {
mImpl.setVerticalAlign(verticalAlign.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(verticalAlign.getFingerprint()).aggregateValueAsInt());
@@ -4470,8 +4173,7 @@
* center. If not defined, defaults to VERTICAL_ALIGN_CENTER.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setVerticalAlign(@VerticalAlignment int verticalAlign) {
+ public @NonNull Builder setVerticalAlign(@VerticalAlignment int verticalAlign) {
return setVerticalAlign(
new VerticalAlignmentProp.Builder().setValue(verticalAlign).build());
}
@@ -4480,8 +4182,7 @@
* Sets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setModifiers(@NonNull Modifiers modifiers) {
+ public @NonNull Builder setModifiers(@NonNull Modifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -4493,8 +4194,7 @@
* ARC_DIRECTION_NORMAL.
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setArcDirection(@NonNull ArcDirectionProp arcDirection) {
+ public @NonNull Builder setArcDirection(@NonNull ArcDirectionProp arcDirection) {
mImpl.setArcDirection(arcDirection.toProto());
mFingerprint.recordPropertyUpdate(
7, checkNotNull(arcDirection.getFingerprint()).aggregateValueAsInt());
@@ -4506,16 +4206,14 @@
* ARC_DIRECTION_NORMAL.
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setArcDirection(@ArcDirection int arcDirection) {
+ public @NonNull Builder setArcDirection(@ArcDirection int arcDirection) {
return setArcDirection(
new ArcDirectionProp.Builder().setValue(arcDirection).build());
}
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public Arc build() {
+ public @NonNull Arc build() {
return new Arc(mImpl.build(), mFingerprint);
}
}
@@ -4525,7 +4223,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class ArcText implements ArcLayoutElement {
private final LayoutElementProto.ArcText mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ArcText(LayoutElementProto.ArcText impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -4533,8 +4231,7 @@
}
/** Gets the text to render. */
- @Nullable
- public StringProp getText() {
+ public @Nullable StringProp getText() {
if (mImpl.hasText()) {
return StringProp.fromProto(mImpl.getText());
} else {
@@ -4546,8 +4243,7 @@
* Gets the style of font to use (size, bold etc). If not specified, defaults to the
* platform's default body font.
*/
- @Nullable
- public FontStyle getFontStyle() {
+ public @Nullable FontStyle getFontStyle() {
if (mImpl.hasFontStyle()) {
return FontStyle.fromProto(mImpl.getFontStyle());
} else {
@@ -4556,8 +4252,7 @@
}
/** Gets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element. */
- @Nullable
- public ArcModifiers getModifiers() {
+ public @Nullable ArcModifiers getModifiers() {
if (mImpl.hasModifiers()) {
return ArcModifiers.fromProto(mImpl.getModifiers());
} else {
@@ -4566,8 +4261,7 @@
}
/** Gets defines the direction in which text is drawn.*/
- @Nullable
- public ArcDirectionProp getArcDirection() {
+ public @Nullable ArcDirectionProp getArcDirection() {
if (mImpl.hasArcDirection()) {
return ArcDirectionProp.fromProto(mImpl.getArcDirection());
} else {
@@ -4577,41 +4271,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ArcText fromProto(
- @NonNull LayoutElementProto.ArcText proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ArcText fromProto(
+ LayoutElementProto.@NonNull ArcText proto, @Nullable Fingerprint fingerprint) {
return new ArcText(proto, fingerprint);
}
- @NonNull
- static ArcText fromProto(@NonNull LayoutElementProto.ArcText proto) {
+ static @NonNull ArcText fromProto(LayoutElementProto.@NonNull ArcText proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.ArcText toProto() {
+ LayoutElementProto.@NonNull ArcText toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.ArcLayoutElement toArcLayoutElementProto() {
+ public LayoutElementProto.@NonNull ArcLayoutElement toArcLayoutElementProto() {
return LayoutElementProto.ArcLayoutElement.newBuilder().setText(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ArcText{"
+ "text="
+ getText()
@@ -4640,8 +4328,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setText(@NonNull StringProp text) {
+ public @NonNull Builder setText(@NonNull StringProp text) {
if (text.getDynamicValue() != null) {
throw new IllegalArgumentException(
"ArcText.Builder.setText doesn't support dynamic values.");
@@ -4653,8 +4340,7 @@
}
/** Sets the text to render. */
- @NonNull
- public Builder setText(@NonNull String text) {
+ public @NonNull Builder setText(@NonNull String text) {
return setText(new StringProp.Builder(text).build());
}
@@ -4663,8 +4349,7 @@
* platform's default body font.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setFontStyle(@NonNull FontStyle fontStyle) {
+ public @NonNull Builder setFontStyle(@NonNull FontStyle fontStyle) {
mImpl.setFontStyle(fontStyle.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(fontStyle.getFingerprint()).aggregateValueAsInt());
@@ -4675,8 +4360,7 @@
* Sets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setModifiers(@NonNull ArcModifiers modifiers) {
+ public @NonNull Builder setModifiers(@NonNull ArcModifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -4688,8 +4372,7 @@
* ARC_DIRECTION_CLOCKWISE.
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setArcDirection(@NonNull ArcDirectionProp arcDirection) {
+ public @NonNull Builder setArcDirection(@NonNull ArcDirectionProp arcDirection) {
mImpl.setArcDirection(arcDirection.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(arcDirection.getFingerprint()).aggregateValueAsInt());
@@ -4701,16 +4384,14 @@
* ARC_DIRECTION_CLOCKWISE.
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setArcDirection(@ArcDirection int arcDirection) {
+ public @NonNull Builder setArcDirection(@ArcDirection int arcDirection) {
return setArcDirection(
new ArcDirectionProp.Builder().setValue(arcDirection).build());
}
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public ArcText build() {
+ public @NonNull ArcText build() {
return new ArcText(mImpl.build(), mFingerprint);
}
}
@@ -4720,7 +4401,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class ArcLine implements ArcLayoutElement {
private final LayoutElementProto.ArcLine mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ArcLine(LayoutElementProto.ArcLine impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -4738,8 +4419,7 @@
* {@code setLayoutConstraintsForDynamicLength(AngularLayoutConstraint)} otherwise {@code
* build()} fails.
*/
- @Nullable
- public DegreesProp getLength() {
+ public @Nullable DegreesProp getLength() {
if (mImpl.hasLength()) {
return DegreesProp.fromProto(mImpl.getLength());
} else {
@@ -4748,8 +4428,7 @@
}
/** Gets the thickness of this line. If not defined, defaults to 0. */
- @Nullable
- public DpProp getThickness() {
+ public @Nullable DpProp getThickness() {
if (mImpl.hasThickness()) {
return DpProp.fromProto(mImpl.getThickness());
} else {
@@ -4765,8 +4444,7 @@
*
* <p>If a brush is set, this color will not be used.
*/
- @Nullable
- public ColorProp getColor() {
+ public @Nullable ColorProp getColor() {
if (mImpl.hasColor()) {
return ColorProp.fromProto(mImpl.getColor());
} else {
@@ -4778,8 +4456,7 @@
* Gets a brush used to draw this line. If set, the brush will be used instead of the color
* provided in {@code setColor()}.
*/
- @Nullable
- public Brush getBrush() {
+ public @Nullable Brush getBrush() {
if (mImpl.hasBrush()) {
return ColorBuilders.brushFromProto(mImpl.getBrush());
} else {
@@ -4788,8 +4465,7 @@
}
/** Gets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element. */
- @Nullable
- public ArcModifiers getModifiers() {
+ public @Nullable ArcModifiers getModifiers() {
if (mImpl.hasModifiers()) {
return ArcModifiers.fromProto(mImpl.getModifiers());
} else {
@@ -4798,8 +4474,7 @@
}
/** Gets the line stroke cap. If not defined, defaults to STROKE_CAP_ROUND. */
- @Nullable
- public StrokeCapProp getStrokeCap() {
+ public @Nullable StrokeCapProp getStrokeCap() {
if (mImpl.hasStrokeCap()) {
return StrokeCapProp.fromProto(mImpl.getStrokeCap());
} else {
@@ -4808,8 +4483,7 @@
}
/** Gets defines the direction in which line drawn. */
- @Nullable
- public ArcDirectionProp getArcDirection() {
+ public @Nullable ArcDirectionProp getArcDirection() {
if (mImpl.hasArcDirection()) {
return ArcDirectionProp.fromProto(mImpl.getArcDirection());
} else {
@@ -4821,8 +4495,7 @@
* Gets the bounding constraints for the layout affected by the dynamic value from {@link
* #getLength()}.
*/
- @Nullable
- public AngularLayoutConstraint getLayoutConstraintsForDynamicLength() {
+ public @Nullable AngularLayoutConstraint getLayoutConstraintsForDynamicLength() {
if (mImpl.hasLength()) {
return AngularLayoutConstraint.fromProto(mImpl.getLength());
} else {
@@ -4832,41 +4505,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ArcLine fromProto(
- @NonNull LayoutElementProto.ArcLine proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ArcLine fromProto(
+ LayoutElementProto.@NonNull ArcLine proto, @Nullable Fingerprint fingerprint) {
return new ArcLine(proto, fingerprint);
}
- @NonNull
- static ArcLine fromProto(@NonNull LayoutElementProto.ArcLine proto) {
+ static @NonNull ArcLine fromProto(LayoutElementProto.@NonNull ArcLine proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.ArcLine toProto() {
+ LayoutElementProto.@NonNull ArcLine toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.ArcLayoutElement toArcLayoutElementProto() {
+ public LayoutElementProto.@NonNull ArcLayoutElement toArcLayoutElementProto() {
return LayoutElementProto.ArcLayoutElement.newBuilder().setLine(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ArcLine{"
+ "length="
+ getLength()
@@ -4907,8 +4574,7 @@
* build()} fails.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setLength(@NonNull DegreesProp length) {
+ public @NonNull Builder setLength(@NonNull DegreesProp length) {
mImpl.mergeLength(length.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(length.getFingerprint()).aggregateValueAsInt());
@@ -4920,9 +4586,8 @@
* {@link #setLength(DegreesProp)}.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setLayoutConstraintsForDynamicLength(
- @NonNull DimensionBuilders.AngularLayoutConstraint angularLayoutConstraint) {
+ public @NonNull Builder setLayoutConstraintsForDynamicLength(
+ DimensionBuilders.@NonNull AngularLayoutConstraint angularLayoutConstraint) {
mImpl.mergeLength(angularLayoutConstraint.toProto());
mFingerprint.recordPropertyUpdate(
1,
@@ -4937,8 +4602,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setThickness(@NonNull DpProp thickness) {
+ public @NonNull Builder setThickness(@NonNull DpProp thickness) {
if (thickness.getDynamicValue() != null) {
throw new IllegalArgumentException(
"ArcLine.Builder.setThickness doesn't support dynamic values.");
@@ -4958,8 +4622,7 @@
* <p>If a brush is set, this color will not be used.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setColor(@NonNull ColorProp color) {
+ public @NonNull Builder setColor(@NonNull ColorProp color) {
mImpl.setColor(color.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(color.getFingerprint()).aggregateValueAsInt());
@@ -4971,8 +4634,7 @@
* color provided in {@code setColor()}.
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setBrush(@NonNull Brush brush) {
+ public @NonNull Builder setBrush(@NonNull Brush brush) {
mImpl.setBrush(brush.toBrushProto());
mFingerprint.recordPropertyUpdate(
7, checkNotNull(brush.getFingerprint()).aggregateValueAsInt());
@@ -4983,8 +4645,7 @@
* Sets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setModifiers(@NonNull ArcModifiers modifiers) {
+ public @NonNull Builder setModifiers(@NonNull ArcModifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -4993,8 +4654,7 @@
/** Sets the line stroke cap. If not defined, defaults to STROKE_CAP_ROUND. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setStrokeCap(@NonNull StrokeCapProp strokeCap) {
+ public @NonNull Builder setStrokeCap(@NonNull StrokeCapProp strokeCap) {
mImpl.setStrokeCap(strokeCap.toProto());
mFingerprint.recordPropertyUpdate(
6, checkNotNull(strokeCap.getFingerprint()).aggregateValueAsInt());
@@ -5006,8 +4666,7 @@
* ARC_DIRECTION_CLOCKWISE.
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setArcDirection(@NonNull ArcDirectionProp arcDirection) {
+ public @NonNull Builder setArcDirection(@NonNull ArcDirectionProp arcDirection) {
mImpl.setArcDirection(arcDirection.toProto());
mFingerprint.recordPropertyUpdate(
8, checkNotNull(arcDirection.getFingerprint()).aggregateValueAsInt());
@@ -5019,22 +4678,19 @@
* ARC_DIRECTION_CLOCKWISE.
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setArcDirection(@ArcDirection int arcDirection) {
+ public @NonNull Builder setArcDirection(@ArcDirection int arcDirection) {
return setArcDirection(
new ArcDirectionProp.Builder().setValue(arcDirection).build());
}
/** Sets the line stroke cap. If not defined, defaults to STROKE_CAP_ROUND. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setStrokeCap(@StrokeCap int strokeCap) {
+ public @NonNull Builder setStrokeCap(@StrokeCap int strokeCap) {
return setStrokeCap(new StrokeCapProp.Builder().setValue(strokeCap).build());
}
@Override
- @NonNull
- public ArcLine build() {
+ public @NonNull ArcLine build() {
DimensionProto.DegreesProp length = mImpl.getLength();
if (length.hasDynamicValue() && !length.hasValueForLayout()) {
throw new IllegalStateException(
@@ -5068,7 +4724,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
public static final class StrokeCapProp {
private final LayoutElementProto.StrokeCapProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
StrokeCapProp(LayoutElementProto.StrokeCapProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -5088,8 +4744,7 @@
* <p>Only opaque colors are supported in {@link ArcLine} if a shadow is set. Any
* transparent colors will have their alpha component set to 0xFF (opaque).
*/
- @Nullable
- public Shadow getShadow() {
+ public @Nullable Shadow getShadow() {
if (mImpl.hasShadow()) {
return Shadow.fromProto(mImpl.getShadow());
} else {
@@ -5099,35 +4754,30 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static StrokeCapProp fromProto(
- @NonNull LayoutElementProto.StrokeCapProp proto,
+ public static @NonNull StrokeCapProp fromProto(
+ LayoutElementProto.@NonNull StrokeCapProp proto,
@Nullable Fingerprint fingerprint) {
return new StrokeCapProp(proto, fingerprint);
}
- @NonNull
- static StrokeCapProp fromProto(@NonNull LayoutElementProto.StrokeCapProp proto) {
+ static @NonNull StrokeCapProp fromProto(LayoutElementProto.@NonNull StrokeCapProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.StrokeCapProp toProto() {
+ public LayoutElementProto.@NonNull StrokeCapProp toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "StrokeCapProp{" + "value=" + getValue() + ", shadow=" + getShadow() + "}";
}
@@ -5143,8 +4793,7 @@
/** Sets the value. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setValue(@StrokeCap int value) {
+ public @NonNull Builder setValue(@StrokeCap int value) {
mImpl.setValue(LayoutElementProto.StrokeCap.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
@@ -5158,8 +4807,7 @@
* transparent colors will have their alpha component set to 0xFF (opaque).
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setShadow(@NonNull Shadow shadow) {
+ public @NonNull Builder setShadow(@NonNull Shadow shadow) {
mImpl.setShadow(shadow.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(shadow.getFingerprint()).aggregateValueAsInt());
@@ -5167,8 +4815,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public StrokeCapProp build() {
+ public @NonNull StrokeCapProp build() {
return new StrokeCapProp(mImpl.build(), mFingerprint);
}
}
@@ -5181,7 +4828,7 @@
@RequiresSchemaVersion(major = 1, minor = 500)
public static final class DashedArcLine implements ArcLayoutElement {
private final LayoutElementProto.DashedArcLine mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
DashedArcLine(LayoutElementProto.DashedArcLine impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -5195,8 +4842,7 @@
* affected layout element through {@code setLayoutConstraintsForDynamicLength
* (AngularLayoutConstraint)}, otherwise {@code build()} fails.
*/
- @Nullable
- public DegreesProp getLength() {
+ public @Nullable DegreesProp getLength() {
if (mImpl.hasLength()) {
return DegreesProp.fromProto(mImpl.getLength());
} else {
@@ -5215,8 +4861,7 @@
}
/** Gets the color of this line. */
- @Nullable
- public ColorProp getColor() {
+ public @Nullable ColorProp getColor() {
if (mImpl.hasColor()) {
return ColorProp.fromProto(mImpl.getColor());
} else {
@@ -5225,8 +4870,7 @@
}
/** Gets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element. */
- @Nullable
- public ArcModifiers getModifiers() {
+ public @Nullable ArcModifiers getModifiers() {
if (mImpl.hasModifiers()) {
return ArcModifiers.fromProto(mImpl.getModifiers());
} else {
@@ -5235,8 +4879,7 @@
}
/** Gets the direction in which this line is drawn. */
- @Nullable
- public ArcDirectionProp getArcDirection() {
+ public @Nullable ArcDirectionProp getArcDirection() {
if (mImpl.hasArcDirection()) {
return ArcDirectionProp.fromProto(mImpl.getArcDirection());
} else {
@@ -5245,8 +4888,7 @@
}
/** Gets the dashed line pattern which describes how the arc line is segmented by gaps. */
- @Nullable
- public DashedLinePattern getLinePattern() {
+ public @Nullable DashedLinePattern getLinePattern() {
if (mImpl.hasLinePattern()) {
return DashedLinePattern.fromProto(mImpl.getLinePattern());
} else {
@@ -5258,8 +4900,7 @@
* Gets the bounding constraints for the layout affected by the dynamic value from {@link
* #getLength()}.
*/
- @Nullable
- public AngularLayoutConstraint getLayoutConstraintsForDynamicLength() {
+ public @Nullable AngularLayoutConstraint getLayoutConstraintsForDynamicLength() {
if (mImpl.hasLength()) {
return AngularLayoutConstraint.fromProto(mImpl.getLength());
} else {
@@ -5269,41 +4910,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DashedArcLine fromProto(
- @NonNull LayoutElementProto.DashedArcLine proto,
+ public static @NonNull DashedArcLine fromProto(
+ LayoutElementProto.@NonNull DashedArcLine proto,
@Nullable Fingerprint fingerprint) {
return new DashedArcLine(proto, fingerprint);
}
- @NonNull
- static DashedArcLine fromProto(@NonNull LayoutElementProto.DashedArcLine proto) {
+ static @NonNull DashedArcLine fromProto(LayoutElementProto.@NonNull DashedArcLine proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
- @NonNull
- LayoutElementProto.DashedArcLine toProto() {
+ LayoutElementProto.@NonNull DashedArcLine toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.ArcLayoutElement toArcLayoutElementProto() {
+ public LayoutElementProto.@NonNull ArcLayoutElement toArcLayoutElementProto() {
return LayoutElementProto.ArcLayoutElement.newBuilder().setDashedLine(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "DashedArcLine{"
+ "length="
+ getLength()
@@ -5339,8 +4974,7 @@
* (AngularLayoutConstraint)} otherwise {@code build()} fails.
*/
@RequiresSchemaVersion(major = 1, minor = 500)
- @NonNull
- public Builder setLength(@NonNull DegreesProp length) {
+ public @NonNull Builder setLength(@NonNull DegreesProp length) {
mImpl.mergeLength(length.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(length.getFingerprint()).aggregateValueAsInt());
@@ -5351,8 +4985,7 @@
* Sets the thickness of this line. If not defined, defaults to 0.
*/
@RequiresSchemaVersion(major = 1, minor = 500)
- @NonNull
- public Builder setThickness(@Dimension(unit = DP) float thickness) {
+ public @NonNull Builder setThickness(@Dimension(unit = DP) float thickness) {
DpProp thicknessProp = dp(thickness);
mImpl.setThickness(thicknessProp.toProto());
mFingerprint.recordPropertyUpdate(
@@ -5364,8 +4997,7 @@
* Sets the color of this line.
*/
@RequiresSchemaVersion(major = 1, minor = 500)
- @NonNull
- public Builder setColor(@NonNull ColorProp color) {
+ public @NonNull Builder setColor(@NonNull ColorProp color) {
mImpl.setColor(color.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(color.getFingerprint()).aggregateValueAsInt());
@@ -5376,8 +5008,7 @@
* Sets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element.
*/
@RequiresSchemaVersion(major = 1, minor = 500)
- @NonNull
- public Builder setModifiers(@NonNull ArcModifiers modifiers) {
+ public @NonNull Builder setModifiers(@NonNull ArcModifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -5389,8 +5020,7 @@
* ARC_DIRECTION_CLOCKWISE.
*/
@RequiresSchemaVersion(major = 1, minor = 500)
- @NonNull
- public Builder setArcDirection(@NonNull ArcDirectionProp arcDirection) {
+ public @NonNull Builder setArcDirection(@NonNull ArcDirectionProp arcDirection) {
mImpl.setArcDirection(arcDirection.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(arcDirection.getFingerprint()).aggregateValueAsInt());
@@ -5402,8 +5032,7 @@
* ARC_DIRECTION_CLOCKWISE.
*/
@RequiresSchemaVersion(major = 1, minor = 500)
- @NonNull
- public Builder setArcDirection(@ArcDirection int arcDirection) {
+ public @NonNull Builder setArcDirection(@ArcDirection int arcDirection) {
return setArcDirection(
new ArcDirectionProp.Builder().setValue(arcDirection).build());
}
@@ -5412,8 +5041,7 @@
* Sets the dashed line pattern which describes how the arc line is segmented by gaps.
*/
@RequiresSchemaVersion(major = 1, minor = 500)
- @NonNull
- public Builder setLinePattern(@NonNull DashedLinePattern linePattern) {
+ public @NonNull Builder setLinePattern(@NonNull DashedLinePattern linePattern) {
mImpl.setLinePattern(linePattern.toProto());
mFingerprint.recordPropertyUpdate(
6, checkNotNull(linePattern.getFingerprint()).aggregateValueAsInt());
@@ -5424,8 +5052,7 @@
* {@link #setLength(DegreesProp)}.
*/
@RequiresSchemaVersion(major = 1, minor = 500)
- @NonNull
- public Builder setLayoutConstraintsForDynamicLength(
+ public @NonNull Builder setLayoutConstraintsForDynamicLength(
@NonNull AngularLayoutConstraint angularLayoutConstraint) {
mImpl.mergeLength(angularLayoutConstraint.toProto());
mFingerprint.recordPropertyUpdate(
@@ -5438,8 +5065,7 @@
/** Builds an instance with the values accumulated in this Builder. */
@SuppressLint("ProtoLayoutMinSchema")
@Override
- @NonNull
- public DashedArcLine build() {
+ public @NonNull DashedArcLine build() {
DimensionProto.DegreesProp length = mImpl.getLength();
if (length.hasDynamicValue() && !length.hasValueForLayout()) {
throw new IllegalStateException(
@@ -5456,7 +5082,7 @@
@RequiresSchemaVersion(major = 1, minor = 500)
public static final class DashedLinePattern {
private final LayoutElementProto.DashedLinePattern mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
DashedLinePattern(
LayoutElementProto.DashedLinePattern impl, @Nullable Fingerprint fingerprint) {
@@ -5465,8 +5091,7 @@
}
/** Gets the size in dp of the gap between the arc line segments. */
- @Nullable
- public DpProp getGapSize() {
+ public @Nullable DpProp getGapSize() {
if (mImpl.hasGapSize()) {
return DpProp.fromProto(mImpl.getGapSize());
} else {
@@ -5475,8 +5100,7 @@
}
/** Gets the list of each gap's center location in degrees. */
- @NonNull
- public List<DegreesProp> getGapLocations() {
+ public @NonNull List<DegreesProp> getGapLocations() {
List<DegreesProp> list = new ArrayList<>();
for (DimensionProto.DegreesProp item : mImpl.getGapLocationsList()) {
list.add(DegreesProp.fromProto(item));
@@ -5486,35 +5110,31 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static DashedLinePattern fromProto(
- @NonNull LayoutElementProto.DashedLinePattern proto,
+ public static @NonNull DashedLinePattern fromProto(
+ LayoutElementProto.@NonNull DashedLinePattern proto,
@Nullable Fingerprint fingerprint) {
return new DashedLinePattern(proto, fingerprint);
}
- @NonNull
- static DashedLinePattern fromProto(@NonNull LayoutElementProto.DashedLinePattern proto) {
+ static @NonNull DashedLinePattern fromProto(
+ LayoutElementProto.@NonNull DashedLinePattern proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.DashedLinePattern toProto() {
+ public LayoutElementProto.@NonNull DashedLinePattern toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "DashedLinePattern{"
+ "gapSize="
+ getGapSize()
@@ -5537,8 +5157,7 @@
* Sets the size in dp of the gap between the segments. If not defined, defaults to 0.
*/
@RequiresSchemaVersion(major = 1, minor = 500)
- @NonNull
- public Builder setGapSize(@Dimension(unit = DP) float gapSizeInDp) {
+ public @NonNull Builder setGapSize(@Dimension(unit = DP) float gapSizeInDp) {
DpProp gapSizeProp = dp(gapSizeInDp);
mImpl.setGapSize(gapSizeProp.toProto());
mFingerprint.recordPropertyUpdate(
@@ -5552,8 +5171,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 500)
- @NonNull
- private Builder addGapLocation(@NonNull DegreesProp gapLocation) {
+ private @NonNull Builder addGapLocation(@NonNull DegreesProp gapLocation) {
if (gapLocation.getDynamicValue() != null) {
throw new IllegalArgumentException(
"DashedLinePattern.Builder.addGapLocation doesn't support dynamic "
@@ -5575,8 +5193,7 @@
* #setGapInterval}
*/
@RequiresSchemaVersion(major = 1, minor = 500)
- @NonNull
- public Builder setGapLocations(@NonNull float... gapLocationsInDegrees) {
+ public @NonNull Builder setGapLocations(float @NonNull ... gapLocationsInDegrees) {
mImpl.clearGapLocations();
for (float gapLocation: gapLocationsInDegrees) {
@@ -5596,9 +5213,8 @@
* with {@link #setGapLocations}
*/
@RequiresSchemaVersion(major = 1, minor = 500)
- @NonNull
@SuppressLint("MissingGetterMatchingBuilder")
- public Builder setGapInterval(float gapIntervalInDegrees) {
+ public @NonNull Builder setGapInterval(float gapIntervalInDegrees) {
mImpl.clearGapLocations();
float gapLocation = gapIntervalInDegrees;
@@ -5613,8 +5229,7 @@
private static final int GAP_COUNTS_LIMIT = 100;
/** Builds an instance from accumulated values. */
- @NonNull
- public DashedLinePattern build() {
+ public @NonNull DashedLinePattern build() {
if (mImpl.getGapLocationsList().size() > GAP_COUNTS_LIMIT) {
throw new IllegalArgumentException(
"Number of gaps can't be larger than " + GAP_COUNTS_LIMIT + ".");
@@ -5629,7 +5244,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class ArcSpacer implements ArcLayoutElement {
private final LayoutElementProto.ArcSpacer mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ArcSpacer(LayoutElementProto.ArcSpacer impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -5637,8 +5252,7 @@
}
/** Gets the length of this spacer, in degrees. If not defined, defaults to 0. */
- @Nullable
- public DegreesProp getLength() {
+ public @Nullable DegreesProp getLength() {
if (mImpl.hasLength()) {
return DegreesProp.fromProto(mImpl.getLength());
} else {
@@ -5647,8 +5261,7 @@
}
/** Gets the thickness of this spacer, in DP. If not defined, defaults to 0. */
- @Nullable
- public DpProp getThickness() {
+ public @Nullable DpProp getThickness() {
if (mImpl.hasThickness()) {
return DpProp.fromProto(mImpl.getThickness());
} else {
@@ -5657,8 +5270,7 @@
}
/** Gets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element. */
- @Nullable
- public ArcModifiers getModifiers() {
+ public @Nullable ArcModifiers getModifiers() {
if (mImpl.hasModifiers()) {
return ArcModifiers.fromProto(mImpl.getModifiers());
} else {
@@ -5667,8 +5279,7 @@
}
/** Gets the length of this spacer.*/
- @Nullable
- public AngularDimension getAngularLength() {
+ public @Nullable AngularDimension getAngularLength() {
if (mImpl.hasAngularLength()) {
return DimensionBuilders.angularDimensionFromProto(mImpl.getAngularLength());
} else {
@@ -5678,41 +5289,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ArcSpacer fromProto(
- @NonNull LayoutElementProto.ArcSpacer proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ArcSpacer fromProto(
+ LayoutElementProto.@NonNull ArcSpacer proto, @Nullable Fingerprint fingerprint) {
return new ArcSpacer(proto, fingerprint);
}
- @NonNull
- static ArcSpacer fromProto(@NonNull LayoutElementProto.ArcSpacer proto) {
+ static @NonNull ArcSpacer fromProto(LayoutElementProto.@NonNull ArcSpacer proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.ArcSpacer toProto() {
+ LayoutElementProto.@NonNull ArcSpacer toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.ArcLayoutElement toArcLayoutElementProto() {
+ public LayoutElementProto.@NonNull ArcLayoutElement toArcLayoutElementProto() {
return LayoutElementProto.ArcLayoutElement.newBuilder().setSpacer(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ArcSpacer{"
+ "length="
+ getLength()
@@ -5744,8 +5349,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setLength(@NonNull DegreesProp length) {
+ public @NonNull Builder setLength(@NonNull DegreesProp length) {
if (length.getDynamicValue() != null) {
throw new IllegalArgumentException(
"ArcSpacer.Builder.setLength doesn't support dynamic values.");
@@ -5762,8 +5366,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setThickness(@NonNull DpProp thickness) {
+ public @NonNull Builder setThickness(@NonNull DpProp thickness) {
if (thickness.getDynamicValue() != null) {
throw new IllegalArgumentException(
"ArcSpacer.Builder.setThickness doesn't support dynamic values.");
@@ -5778,8 +5381,7 @@
* Sets {@link androidx.wear.protolayout.ModifiersBuilders.Modifiers} for this element.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setModifiers(@NonNull ArcModifiers modifiers) {
+ public @NonNull Builder setModifiers(@NonNull ArcModifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -5793,8 +5395,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 500)
- @NonNull
- public Builder setAngularLength(@NonNull AngularDimension angularLength) {
+ public @NonNull Builder setAngularLength(@NonNull AngularDimension angularLength) {
DimensionProto. AngularDimension angularDimensionProto =
angularLength.toAngularDimensionProto();
if ((angularDimensionProto.hasDegrees()
@@ -5813,8 +5414,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public ArcSpacer build() {
+ public @NonNull ArcSpacer build() {
return new ArcSpacer(mImpl.build(), mFingerprint);
}
}
@@ -5824,7 +5424,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class ArcAdapter implements ArcLayoutElement {
private final LayoutElementProto.ArcAdapter mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ArcAdapter(LayoutElementProto.ArcAdapter impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -5832,8 +5432,7 @@
}
/** Gets the element to adapt to an {@link Arc}. */
- @Nullable
- public LayoutElement getContent() {
+ public @Nullable LayoutElement getContent() {
if (mImpl.hasContent()) {
return LayoutElementBuilders.layoutElementFromProto(mImpl.getContent());
} else {
@@ -5849,8 +5448,7 @@
* rotate_contents = false, the image will be placed at the 3 o clock position, but itself
* will not be rotated. If not defined, defaults to false.
*/
- @Nullable
- private BoolProp isRotateContents() {
+ private @Nullable BoolProp isRotateContents() {
if (mImpl.hasRotateContents()) {
return BoolProp.fromProto(mImpl.getRotateContents());
} else {
@@ -5867,48 +5465,41 @@
* image will be placed at the 3 o clock position, but itself will not be rotated. If not
* defined, defaults to false.
*/
- @Nullable
- public BoolProp getRotateContents() {
+ public @Nullable BoolProp getRotateContents() {
return isRotateContents();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ArcAdapter fromProto(
- @NonNull LayoutElementProto.ArcAdapter proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ArcAdapter fromProto(
+ LayoutElementProto.@NonNull ArcAdapter proto, @Nullable Fingerprint fingerprint) {
return new ArcAdapter(proto, fingerprint);
}
- @NonNull
- static ArcAdapter fromProto(@NonNull LayoutElementProto.ArcAdapter proto) {
+ static @NonNull ArcAdapter fromProto(LayoutElementProto.@NonNull ArcAdapter proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.ArcAdapter toProto() {
+ LayoutElementProto.@NonNull ArcAdapter toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.ArcLayoutElement toArcLayoutElementProto() {
+ public LayoutElementProto.@NonNull ArcLayoutElement toArcLayoutElementProto() {
return LayoutElementProto.ArcLayoutElement.newBuilder().setAdapter(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ArcAdapter{"
+ "content="
+ getContent()
@@ -5938,8 +5529,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setRotateContents(@NonNull BoolProp rotateContents) {
+ public @NonNull Builder setRotateContents(@NonNull BoolProp rotateContents) {
if (rotateContents.getDynamicValue() != null) {
throw new IllegalArgumentException(
"ArcAdapter.Builder.setRotateContents doesn't support dynamic values.");
@@ -5959,8 +5549,7 @@
* position, but itself will not be rotated. If not defined, defaults to false.
*/
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setRotateContents(boolean rotateContents) {
+ public @NonNull Builder setRotateContents(boolean rotateContents) {
return setRotateContents(new BoolProp.Builder(rotateContents).build());
}
@@ -5971,8 +5560,7 @@
* modifier.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setContent(@NonNull LayoutElement content) {
+ public @NonNull Builder setContent(@NonNull LayoutElement content) {
LayoutElementProto.LayoutElement contentProto = content.toLayoutElementProto();
if (hasTransformation(contentProto)) {
throw new IllegalArgumentException(
@@ -5986,8 +5574,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public ArcAdapter build() {
+ public @NonNull ArcAdapter build() {
return new ArcAdapter(mImpl.build(), mFingerprint);
}
}
@@ -6000,7 +5587,7 @@
@RequiresSchemaVersion(major = 1, minor = 300)
public static final class ArcDirectionProp {
private final LayoutElementProto.ArcDirectionProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ArcDirectionProp(
LayoutElementProto.ArcDirectionProp impl,
@@ -6017,35 +5604,31 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ArcDirectionProp fromProto(
- @NonNull LayoutElementProto.ArcDirectionProp proto,
+ public static @NonNull ArcDirectionProp fromProto(
+ LayoutElementProto.@NonNull ArcDirectionProp proto,
@Nullable Fingerprint fingerprint) {
return new ArcDirectionProp(proto, fingerprint);
}
- @NonNull
- static ArcDirectionProp fromProto(@NonNull LayoutElementProto.ArcDirectionProp proto) {
+ static @NonNull ArcDirectionProp fromProto(
+ LayoutElementProto.@NonNull ArcDirectionProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.ArcDirectionProp toProto() {
+ public LayoutElementProto.@NonNull ArcDirectionProp toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ArcDirectionProp{" + "value=" + getValue() + "}";
}
@@ -6066,16 +5649,14 @@
/** Sets the arc direction value. */
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- Builder setValue(@ArcDirection int value) {
+ @NonNull Builder setValue(@ArcDirection int value) {
mImpl.setValue(LayoutElementProto.ArcDirection.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public ArcDirectionProp build() {
+ public @NonNull ArcDirectionProp build() {
return new ArcDirectionProp(mImpl.build(), mFingerprint);
}
}
@@ -6095,7 +5676,7 @@
@ExperimentalProtoLayoutExtensionApi
public static final class ExtensionLayoutElement implements LayoutElement {
private final LayoutElementProto.ExtensionLayoutElement mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ExtensionLayoutElement(
LayoutElementProto.ExtensionLayoutElement impl, @Nullable Fingerprint fingerprint) {
@@ -6107,8 +5688,7 @@
* Gets the content of the renderer extension element. This can be any data; it is expected
* that the renderer extension knows how to parse this field.
*/
- @NonNull
- public byte[] getPayload() {
+ public byte @NonNull [] getPayload() {
return mImpl.getPayload().toByteArray();
}
@@ -6116,14 +5696,12 @@
* Gets the ID of the renderer extension that should be used for rendering this layout
* element.
*/
- @NonNull
- public String getExtensionId() {
+ public @NonNull String getExtensionId() {
return mImpl.getExtensionId();
}
/** Gets the width of this element. */
- @Nullable
- public ExtensionDimension getWidth() {
+ public @Nullable ExtensionDimension getWidth() {
if (mImpl.hasWidth()) {
return DimensionBuilders.extensionDimensionFromProto(mImpl.getWidth());
} else {
@@ -6132,8 +5710,7 @@
}
/** Gets the height of this element. */
- @Nullable
- public ExtensionDimension getHeight() {
+ public @Nullable ExtensionDimension getHeight() {
if (mImpl.hasHeight()) {
return DimensionBuilders.extensionDimensionFromProto(mImpl.getHeight());
} else {
@@ -6143,43 +5720,37 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ExtensionLayoutElement fromProto(
- @NonNull LayoutElementProto.ExtensionLayoutElement proto,
+ public static @NonNull ExtensionLayoutElement fromProto(
+ LayoutElementProto.@NonNull ExtensionLayoutElement proto,
@Nullable Fingerprint fingerprint) {
return new ExtensionLayoutElement(proto, fingerprint);
}
- @NonNull
- static ExtensionLayoutElement fromProto(
- @NonNull LayoutElementProto.ExtensionLayoutElement proto) {
+ static @NonNull ExtensionLayoutElement fromProto(
+ LayoutElementProto.@NonNull ExtensionLayoutElement proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.ExtensionLayoutElement toProto() {
+ LayoutElementProto.@NonNull ExtensionLayoutElement toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return LayoutElementProto.LayoutElement.newBuilder().setExtension(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ExtensionLayoutElement{"
+ "payload="
+ Arrays.toString(getPayload())
@@ -6208,8 +5779,7 @@
* expected that the renderer extension knows how to parse this field.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setPayload(@NonNull byte[] payload) {
+ public @NonNull Builder setPayload(byte @NonNull [] payload) {
mImpl.setPayload(ByteString.copyFrom(payload));
mFingerprint.recordPropertyUpdate(1, Arrays.hashCode(payload));
return this;
@@ -6220,8 +5790,7 @@
* element.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setExtensionId(@NonNull String extensionId) {
+ public @NonNull Builder setExtensionId(@NonNull String extensionId) {
mImpl.setExtensionId(extensionId);
mFingerprint.recordPropertyUpdate(2, extensionId.hashCode());
return this;
@@ -6229,8 +5798,7 @@
/** Sets the width of this element. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setWidth(@NonNull ExtensionDimension width) {
+ public @NonNull Builder setWidth(@NonNull ExtensionDimension width) {
mImpl.setWidth(width.toExtensionDimensionProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(width.getFingerprint()).aggregateValueAsInt());
@@ -6239,8 +5807,7 @@
/** Sets the height of this element. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setHeight(@NonNull ExtensionDimension height) {
+ public @NonNull Builder setHeight(@NonNull ExtensionDimension height) {
mImpl.setHeight(height.toExtensionDimensionProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(height.getFingerprint()).aggregateValueAsInt());
@@ -6249,8 +5816,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public ExtensionLayoutElement build() {
+ public @NonNull ExtensionLayoutElement build() {
return new ExtensionLayoutElement(mImpl.build(), mFingerprint);
}
}
@@ -6264,30 +5830,26 @@
public interface LayoutElement {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.LayoutElement toLayoutElementProto();
+ LayoutElementProto.@NonNull LayoutElement toLayoutElementProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link LayoutElement} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- LayoutElement build();
+ @NonNull LayoutElement build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
@OptIn(markerClass = ExperimentalProtoLayoutExtensionApi.class)
- public static LayoutElement layoutElementFromProto(
- @NonNull LayoutElementProto.LayoutElement proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull LayoutElement layoutElementFromProto(
+ LayoutElementProto.@NonNull LayoutElement proto, @Nullable Fingerprint fingerprint) {
if (proto.hasColumn()) {
return Column.fromProto(proto.getColumn(), fingerprint);
}
@@ -6318,8 +5880,8 @@
throw new IllegalStateException("Proto was not a recognised instance of LayoutElement");
}
- @NonNull
- static LayoutElement layoutElementFromProto(@NonNull LayoutElementProto.LayoutElement proto) {
+ static @NonNull LayoutElement layoutElementFromProto(
+ LayoutElementProto.@NonNull LayoutElement proto) {
return layoutElementFromProto(proto, null);
}
@@ -6331,29 +5893,25 @@
public interface ArcLayoutElement {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.ArcLayoutElement toArcLayoutElementProto();
+ LayoutElementProto.@NonNull ArcLayoutElement toArcLayoutElementProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link ArcLayoutElement} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- ArcLayoutElement build();
+ @NonNull ArcLayoutElement build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ArcLayoutElement arcLayoutElementFromProto(
- @NonNull LayoutElementProto.ArcLayoutElement proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ArcLayoutElement arcLayoutElementFromProto(
+ LayoutElementProto.@NonNull ArcLayoutElement proto, @Nullable Fingerprint fingerprint) {
if (proto.hasText()) {
return ArcText.fromProto(proto.getText(), fingerprint);
}
@@ -6372,9 +5930,8 @@
throw new IllegalStateException("Proto was not a recognised instance of ArcLayoutElement");
}
- @NonNull
- static ArcLayoutElement arcLayoutElementFromProto(
- @NonNull LayoutElementProto.ArcLayoutElement proto) {
+ static @NonNull ArcLayoutElement arcLayoutElementFromProto(
+ LayoutElementProto.@NonNull ArcLayoutElement proto) {
return arcLayoutElementFromProto(proto, null);
}
@@ -6388,8 +5945,7 @@
}
/** Gets the root element in the layout. */
- @Nullable
- public LayoutElement getRoot() {
+ public @Nullable LayoutElement getRoot() {
if (mImpl.hasRoot()) {
return LayoutElementBuilders.layoutElementFromProto(mImpl.getRoot());
} else {
@@ -6398,23 +5954,20 @@
}
/** Creates a {@link Layout} object containing the given layout element. */
- @NonNull
- public static Layout fromLayoutElement(@NonNull LayoutElement layoutElement) {
+ public static @NonNull Layout fromLayoutElement(@NonNull LayoutElement layoutElement) {
return new Builder().setRoot(layoutElement).build();
}
/** Converts to byte array representation. */
- @NonNull
@ProtoLayoutExperimental
- public byte[] toByteArray() {
+ public byte @NonNull [] toByteArray() {
return mImpl.toByteArray();
}
/** Converts from byte array representation. */
@SuppressWarnings("ProtoParseWithRegistry")
- @Nullable
@ProtoLayoutExperimental
- public static Layout fromByteArray(@NonNull byte[] byteArray) {
+ public static @Nullable Layout fromByteArray(byte @NonNull [] byteArray) {
try {
return fromProto(LayoutElementProto.Layout.parseFrom(byteArray));
} catch (InvalidProtocolBufferException e) {
@@ -6424,21 +5977,18 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Layout fromProto(@NonNull LayoutElementProto.Layout proto) {
+ public static @NonNull Layout fromProto(LayoutElementProto.@NonNull Layout proto) {
return new Layout(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.Layout toProto() {
+ public LayoutElementProto.@NonNull Layout toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Layout{" + "root=" + getRoot() + "}";
}
@@ -6451,10 +6001,9 @@
public Builder() {}
/** Sets the root element in the layout. */
- @NonNull
- public Builder setRoot(@NonNull LayoutElement root) {
+ public @NonNull Builder setRoot(@NonNull LayoutElement root) {
mImpl.setRoot(root.toLayoutElementProto());
- @Nullable Fingerprint fingerprint = root.getFingerprint();
+ Fingerprint fingerprint = root.getFingerprint();
if (fingerprint != null) {
mImpl.setFingerprint(
TreeFingerprint.newBuilder().setRoot(fingerprintToProto(fingerprint)));
@@ -6482,8 +6031,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Layout build() {
+ public @NonNull Layout build() {
return Layout.fromProto(mImpl.build());
}
}
@@ -6693,7 +6241,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class HorizontalAlignmentProp {
private final AlignmentProto.HorizontalAlignmentProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
HorizontalAlignmentProp(
AlignmentProto.HorizontalAlignmentProp impl, @Nullable Fingerprint fingerprint) {
@@ -6709,36 +6257,31 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static HorizontalAlignmentProp fromProto(
- @NonNull AlignmentProto.HorizontalAlignmentProp proto,
+ public static @NonNull HorizontalAlignmentProp fromProto(
+ AlignmentProto.@NonNull HorizontalAlignmentProp proto,
@Nullable Fingerprint fingerprint) {
return new HorizontalAlignmentProp(proto, fingerprint);
}
- @NonNull
- static HorizontalAlignmentProp fromProto(
- @NonNull AlignmentProto.HorizontalAlignmentProp proto) {
+ static @NonNull HorizontalAlignmentProp fromProto(
+ AlignmentProto.@NonNull HorizontalAlignmentProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public AlignmentProto.HorizontalAlignmentProp toProto() {
+ public AlignmentProto.@NonNull HorizontalAlignmentProp toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "HorizontalAlignmentProp{" + "value=" + getValue() + "}";
}
@@ -6753,16 +6296,14 @@
/** Sets the value. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(@HorizontalAlignment int value) {
+ public @NonNull Builder setValue(@HorizontalAlignment int value) {
mImpl.setValue(AlignmentProto.HorizontalAlignment.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public HorizontalAlignmentProp build() {
+ public @NonNull HorizontalAlignmentProp build() {
return new HorizontalAlignmentProp(mImpl.build(), mFingerprint);
}
}
@@ -6772,7 +6313,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class VerticalAlignmentProp {
private final AlignmentProto.VerticalAlignmentProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
VerticalAlignmentProp(
AlignmentProto.VerticalAlignmentProp impl, @Nullable Fingerprint fingerprint) {
@@ -6788,36 +6329,31 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static VerticalAlignmentProp fromProto(
- @NonNull AlignmentProto.VerticalAlignmentProp proto,
+ public static @NonNull VerticalAlignmentProp fromProto(
+ AlignmentProto.@NonNull VerticalAlignmentProp proto,
@Nullable Fingerprint fingerprint) {
return new VerticalAlignmentProp(proto, fingerprint);
}
- @NonNull
- static VerticalAlignmentProp fromProto(
- @NonNull AlignmentProto.VerticalAlignmentProp proto) {
+ static @NonNull VerticalAlignmentProp fromProto(
+ AlignmentProto.@NonNull VerticalAlignmentProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public AlignmentProto.VerticalAlignmentProp toProto() {
+ public AlignmentProto.@NonNull VerticalAlignmentProp toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "VerticalAlignmentProp{" + "value=" + getValue() + "}";
}
@@ -6832,16 +6368,14 @@
/** Sets the value. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(@VerticalAlignment int value) {
+ public @NonNull Builder setValue(@VerticalAlignment int value) {
mImpl.setValue(AlignmentProto.VerticalAlignment.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public VerticalAlignmentProp build() {
+ public @NonNull VerticalAlignmentProp build() {
return new VerticalAlignmentProp(mImpl.build(), mFingerprint);
}
}
@@ -6851,7 +6385,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class TextAlignmentProp {
private final AlignmentProto.TextAlignmentProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
TextAlignmentProp(
AlignmentProto.TextAlignmentProp impl, @Nullable Fingerprint fingerprint) {
@@ -6867,35 +6401,31 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static TextAlignmentProp fromProto(
- @NonNull AlignmentProto.TextAlignmentProp proto,
+ public static @NonNull TextAlignmentProp fromProto(
+ AlignmentProto.@NonNull TextAlignmentProp proto,
@Nullable Fingerprint fingerprint) {
return new TextAlignmentProp(proto, fingerprint);
}
- @NonNull
- static TextAlignmentProp fromProto(@NonNull AlignmentProto.TextAlignmentProp proto) {
+ static @NonNull TextAlignmentProp fromProto(
+ AlignmentProto.@NonNull TextAlignmentProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public AlignmentProto.TextAlignmentProp toProto() {
+ public AlignmentProto.@NonNull TextAlignmentProp toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "TextAlignmentProp{" + "value=" + getValue() + "}";
}
@@ -6910,16 +6440,14 @@
/** Sets the value. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(@TextAlignment int value) {
+ public @NonNull Builder setValue(@TextAlignment int value) {
mImpl.setValue(AlignmentProto.TextAlignment.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public TextAlignmentProp build() {
+ public @NonNull TextAlignmentProp build() {
return new TextAlignmentProp(mImpl.build(), mFingerprint);
}
}
@@ -6929,7 +6457,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class ArcAnchorTypeProp {
private final AlignmentProto.ArcAnchorTypeProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ArcAnchorTypeProp(
AlignmentProto.ArcAnchorTypeProp impl, @Nullable Fingerprint fingerprint) {
@@ -6945,35 +6473,31 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ArcAnchorTypeProp fromProto(
- @NonNull AlignmentProto.ArcAnchorTypeProp proto,
+ public static @NonNull ArcAnchorTypeProp fromProto(
+ AlignmentProto.@NonNull ArcAnchorTypeProp proto,
@Nullable Fingerprint fingerprint) {
return new ArcAnchorTypeProp(proto, fingerprint);
}
- @NonNull
- static ArcAnchorTypeProp fromProto(@NonNull AlignmentProto.ArcAnchorTypeProp proto) {
+ static @NonNull ArcAnchorTypeProp fromProto(
+ AlignmentProto.@NonNull ArcAnchorTypeProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public AlignmentProto.ArcAnchorTypeProp toProto() {
+ public AlignmentProto.@NonNull ArcAnchorTypeProp toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ArcAnchorTypeProp{" + "value=" + getValue() + "}";
}
@@ -6988,16 +6512,14 @@
/** Sets the value. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(@ArcAnchorType int value) {
+ public @NonNull Builder setValue(@ArcAnchorType int value) {
mImpl.setValue(AlignmentProto.ArcAnchorType.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public ArcAnchorTypeProp build() {
+ public @NonNull ArcAnchorTypeProp build() {
return new ArcAnchorTypeProp(mImpl.build(), mFingerprint);
}
}
@@ -7024,9 +6546,9 @@
* @deprecated Use {@link androidx.wear.protolayout.material.Typography#TYPOGRAPHY_DISPLAY1}
* on Material {@link androidx.wear.protolayout.material.Text}.
*/
- @NonNull
@Deprecated
- public static FontStyle.Builder display1(@NonNull DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder display1(
+ @NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setWeight(FONT_WEIGHT_BOLD)
.setSize(sp(isLargeScreen(deviceParameters) ? 54 : 50));
@@ -7038,9 +6560,9 @@
* @deprecated Use {@link androidx.wear.protolayout.material.Typography#TYPOGRAPHY_DISPLAY2}
* on Material {@link androidx.wear.protolayout.material.Text}.
*/
- @NonNull
@Deprecated
- public static FontStyle.Builder display2(@NonNull DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder display2(
+ @NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setWeight(FONT_WEIGHT_BOLD)
.setSize(sp(isLargeScreen(deviceParameters) ? 44 : 40));
@@ -7052,9 +6574,9 @@
* @deprecated Use {@link androidx.wear.protolayout.material.Typography#TYPOGRAPHY_DISPLAY3}
* on Material {@link androidx.wear.protolayout.material.Text}.
*/
- @NonNull
@Deprecated
- public static FontStyle.Builder display3(@NonNull DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder display3(
+ @NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setWeight(FONT_WEIGHT_BOLD)
.setSize(sp(isLargeScreen(deviceParameters) ? 34 : 30));
@@ -7066,9 +6588,9 @@
* @deprecated Use {@link androidx.wear.protolayout.material.Typography#TYPOGRAPHY_TITLE1}
* on Material {@link androidx.wear.protolayout.material.Text}.
*/
- @NonNull
@Deprecated
- public static FontStyle.Builder title1(@NonNull DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder title1(
+ @NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setWeight(FONT_WEIGHT_BOLD)
.setSize(sp(isLargeScreen(deviceParameters) ? 26 : 24));
@@ -7080,9 +6602,9 @@
* @deprecated Use {@link androidx.wear.protolayout.material.Typography#TYPOGRAPHY_TITLE2}
* on Material {@link androidx.wear.protolayout.material.Text}.
*/
- @NonNull
@Deprecated
- public static FontStyle.Builder title2(@NonNull DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder title2(
+ @NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setWeight(FONT_WEIGHT_BOLD)
.setSize(sp(isLargeScreen(deviceParameters) ? 22 : 20));
@@ -7094,9 +6616,9 @@
* @deprecated Use {@link androidx.wear.protolayout.material.Typography#TYPOGRAPHY_TITLE3}
* on Material {@link androidx.wear.protolayout.material.Text}.
*/
- @NonNull
@Deprecated
- public static FontStyle.Builder title3(@NonNull DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder title3(
+ @NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setWeight(FONT_WEIGHT_BOLD)
.setSize(sp(isLargeScreen(deviceParameters) ? 18 : 16));
@@ -7108,9 +6630,8 @@
* @deprecated Use {@link androidx.wear.protolayout.material.Typography#TYPOGRAPHY_BODY1} on
* Material {@link androidx.wear.protolayout.material.Text}.
*/
- @NonNull
@Deprecated
- public static FontStyle.Builder body1(@NonNull DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder body1(@NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setSize(sp(isLargeScreen(deviceParameters) ? 18 : 16));
}
@@ -7121,9 +6642,8 @@
* @deprecated Use {@link androidx.wear.protolayout.material.Typography#TYPOGRAPHY_BODY2} on
* Material {@link androidx.wear.protolayout.material.Text}.
*/
- @NonNull
@Deprecated
- public static FontStyle.Builder body2(@NonNull DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder body2(@NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setSize(sp(isLargeScreen(deviceParameters) ? 16 : 14));
}
@@ -7134,9 +6654,9 @@
* @deprecated Use {@link androidx.wear.protolayout.material.Typography#TYPOGRAPHY_BUTTON}
* on Material {@link androidx.wear.protolayout.material.Text}.
*/
- @NonNull
@Deprecated
- public static FontStyle.Builder button(@NonNull DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder button(
+ @NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setWeight(FONT_WEIGHT_BOLD)
.setSize(sp(isLargeScreen(deviceParameters) ? 16 : 14));
@@ -7148,9 +6668,9 @@
* @deprecated Use {@link androidx.wear.protolayout.material.Typography#TYPOGRAPHY_CAPTION1}
* on Material {@link androidx.wear.protolayout.material.Text}.
*/
- @NonNull
@Deprecated
- public static FontStyle.Builder caption1(@NonNull DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder caption1(
+ @NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setSize(sp(isLargeScreen(deviceParameters) ? 16 : 14));
}
@@ -7161,9 +6681,9 @@
* @deprecated Use {@link androidx.wear.protolayout.material.Typography#TYPOGRAPHY_CAPTION2}
* on Material {@link androidx.wear.protolayout.material.Text}.
*/
- @NonNull
@Deprecated
- public static FontStyle.Builder caption2(@NonNull DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder caption2(
+ @NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setSize(sp(isLargeScreen(deviceParameters) ? 14 : 12));
}
@@ -7172,7 +6692,7 @@
}
/** Checks whether a layout element has a transformation modifier. */
- private static boolean hasTransformation(@NonNull LayoutElementProto.LayoutElement content) {
+ private static boolean hasTransformation(LayoutElementProto.@NonNull LayoutElement content) {
switch (content.getInnerCase()) {
case IMAGE:
return content.getImage().hasModifiers()
diff --git a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/ModifiersBuilders.java b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/ModifiersBuilders.java
index e667ac5..9496a5c 100644
--- a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/ModifiersBuilders.java
+++ b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/ModifiersBuilders.java
@@ -23,8 +23,6 @@
import androidx.annotation.FloatRange;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.OptIn;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
@@ -43,6 +41,9 @@
import androidx.wear.protolayout.proto.ModifiersProto;
import androidx.wear.protolayout.protobuf.ByteString;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
@@ -85,8 +86,7 @@
* fully invisible to fully visible.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public static EnterTransition fadeIn() {
+ public static @NonNull EnterTransition fadeIn() {
return FADE_IN_ENTER_TRANSITION;
}
@@ -95,8 +95,7 @@
* its position from the parent edge in the given direction.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public static EnterTransition slideIn(@SlideDirection int slideDirection) {
+ public static @NonNull EnterTransition slideIn(@SlideDirection int slideDirection) {
return new EnterTransition.Builder()
.setSlideIn(slideInTransition(slideDirection))
.build();
@@ -110,8 +109,7 @@
* @param slideDirection The direction for sliding in part of transition.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public static EnterTransition fadeInSlideIn(@SlideDirection int slideDirection) {
+ public static @NonNull EnterTransition fadeInSlideIn(@SlideDirection int slideDirection) {
return new EnterTransition.Builder()
.setFadeIn(FADE_IN_TRANSITION)
.setSlideIn(slideInTransition(slideDirection))
@@ -149,8 +147,7 @@
* fully visible to fully invisible.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public static ExitTransition fadeOut() {
+ public static @NonNull ExitTransition fadeOut() {
return FADE_OUT_EXIT_TRANSITION;
}
@@ -159,8 +156,7 @@
* its position to the parent edge in the given direction.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public static ExitTransition slideOut(@SlideDirection int slideDirection) {
+ public static @NonNull ExitTransition slideOut(@SlideDirection int slideDirection) {
return new ExitTransition.Builder()
.setSlideOut(slideOutTransition(slideDirection))
.build();
@@ -174,8 +170,7 @@
* @param slideDirection The direction for sliding in part of transition.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public static ExitTransition fadeOutSlideOut(@SlideDirection int slideDirection) {
+ public static @NonNull ExitTransition fadeOutSlideOut(@SlideDirection int slideDirection) {
return new ExitTransition.Builder()
.setFadeOut(FADE_OUT_TRANSITION)
.setSlideOut(slideOutTransition(slideDirection))
@@ -311,7 +306,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class Clickable {
private final ModifiersProto.Clickable mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Clickable(ModifiersProto.Clickable impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -319,14 +314,12 @@
}
/** Gets the ID associated with this action. */
- @NonNull
- public String getId() {
+ public @NonNull String getId() {
return mImpl.getId();
}
/** Gets the action to perform when the element this modifier is attached to is clicked. */
- @Nullable
- public Action getOnClick() {
+ public @Nullable Action getOnClick() {
if (mImpl.hasOnClick()) {
return ActionBuilders.actionFromProto(mImpl.getOnClick());
} else {
@@ -341,8 +334,7 @@
* that this value does not affect the layout, so the minimum clickable width is not
* guaranteed unless there is enough space around the element within its parent bounds.
*/
- @NonNull
- public DpProp getMinimumClickableWidth() {
+ public @NonNull DpProp getMinimumClickableWidth() {
if (mImpl.hasMinimumClickableWidth()) {
return DpProp.fromProto(mImpl.getMinimumClickableWidth());
} else {
@@ -357,8 +349,7 @@
* that this value does not affect the layout, so the minimum clickable height is not
* guaranteed unless there is enough space around the element within its parent bounds.
*/
- @NonNull
- public DpProp getMinimumClickableHeight() {
+ public @NonNull DpProp getMinimumClickableHeight() {
if (mImpl.hasMinimumClickableHeight()) {
return DpProp.fromProto(mImpl.getMinimumClickableHeight());
} else {
@@ -380,34 +371,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Clickable fromProto(
- @NonNull ModifiersProto.Clickable proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Clickable fromProto(
+ ModifiersProto.@NonNull Clickable proto, @Nullable Fingerprint fingerprint) {
return new Clickable(proto, fingerprint);
}
- @NonNull
- static Clickable fromProto(@NonNull ModifiersProto.Clickable proto) {
+ static @NonNull Clickable fromProto(ModifiersProto.@NonNull Clickable proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.Clickable toProto() {
+ public ModifiersProto.@NonNull Clickable toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Clickable{"
+ "id="
+ getId()
@@ -433,8 +419,7 @@
/** Sets the ID associated with this action. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setId(@NonNull String id) {
+ public @NonNull Builder setId(@NonNull String id) {
mImpl.setId(id);
mFingerprint.recordPropertyUpdate(1, id.hashCode());
return this;
@@ -444,8 +429,7 @@
* Sets the action to perform when the element this modifier is attached to is clicked.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setOnClick(@NonNull Action onClick) {
+ public @NonNull Builder setOnClick(@NonNull Action onClick) {
mImpl.setOnClick(onClick.toActionProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(onClick.getFingerprint()).aggregateValueAsInt());
@@ -463,8 +447,8 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setMinimumClickableWidth(@NonNull DpProp minimumClickableWidth) {
+ public @NonNull Builder setMinimumClickableWidth(
+ @NonNull DpProp minimumClickableWidth) {
if (minimumClickableWidth.getDynamicValue() != null) {
throw new IllegalArgumentException(
"Clickable.Builder.setMinimumClickableWidth doesn't support dynamic"
@@ -488,8 +472,8 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setMinimumClickableHeight(@NonNull DpProp minimumClickableHeight) {
+ public @NonNull Builder setMinimumClickableHeight(
+ @NonNull DpProp minimumClickableHeight) {
if (minimumClickableHeight.getDynamicValue() != null) {
throw new IllegalArgumentException(
"Clickable.Builder.setMinimumClickableHeight doesn't support dynamic"
@@ -508,16 +492,14 @@
* to true.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setVisualFeedbackEnabled(boolean visualFeedbackEnabled) {
+ public @NonNull Builder setVisualFeedbackEnabled(boolean visualFeedbackEnabled) {
mImpl.setVisualFeedbackEnabled(visualFeedbackEnabled);
mFingerprint.recordPropertyUpdate(5, Boolean.hashCode(visualFeedbackEnabled));
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Clickable build() {
+ public @NonNull Clickable build() {
return new Clickable(mImpl.build(), mFingerprint);
}
}
@@ -531,7 +513,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class Semantics {
private final ModifiersProto.Semantics mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Semantics(ModifiersProto.Semantics impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -545,8 +527,7 @@
* <p>While this field is statically accessible from 1.0, it's only bindable since version
* 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
- @Nullable
- public StringProp getContentDescription() {
+ public @Nullable StringProp getContentDescription() {
if (mImpl.hasContentDescription()) {
return StringProp.fromProto(mImpl.getContentDescription());
} else {
@@ -569,8 +550,7 @@
*
* <p>This field is bindable and will use the dynamic value (if set).
*/
- @Nullable
- public StringProp getStateDescription() {
+ public @Nullable StringProp getStateDescription() {
if (mImpl.hasStateDescription()) {
return StringProp.fromProto(mImpl.getStateDescription());
} else {
@@ -580,34 +560,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Semantics fromProto(
- @NonNull ModifiersProto.Semantics proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Semantics fromProto(
+ ModifiersProto.@NonNull Semantics proto, @Nullable Fingerprint fingerprint) {
return new Semantics(proto, fingerprint);
}
- @NonNull
- static Semantics fromProto(@NonNull ModifiersProto.Semantics proto) {
+ static @NonNull Semantics fromProto(ModifiersProto.@NonNull Semantics proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.Semantics toProto() {
+ public ModifiersProto.@NonNull Semantics toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Semantics{"
+ "contentDescription="
+ getContentDescription()
@@ -632,8 +607,7 @@
* describe the element or do customizations.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setRole(@SemanticsRole int role) {
+ public @NonNull Builder setRole(@SemanticsRole int role) {
mImpl.setRole(ModifiersProto.SemanticsRole.forNumber(role));
mFingerprint.recordPropertyUpdate(2, role);
return this;
@@ -646,8 +620,7 @@
* <p>This field is bindable and will use the dynamic value (if set).
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setStateDescription(@NonNull StringProp stateDescription) {
+ public @NonNull Builder setStateDescription(@NonNull StringProp stateDescription) {
mImpl.setStateDescription(stateDescription.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(stateDescription.getFingerprint()).aggregateValueAsInt());
@@ -659,10 +632,9 @@
* the element is focused by the screen reader.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
@SuppressWarnings(
"deprecation") // Updating a deprecated field for backward compatibility
- public Builder setContentDescription(@NonNull String contentDescription) {
+ public @NonNull Builder setContentDescription(@NonNull String contentDescription) {
return setContentDescription(new StringProp.Builder(contentDescription).build());
}
@@ -674,10 +646,9 @@
* version 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
@SuppressWarnings(
"deprecation") // Updating a deprecated field for backward compatibility
- public Builder setContentDescription(@NonNull StringProp contentDescription) {
+ public @NonNull Builder setContentDescription(@NonNull StringProp contentDescription) {
mImpl.setObsoleteContentDescription(contentDescription.getValue());
mImpl.setContentDescription(contentDescription.toProto());
mFingerprint.recordPropertyUpdate(
@@ -686,8 +657,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Semantics build() {
+ public @NonNull Semantics build() {
return new Semantics(mImpl.build(), mFingerprint);
}
}
@@ -697,7 +667,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class Padding {
private final ModifiersProto.Padding mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Padding(ModifiersProto.Padding impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -708,8 +678,7 @@
* Gets the padding on the end of the content, depending on the layout direction, in DP and
* the value of "rtl_aware".
*/
- @Nullable
- public DpProp getEnd() {
+ public @Nullable DpProp getEnd() {
if (mImpl.hasEnd()) {
return DpProp.fromProto(mImpl.getEnd());
} else {
@@ -721,8 +690,7 @@
* Gets the padding on the start of the content, depending on the layout direction, in DP
* and the value of "rtl_aware".
*/
- @Nullable
- public DpProp getStart() {
+ public @Nullable DpProp getStart() {
if (mImpl.hasStart()) {
return DpProp.fromProto(mImpl.getStart());
} else {
@@ -731,8 +699,7 @@
}
/** Gets the padding at the top, in DP. */
- @Nullable
- public DpProp getTop() {
+ public @Nullable DpProp getTop() {
if (mImpl.hasTop()) {
return DpProp.fromProto(mImpl.getTop());
} else {
@@ -741,8 +708,7 @@
}
/** Gets the padding at the bottom, in DP. */
- @Nullable
- public DpProp getBottom() {
+ public @Nullable DpProp getBottom() {
if (mImpl.hasBottom()) {
return DpProp.fromProto(mImpl.getBottom());
} else {
@@ -756,8 +722,7 @@
* of the container if the device is using an RTL locale). If false, start/end will always
* map to left/right, accordingly.
*/
- @Nullable
- BoolProp isRtlAware() {
+ @Nullable BoolProp isRtlAware() {
if (mImpl.hasRtlAware()) {
return BoolProp.fromProto(mImpl.getRtlAware());
} else {
@@ -771,41 +736,35 @@
* of the container if the device is using an RTL locale). If false, start/end will always
* map to left/right, accordingly.
*/
- @Nullable
- public BoolProp getRtlAware() {
+ public @Nullable BoolProp getRtlAware() {
return isRtlAware();
}
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Padding fromProto(
- @NonNull ModifiersProto.Padding proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Padding fromProto(
+ ModifiersProto.@NonNull Padding proto, @Nullable Fingerprint fingerprint) {
return new Padding(proto, fingerprint);
}
- @NonNull
- static Padding fromProto(@NonNull ModifiersProto.Padding proto) {
+ static @NonNull Padding fromProto(ModifiersProto.@NonNull Padding proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.Padding toProto() {
+ public ModifiersProto.@NonNull Padding toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Padding{"
+ "end="
+ getEnd()
@@ -836,8 +795,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setEnd(@NonNull DpProp end) {
+ public @NonNull Builder setEnd(@NonNull DpProp end) {
if (end.getDynamicValue() != null) {
throw new IllegalArgumentException(
"Padding.Builder.setEnd doesn't support dynamic values.");
@@ -855,8 +813,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setStart(@NonNull DpProp start) {
+ public @NonNull Builder setStart(@NonNull DpProp start) {
if (start.getDynamicValue() != null) {
throw new IllegalArgumentException(
"Padding.Builder.setStart doesn't support dynamic values.");
@@ -873,8 +830,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setTop(@NonNull DpProp top) {
+ public @NonNull Builder setTop(@NonNull DpProp top) {
if (top.getDynamicValue() != null) {
throw new IllegalArgumentException(
"Padding.Builder.setTop doesn't support dynamic values.");
@@ -891,8 +847,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setBottom(@NonNull DpProp bottom) {
+ public @NonNull Builder setBottom(@NonNull DpProp bottom) {
if (bottom.getDynamicValue() != null) {
throw new IllegalArgumentException(
"Padding.Builder.setBottom doesn't support dynamic values.");
@@ -912,8 +867,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setRtlAware(@NonNull BoolProp rtlAware) {
+ public @NonNull Builder setRtlAware(@NonNull BoolProp rtlAware) {
if (rtlAware.getDynamicValue() != null) {
throw new IllegalArgumentException(
"Padding.Builder.setRtlAware doesn't support dynamic values.");
@@ -932,22 +886,19 @@
*/
@RequiresSchemaVersion(major = 1, minor = 0)
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setRtlAware(boolean rtlAware) {
+ public @NonNull Builder setRtlAware(boolean rtlAware) {
return setRtlAware(new BoolProp.Builder(rtlAware).build());
}
/** Sets the padding for all sides of the content, in DP. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
@SuppressLint("MissingGetterMatchingBuilder")
- public Builder setAll(@NonNull DpProp value) {
+ public @NonNull Builder setAll(@NonNull DpProp value) {
return setStart(value).setEnd(value).setTop(value).setBottom(value);
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Padding build() {
+ public @NonNull Padding build() {
return new Padding(mImpl.build(), mFingerprint);
}
}
@@ -957,7 +908,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class Border {
private final ModifiersProto.Border mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Border(ModifiersProto.Border impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -965,8 +916,7 @@
}
/** Gets the width of the border, in DP. */
- @Nullable
- public DpProp getWidth() {
+ public @Nullable DpProp getWidth() {
if (mImpl.hasWidth()) {
return DpProp.fromProto(mImpl.getWidth());
} else {
@@ -980,8 +930,7 @@
* <p>While this field is statically accessible from 1.0, it's only bindable since version
* 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
- @Nullable
- public ColorProp getColor() {
+ public @Nullable ColorProp getColor() {
if (mImpl.hasColor()) {
return ColorProp.fromProto(mImpl.getColor());
} else {
@@ -991,34 +940,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Border fromProto(
- @NonNull ModifiersProto.Border proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Border fromProto(
+ ModifiersProto.@NonNull Border proto, @Nullable Fingerprint fingerprint) {
return new Border(proto, fingerprint);
}
- @NonNull
- static Border fromProto(@NonNull ModifiersProto.Border proto) {
+ static @NonNull Border fromProto(ModifiersProto.@NonNull Border proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.Border toProto() {
+ public ModifiersProto.@NonNull Border toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Border{" + "width=" + getWidth() + ", color=" + getColor() + "}";
}
@@ -1036,8 +980,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setWidth(@NonNull DpProp width) {
+ public @NonNull Builder setWidth(@NonNull DpProp width) {
if (width.getDynamicValue() != null) {
throw new IllegalArgumentException(
"Border.Builder.setWidth doesn't support dynamic values.");
@@ -1055,8 +998,7 @@
* version 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setColor(@NonNull ColorProp color) {
+ public @NonNull Builder setColor(@NonNull ColorProp color) {
mImpl.setColor(color.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(color.getFingerprint()).aggregateValueAsInt());
@@ -1064,8 +1006,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Border build() {
+ public @NonNull Border build() {
return new Border(mImpl.build(), mFingerprint);
}
}
@@ -1075,8 +1016,7 @@
@RequiresSchemaVersion(major = 1, minor = 400)
public static final class CornerRadius {
private final ModifiersProto.CornerRadius mImpl;
- @Nullable
- private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
CornerRadius(ModifiersProto.CornerRadius impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -1084,14 +1024,12 @@
}
/** Gets the radius value in dp on the horizontal axis. */
- @NonNull
- public DpProp getX() {
+ public @NonNull DpProp getX() {
return DpProp.fromProto(mImpl.getX());
}
/** Gets the radius value in dp on the vertical axis. */
- @NonNull
- public DpProp getY() {
+ public @NonNull DpProp getY() {
return DpProp.fromProto(mImpl.getY());
}
@@ -1107,34 +1045,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static CornerRadius fromProto(
- @NonNull ModifiersProto.CornerRadius proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull CornerRadius fromProto(
+ ModifiersProto.@NonNull CornerRadius proto, @Nullable Fingerprint fingerprint) {
return new CornerRadius(proto, fingerprint);
}
- @NonNull
- static CornerRadius fromProto(@NonNull ModifiersProto.CornerRadius proto) {
+ static @NonNull CornerRadius fromProto(ModifiersProto.@NonNull CornerRadius proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.CornerRadius toProto() {
+ public ModifiersProto.@NonNull CornerRadius toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "CornerRadius{" + "x=" + getX() + ", y=" + getY() + "}";
}
@@ -1167,8 +1100,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- Builder setX(@NonNull DpProp x) {
+ @NonNull Builder setX(@NonNull DpProp x) {
if (x.getDynamicValue() != null) {
throw new IllegalArgumentException(
"CornerRadius.Builder.setX doesn't support dynamic values.");
@@ -1185,8 +1117,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- Builder setY(@NonNull DpProp y) {
+ @NonNull Builder setY(@NonNull DpProp y) {
if (y.getDynamicValue() != null) {
throw new IllegalArgumentException(
"CornerRadius.Builder.setY doesn't support dynamic values.");
@@ -1198,8 +1129,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public CornerRadius build() {
+ public @NonNull CornerRadius build() {
return new CornerRadius(mImpl.build(), mFingerprint);
}
}
@@ -1209,7 +1139,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class Corner {
private final ModifiersProto.Corner mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Corner(ModifiersProto.Corner impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -1217,8 +1147,7 @@
}
/** Gets the radius of the corner in DP. */
- @Nullable
- public DpProp getRadius() {
+ public @Nullable DpProp getRadius() {
if (mImpl.hasRadius()) {
return DpProp.fromProto(mImpl.getRadius());
} else {
@@ -1227,8 +1156,7 @@
}
/** Gets the radius for the top-left corner of either circular or elliptical shapes. */
- @NonNull
- public CornerRadius getTopLeftRadius() {
+ public @NonNull CornerRadius getTopLeftRadius() {
if (mImpl.hasTopLeftRadius()) {
return CornerRadius.fromProto(mImpl.getTopLeftRadius());
} else {
@@ -1237,8 +1165,7 @@
}
/** Gets the radius for the top-right corner of either circular or elliptical shapes. */
- @NonNull
- public CornerRadius getTopRightRadius() {
+ public @NonNull CornerRadius getTopRightRadius() {
if (mImpl.hasTopRightRadius()) {
return CornerRadius.fromProto(mImpl.getTopRightRadius());
} else {
@@ -1247,8 +1174,7 @@
}
/** Gets the radius for the bottom-right corner of either circular or elliptical shapes. */
- @NonNull
- public CornerRadius getBottomRightRadius() {
+ public @NonNull CornerRadius getBottomRightRadius() {
if (mImpl.hasBottomRightRadius()) {
return CornerRadius.fromProto(mImpl.getBottomRightRadius());
} else {
@@ -1257,8 +1183,7 @@
}
/** Gets the radius for the bottom-left corner of either circular or elliptical shapes. */
- @NonNull
- public CornerRadius getBottomLeftRadius() {
+ public @NonNull CornerRadius getBottomLeftRadius() {
if (mImpl.hasBottomLeftRadius()) {
return CornerRadius.fromProto(mImpl.getBottomLeftRadius());
} else {
@@ -1267,8 +1192,7 @@
}
@SuppressLint("ProtoLayoutMinSchema")
- @NonNull
- private CornerRadius toCornerRadius(@Nullable DpProp radius) {
+ private @NonNull CornerRadius toCornerRadius(@Nullable DpProp radius) {
return radius == null
? CornerRadius.ZERO
: new CornerRadius.Builder(
@@ -1279,34 +1203,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Corner fromProto(
- @NonNull ModifiersProto.Corner proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Corner fromProto(
+ ModifiersProto.@NonNull Corner proto, @Nullable Fingerprint fingerprint) {
return new Corner(proto, fingerprint);
}
- @NonNull
- static Corner fromProto(@NonNull ModifiersProto.Corner proto) {
+ static @NonNull Corner fromProto(ModifiersProto.@NonNull Corner proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.Corner toProto() {
+ public ModifiersProto.@NonNull Corner toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Corner{"
+ "radius="
+ getRadius()
@@ -1338,8 +1257,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setRadius(@NonNull DpProp radius) {
+ public @NonNull Builder setRadius(@NonNull DpProp radius) {
if (radius.getDynamicValue() != null) {
throw new IllegalArgumentException(
"Corner.Builder.setRadius doesn't support dynamic values.");
@@ -1356,8 +1274,7 @@
* or defaults to zeros when radius is also not set.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setTopLeftRadius(@NonNull CornerRadius topLeftRadius) {
+ public @NonNull Builder setTopLeftRadius(@NonNull CornerRadius topLeftRadius) {
mImpl.setTopLeftRadius(topLeftRadius.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(topLeftRadius.getFingerprint()).aggregateValueAsInt());
@@ -1370,8 +1287,7 @@
* or defaults to zeros when radius is also not set.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setTopRightRadius(@NonNull CornerRadius topRightRadius) {
+ public @NonNull Builder setTopRightRadius(@NonNull CornerRadius topRightRadius) {
mImpl.setTopRightRadius(topRightRadius.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(topRightRadius.getFingerprint()).aggregateValueAsInt());
@@ -1384,8 +1300,7 @@
* set; or defaults to zeros when radius is also not set.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setBottomRightRadius(@NonNull CornerRadius bottomRightRadius) {
+ public @NonNull Builder setBottomRightRadius(@NonNull CornerRadius bottomRightRadius) {
mImpl.setBottomRightRadius(bottomRightRadius.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(bottomRightRadius.getFingerprint()).aggregateValueAsInt());
@@ -1398,8 +1313,7 @@
* set; or defaults to zeros when radius is also not set.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setBottomLeftRadius(@NonNull CornerRadius bottomLeftRadius) {
+ public @NonNull Builder setBottomLeftRadius(@NonNull CornerRadius bottomLeftRadius) {
mImpl.setBottomLeftRadius(bottomLeftRadius.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(bottomLeftRadius.getFingerprint()).aggregateValueAsInt());
@@ -1412,8 +1326,8 @@
* or defaults to zeros when radius is also not set.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setTopLeftRadius(@NonNull DpProp xRadius, @NonNull DpProp yRadius) {
+ public @NonNull Builder setTopLeftRadius(@NonNull DpProp xRadius,
+ @NonNull DpProp yRadius) {
return setTopLeftRadius(new CornerRadius.Builder(xRadius, yRadius).build());
}
@@ -1423,8 +1337,8 @@
* or defaults to zeros when radius is also not set.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setTopRightRadius(@NonNull DpProp xRadius, @NonNull DpProp yRadius) {
+ public @NonNull Builder setTopRightRadius(@NonNull DpProp xRadius,
+ @NonNull DpProp yRadius) {
return setTopRightRadius(new CornerRadius.Builder(xRadius, yRadius).build());
}
@@ -1434,8 +1348,8 @@
* set; or defaults to zeros when radius is also not set.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setBottomRightRadius(@NonNull DpProp xRadius, @NonNull DpProp yRadius) {
+ public @NonNull Builder setBottomRightRadius(@NonNull DpProp xRadius,
+ @NonNull DpProp yRadius) {
return setBottomRightRadius(new CornerRadius.Builder(xRadius, yRadius).build());
}
@@ -1445,14 +1359,13 @@
* set; or defaults to zeros when radius is also not set.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setBottomLeftRadius(@NonNull DpProp xRadius, @NonNull DpProp yRadius) {
+ public @NonNull Builder setBottomLeftRadius(@NonNull DpProp xRadius,
+ @NonNull DpProp yRadius) {
return setBottomLeftRadius(new CornerRadius.Builder(xRadius, yRadius).build());
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Corner build() {
+ public @NonNull Corner build() {
return new Corner(mImpl.build(), mFingerprint);
}
}
@@ -1462,7 +1375,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class Background {
private final ModifiersProto.Background mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Background(ModifiersProto.Background impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -1476,8 +1389,7 @@
* <p>While this field is statically accessible from 1.0, it's only bindable since version
* 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
- @Nullable
- public ColorProp getColor() {
+ public @Nullable ColorProp getColor() {
if (mImpl.hasColor()) {
return ColorProp.fromProto(mImpl.getColor());
} else {
@@ -1490,8 +1402,7 @@
* if it has a background color or border. If not defined, defaults to having a square
* corner.
*/
- @Nullable
- public Corner getCorner() {
+ public @Nullable Corner getCorner() {
if (mImpl.hasCorner()) {
return Corner.fromProto(mImpl.getCorner());
} else {
@@ -1501,34 +1412,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Background fromProto(
- @NonNull ModifiersProto.Background proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Background fromProto(
+ ModifiersProto.@NonNull Background proto, @Nullable Fingerprint fingerprint) {
return new Background(proto, fingerprint);
}
- @NonNull
- static Background fromProto(@NonNull ModifiersProto.Background proto) {
+ static @NonNull Background fromProto(ModifiersProto.@NonNull Background proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.Background toProto() {
+ public ModifiersProto.@NonNull Background toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Background{" + "color=" + getColor() + ", corner=" + getCorner() + "}";
}
@@ -1549,8 +1455,7 @@
* version 1.2 and renderers supporting version 1.2 will use the dynamic value (if set).
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setColor(@NonNull ColorProp color) {
+ public @NonNull Builder setColor(@NonNull ColorProp color) {
mImpl.setColor(color.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(color.getFingerprint()).aggregateValueAsInt());
@@ -1563,8 +1468,7 @@
* square corner.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setCorner(@NonNull Corner corner) {
+ public @NonNull Builder setCorner(@NonNull Corner corner) {
mImpl.setCorner(corner.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(corner.getFingerprint()).aggregateValueAsInt());
@@ -1572,8 +1476,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Background build() {
+ public @NonNull Background build() {
return new Background(mImpl.build(), mFingerprint);
}
}
@@ -1586,7 +1489,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class ElementMetadata {
private final ModifiersProto.ElementMetadata mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ElementMetadata(ModifiersProto.ElementMetadata impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -1597,41 +1500,35 @@
* Gets property describing the element with which it is associated. For use by libraries
* building higher-level components only. This can be used to track component metadata.
*/
- @NonNull
- public byte[] getTagData() {
+ public byte @NonNull [] getTagData() {
return mImpl.getTagData().toByteArray();
}
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ElementMetadata fromProto(
- @NonNull ModifiersProto.ElementMetadata proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ElementMetadata fromProto(
+ ModifiersProto.@NonNull ElementMetadata proto, @Nullable Fingerprint fingerprint) {
return new ElementMetadata(proto, fingerprint);
}
- @NonNull
- static ElementMetadata fromProto(@NonNull ModifiersProto.ElementMetadata proto) {
+ static @NonNull ElementMetadata fromProto(ModifiersProto.@NonNull ElementMetadata proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.ElementMetadata toProto() {
+ public ModifiersProto.@NonNull ElementMetadata toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ElementMetadata{" + "tagData=" + Arrays.toString(getTagData()) + "}";
}
@@ -1650,16 +1547,14 @@
* metadata.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setTagData(@NonNull byte[] tagData) {
+ public @NonNull Builder setTagData(byte @NonNull [] tagData) {
mImpl.setTagData(ByteString.copyFrom(tagData));
mFingerprint.recordPropertyUpdate(1, Arrays.hashCode(tagData));
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public ElementMetadata build() {
+ public @NonNull ElementMetadata build() {
return new ElementMetadata(mImpl.build(), mFingerprint);
}
}
@@ -1672,7 +1567,7 @@
@RequiresSchemaVersion(major = 1, minor = 400)
public static final class Transformation {
private final ModifiersProto.Transformation mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Transformation(ModifiersProto.Transformation impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -1683,8 +1578,7 @@
* Gets the horizontal offset of this element relative to the location where the element's
* layout placed it.
*/
- @NonNull
- public DpProp getTranslationX() {
+ public @NonNull DpProp getTranslationX() {
if (mImpl.hasTranslationX()) {
return DpProp.fromProto(mImpl.getTranslationX());
} else {
@@ -1696,8 +1590,7 @@
* Gets the vertical offset of this element in addition to the location where the element's
* layout placed it.
*/
- @NonNull
- public DpProp getTranslationY() {
+ public @NonNull DpProp getTranslationY() {
if (mImpl.hasTranslationY()) {
return DpProp.fromProto(mImpl.getTranslationY());
} else {
@@ -1709,8 +1602,7 @@
* Gets the scale of this element in the x direction around the pivot point, as a proportion
* of the element's unscaled width.
*/
- @NonNull
- public FloatProp getScaleX() {
+ public @NonNull FloatProp getScaleX() {
if (mImpl.hasScaleX()) {
return FloatProp.fromProto(mImpl.getScaleX());
} else {
@@ -1722,8 +1614,7 @@
* Gets the scale of this element in the y direction around the pivot point, as a proportion
* of the element's unscaled height.
*/
- @NonNull
- public FloatProp getScaleY() {
+ public @NonNull FloatProp getScaleY() {
if (mImpl.hasScaleY()) {
return FloatProp.fromProto(mImpl.getScaleY());
} else {
@@ -1732,8 +1623,7 @@
}
/** Gets the clockwise Degrees that the element is rotated around the pivot point. */
- @NonNull
- public DegreesProp getRotation() {
+ public @NonNull DegreesProp getRotation() {
if (mImpl.hasRotation()) {
return DegreesProp.fromProto(mImpl.getRotation());
} else {
@@ -1746,8 +1636,7 @@
* With type {@link DpProp}, it is the offset from the element center; otherwise with type
* {@link BoundingBoxRatio}, it is the location proportional to the bounding box width.
*/
- @NonNull
- public PivotDimension getPivotX() {
+ public @NonNull PivotDimension getPivotX() {
if (mImpl.hasPivotX()) {
return DimensionBuilders.pivotDimensionFromProto(mImpl.getPivotX());
} else {
@@ -1760,8 +1649,7 @@
* With type {@link DpProp}, it is the offset from the element center; otherwise with type
* {@link BoundingBoxRatio}, it is the location proportional to the bounding box height.
*/
- @NonNull
- public PivotDimension getPivotY() {
+ public @NonNull PivotDimension getPivotY() {
if (mImpl.hasPivotY()) {
return DimensionBuilders.pivotDimensionFromProto(mImpl.getPivotY());
} else {
@@ -1771,34 +1659,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Transformation fromProto(
- @NonNull ModifiersProto.Transformation proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Transformation fromProto(
+ ModifiersProto.@NonNull Transformation proto, @Nullable Fingerprint fingerprint) {
return new Transformation(proto, fingerprint);
}
- @NonNull
- static Transformation fromProto(@NonNull ModifiersProto.Transformation proto) {
+ static @NonNull Transformation fromProto(ModifiersProto.@NonNull Transformation proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.Transformation toProto() {
+ public ModifiersProto.@NonNull Transformation toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Transformation{"
+ "translationX="
+ getTranslationX()
@@ -1831,8 +1714,7 @@
* element's layout placed it. If not set, defaults to zero.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setTranslationX(@NonNull DpProp translationX) {
+ public @NonNull Builder setTranslationX(@NonNull DpProp translationX) {
mImpl.setTranslationX(translationX.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(translationX.getFingerprint()).aggregateValueAsInt());
@@ -1844,8 +1726,7 @@
* element's layout placed it. If not set, defaults to zero.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setTranslationY(@NonNull DpProp translationY) {
+ public @NonNull Builder setTranslationY(@NonNull DpProp translationY) {
mImpl.setTranslationY(translationY.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(translationY.getFingerprint()).aggregateValueAsInt());
@@ -1857,8 +1738,7 @@
* proportion of the element's unscaled width. If not set, defaults to one.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setScaleX(@NonNull FloatProp scaleX) {
+ public @NonNull Builder setScaleX(@NonNull FloatProp scaleX) {
mImpl.setScaleX(scaleX.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(scaleX.getFingerprint()).aggregateValueAsInt());
@@ -1870,8 +1750,7 @@
* proportion of the element's unscaled height. If not set, defaults to one.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setScaleY(@NonNull FloatProp scaleY) {
+ public @NonNull Builder setScaleY(@NonNull FloatProp scaleY) {
mImpl.setScaleY(scaleY.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(scaleY.getFingerprint()).aggregateValueAsInt());
@@ -1883,8 +1762,7 @@
* set, defaults to zero.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setRotation(@NonNull DegreesProp rotation) {
+ public @NonNull Builder setRotation(@NonNull DegreesProp rotation) {
mImpl.setRotation(rotation.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(rotation.getFingerprint()).aggregateValueAsInt());
@@ -1898,8 +1776,7 @@
* box width. Dynamic value is supported. If not set, defaults to the element center.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setPivotX(@NonNull PivotDimension pivotX) {
+ public @NonNull Builder setPivotX(@NonNull PivotDimension pivotX) {
mImpl.setPivotX(pivotX.toPivotDimensionProto());
mFingerprint.recordPropertyUpdate(
6, checkNotNull(pivotX.getFingerprint()).aggregateValueAsInt());
@@ -1913,8 +1790,7 @@
* box height. Dynamic value is supported. If not set, defaults to the element center.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setPivotY(@NonNull PivotDimension pivotY) {
+ public @NonNull Builder setPivotY(@NonNull PivotDimension pivotY) {
mImpl.setPivotY(pivotY.toPivotDimensionProto());
mFingerprint.recordPropertyUpdate(
7, checkNotNull(pivotY.getFingerprint()).aggregateValueAsInt());
@@ -1922,8 +1798,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Transformation build() {
+ public @NonNull Transformation build() {
return new Transformation(mImpl.build(), mFingerprint);
}
}
@@ -1937,7 +1812,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class Modifiers {
private final ModifiersProto.Modifiers mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Modifiers(ModifiersProto.Modifiers impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -1948,8 +1823,7 @@
* Gets the clickable property of the modified element. It allows its wrapped element to
* have actions associated with it, which will be executed when the element is tapped.
*/
- @Nullable
- public Clickable getClickable() {
+ public @Nullable Clickable getClickable() {
if (mImpl.hasClickable()) {
return Clickable.fromProto(mImpl.getClickable());
} else {
@@ -1961,8 +1835,7 @@
* Gets the semantics of the modified element. This can be used to add metadata to the
* modified element (eg. screen reader content descriptions).
*/
- @Nullable
- public Semantics getSemantics() {
+ public @Nullable Semantics getSemantics() {
if (mImpl.hasSemantics()) {
return Semantics.fromProto(mImpl.getSemantics());
} else {
@@ -1971,8 +1844,7 @@
}
/** Gets the padding of the modified element. */
- @Nullable
- public Padding getPadding() {
+ public @Nullable Padding getPadding() {
if (mImpl.hasPadding()) {
return Padding.fromProto(mImpl.getPadding());
} else {
@@ -1981,8 +1853,7 @@
}
/** Gets the border of the modified element. */
- @Nullable
- public Border getBorder() {
+ public @Nullable Border getBorder() {
if (mImpl.hasBorder()) {
return Border.fromProto(mImpl.getBorder());
} else {
@@ -1991,8 +1862,7 @@
}
/** Gets the background (with optional corner radius) of the modified element. */
- @Nullable
- public Background getBackground() {
+ public @Nullable Background getBackground() {
if (mImpl.hasBackground()) {
return Background.fromProto(mImpl.getBackground());
} else {
@@ -2004,8 +1874,7 @@
* Gets metadata about an element. For use by libraries building higher-level components
* only. This can be used to track component metadata.
*/
- @Nullable
- public ElementMetadata getMetadata() {
+ public @Nullable ElementMetadata getMetadata() {
if (mImpl.hasMetadata()) {
return ElementMetadata.fromProto(mImpl.getMetadata());
} else {
@@ -2018,8 +1887,7 @@
* trigger this animation for this element and everything underneath it.
*/
@ProtoLayoutExperimental
- @Nullable
- public AnimatedVisibility getContentUpdateAnimation() {
+ public @Nullable AnimatedVisibility getContentUpdateAnimation() {
if (mImpl.hasContentUpdateAnimation()) {
return AnimatedVisibility.fromProto(mImpl.getContentUpdateAnimation());
} else {
@@ -2033,8 +1901,7 @@
* children render any contents. Defaults to visible.
*/
@ProtoLayoutExperimental
- @NonNull
- public BoolProp isVisible() {
+ public @NonNull BoolProp isVisible() {
if (mImpl.hasVisible()) {
return BoolProp.fromProto(mImpl.getVisible());
} else {
@@ -2043,8 +1910,7 @@
}
/** Gets the transformation applied to the element post-layout. */
- @Nullable
- public Transformation getTransformation() {
+ public @Nullable Transformation getTransformation() {
if (mImpl.hasTransformation()) {
return Transformation.fromProto(mImpl.getTransformation());
} else {
@@ -2056,8 +1922,7 @@
* Gets the opacity of the element with a value from 0 to 1, where 0 means the view is the
* element is completely transparent and 1 means the element is completely opaque.
*/
- @Nullable
- public FloatProp getOpacity() {
+ public @Nullable FloatProp getOpacity() {
if (mImpl.hasOpacity()) {
return FloatProp.fromProto(mImpl.getOpacity());
} else {
@@ -2067,16 +1932,14 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Modifiers fromProto(
- @NonNull ModifiersProto.Modifiers proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Modifiers fromProto(
+ ModifiersProto.@NonNull Modifiers proto, @Nullable Fingerprint fingerprint) {
return new Modifiers(proto, fingerprint);
}
@@ -2085,22 +1948,19 @@
* object created using this method can't be added to any other wrapper.
*/
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Modifiers fromProto(@NonNull ModifiersProto.Modifiers proto) {
+ public static @NonNull Modifiers fromProto(ModifiersProto.@NonNull Modifiers proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.Modifiers toProto() {
+ public ModifiersProto.@NonNull Modifiers toProto() {
return mImpl;
}
@Override
@OptIn(markerClass = ProtoLayoutExperimental.class)
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Modifiers{"
+ "clickable="
+ getClickable()
@@ -2139,8 +1999,7 @@
* have actions associated with it, which will be executed when the element is tapped.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setClickable(@NonNull Clickable clickable) {
+ public @NonNull Builder setClickable(@NonNull Clickable clickable) {
mImpl.setClickable(clickable.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(clickable.getFingerprint()).aggregateValueAsInt());
@@ -2152,8 +2011,7 @@
* modified element (eg. screen reader content descriptions).
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setSemantics(@NonNull Semantics semantics) {
+ public @NonNull Builder setSemantics(@NonNull Semantics semantics) {
mImpl.setSemantics(semantics.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(semantics.getFingerprint()).aggregateValueAsInt());
@@ -2162,8 +2020,7 @@
/** Sets the padding of the modified element. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setPadding(@NonNull Padding padding) {
+ public @NonNull Builder setPadding(@NonNull Padding padding) {
mImpl.setPadding(padding.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(padding.getFingerprint()).aggregateValueAsInt());
@@ -2172,8 +2029,7 @@
/** Sets the border of the modified element. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setBorder(@NonNull Border border) {
+ public @NonNull Builder setBorder(@NonNull Border border) {
mImpl.setBorder(border.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(border.getFingerprint()).aggregateValueAsInt());
@@ -2182,8 +2038,7 @@
/** Sets the background (with optional corner radius) of the modified element. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setBackground(@NonNull Background background) {
+ public @NonNull Builder setBackground(@NonNull Background background) {
mImpl.setBackground(background.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(background.getFingerprint()).aggregateValueAsInt());
@@ -2195,8 +2050,7 @@
* only. This can be used to track component metadata.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setMetadata(@NonNull ElementMetadata metadata) {
+ public @NonNull Builder setMetadata(@NonNull ElementMetadata metadata) {
mImpl.setMetadata(metadata.toProto());
mFingerprint.recordPropertyUpdate(
6, checkNotNull(metadata.getFingerprint()).aggregateValueAsInt());
@@ -2209,8 +2063,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@ProtoLayoutExperimental
- @NonNull
- public Builder setContentUpdateAnimation(
+ public @NonNull Builder setContentUpdateAnimation(
@NonNull AnimatedVisibility contentUpdateAnimation) {
mImpl.setContentUpdateAnimation(contentUpdateAnimation.toProto());
mFingerprint.recordPropertyUpdate(
@@ -2233,8 +2086,7 @@
@RequiresSchemaVersion(major = 1, minor = 300)
@ProtoLayoutExperimental
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setVisible(@NonNull BoolProp visible) {
+ public @NonNull Builder setVisible(@NonNull BoolProp visible) {
mImpl.setVisible(visible.toProto());
mFingerprint.recordPropertyUpdate(
10, checkNotNull(visible.getFingerprint()).aggregateValueAsInt());
@@ -2243,8 +2095,7 @@
/** Sets the transformation applied to the element post-layout. */
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setTransformation(@NonNull Transformation transformation) {
+ public @NonNull Builder setTransformation(@NonNull Transformation transformation) {
mImpl.setTransformation(transformation.toProto());
mFingerprint.recordPropertyUpdate(
11, checkNotNull(transformation.getFingerprint()).aggregateValueAsInt());
@@ -2257,8 +2108,7 @@
* is supported.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setOpacity(@NonNull FloatProp opacity) {
+ public @NonNull Builder setOpacity(@NonNull FloatProp opacity) {
mImpl.setOpacity(opacity.toProto());
mFingerprint.recordPropertyUpdate(
12, checkNotNull(opacity.getFingerprint()).aggregateValueAsInt());
@@ -2266,8 +2116,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Modifiers build() {
+ public @NonNull Modifiers build() {
return new Modifiers(mImpl.build(), mFingerprint);
}
}
@@ -2281,7 +2130,7 @@
@ProtoLayoutExperimental
public static final class AnimatedVisibility {
private final ModifiersProto.AnimatedVisibility mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AnimatedVisibility(
ModifiersProto.AnimatedVisibility impl, @Nullable Fingerprint fingerprint) {
@@ -2290,8 +2139,7 @@
}
/** Gets the content transition that is triggered when element enters the layout. */
- @Nullable
- public EnterTransition getEnterTransition() {
+ public @Nullable EnterTransition getEnterTransition() {
if (mImpl.hasEnterTransition()) {
return EnterTransition.fromProto(mImpl.getEnterTransition());
} else {
@@ -2303,8 +2151,7 @@
* Gets the content transition that is triggered when element exits the layout. Note that
* indefinite exit animations are ignored.
*/
- @Nullable
- public ExitTransition getExitTransition() {
+ public @Nullable ExitTransition getExitTransition() {
if (mImpl.hasExitTransition()) {
return ExitTransition.fromProto(mImpl.getExitTransition());
} else {
@@ -2314,35 +2161,31 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AnimatedVisibility fromProto(
- @NonNull ModifiersProto.AnimatedVisibility proto,
+ public static @NonNull AnimatedVisibility fromProto(
+ ModifiersProto.@NonNull AnimatedVisibility proto,
@Nullable Fingerprint fingerprint) {
return new AnimatedVisibility(proto, fingerprint);
}
- @NonNull
- static AnimatedVisibility fromProto(@NonNull ModifiersProto.AnimatedVisibility proto) {
+ static @NonNull AnimatedVisibility fromProto(
+ ModifiersProto.@NonNull AnimatedVisibility proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.AnimatedVisibility toProto() {
+ public ModifiersProto.@NonNull AnimatedVisibility toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AnimatedVisibility{"
+ "enterTransition="
+ getEnterTransition()
@@ -2362,8 +2205,7 @@
/** Sets the content transition that is triggered when element enters the layout. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setEnterTransition(@NonNull EnterTransition enterTransition) {
+ public @NonNull Builder setEnterTransition(@NonNull EnterTransition enterTransition) {
mImpl.setEnterTransition(enterTransition.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(enterTransition.getFingerprint()).aggregateValueAsInt());
@@ -2375,8 +2217,7 @@
* that indefinite exit animations are ignored.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setExitTransition(@NonNull ExitTransition exitTransition) {
+ public @NonNull Builder setExitTransition(@NonNull ExitTransition exitTransition) {
mImpl.setExitTransition(exitTransition.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(exitTransition.getFingerprint()).aggregateValueAsInt());
@@ -2384,8 +2225,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public AnimatedVisibility build() {
+ public @NonNull AnimatedVisibility build() {
return new AnimatedVisibility(mImpl.build(), mFingerprint);
}
}
@@ -2396,7 +2236,7 @@
@ProtoLayoutExperimental
public static final class EnterTransition {
private final ModifiersProto.EnterTransition mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
EnterTransition(ModifiersProto.EnterTransition impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -2407,8 +2247,7 @@
* Gets the fading in animation for content transition of an element and its children
* happening when entering the layout.
*/
- @Nullable
- public FadeInTransition getFadeIn() {
+ public @Nullable FadeInTransition getFadeIn() {
if (mImpl.hasFadeIn()) {
return FadeInTransition.fromProto(mImpl.getFadeIn());
} else {
@@ -2420,8 +2259,7 @@
* Gets the sliding in animation for content transition of an element and its children
* happening when entering the layout.
*/
- @Nullable
- public SlideInTransition getSlideIn() {
+ public @Nullable SlideInTransition getSlideIn() {
if (mImpl.hasSlideIn()) {
return SlideInTransition.fromProto(mImpl.getSlideIn());
} else {
@@ -2431,34 +2269,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static EnterTransition fromProto(
- @NonNull ModifiersProto.EnterTransition proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull EnterTransition fromProto(
+ ModifiersProto.@NonNull EnterTransition proto, @Nullable Fingerprint fingerprint) {
return new EnterTransition(proto, fingerprint);
}
- @NonNull
- static EnterTransition fromProto(@NonNull ModifiersProto.EnterTransition proto) {
+ static @NonNull EnterTransition fromProto(ModifiersProto.@NonNull EnterTransition proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.EnterTransition toProto() {
+ public ModifiersProto.@NonNull EnterTransition toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "EnterTransition{" + "fadeIn=" + getFadeIn() + ", slideIn=" + getSlideIn() + "}";
}
@@ -2476,8 +2309,7 @@
* happening when entering the layout.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setFadeIn(@NonNull FadeInTransition fadeIn) {
+ public @NonNull Builder setFadeIn(@NonNull FadeInTransition fadeIn) {
mImpl.setFadeIn(fadeIn.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(fadeIn.getFingerprint()).aggregateValueAsInt());
@@ -2489,8 +2321,7 @@
* happening when entering the layout.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setSlideIn(@NonNull SlideInTransition slideIn) {
+ public @NonNull Builder setSlideIn(@NonNull SlideInTransition slideIn) {
mImpl.setSlideIn(slideIn.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(slideIn.getFingerprint()).aggregateValueAsInt());
@@ -2498,8 +2329,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public EnterTransition build() {
+ public @NonNull EnterTransition build() {
return new EnterTransition(mImpl.build(), mFingerprint);
}
}
@@ -2513,7 +2343,7 @@
@ProtoLayoutExperimental
public static final class FadeInTransition {
private final ModifiersProto.FadeInTransition mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FadeInTransition(ModifiersProto.FadeInTransition impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -2530,8 +2360,7 @@
}
/** Gets the animation parameters for duration, delay, etc. */
- @Nullable
- public AnimationSpec getAnimationSpec() {
+ public @Nullable AnimationSpec getAnimationSpec() {
if (mImpl.hasAnimationSpec()) {
return AnimationSpec.fromProto(mImpl.getAnimationSpec());
} else {
@@ -2541,34 +2370,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static FadeInTransition fromProto(
- @NonNull ModifiersProto.FadeInTransition proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull FadeInTransition fromProto(
+ ModifiersProto.@NonNull FadeInTransition proto, @Nullable Fingerprint fingerprint) {
return new FadeInTransition(proto, fingerprint);
}
- @NonNull
- static FadeInTransition fromProto(@NonNull ModifiersProto.FadeInTransition proto) {
+ static @NonNull FadeInTransition fromProto(ModifiersProto.@NonNull FadeInTransition proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.FadeInTransition toProto() {
+ public ModifiersProto.@NonNull FadeInTransition toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "FadeInTransition{"
+ "initialAlpha="
+ getInitialAlpha()
@@ -2591,8 +2415,8 @@
* not set, defaults to fully transparent, i.e. 0.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInitialAlpha(@FloatRange(from = 0.0, to = 1.0) float initialAlpha) {
+ public @NonNull Builder setInitialAlpha(
+ @FloatRange(from = 0.0, to = 1.0) float initialAlpha) {
mImpl.setInitialAlpha(initialAlpha);
mFingerprint.recordPropertyUpdate(1, Float.floatToIntBits(initialAlpha));
return this;
@@ -2600,8 +2424,7 @@
/** Sets the animation parameters for duration, delay, etc. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
+ public @NonNull Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
mImpl.setAnimationSpec(animationSpec.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(animationSpec.getFingerprint()).aggregateValueAsInt());
@@ -2609,8 +2432,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public FadeInTransition build() {
+ public @NonNull FadeInTransition build() {
return new FadeInTransition(mImpl.build(), mFingerprint);
}
}
@@ -2621,7 +2443,7 @@
@ProtoLayoutExperimental
public static final class SlideInTransition {
private final ModifiersProto.SlideInTransition mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
SlideInTransition(
ModifiersProto.SlideInTransition impl, @Nullable Fingerprint fingerprint) {
@@ -2645,8 +2467,7 @@
* Note that sliding from the screen boundaries can only be achieved if all parent's sizes
* are big enough to accommodate it.
*/
- @Nullable
- public SlideBound getInitialSlideBound() {
+ public @Nullable SlideBound getInitialSlideBound() {
if (mImpl.hasInitialSlideBound()) {
return ModifiersBuilders.slideBoundFromProto(mImpl.getInitialSlideBound());
} else {
@@ -2655,8 +2476,7 @@
}
/** Gets the animation parameters for duration, delay, etc. */
- @Nullable
- public AnimationSpec getAnimationSpec() {
+ public @Nullable AnimationSpec getAnimationSpec() {
if (mImpl.hasAnimationSpec()) {
return AnimationSpec.fromProto(mImpl.getAnimationSpec());
} else {
@@ -2666,35 +2486,31 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static SlideInTransition fromProto(
- @NonNull ModifiersProto.SlideInTransition proto,
+ public static @NonNull SlideInTransition fromProto(
+ ModifiersProto.@NonNull SlideInTransition proto,
@Nullable Fingerprint fingerprint) {
return new SlideInTransition(proto, fingerprint);
}
- @NonNull
- static SlideInTransition fromProto(@NonNull ModifiersProto.SlideInTransition proto) {
+ static @NonNull SlideInTransition fromProto(
+ ModifiersProto.@NonNull SlideInTransition proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.SlideInTransition toProto() {
+ public ModifiersProto.@NonNull SlideInTransition toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "SlideInTransition{"
+ "direction="
+ getDirection()
@@ -2720,8 +2536,7 @@
* to the right.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setDirection(@SlideDirection int direction) {
+ public @NonNull Builder setDirection(@SlideDirection int direction) {
mImpl.setDirection(ModifiersProto.SlideDirection.forNumber(direction));
mFingerprint.recordPropertyUpdate(1, direction);
return this;
@@ -2734,8 +2549,7 @@
* sizes are big enough to accommodate it.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setInitialSlideBound(@NonNull SlideBound initialSlideBound) {
+ public @NonNull Builder setInitialSlideBound(@NonNull SlideBound initialSlideBound) {
mImpl.setInitialSlideBound(initialSlideBound.toSlideBoundProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(initialSlideBound.getFingerprint()).aggregateValueAsInt());
@@ -2744,8 +2558,7 @@
/** Sets the animation parameters for duration, delay, etc. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
+ public @NonNull Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
mImpl.setAnimationSpec(animationSpec.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(animationSpec.getFingerprint()).aggregateValueAsInt());
@@ -2753,8 +2566,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public SlideInTransition build() {
+ public @NonNull SlideInTransition build() {
return new SlideInTransition(mImpl.build(), mFingerprint);
}
}
@@ -2765,7 +2577,7 @@
@ProtoLayoutExperimental
public static final class ExitTransition {
private final ModifiersProto.ExitTransition mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ExitTransition(ModifiersProto.ExitTransition impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -2776,8 +2588,7 @@
* Gets the fading out animation for content transition of an element and its children
* happening when exiting the layout.
*/
- @Nullable
- public FadeOutTransition getFadeOut() {
+ public @Nullable FadeOutTransition getFadeOut() {
if (mImpl.hasFadeOut()) {
return FadeOutTransition.fromProto(mImpl.getFadeOut());
} else {
@@ -2789,8 +2600,7 @@
* Gets the sliding out animation for content transition of an element and its children
* happening when exiting the layout.
*/
- @Nullable
- public SlideOutTransition getSlideOut() {
+ public @Nullable SlideOutTransition getSlideOut() {
if (mImpl.hasSlideOut()) {
return SlideOutTransition.fromProto(mImpl.getSlideOut());
} else {
@@ -2800,34 +2610,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ExitTransition fromProto(
- @NonNull ModifiersProto.ExitTransition proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ExitTransition fromProto(
+ ModifiersProto.@NonNull ExitTransition proto, @Nullable Fingerprint fingerprint) {
return new ExitTransition(proto, fingerprint);
}
- @NonNull
- static ExitTransition fromProto(@NonNull ModifiersProto.ExitTransition proto) {
+ static @NonNull ExitTransition fromProto(ModifiersProto.@NonNull ExitTransition proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.ExitTransition toProto() {
+ public ModifiersProto.@NonNull ExitTransition toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ExitTransition{"
+ "fadeOut="
+ getFadeOut()
@@ -2850,8 +2655,7 @@
* happening when exiting the layout.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setFadeOut(@NonNull FadeOutTransition fadeOut) {
+ public @NonNull Builder setFadeOut(@NonNull FadeOutTransition fadeOut) {
mImpl.setFadeOut(fadeOut.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(fadeOut.getFingerprint()).aggregateValueAsInt());
@@ -2863,8 +2667,7 @@
* happening when exiting the layout.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setSlideOut(@NonNull SlideOutTransition slideOut) {
+ public @NonNull Builder setSlideOut(@NonNull SlideOutTransition slideOut) {
mImpl.setSlideOut(slideOut.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(slideOut.getFingerprint()).aggregateValueAsInt());
@@ -2872,8 +2675,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public ExitTransition build() {
+ public @NonNull ExitTransition build() {
return new ExitTransition(mImpl.build(), mFingerprint);
}
}
@@ -2887,7 +2689,7 @@
@ProtoLayoutExperimental
public static final class FadeOutTransition {
private final ModifiersProto.FadeOutTransition mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FadeOutTransition(
ModifiersProto.FadeOutTransition impl, @Nullable Fingerprint fingerprint) {
@@ -2905,8 +2707,7 @@
}
/** Gets the animation parameters for duration, delay, etc. */
- @Nullable
- public AnimationSpec getAnimationSpec() {
+ public @Nullable AnimationSpec getAnimationSpec() {
if (mImpl.hasAnimationSpec()) {
return AnimationSpec.fromProto(mImpl.getAnimationSpec());
} else {
@@ -2916,35 +2717,31 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static FadeOutTransition fromProto(
- @NonNull ModifiersProto.FadeOutTransition proto,
+ public static @NonNull FadeOutTransition fromProto(
+ ModifiersProto.@NonNull FadeOutTransition proto,
@Nullable Fingerprint fingerprint) {
return new FadeOutTransition(proto, fingerprint);
}
- @NonNull
- static FadeOutTransition fromProto(@NonNull ModifiersProto.FadeOutTransition proto) {
+ static @NonNull FadeOutTransition fromProto(
+ ModifiersProto.@NonNull FadeOutTransition proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.FadeOutTransition toProto() {
+ public ModifiersProto.@NonNull FadeOutTransition toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "FadeOutTransition{"
+ "targetAlpha="
+ getTargetAlpha()
@@ -2966,8 +2763,8 @@
* Sets the target alpha of the fade out transition. It should be between 0 and 1. If
* not set, defaults to fully invisible, i.e. 0.
*/
- @NonNull
- public Builder setTargetAlpha(@FloatRange(from = 0.0, to = 1.0) float targetAlpha) {
+ public @NonNull Builder setTargetAlpha(
+ @FloatRange(from = 0.0, to = 1.0) float targetAlpha) {
mImpl.setTargetAlpha(targetAlpha);
mFingerprint.recordPropertyUpdate(1, Float.floatToIntBits(targetAlpha));
return this;
@@ -2975,8 +2772,7 @@
/** Sets the animation parameters for duration, delay, etc. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
+ public @NonNull Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
mImpl.setAnimationSpec(animationSpec.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(animationSpec.getFingerprint()).aggregateValueAsInt());
@@ -2984,8 +2780,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public FadeOutTransition build() {
+ public @NonNull FadeOutTransition build() {
return new FadeOutTransition(mImpl.build(), mFingerprint);
}
}
@@ -2996,7 +2791,7 @@
@ProtoLayoutExperimental
public static final class SlideOutTransition {
private final ModifiersProto.SlideOutTransition mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
SlideOutTransition(
ModifiersProto.SlideOutTransition impl, @Nullable Fingerprint fingerprint) {
@@ -3020,8 +2815,7 @@
* that sliding from the screen boundaries can only be achieved if all parent's sizes are
* big enough to accommodate it.
*/
- @Nullable
- public SlideBound getTargetSlideBound() {
+ public @Nullable SlideBound getTargetSlideBound() {
if (mImpl.hasTargetSlideBound()) {
return ModifiersBuilders.slideBoundFromProto(mImpl.getTargetSlideBound());
} else {
@@ -3030,8 +2824,7 @@
}
/** Gets the animation parameters for duration, delay, etc. */
- @Nullable
- public AnimationSpec getAnimationSpec() {
+ public @Nullable AnimationSpec getAnimationSpec() {
if (mImpl.hasAnimationSpec()) {
return AnimationSpec.fromProto(mImpl.getAnimationSpec());
} else {
@@ -3041,35 +2834,31 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static SlideOutTransition fromProto(
- @NonNull ModifiersProto.SlideOutTransition proto,
+ public static @NonNull SlideOutTransition fromProto(
+ ModifiersProto.@NonNull SlideOutTransition proto,
@Nullable Fingerprint fingerprint) {
return new SlideOutTransition(proto, fingerprint);
}
- @NonNull
- static SlideOutTransition fromProto(@NonNull ModifiersProto.SlideOutTransition proto) {
+ static @NonNull SlideOutTransition fromProto(
+ ModifiersProto.@NonNull SlideOutTransition proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.SlideOutTransition toProto() {
+ public ModifiersProto.@NonNull SlideOutTransition toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "SlideOutTransition{"
+ "direction="
+ getDirection()
@@ -3095,8 +2884,7 @@
* from right to the left.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setDirection(@SlideDirection int direction) {
+ public @NonNull Builder setDirection(@SlideDirection int direction) {
mImpl.setDirection(ModifiersProto.SlideDirection.forNumber(direction));
mFingerprint.recordPropertyUpdate(1, direction);
return this;
@@ -3108,8 +2896,7 @@
* Note that sliding from the screen boundaries can only be achieved if all parent's
* sizes are big enough to accommodate it.
*/
- @NonNull
- public Builder setTargetSlideBound(@NonNull SlideBound targetSlideBound) {
+ public @NonNull Builder setTargetSlideBound(@NonNull SlideBound targetSlideBound) {
mImpl.setTargetSlideBound(targetSlideBound.toSlideBoundProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(targetSlideBound.getFingerprint()).aggregateValueAsInt());
@@ -3118,8 +2905,7 @@
/** Sets the animation parameters for duration, delay, etc. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
+ public @NonNull Builder setAnimationSpec(@NonNull AnimationSpec animationSpec) {
mImpl.setAnimationSpec(animationSpec.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(animationSpec.getFingerprint()).aggregateValueAsInt());
@@ -3127,8 +2913,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public SlideOutTransition build() {
+ public @NonNull SlideOutTransition build() {
return new SlideOutTransition(mImpl.build(), mFingerprint);
}
}
@@ -3140,39 +2925,34 @@
public interface SlideBound {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- ModifiersProto.SlideBound toSlideBoundProto();
+ ModifiersProto.@NonNull SlideBound toSlideBoundProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link SlideBound} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- SlideBound build();
+ @NonNull SlideBound build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
@ProtoLayoutExperimental
- public static SlideBound slideBoundFromProto(
- @NonNull ModifiersProto.SlideBound proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull SlideBound slideBoundFromProto(
+ ModifiersProto.@NonNull SlideBound proto, @Nullable Fingerprint fingerprint) {
if (proto.hasParentBound()) {
return SlideParentBound.fromProto(proto.getParentBound(), fingerprint);
}
throw new IllegalStateException("Proto was not a recognised instance of SlideBound");
}
- @NonNull
@ProtoLayoutExperimental
- static SlideBound slideBoundFromProto(@NonNull ModifiersProto.SlideBound proto) {
+ static @NonNull SlideBound slideBoundFromProto(ModifiersProto.@NonNull SlideBound proto) {
return slideBoundFromProto(proto, null);
}
@@ -3181,7 +2961,7 @@
@ProtoLayoutExperimental
public static final class SlideParentBound implements SlideBound {
private final ModifiersProto.SlideParentBound mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
SlideParentBound(ModifiersProto.SlideParentBound impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -3199,42 +2979,36 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static SlideParentBound fromProto(
- @NonNull ModifiersProto.SlideParentBound proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull SlideParentBound fromProto(
+ ModifiersProto.@NonNull SlideParentBound proto, @Nullable Fingerprint fingerprint) {
return new SlideParentBound(proto, fingerprint);
}
- @NonNull
- static SlideParentBound fromProto(@NonNull ModifiersProto.SlideParentBound proto) {
+ static @NonNull SlideParentBound fromProto(ModifiersProto.@NonNull SlideParentBound proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- ModifiersProto.SlideParentBound toProto() {
+ ModifiersProto.@NonNull SlideParentBound toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
@ProtoLayoutExperimental
- public ModifiersProto.SlideBound toSlideBoundProto() {
+ public ModifiersProto.@NonNull SlideBound toSlideBoundProto() {
return ModifiersProto.SlideBound.newBuilder().setParentBound(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "SlideParentBound{" + "snapTo=" + getSnapTo() + "}";
}
@@ -3253,8 +3027,7 @@
* SLIDE_PARENT_SNAP_TO_INSIDE if not specified.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setSnapTo(@SlideParentSnapOption int snapTo) {
+ public @NonNull Builder setSnapTo(@SlideParentSnapOption int snapTo) {
mImpl.setSnapTo(ModifiersProto.SlideParentSnapOption.forNumber(snapTo));
mFingerprint.recordPropertyUpdate(1, snapTo);
return this;
@@ -3262,8 +3035,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public SlideParentBound build() {
+ public @NonNull SlideParentBound build() {
return new SlideParentBound(mImpl.build(), mFingerprint);
}
}
@@ -3276,7 +3048,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class ArcModifiers {
private final ModifiersProto.ArcModifiers mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ArcModifiers(ModifiersProto.ArcModifiers impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -3287,8 +3059,7 @@
* Gets allows its wrapped element to have actions associated with it, which will be
* executed when the element is tapped.
*/
- @Nullable
- public Clickable getClickable() {
+ public @Nullable Clickable getClickable() {
if (mImpl.hasClickable()) {
return Clickable.fromProto(mImpl.getClickable());
} else {
@@ -3300,8 +3071,7 @@
* Gets adds metadata for the modified element, for example, screen reader content
* descriptions.
*/
- @Nullable
- public Semantics getSemantics() {
+ public @Nullable Semantics getSemantics() {
if (mImpl.hasSemantics()) {
return Semantics.fromProto(mImpl.getSemantics());
} else {
@@ -3314,8 +3084,7 @@
* completely transparent and 1 means the element is completely opaque. Dynamic value is
* supported.
*/
- @Nullable
- public FloatProp getOpacity() {
+ public @Nullable FloatProp getOpacity() {
if (mImpl.hasOpacity()) {
return FloatProp.fromProto(mImpl.getOpacity());
} else {
@@ -3325,34 +3094,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ArcModifiers fromProto(
- @NonNull ModifiersProto.ArcModifiers proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull ArcModifiers fromProto(
+ ModifiersProto.@NonNull ArcModifiers proto, @Nullable Fingerprint fingerprint) {
return new ArcModifiers(proto, fingerprint);
}
- @NonNull
- static ArcModifiers fromProto(@NonNull ModifiersProto.ArcModifiers proto) {
+ static @NonNull ArcModifiers fromProto(ModifiersProto.@NonNull ArcModifiers proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.ArcModifiers toProto() {
+ public ModifiersProto.@NonNull ArcModifiers toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ArcModifiers{"
+ "clickable="
+ getClickable()
@@ -3377,8 +3141,7 @@
* executed when the element is tapped.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setClickable(@NonNull Clickable clickable) {
+ public @NonNull Builder setClickable(@NonNull Clickable clickable) {
mImpl.setClickable(clickable.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(clickable.getFingerprint()).aggregateValueAsInt());
@@ -3390,8 +3153,7 @@
* descriptions.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setSemantics(@NonNull Semantics semantics) {
+ public @NonNull Builder setSemantics(@NonNull Semantics semantics) {
mImpl.setSemantics(semantics.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(semantics.getFingerprint()).aggregateValueAsInt());
@@ -3400,8 +3162,7 @@
/** Sets the opacity of the element. */
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setOpacity(@NonNull FloatProp opacity) {
+ public @NonNull Builder setOpacity(@NonNull FloatProp opacity) {
mImpl.setOpacity(opacity.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(opacity.getFingerprint()).aggregateValueAsInt());
@@ -3409,8 +3170,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public ArcModifiers build() {
+ public @NonNull ArcModifiers build() {
return new ArcModifiers(mImpl.build(), mFingerprint);
}
}
@@ -3424,7 +3184,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class SpanModifiers {
private final ModifiersProto.SpanModifiers mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
SpanModifiers(ModifiersProto.SpanModifiers impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -3435,8 +3195,7 @@
* Gets allows its wrapped element to have actions associated with it, which will be
* executed when the element is tapped.
*/
- @Nullable
- public Clickable getClickable() {
+ public @Nullable Clickable getClickable() {
if (mImpl.hasClickable()) {
return Clickable.fromProto(mImpl.getClickable());
} else {
@@ -3446,34 +3205,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static SpanModifiers fromProto(
- @NonNull ModifiersProto.SpanModifiers proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull SpanModifiers fromProto(
+ ModifiersProto.@NonNull SpanModifiers proto, @Nullable Fingerprint fingerprint) {
return new SpanModifiers(proto, fingerprint);
}
- @NonNull
- static SpanModifiers fromProto(@NonNull ModifiersProto.SpanModifiers proto) {
+ static @NonNull SpanModifiers fromProto(ModifiersProto.@NonNull SpanModifiers proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.SpanModifiers toProto() {
+ public ModifiersProto.@NonNull SpanModifiers toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "SpanModifiers{" + "clickable=" + getClickable() + "}";
}
@@ -3491,8 +3245,7 @@
* executed when the element is tapped.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setClickable(@NonNull Clickable clickable) {
+ public @NonNull Builder setClickable(@NonNull Clickable clickable) {
mImpl.setClickable(clickable.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(clickable.getFingerprint()).aggregateValueAsInt());
@@ -3500,8 +3253,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public SpanModifiers build() {
+ public @NonNull SpanModifiers build() {
return new SpanModifiers(mImpl.build(), mFingerprint);
}
}
@@ -3511,7 +3263,7 @@
@RequiresSchemaVersion(major = 1, minor = 300)
public static final class Shadow {
private final ModifiersProto.Shadow mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Shadow(ModifiersProto.Shadow impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -3522,8 +3274,7 @@
* Gets the blur radius of the shadow. It controls the size of the blur that is drawn. When
* set to zero, the shadow is not drawn. Defaults to zero.
*/
- @NonNull
- public DpProp getBlurRadius() {
+ public @NonNull DpProp getBlurRadius() {
if (mImpl.hasBlurRadius()) {
return DpProp.fromProto(mImpl.getBlurRadius());
} else {
@@ -3532,8 +3283,7 @@
}
/** Gets the color used in the shadow. Defaults to Black. */
- @NonNull
- public ColorProp getColor() {
+ public @NonNull ColorProp getColor() {
if (mImpl.hasColor()) {
return ColorProp.fromProto(mImpl.getColor());
} else {
@@ -3543,34 +3293,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Shadow fromProto(
- @NonNull ModifiersProto.Shadow proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Shadow fromProto(
+ ModifiersProto.@NonNull Shadow proto, @Nullable Fingerprint fingerprint) {
return new Shadow(proto, fingerprint);
}
- @NonNull
- static Shadow fromProto(@NonNull ModifiersProto.Shadow proto) {
+ static @NonNull Shadow fromProto(ModifiersProto.@NonNull Shadow proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.Shadow toProto() {
+ public ModifiersProto.@NonNull Shadow toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Shadow{" + "blurRadius=" + getBlurRadius() + ", color=" + getColor() + "}";
}
@@ -3589,8 +3334,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setBlurRadius(@NonNull DpProp blurRadius) {
+ public @NonNull Builder setBlurRadius(@NonNull DpProp blurRadius) {
if (blurRadius.getDynamicValue() != null) {
throw new IllegalArgumentException(
"Shadow.Builder.setBlurRadius doesn't support dynamic values.");
@@ -3607,8 +3351,7 @@
* <p>Note that this field only supports static values.
*/
@RequiresSchemaVersion(major = 1, minor = 300)
- @NonNull
- public Builder setColor(@NonNull ColorProp color) {
+ public @NonNull Builder setColor(@NonNull ColorProp color) {
if (color.getDynamicValue() != null) {
throw new IllegalArgumentException(
"Shadow.Builder.setColor doesn't support dynamic values.");
@@ -3620,8 +3363,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Shadow build() {
+ public @NonNull Shadow build() {
return new Shadow(mImpl.build(), mFingerprint);
}
}
diff --git a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/ResourceBuilders.java b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/ResourceBuilders.java
index 72d7ef0..0fff0a2 100644
--- a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/ResourceBuilders.java
+++ b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/ResourceBuilders.java
@@ -23,8 +23,6 @@
import androidx.annotation.Dimension;
import androidx.annotation.DrawableRes;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.OptIn;
import androidx.annotation.RawRes;
import androidx.annotation.RestrictTo;
@@ -37,6 +35,9 @@
import androidx.wear.protolayout.proto.ResourceProto;
import androidx.wear.protolayout.protobuf.ByteString;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
@@ -109,22 +110,19 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AndroidImageResourceByResId fromProto(
- @NonNull ResourceProto.AndroidImageResourceByResId proto) {
+ public static @NonNull AndroidImageResourceByResId fromProto(
+ ResourceProto.@NonNull AndroidImageResourceByResId proto) {
return new AndroidImageResourceByResId(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ResourceProto.AndroidImageResourceByResId toProto() {
+ public ResourceProto.@NonNull AndroidImageResourceByResId toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AndroidImageResourceByResId{" + "resourceId=" + getResourceId() + "}";
}
@@ -141,15 +139,13 @@
* R.drawable.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setResourceId(@DrawableRes int resourceId) {
+ public @NonNull Builder setResourceId(@DrawableRes int resourceId) {
mImpl.setResourceId(resourceId);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public AndroidImageResourceByResId build() {
+ public @NonNull AndroidImageResourceByResId build() {
return AndroidImageResourceByResId.fromProto(mImpl.build());
}
}
@@ -168,8 +164,7 @@
}
/** Gets the byte array representing the image. */
- @NonNull
- public byte[] getData() {
+ public byte @NonNull [] getData() {
return mImpl.getData().toByteArray();
}
@@ -204,22 +199,19 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static InlineImageResource fromProto(
- @NonNull ResourceProto.InlineImageResource proto) {
+ public static @NonNull InlineImageResource fromProto(
+ ResourceProto.@NonNull InlineImageResource proto) {
return new InlineImageResource(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ResourceProto.InlineImageResource toProto() {
+ public ResourceProto.@NonNull InlineImageResource toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "InlineImageResource{"
+ "data="
+ Arrays.toString(getData())
@@ -242,8 +234,7 @@
/** Sets the byte array representing the image. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setData(@NonNull byte[] data) {
+ public @NonNull Builder setData(byte @NonNull [] data) {
mImpl.setData(ByteString.copyFrom(data));
return this;
}
@@ -253,8 +244,7 @@
* IMAGE_FORMAT_RGB_565) where the image data does not include size.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setWidthPx(@Dimension(unit = PX) int widthPx) {
+ public @NonNull Builder setWidthPx(@Dimension(unit = PX) int widthPx) {
mImpl.setWidthPx(widthPx);
return this;
}
@@ -264,8 +254,7 @@
* IMAGE_FORMAT_RGB_565) where the image data does not include size.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setHeightPx(@Dimension(unit = PX) int heightPx) {
+ public @NonNull Builder setHeightPx(@Dimension(unit = PX) int heightPx) {
mImpl.setHeightPx(heightPx);
return this;
}
@@ -277,15 +266,13 @@
* the image will not be decoded or displayed.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setFormat(@ImageFormat int format) {
+ public @NonNull Builder setFormat(@ImageFormat int format) {
mImpl.setFormat(ResourceProto.ImageFormat.forNumber(format));
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public InlineImageResource build() {
+ public @NonNull InlineImageResource build() {
return InlineImageResource.fromProto(mImpl.build());
}
}
@@ -318,8 +305,7 @@
}
/** Gets the trigger to start the animation. */
- @Nullable
- public Trigger getStartTrigger() {
+ public @Nullable Trigger getStartTrigger() {
if (mImpl.hasStartTrigger()) {
return TriggerBuilders.triggerFromProto(mImpl.getStartTrigger());
} else {
@@ -329,22 +315,19 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AndroidAnimatedImageResourceByResId fromProto(
- @NonNull ResourceProto.AndroidAnimatedImageResourceByResId proto) {
+ public static @NonNull AndroidAnimatedImageResourceByResId fromProto(
+ ResourceProto.@NonNull AndroidAnimatedImageResourceByResId proto) {
return new AndroidAnimatedImageResourceByResId(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ResourceProto.AndroidAnimatedImageResourceByResId toProto() {
+ public ResourceProto.@NonNull AndroidAnimatedImageResourceByResId toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AndroidAnimatedImageResourceByResId{"
+ "animatedImageFormat="
+ getAnimatedImageFormat()
@@ -365,8 +348,8 @@
/** Sets the format for the animated image. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setAnimatedImageFormat(@AnimatedImageFormat int animatedImageFormat) {
+ public @NonNull Builder setAnimatedImageFormat(
+ @AnimatedImageFormat int animatedImageFormat) {
mImpl.setAnimatedImageFormat(
ResourceProto.AnimatedImageFormat.forNumber(animatedImageFormat));
return this;
@@ -374,23 +357,20 @@
/** Sets the Android resource ID, e.g. R.drawable.foo. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setResourceId(@DrawableRes int resourceId) {
+ public @NonNull Builder setResourceId(@DrawableRes int resourceId) {
mImpl.setResourceId(resourceId);
return this;
}
/** Sets the trigger to start the animation. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setStartTrigger(@NonNull Trigger startTrigger) {
+ public @NonNull Builder setStartTrigger(@NonNull Trigger startTrigger) {
mImpl.setStartTrigger(startTrigger.toTriggerProto());
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public AndroidAnimatedImageResourceByResId build() {
+ public @NonNull AndroidAnimatedImageResourceByResId build() {
return AndroidAnimatedImageResourceByResId.fromProto(mImpl.build());
}
}
@@ -432,8 +412,7 @@
* new value on subsequent updates. If not set, the animation will play on load (similar to
* a non-seekable animated).
*/
- @Nullable
- public DynamicFloat getProgress() {
+ public @Nullable DynamicFloat getProgress() {
if (mImpl.hasProgress()) {
return DynamicBuilders.dynamicFloatFromProto(mImpl.getProgress());
} else {
@@ -443,22 +422,19 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AndroidSeekableAnimatedImageResourceByResId fromProto(
- @NonNull ResourceProto.AndroidSeekableAnimatedImageResourceByResId proto) {
+ public static @NonNull AndroidSeekableAnimatedImageResourceByResId fromProto(
+ ResourceProto.@NonNull AndroidSeekableAnimatedImageResourceByResId proto) {
return new AndroidSeekableAnimatedImageResourceByResId(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ResourceProto.AndroidSeekableAnimatedImageResourceByResId toProto() {
+ public ResourceProto.@NonNull AndroidSeekableAnimatedImageResourceByResId toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AndroidSeekableAnimatedImageResourceByResId{"
+ "animatedImageFormat="
+ getAnimatedImageFormat()
@@ -479,8 +455,8 @@
/** Sets the format for the animated image. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setAnimatedImageFormat(@AnimatedImageFormat int animatedImageFormat) {
+ public @NonNull Builder setAnimatedImageFormat(
+ @AnimatedImageFormat int animatedImageFormat) {
mImpl.setAnimatedImageFormat(
ResourceProto.AnimatedImageFormat.forNumber(animatedImageFormat));
return this;
@@ -488,8 +464,7 @@
/** Sets the Android resource ID, e.g. R.drawable.foo. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setResourceId(@DrawableRes int resourceId) {
+ public @NonNull Builder setResourceId(@DrawableRes int resourceId) {
mImpl.setResourceId(resourceId);
return this;
}
@@ -505,15 +480,13 @@
* on load (similar to a non-seekable animated).
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setProgress(@NonNull DynamicFloat progress) {
+ public @NonNull Builder setProgress(@NonNull DynamicFloat progress) {
mImpl.setProgress(progress.toDynamicFloatProto());
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public AndroidSeekableAnimatedImageResourceByResId build() {
+ public @NonNull AndroidSeekableAnimatedImageResourceByResId build() {
return AndroidSeekableAnimatedImageResourceByResId.fromProto(mImpl.build());
}
}
@@ -539,8 +512,7 @@
* normally transformed from certain states with the data binding pipeline to control the
* progress of the animation.
*/
- @Nullable
- public DynamicFloat getProgress() {
+ public @Nullable DynamicFloat getProgress() {
if (mImpl.hasProgress()) {
return DynamicBuilders.dynamicFloatFromProto(mImpl.getProgress());
} else {
@@ -550,22 +522,19 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static AndroidLottieResourceByResId fromProto(
- @NonNull ResourceProto.AndroidLottieResourceByResId proto) {
+ public static @NonNull AndroidLottieResourceByResId fromProto(
+ ResourceProto.@NonNull AndroidLottieResourceByResId proto) {
return new AndroidLottieResourceByResId(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ResourceProto.AndroidLottieResourceByResId toProto() {
+ public ResourceProto.@NonNull AndroidLottieResourceByResId toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "AndroidLottieResourceByResId{"
+ "rawResourceId="
+ getRawResourceId()
@@ -595,8 +564,7 @@
/** Sets the Android resource ID, e.g. R.raw.foo. */
@RequiresSchemaVersion(major = 1, minor = 500)
- @NonNull
- Builder setRawResourceId(@RawRes int rawResourceId) {
+ @NonNull Builder setRawResourceId(@RawRes int rawResourceId) {
mImpl.setRawResourceId(rawResourceId);
return this;
}
@@ -617,15 +585,13 @@
* <p>If not set, the animation will play on load.
*/
@RequiresSchemaVersion(major = 1, minor = 500)
- @NonNull
- public Builder setProgress(@NonNull DynamicFloat progress) {
+ public @NonNull Builder setProgress(@NonNull DynamicFloat progress) {
mImpl.setProgress(progress.toDynamicFloatProto());
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public AndroidLottieResourceByResId build() {
+ public @NonNull AndroidLottieResourceByResId build() {
return AndroidLottieResourceByResId.fromProto(mImpl.build());
}
}
@@ -644,8 +610,7 @@
}
/** Gets an image resource that maps to an Android drawable by resource ID. */
- @Nullable
- public AndroidImageResourceByResId getAndroidResourceByResId() {
+ public @Nullable AndroidImageResourceByResId getAndroidResourceByResId() {
if (mImpl.hasAndroidResourceByResId()) {
return AndroidImageResourceByResId.fromProto(mImpl.getAndroidResourceByResId());
} else {
@@ -654,8 +619,7 @@
}
/** Gets an image resource that contains the image data inline. */
- @Nullable
- public InlineImageResource getInlineResource() {
+ public @Nullable InlineImageResource getInlineResource() {
if (mImpl.hasInlineResource()) {
return InlineImageResource.fromProto(mImpl.getInlineResource());
} else {
@@ -667,9 +631,8 @@
* Gets a non-seekable animated image resource that maps to an Android drawable by resource
* ID. The animation is started with given trigger, fire and forget.
*/
- @Nullable
@ProtoLayoutExperimental
- public AndroidAnimatedImageResourceByResId getAndroidAnimatedResourceByResId() {
+ public @Nullable AndroidAnimatedImageResourceByResId getAndroidAnimatedResourceByResId() {
if (mImpl.hasAndroidAnimatedResourceByResId()) {
return AndroidAnimatedImageResourceByResId.fromProto(
mImpl.getAndroidAnimatedResourceByResId());
@@ -682,9 +645,8 @@
* Gets a seekable animated image resource that maps to an Android drawable by resource ID.
* The animation progress is bound to the provided dynamic float.
*/
- @Nullable
@ProtoLayoutExperimental
- public AndroidSeekableAnimatedImageResourceByResId
+ public @Nullable AndroidSeekableAnimatedImageResourceByResId
getAndroidSeekableAnimatedResourceByResId() {
if (mImpl.hasAndroidSeekableAnimatedResourceByResId()) {
return AndroidSeekableAnimatedImageResourceByResId.fromProto(
@@ -695,8 +657,7 @@
}
/** Gets a Lottie resource that is read from a raw Android resource ID. */
- @Nullable
- public AndroidLottieResourceByResId getAndroidLottieResourceByResId() {
+ public @Nullable AndroidLottieResourceByResId getAndroidLottieResourceByResId() {
if (mImpl.hasAndroidLottieResourceByResId()) {
return AndroidLottieResourceByResId.fromProto(
mImpl.getAndroidLottieResourceByResId());
@@ -707,22 +668,19 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ImageResource fromProto(@NonNull ResourceProto.ImageResource proto) {
+ public static @NonNull ImageResource fromProto(ResourceProto.@NonNull ImageResource proto) {
return new ImageResource(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ResourceProto.ImageResource toProto() {
+ public ResourceProto.@NonNull ImageResource toProto() {
return mImpl;
}
@Override
- @NonNull
@OptIn(markerClass = ProtoLayoutExperimental.class)
- public String toString() {
+ public @NonNull String toString() {
return "ImageResource{"
+ "androidResourceByResId="
+ getAndroidResourceByResId()
@@ -747,8 +705,7 @@
/** Sets an image resource that maps to an Android drawable by resource ID. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setAndroidResourceByResId(
+ public @NonNull Builder setAndroidResourceByResId(
@NonNull AndroidImageResourceByResId androidResourceByResId) {
mImpl.setAndroidResourceByResId(androidResourceByResId.toProto());
return this;
@@ -756,8 +713,7 @@
/** Sets an image resource that contains the image data inline. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setInlineResource(@NonNull InlineImageResource inlineResource) {
+ public @NonNull Builder setInlineResource(@NonNull InlineImageResource inlineResource) {
mImpl.setInlineResource(inlineResource.toProto());
return this;
}
@@ -767,9 +723,8 @@
* resource ID. The animation is started with given trigger, fire and forget.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
@ProtoLayoutExperimental
- public Builder setAndroidAnimatedResourceByResId(
+ public @NonNull Builder setAndroidAnimatedResourceByResId(
@NonNull AndroidAnimatedImageResourceByResId androidAnimatedResourceByResId) {
mImpl.setAndroidAnimatedResourceByResId(androidAnimatedResourceByResId.toProto());
return this;
@@ -780,11 +735,9 @@
* ID. The animation progress is bound to the provided dynamic float.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
@ProtoLayoutExperimental
- public Builder setAndroidSeekableAnimatedResourceByResId(
- @NonNull
- AndroidSeekableAnimatedImageResourceByResId
+ public @NonNull Builder setAndroidSeekableAnimatedResourceByResId(
+ @NonNull AndroidSeekableAnimatedImageResourceByResId
androidSeekableAnimatedResourceByResId) {
mImpl.setAndroidSeekableAnimatedResourceByResId(
androidSeekableAnimatedResourceByResId.toProto());
@@ -793,16 +746,14 @@
/** sets a Lottie resource that is read from a raw Android resource ID. */
@RequiresSchemaVersion(major = 1, minor = 500)
- @NonNull
- public Builder setAndroidLottieResourceByResId(
+ public @NonNull Builder setAndroidLottieResourceByResId(
@NonNull AndroidLottieResourceByResId androidLottieResourceByResId) {
mImpl.setAndroidLottieResourceByResId(androidLottieResourceByResId.toProto());
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public ImageResource build() {
+ public @NonNull ImageResource build() {
return ImageResource.fromProto(mImpl.build());
}
}
@@ -828,14 +779,12 @@
* layout to render successfully, and must match the resource version specified in
* ResourcesRequest which triggered this request.
*/
- @NonNull
- public String getVersion() {
+ public @NonNull String getVersion() {
return mImpl.getVersion();
}
/** Gets a map of resource_ids to images, which can be used by layouts. */
- @NonNull
- public Map<String, ImageResource> getIdToImageMapping() {
+ public @NonNull Map<String, ImageResource> getIdToImageMapping() {
Map<String, ImageResource> map = new HashMap<>();
for (Entry<String, ResourceProto.ImageResource> entry :
mImpl.getIdToImageMap().entrySet()) {
@@ -846,21 +795,18 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Resources fromProto(@NonNull ResourceProto.Resources proto) {
+ public static @NonNull Resources fromProto(ResourceProto.@NonNull Resources proto) {
return new Resources(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ResourceProto.Resources toProto() {
+ public ResourceProto.@NonNull Resources toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Resources{"
+ "version="
+ getVersion()
@@ -889,8 +835,7 @@
* ResourcesRequest which triggered this request.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setVersion(@NonNull String version) {
+ public @NonNull Builder setVersion(@NonNull String version) {
mImpl.setVersion(version);
return this;
}
@@ -898,15 +843,14 @@
/** Adds an entry into a map of resource_ids to images, which can be used by layouts. */
@RequiresSchemaVersion(major = 1, minor = 0)
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addIdToImageMapping(@NonNull String id, @NonNull ImageResource image) {
+ public @NonNull Builder addIdToImageMapping(@NonNull String id,
+ @NonNull ImageResource image) {
mImpl.putIdToImage(id, image.toProto());
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Resources build() {
+ public @NonNull Resources build() {
return Resources.fromProto(mImpl.build());
}
}
diff --git a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/StateBuilders.java b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/StateBuilders.java
index 2213aac..33ea445 100644
--- a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/StateBuilders.java
+++ b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/StateBuilders.java
@@ -20,8 +20,6 @@
import android.annotation.SuppressLint;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.AppDataKey;
@@ -33,6 +31,9 @@
import androidx.wear.protolayout.expression.proto.DynamicDataProto;
import androidx.wear.protolayout.proto.StateProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -46,7 +47,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class State {
private final StateProto.State mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
private static final int MAX_STATE_ENTRY_COUNT = 30;
@@ -68,14 +69,12 @@
}
/** Gets the ID of the clickable that was last clicked. */
- @NonNull
- public String getLastClickableId() {
+ public @NonNull String getLastClickableId() {
return mImpl.getLastClickableId();
}
/** Gets any shared state between the provider and renderer. */
- @NonNull
- public Map<AppDataKey<?>, DynamicDataValue<?>> getKeyToValueMapping() {
+ public @NonNull Map<AppDataKey<?>, DynamicDataValue<?>> getKeyToValueMapping() {
Map<AppDataKey<?>, DynamicDataValue<?>> map = new HashMap<>();
for (Entry<String, DynamicDataProto.DynamicDataValue> entry :
mImpl.getIdToValueMap().entrySet()) {
@@ -88,16 +87,14 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static State fromProto(
- @NonNull StateProto.State proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull State fromProto(
+ StateProto.@NonNull State proto, @Nullable Fingerprint fingerprint) {
return new State(proto, fingerprint);
}
@@ -106,21 +103,18 @@
* object created using this method can't be added to any other wrapper.
*/
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static State fromProto(@NonNull StateProto.State proto) {
+ public static @NonNull State fromProto(StateProto.@NonNull State proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public StateProto.State toProto() {
+ public StateProto.@NonNull State toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "State{"
+ "lastClickableId="
+ getLastClickableId()
@@ -145,8 +139,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 200)
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public <T extends DynamicType> Builder addKeyToValueMapping(
+ public <T extends DynamicType> @NonNull Builder addKeyToValueMapping(
@NonNull AppDataKey<T> sourceKey, @NonNull DynamicDataValue<T> value) {
if (mImpl.getIdToValueMap().size() >= getMaxStateEntryCount()) {
throw new IllegalStateException(
@@ -168,8 +161,7 @@
* @throws IllegalStateException if number of key/value pairs are greater than {@link
* #getMaxStateEntryCount()}.
*/
- @NonNull
- public State build() {
+ public @NonNull State build() {
if (mImpl.getIdToValueMap().size() > getMaxStateEntryCount()) {
throw new IllegalStateException(
String.format(
diff --git a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/TimelineBuilders.java b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/TimelineBuilders.java
index 4731b4c..63cb4be 100644
--- a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/TimelineBuilders.java
+++ b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/TimelineBuilders.java
@@ -16,14 +16,15 @@
package androidx.wear.protolayout;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.LayoutElementBuilders.Layout;
import androidx.wear.protolayout.expression.RequiresSchemaVersion;
import androidx.wear.protolayout.proto.TimelineProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -58,21 +59,18 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static TimeInterval fromProto(@NonNull TimelineProto.TimeInterval proto) {
+ public static @NonNull TimeInterval fromProto(TimelineProto.@NonNull TimeInterval proto) {
return new TimeInterval(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public TimelineProto.TimeInterval toProto() {
+ public TimelineProto.@NonNull TimeInterval toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "TimeInterval{"
+ "startMillis="
+ getStartMillis()
@@ -91,23 +89,20 @@
/** Sets starting point of the time interval, in milliseconds since the Unix epoch. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setStartMillis(long startMillis) {
+ public @NonNull Builder setStartMillis(long startMillis) {
mImpl.setStartMillis(startMillis);
return this;
}
/** Sets end point of the time interval, in milliseconds since the Unix epoch. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setEndMillis(long endMillis) {
+ public @NonNull Builder setEndMillis(long endMillis) {
mImpl.setEndMillis(endMillis);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public TimeInterval build() {
+ public @NonNull TimeInterval build() {
return TimeInterval.fromProto(mImpl.build());
}
}
@@ -123,8 +118,7 @@
}
/** Gets the validity period for this timeline entry. */
- @Nullable
- public TimeInterval getValidity() {
+ public @Nullable TimeInterval getValidity() {
if (mImpl.hasValidity()) {
return TimeInterval.fromProto(mImpl.getValidity());
} else {
@@ -133,8 +127,7 @@
}
/** Gets the contents of this timeline entry. */
- @Nullable
- public Layout getLayout() {
+ public @Nullable Layout getLayout() {
if (mImpl.hasLayout()) {
return Layout.fromProto(mImpl.getLayout());
} else {
@@ -144,29 +137,25 @@
/** Returns the {@link TimelineEntry} object containing the given layout element. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public static TimelineEntry fromLayoutElement(
- @NonNull LayoutElementBuilders.LayoutElement layoutElement) {
+ public static @NonNull TimelineEntry fromLayoutElement(
+ LayoutElementBuilders.@NonNull LayoutElement layoutElement) {
return new Builder().setLayout(Layout.fromLayoutElement(layoutElement)).build();
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static TimelineEntry fromProto(@NonNull TimelineProto.TimelineEntry proto) {
+ public static @NonNull TimelineEntry fromProto(TimelineProto.@NonNull TimelineEntry proto) {
return new TimelineEntry(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public TimelineProto.TimelineEntry toProto() {
+ public TimelineProto.@NonNull TimelineEntry toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "TimelineEntry{" + "validity=" + getValidity() + ", layout=" + getLayout() + "}";
}
@@ -180,23 +169,20 @@
/** Sets the validity period for this timeline entry. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValidity(@NonNull TimeInterval validity) {
+ public @NonNull Builder setValidity(@NonNull TimeInterval validity) {
mImpl.setValidity(validity.toProto());
return this;
}
/** Sets the contents of this timeline entry. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setLayout(@NonNull Layout layout) {
+ public @NonNull Builder setLayout(@NonNull Layout layout) {
mImpl.setLayout(layout.toProto());
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public TimelineEntry build() {
+ public @NonNull TimelineEntry build() {
return TimelineEntry.fromProto(mImpl.build());
}
}
@@ -225,8 +211,7 @@
}
/** Gets the entries in a timeline. */
- @NonNull
- public List<TimelineEntry> getTimelineEntries() {
+ public @NonNull List<TimelineEntry> getTimelineEntries() {
List<TimelineEntry> list = new ArrayList<>();
for (TimelineProto.TimelineEntry item : mImpl.getTimelineEntriesList()) {
list.add(TimelineEntry.fromProto(item));
@@ -236,9 +221,8 @@
/** Returns the {@link Timeline} object containing the given layout element. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public static Timeline fromLayoutElement(
- @NonNull LayoutElementBuilders.LayoutElement layoutElement) {
+ public static @NonNull Timeline fromLayoutElement(
+ LayoutElementBuilders.@NonNull LayoutElement layoutElement) {
return new Builder()
.addTimelineEntry(TimelineEntry.fromLayoutElement(layoutElement))
.build();
@@ -246,21 +230,18 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Timeline fromProto(@NonNull TimelineProto.Timeline proto) {
+ public static @NonNull Timeline fromProto(TimelineProto.@NonNull Timeline proto) {
return new Timeline(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public TimelineProto.Timeline toProto() {
+ public TimelineProto.@NonNull Timeline toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Timeline{" + "timelineEntries=" + getTimelineEntries() + "}";
}
@@ -274,15 +255,13 @@
/** Adds one item to the entries in a timeline. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder addTimelineEntry(@NonNull TimelineEntry timelineEntry) {
+ public @NonNull Builder addTimelineEntry(@NonNull TimelineEntry timelineEntry) {
mImpl.addTimelineEntries(timelineEntry.toProto());
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Timeline build() {
+ public @NonNull Timeline build() {
return Timeline.fromProto(mImpl.build());
}
}
diff --git a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/TriggerBuilders.java b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/TriggerBuilders.java
index a35d6f8..1a96d0e 100644
--- a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/TriggerBuilders.java
+++ b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/TriggerBuilders.java
@@ -18,8 +18,6 @@
import static androidx.wear.protolayout.expression.Preconditions.checkNotNull;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.DynamicBuilders;
@@ -28,14 +26,16 @@
import androidx.wear.protolayout.expression.RequiresSchemaVersion;
import androidx.wear.protolayout.proto.TriggerProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/** Builders for triggers that can be used to start an animation. */
public final class TriggerBuilders {
private TriggerBuilders() {}
/** Creates a {@link Trigger} that fires immediately when the layout is loaded / reloaded. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public static Trigger createOnLoadTrigger() {
+ public static @NonNull Trigger createOnLoadTrigger() {
return new OnLoadTrigger.Builder().build();
}
@@ -44,8 +44,7 @@
* If the condition is true initially, that will fire the trigger on load.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public static Trigger createOnConditionMetTrigger(@NonNull DynamicBool dynamicBool) {
+ public static @NonNull Trigger createOnConditionMetTrigger(@NonNull DynamicBool dynamicBool) {
return new OnConditionMetTrigger.Builder().setCondition(dynamicBool).build();
}
@@ -53,7 +52,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class OnLoadTrigger implements Trigger {
private final TriggerProto.OnLoadTrigger mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
OnLoadTrigger(TriggerProto.OnLoadTrigger impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -62,41 +61,35 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static OnLoadTrigger fromProto(
- @NonNull TriggerProto.OnLoadTrigger proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull OnLoadTrigger fromProto(
+ TriggerProto.@NonNull OnLoadTrigger proto, @Nullable Fingerprint fingerprint) {
return new OnLoadTrigger(proto, fingerprint);
}
- @NonNull
- static OnLoadTrigger fromProto(@NonNull TriggerProto.OnLoadTrigger proto) {
+ static @NonNull OnLoadTrigger fromProto(TriggerProto.@NonNull OnLoadTrigger proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- TriggerProto.OnLoadTrigger toProto() {
+ TriggerProto.@NonNull OnLoadTrigger toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public TriggerProto.Trigger toTriggerProto() {
+ public TriggerProto.@NonNull Trigger toTriggerProto() {
return TriggerProto.Trigger.newBuilder().setOnLoadTrigger(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "OnLoadTrigger";
}
@@ -112,8 +105,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public OnLoadTrigger build() {
+ public @NonNull OnLoadTrigger build() {
return new OnLoadTrigger(mImpl.build(), mFingerprint);
}
}
@@ -126,7 +118,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
static final class OnConditionMetTrigger implements Trigger {
private final TriggerProto.OnConditionMetTrigger mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
OnConditionMetTrigger(
TriggerProto.OnConditionMetTrigger impl, @Nullable Fingerprint fingerprint) {
@@ -135,8 +127,7 @@
}
/** Gets dynamic boolean used as trigger. */
- @Nullable
- public DynamicBool getCondition() {
+ public @Nullable DynamicBool getCondition() {
if (mImpl.hasCondition()) {
return DynamicBuilders.dynamicBoolFromProto(mImpl.getCondition());
} else {
@@ -146,42 +137,37 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static OnConditionMetTrigger fromProto(
- @NonNull TriggerProto.OnConditionMetTrigger proto,
+ public static @NonNull OnConditionMetTrigger fromProto(
+ TriggerProto.@NonNull OnConditionMetTrigger proto,
@Nullable Fingerprint fingerprint) {
return new OnConditionMetTrigger(proto, fingerprint);
}
- @NonNull
- static OnConditionMetTrigger fromProto(@NonNull TriggerProto.OnConditionMetTrigger proto) {
+ static @NonNull OnConditionMetTrigger fromProto(
+ TriggerProto.@NonNull OnConditionMetTrigger proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- TriggerProto.OnConditionMetTrigger toProto() {
+ TriggerProto.@NonNull OnConditionMetTrigger toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public TriggerProto.Trigger toTriggerProto() {
+ public TriggerProto.@NonNull Trigger toTriggerProto() {
return TriggerProto.Trigger.newBuilder().setOnConditionMetTrigger(mImpl).build();
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "OnConditionMetTrigger{" + "condition=" + getCondition() + "}";
}
@@ -197,8 +183,7 @@
/** Sets dynamic boolean used as trigger. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setCondition(@NonNull DynamicBool condition) {
+ public @NonNull Builder setCondition(@NonNull DynamicBool condition) {
mImpl.setCondition(condition.toDynamicBoolProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(condition.getFingerprint()).aggregateValueAsInt());
@@ -207,8 +192,7 @@
/** Builds an instance from accumulated values. */
@Override
- @NonNull
- public OnConditionMetTrigger build() {
+ public @NonNull OnConditionMetTrigger build() {
return new OnConditionMetTrigger(mImpl.build(), mFingerprint);
}
}
@@ -222,29 +206,25 @@
public interface Trigger {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- TriggerProto.Trigger toTriggerProto();
+ TriggerProto.@NonNull Trigger toTriggerProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link Trigger} objects. */
@RestrictTo(Scope.LIBRARY_GROUP)
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- Trigger build();
+ @NonNull Trigger build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Trigger triggerFromProto(
- @NonNull TriggerProto.Trigger proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Trigger triggerFromProto(
+ TriggerProto.@NonNull Trigger proto, @Nullable Fingerprint fingerprint) {
if (proto.hasOnLoadTrigger()) {
return OnLoadTrigger.fromProto(proto.getOnLoadTrigger(), fingerprint);
}
@@ -254,8 +234,7 @@
throw new IllegalStateException("Proto was not a recognised instance of Trigger");
}
- @NonNull
- static Trigger triggerFromProto(@NonNull TriggerProto.Trigger proto) {
+ static @NonNull Trigger triggerFromProto(TriggerProto.@NonNull Trigger proto) {
return triggerFromProto(proto, null);
}
}
diff --git a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/TypeBuilders.java b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/TypeBuilders.java
index d787564..24d40db 100644
--- a/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/TypeBuilders.java
+++ b/wear/protolayout/protolayout/src/main/java/androidx/wear/protolayout/TypeBuilders.java
@@ -20,8 +20,6 @@
import android.annotation.SuppressLint;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.DynamicBuilders;
@@ -33,6 +31,9 @@
import androidx.wear.protolayout.proto.AlignmentProto;
import androidx.wear.protolayout.proto.TypesProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Objects;
/** Builders for extensible primitive types used by layout elements. */
@@ -46,7 +47,7 @@
@RequiresSchemaVersion(major = 1, minor = 200)
public static final class StringLayoutConstraint {
private final TypesProto.StringProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
StringLayoutConstraint(TypesProto.StringProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -57,8 +58,7 @@
* Gets the text string to use as the pattern for the largest text that can be laid out.
* Used to ensure that the layout is of a known size during the layout pass.
*/
- @NonNull
- public String getPatternForLayout() {
+ public @NonNull String getPatternForLayout() {
return mImpl.getValueForLayout();
}
@@ -69,19 +69,16 @@
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public TypesProto.StringProp toProto() {
+ public TypesProto.@NonNull StringProp toProto() {
return mImpl;
}
- @NonNull
- static StringLayoutConstraint fromProto(@NonNull TypesProto.StringProp proto) {
+ static @NonNull StringLayoutConstraint fromProto(TypesProto.@NonNull StringProp proto) {
return new StringLayoutConstraint(proto, null);
}
@@ -98,9 +95,8 @@
&& getAlignment() == other.getAlignment();
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
return "StringLayoutConstraint(patternForLayout="
+ getPatternForLayout()
+ ", alignment="
@@ -135,8 +131,7 @@
* Used to ensure that the layout is of a known size during the layout pass.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- private Builder setValue(@NonNull String patternForLayout) {
+ private @NonNull Builder setValue(@NonNull String patternForLayout) {
mImpl.setValueForLayout(patternForLayout);
mFingerprint.recordPropertyUpdate(3, patternForLayout.hashCode());
return this;
@@ -147,16 +142,15 @@
* not specified, defaults to center alignment.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setAlignment(@LayoutElementBuilders.TextAlignment int alignment) {
+ public @NonNull Builder setAlignment(
+ @LayoutElementBuilders.TextAlignment int alignment) {
mImpl.setTextAlignmentForLayout(AlignmentProto.TextAlignment.forNumber(alignment));
mFingerprint.recordPropertyUpdate(4, alignment);
return this;
}
/** Builds an instance of {@link StringLayoutConstraint}. */
- @NonNull
- public StringLayoutConstraint build() {
+ public @NonNull StringLayoutConstraint build() {
return new StringLayoutConstraint(mImpl.build(), mFingerprint);
}
}
@@ -166,7 +160,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class Int32Prop {
private final TypesProto.Int32Prop mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Int32Prop(TypesProto.Int32Prop impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -180,34 +174,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Int32Prop fromProto(
- @NonNull TypesProto.Int32Prop proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Int32Prop fromProto(
+ TypesProto.@NonNull Int32Prop proto, @Nullable Fingerprint fingerprint) {
return new Int32Prop(proto, fingerprint);
}
- @NonNull
- static Int32Prop fromProto(@NonNull TypesProto.Int32Prop proto) {
+ static @NonNull Int32Prop fromProto(TypesProto.@NonNull Int32Prop proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public TypesProto.Int32Prop toProto() {
+ public TypesProto.@NonNull Int32Prop toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Int32Prop{" + "value=" + getValue() + "}";
}
@@ -221,16 +210,14 @@
/** Sets the static value. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(int value) {
+ public @NonNull Builder setValue(int value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Int32Prop build() {
+ public @NonNull Int32Prop build() {
return new Int32Prop(mImpl.build(), mFingerprint);
}
}
@@ -240,7 +227,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class StringProp {
private final TypesProto.StringProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
StringProp(TypesProto.StringProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -252,8 +239,7 @@
* values for the corresponding field, this static value will be ignored. If the static
* value is not specified, {@code null} will be used instead.
*/
- @NonNull
- public String getValue() {
+ public @NonNull String getValue() {
return mImpl.getValue();
}
@@ -262,8 +248,7 @@
* required to be set to support older renderers that only read the static value. If {@code
* dynamicValue} has an invalid result, the provided static value will be used instead.
*/
- @Nullable
- public DynamicString getDynamicValue() {
+ public @Nullable DynamicString getDynamicValue() {
if (mImpl.hasDynamicValue()) {
return DynamicBuilders.dynamicStringFromProto(mImpl.getDynamicValue());
} else {
@@ -273,34 +258,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static StringProp fromProto(
- @NonNull TypesProto.StringProp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull StringProp fromProto(
+ TypesProto.@NonNull StringProp proto, @Nullable Fingerprint fingerprint) {
return new StringProp(proto, fingerprint);
}
- @NonNull
- static StringProp fromProto(@NonNull TypesProto.StringProp proto) {
+ static @NonNull StringProp fromProto(TypesProto.@NonNull StringProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public TypesProto.StringProp toProto() {
+ public TypesProto.@NonNull StringProp toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "StringProp{"
+ "value="
+ getValue()
@@ -336,8 +316,7 @@
* static value is not specified, {@code null} will be used instead.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(@NonNull String value) {
+ public @NonNull Builder setValue(@NonNull String value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, value.hashCode());
return this;
@@ -350,8 +329,7 @@
* instead.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setDynamicValue(@NonNull DynamicString dynamicValue) {
+ public @NonNull Builder setDynamicValue(@NonNull DynamicString dynamicValue) {
mImpl.setDynamicValue(dynamicValue.toDynamicStringProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(dynamicValue.getFingerprint()).aggregateValueAsInt());
@@ -365,8 +343,7 @@
* #setDynamicValue(DynamicString)} but neither {@link #Builder(String)} nor {@link
* #setValue(String)} is used to provide a static value.
*/
- @NonNull
- public StringProp build() {
+ public @NonNull StringProp build() {
if (mImpl.hasDynamicValue() && !mImpl.hasValue()) {
throw new IllegalStateException("Static value is missing.");
}
@@ -379,7 +356,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class FloatProp {
private final TypesProto.FloatProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FloatProp(TypesProto.FloatProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -400,8 +377,7 @@
* required to be set to support older renderers that only read the static value. If {@code
* dynamicValue} has an invalid result, the provided static value will be used instead.
*/
- @Nullable
- public DynamicFloat getDynamicValue() {
+ public @Nullable DynamicFloat getDynamicValue() {
if (mImpl.hasDynamicValue()) {
return DynamicBuilders.dynamicFloatFromProto(mImpl.getDynamicValue());
} else {
@@ -411,34 +387,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static FloatProp fromProto(
- @NonNull TypesProto.FloatProp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull FloatProp fromProto(
+ TypesProto.@NonNull FloatProp proto, @Nullable Fingerprint fingerprint) {
return new FloatProp(proto, fingerprint);
}
- @NonNull
- static FloatProp fromProto(@NonNull TypesProto.FloatProp proto) {
+ static @NonNull FloatProp fromProto(TypesProto.@NonNull FloatProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public TypesProto.FloatProp toProto() {
+ public TypesProto.@NonNull FloatProp toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "FloatProp{"
+ "value="
+ getValue()
@@ -474,8 +445,7 @@
* static value is not specified, zero will be used instead.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setValue(float value) {
+ public @NonNull Builder setValue(float value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, Float.floatToIntBits(value));
return this;
@@ -488,8 +458,7 @@
* has an invalid result, the provided static value will be used instead.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setDynamicValue(@NonNull DynamicFloat dynamicValue) {
+ public @NonNull Builder setDynamicValue(@NonNull DynamicFloat dynamicValue) {
mImpl.setDynamicValue(dynamicValue.toDynamicFloatProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(dynamicValue.getFingerprint()).aggregateValueAsInt());
@@ -503,8 +472,7 @@
* #setDynamicValue(DynamicFloat)} but neither {@link #Builder(float)} nor {@link
* #setValue(float)} is used to provide a static value.
*/
- @NonNull
- public FloatProp build() {
+ public @NonNull FloatProp build() {
if (mImpl.hasDynamicValue() && !mImpl.hasValue()) {
throw new IllegalStateException("Static value is missing.");
}
@@ -517,7 +485,7 @@
@RequiresSchemaVersion(major = 1, minor = 0)
public static final class BoolProp {
private final TypesProto.BoolProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
BoolProp(TypesProto.BoolProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -547,8 +515,7 @@
* required to be set to support older renderers that only read the static value. If {@code
* dynamicValue} has an invalid result, the provided static value will be used instead.
*/
- @Nullable
- public DynamicBool getDynamicValue() {
+ public @Nullable DynamicBool getDynamicValue() {
if (mImpl.hasDynamicValue()) {
return DynamicBuilders.dynamicBoolFromProto(mImpl.getDynamicValue());
} else {
@@ -558,34 +525,29 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static BoolProp fromProto(
- @NonNull TypesProto.BoolProp proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull BoolProp fromProto(
+ TypesProto.@NonNull BoolProp proto, @Nullable Fingerprint fingerprint) {
return new BoolProp(proto, fingerprint);
}
- @NonNull
- static BoolProp fromProto(@NonNull TypesProto.BoolProp proto) {
+ static @NonNull BoolProp fromProto(TypesProto.@NonNull BoolProp proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public TypesProto.BoolProp toProto() {
+ public TypesProto.@NonNull BoolProp toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "BoolProp{"
+ "value="
+ getValue()
@@ -622,8 +584,7 @@
*/
@RequiresSchemaVersion(major = 1, minor = 0)
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setValue(boolean value) {
+ public @NonNull Builder setValue(boolean value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, Boolean.hashCode(value));
return this;
@@ -636,8 +597,7 @@
* instead.
*/
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setDynamicValue(@NonNull DynamicBool dynamicValue) {
+ public @NonNull Builder setDynamicValue(@NonNull DynamicBool dynamicValue) {
mImpl.setDynamicValue(dynamicValue.toDynamicBoolProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(dynamicValue.getFingerprint()).aggregateValueAsInt());
@@ -651,8 +611,7 @@
* #setDynamicValue(DynamicBool)} but neither {@link #Builder(boolean)} nor {@link
* #setValue(boolean)} is used to provide a static value.
*/
- @NonNull
- public BoolProp build() {
+ public @NonNull BoolProp build() {
if (mImpl.hasDynamicValue() && !mImpl.hasValue()) {
throw new IllegalStateException("Static value is missing.");
}
diff --git a/wear/protolayout/protolayout/src/test/java/androidx/wear/protolayout/DimensionBuildersTest.java b/wear/protolayout/protolayout/src/test/java/androidx/wear/protolayout/DimensionBuildersTest.java
index 8a19995..ba54633 100644
--- a/wear/protolayout/protolayout/src/test/java/androidx/wear/protolayout/DimensionBuildersTest.java
+++ b/wear/protolayout/protolayout/src/test/java/androidx/wear/protolayout/DimensionBuildersTest.java
@@ -23,12 +23,9 @@
import static org.junit.Assert.assertThrows;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.wear.protolayout.expression.AppDataKey;
import androidx.wear.protolayout.expression.DynamicBuilders;
-import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.DimensionProto;
import org.junit.Test;
diff --git a/wear/protolayout/protolayout/src/test/java/androidx/wear/protolayout/LayoutElementBuildersTest.java b/wear/protolayout/protolayout/src/test/java/androidx/wear/protolayout/LayoutElementBuildersTest.java
index 5605c8b..1904f9c 100644
--- a/wear/protolayout/protolayout/src/test/java/androidx/wear/protolayout/LayoutElementBuildersTest.java
+++ b/wear/protolayout/protolayout/src/test/java/androidx/wear/protolayout/LayoutElementBuildersTest.java
@@ -35,10 +35,10 @@
import android.graphics.Color;
import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.wear.protolayout.expression.AppDataKey;
-import androidx.wear.protolayout.expression.DynamicBuilders;
import androidx.wear.protolayout.LayoutElementBuilders.DashedArcLine;
import androidx.wear.protolayout.LayoutElementBuilders.DashedLinePattern;
+import androidx.wear.protolayout.expression.AppDataKey;
+import androidx.wear.protolayout.expression.DynamicBuilders;
import androidx.wear.protolayout.proto.ColorProto;
import androidx.wear.protolayout.proto.DimensionProto;
import androidx.wear.protolayout.proto.LayoutElementProto;
diff --git a/wear/tiles/tiles-material/build.gradle b/wear/tiles/tiles-material/build.gradle
index 5a1fa54..f1afc74 100644
--- a/wear/tiles/tiles-material/build.gradle
+++ b/wear/tiles/tiles-material/build.gradle
@@ -32,6 +32,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.annotation:annotation:1.8.1")
api(project(":wear:tiles:tiles"))
implementation(project(":wear:tiles:tiles-proto"))
diff --git a/wear/tiles/tiles-material/src/androidTest/java/androidx/wear/tiles/material/RunnerUtils.java b/wear/tiles/tiles-material/src/androidTest/java/androidx/wear/tiles/material/RunnerUtils.java
index f630834..a8cb5ea 100644
--- a/wear/tiles/tiles-material/src/androidTest/java/androidx/wear/tiles/material/RunnerUtils.java
+++ b/wear/tiles/tiles-material/src/androidTest/java/androidx/wear/tiles/material/RunnerUtils.java
@@ -22,13 +22,14 @@
import android.graphics.Bitmap;
import android.util.Log;
-import androidx.annotation.NonNull;
import androidx.test.core.app.ActivityScenario;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.screenshot.AndroidXScreenshotTestRule;
import androidx.test.screenshot.matchers.MSSIMMatcher;
import androidx.wear.tiles.material.testapp.GoldenTestActivity;
+import org.jspecify.annotations.NonNull;
+
@SuppressWarnings("deprecation")
public class RunnerUtils {
// This isn't totally ideal right now. The screenshot tests run on a phone, so emulate some
@@ -40,7 +41,7 @@
public static void runSingleScreenshotTest(
@NonNull AndroidXScreenshotTestRule rule,
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement layoutElement,
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement layoutElement,
@NonNull String expected) {
byte[] layoutElementPayload = layoutElement.toLayoutElementProto().toByteArray();
diff --git a/wear/tiles/tiles-material/src/androidTest/java/androidx/wear/tiles/material/TestCasesGenerator.java b/wear/tiles/tiles-material/src/androidTest/java/androidx/wear/tiles/material/TestCasesGenerator.java
index 50d9fb8..531d07f 100644
--- a/wear/tiles/tiles-material/src/androidTest/java/androidx/wear/tiles/material/TestCasesGenerator.java
+++ b/wear/tiles/tiles-material/src/androidTest/java/androidx/wear/tiles/material/TestCasesGenerator.java
@@ -19,7 +19,7 @@
import android.content.Context;
import android.graphics.Color;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
import java.util.HashMap;
import java.util.Map;
@@ -38,11 +38,12 @@
* different for different user font sizes. Note that some of the golden will have the same name
* as it should point on the same size independent image.
*/
- @NonNull
- static Map<String, androidx.wear.tiles.LayoutElementBuilders.LayoutElement> generateTestCases(
- @NonNull Context context,
- @NonNull androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters deviceParameters,
- @NonNull String goldenSuffix) {
+ static @NonNull Map<String, androidx.wear.tiles.LayoutElementBuilders.LayoutElement>
+ generateTestCases(
+ @NonNull Context context,
+ androidx.wear.tiles.DeviceParametersBuilders.@NonNull DeviceParameters
+ deviceParameters,
+ @NonNull String goldenSuffix) {
androidx.wear.tiles.ModifiersBuilders.Clickable clickable =
new androidx.wear.tiles.ModifiersBuilders.Clickable.Builder()
.setOnClick(
diff --git a/wear/tiles/tiles-material/src/androidTest/java/androidx/wear/tiles/material/layouts/TestCasesGenerator.java b/wear/tiles/tiles-material/src/androidTest/java/androidx/wear/tiles/material/layouts/TestCasesGenerator.java
index 5984524..342d482 100644
--- a/wear/tiles/tiles-material/src/androidTest/java/androidx/wear/tiles/material/layouts/TestCasesGenerator.java
+++ b/wear/tiles/tiles-material/src/androidTest/java/androidx/wear/tiles/material/layouts/TestCasesGenerator.java
@@ -20,7 +20,8 @@
import android.graphics.Color;
import androidx.annotation.Dimension;
-import androidx.annotation.NonNull;
+
+import org.jspecify.annotations.NonNull;
import java.util.HashMap;
import java.util.Map;
@@ -37,11 +38,12 @@
* different for different user font sizes. Note that some of the golden will have the same name
* as it should point on the same size independent image.
*/
- @NonNull
- static Map<String, androidx.wear.tiles.LayoutElementBuilders.LayoutElement> generateTestCases(
- @NonNull Context context,
- @NonNull androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters deviceParameters,
- @NonNull String goldenSuffix) {
+ static @NonNull Map<String, androidx.wear.tiles.LayoutElementBuilders.LayoutElement>
+ generateTestCases(
+ @NonNull Context context,
+ androidx.wear.tiles.DeviceParametersBuilders.@NonNull DeviceParameters
+ deviceParameters,
+ @NonNull String goldenSuffix) {
androidx.wear.tiles.ModifiersBuilders.Clickable clickable =
new androidx.wear.tiles.ModifiersBuilders.Clickable.Builder()
.setOnClick(
@@ -635,13 +637,11 @@
return testCases;
}
- @NonNull
- private static androidx.wear.tiles.ColorBuilders.ColorProp color(int yellow) {
+ private static androidx.wear.tiles.ColorBuilders.@NonNull ColorProp color(int yellow) {
return androidx.wear.tiles.ColorBuilders.argb(yellow);
}
- @NonNull
- private static androidx.wear.tiles.material.Text buildTextLabel(
+ private static androidx.wear.tiles.material.@NonNull Text buildTextLabel(
@NonNull Context context, @NonNull String text) {
return new androidx.wear.tiles.material.Text.Builder(context, text)
.setTypography(androidx.wear.tiles.material.Typography.TYPOGRAPHY_CAPTION1)
@@ -649,8 +649,8 @@
.build();
}
- @NonNull
- private static androidx.wear.tiles.LayoutElementBuilders.Box buildColoredBoxMSL(int color) {
+ private static androidx.wear.tiles.LayoutElementBuilders.@NonNull Box buildColoredBoxMSL(
+ int color) {
return new androidx.wear.tiles.LayoutElementBuilders.Box.Builder()
.setWidth(androidx.wear.tiles.DimensionBuilders.dp(60))
.setHeight(androidx.wear.tiles.DimensionBuilders.dp(60))
@@ -665,8 +665,8 @@
.build();
}
- @NonNull
- private static androidx.wear.tiles.LayoutElementBuilders.Box buildColoredBoxPLL(int color) {
+ private static androidx.wear.tiles.LayoutElementBuilders.@NonNull Box buildColoredBoxPLL(
+ int color) {
return new androidx.wear.tiles.LayoutElementBuilders.Box.Builder()
.setWidth(androidx.wear.tiles.DimensionBuilders.expand())
.setHeight(androidx.wear.tiles.DimensionBuilders.dp(60))
diff --git a/wear/tiles/tiles-material/src/androidTest/java/androidx/wear/tiles/material/testapp/GoldenTestActivity.java b/wear/tiles/tiles-material/src/androidTest/java/androidx/wear/tiles/material/testapp/GoldenTestActivity.java
index 8374563..6e4ea0c 100644
--- a/wear/tiles/tiles-material/src/androidTest/java/androidx/wear/tiles/material/testapp/GoldenTestActivity.java
+++ b/wear/tiles/tiles-material/src/androidTest/java/androidx/wear/tiles/material/testapp/GoldenTestActivity.java
@@ -31,7 +31,6 @@
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
-import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.wear.protolayout.LayoutElementBuilders;
import androidx.wear.protolayout.LayoutElementBuilders.Layout;
@@ -42,6 +41,8 @@
import androidx.wear.tiles.material.R;
import androidx.wear.tiles.renderer.TileRenderer;
+import org.jspecify.annotations.Nullable;
+
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Button.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Button.java
index b469d86..2689359 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Button.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Button.java
@@ -22,13 +22,14 @@
import androidx.annotation.Dimension;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.HashMap;
@@ -92,9 +93,9 @@
*/
static final String METADATA_TAG_CUSTOM_CONTENT = "CSTBTN";
- @NonNull private final androidx.wear.tiles.LayoutElementBuilders.Box mElement;
+ private final androidx.wear.tiles.LayoutElementBuilders.@NonNull Box mElement;
- Button(@NonNull androidx.wear.tiles.LayoutElementBuilders.Box element) {
+ Button(androidx.wear.tiles.LayoutElementBuilders.@NonNull Box element) {
mElement = element;
}
@@ -107,27 +108,27 @@
private static final int IMAGE = 2;
private static final int CUSTOM_CONTENT = 3;
- @NonNull static final Map<Integer, String> TYPE_TO_TAG = new HashMap<>();
+ static final @NonNull Map<Integer, String> TYPE_TO_TAG = new HashMap<>();
@RestrictTo(RestrictTo.Scope.LIBRARY)
@Retention(RetentionPolicy.SOURCE)
@IntDef({NOT_SET, ICON, TEXT, IMAGE, CUSTOM_CONTENT})
@interface ButtonType {}
- @NonNull private final Context mContext;
- @Nullable private androidx.wear.tiles.LayoutElementBuilders.LayoutElement mCustomContent;
- @NonNull private final androidx.wear.tiles.ModifiersBuilders.Clickable mClickable;
- @NonNull private CharSequence mContentDescription = "";
+ private final @NonNull Context mContext;
+ private androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement mCustomContent;
+ private final androidx.wear.tiles.ModifiersBuilders.@NonNull Clickable mClickable;
+ private @NonNull CharSequence mContentDescription = "";
- @NonNull
- private androidx.wear.tiles.DimensionBuilders.DpProp mSize = ButtonDefaults.DEFAULT_SIZE;
+ private androidx.wear.tiles.DimensionBuilders.@NonNull DpProp mSize =
+ ButtonDefaults.DEFAULT_SIZE;
- @Nullable private String mText = null;
- @Nullable private Integer mTypographyName = null;
- @Nullable private String mIcon = null;
- @Nullable private androidx.wear.tiles.DimensionBuilders.DpProp mIconSize = null;
- @Nullable private String mImage = null;
- @NonNull private ButtonColors mButtonColors = ButtonDefaults.PRIMARY_COLORS;
+ private @Nullable String mText = null;
+ private @Nullable Integer mTypographyName = null;
+ private @Nullable String mIcon = null;
+ private androidx.wear.tiles.DimensionBuilders.@Nullable DpProp mIconSize = null;
+ private @Nullable String mImage = null;
+ private @NonNull ButtonColors mButtonColors = ButtonDefaults.PRIMARY_COLORS;
@ButtonType private int mType = NOT_SET;
static {
@@ -148,7 +149,7 @@
*/
public Builder(
@NonNull Context context,
- @NonNull androidx.wear.tiles.ModifiersBuilders.Clickable clickable) {
+ androidx.wear.tiles.ModifiersBuilders.@NonNull Clickable clickable) {
mClickable = clickable;
mContext = context;
}
@@ -157,8 +158,7 @@
* Sets the content description for the {@link Button}. It is highly recommended to provide
* this for button containing icon or image.
*/
- @NonNull
- public Builder setContentDescription(@NonNull CharSequence contentDescription) {
+ public @NonNull Builder setContentDescription(@NonNull CharSequence contentDescription) {
this.mContentDescription = contentDescription;
return this;
}
@@ -169,8 +169,8 @@
* ButtonDefaults#EXTRA_LARGE_SIZE}. If not set, {@link ButtonDefaults#DEFAULT_SIZE} will be
* used.
*/
- @NonNull
- public Builder setSize(@NonNull androidx.wear.tiles.DimensionBuilders.DpProp size) {
+ public @NonNull Builder setSize(
+ androidx.wear.tiles.DimensionBuilders.@NonNull DpProp size) {
mSize = size;
return this;
}
@@ -181,8 +181,7 @@
* ButtonDefaults#EXTRA_LARGE_SIZE}. If not set, {@link ButtonDefaults#DEFAULT_SIZE} will be
* used.
*/
- @NonNull
- public Builder setSize(@Dimension(unit = DP) float size) {
+ public @NonNull Builder setSize(@Dimension(unit = DP) float size) {
mSize = androidx.wear.tiles.DimensionBuilders.dp(size);
return this;
}
@@ -191,8 +190,7 @@
* Sets the colors for the {@link Button}. If not set, {@link ButtonDefaults#PRIMARY_COLORS}
* will be used.
*/
- @NonNull
- public Builder setButtonColors(@NonNull ButtonColors buttonColors) {
+ public @NonNull Builder setButtonColors(@NonNull ButtonColors buttonColors) {
mButtonColors = buttonColors;
return this;
}
@@ -200,9 +198,8 @@
/**
* Sets the custom content for this Button. Any previously added content will be overridden.
*/
- @NonNull
- public Builder setCustomContent(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement content) {
+ public @NonNull Builder setCustomContent(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement content) {
resetContent();
this.mCustomContent = content;
this.mType = CUSTOM_CONTENT;
@@ -215,10 +212,9 @@
* from {@link ButtonColors} and with the given size. This icon should be image with chosen
* alpha channel and not an actual image.
*/
- @NonNull
- public Builder setIconContent(
+ public @NonNull Builder setIconContent(
@NonNull String imageResourceId,
- @NonNull androidx.wear.tiles.DimensionBuilders.DpProp size) {
+ androidx.wear.tiles.DimensionBuilders.@NonNull DpProp size) {
resetContent();
this.mIcon = imageResourceId;
this.mType = ICON;
@@ -232,8 +228,7 @@
* icon will be tinted to the given content color from {@link ButtonColors}. This icon
* should be image with chosen alpha channel and not an actual image.
*/
- @NonNull
- public Builder setIconContent(@NonNull String imageResourceId) {
+ public @NonNull Builder setIconContent(@NonNull String imageResourceId) {
resetContent();
this.mIcon = imageResourceId;
this.mType = ICON;
@@ -248,8 +243,7 @@
* Any previously added content will be overridden. Text should contain no more than 3
* characters, otherwise it will overflow from the edges.
*/
- @NonNull
- public Builder setTextContent(@NonNull String text) {
+ public @NonNull Builder setTextContent(@NonNull String text) {
resetContent();
this.mText = text;
this.mType = TEXT;
@@ -262,8 +256,7 @@
* Text} component. Any previously added content will be overridden. Text should contain no
* more than 3 characters, otherwise it will overflow from the edges.
*/
- @NonNull
- public Builder setTextContent(
+ public @NonNull Builder setTextContent(
@NonNull String text, @Typography.TypographyName int typographyName) {
resetContent();
this.mText = text;
@@ -276,8 +269,7 @@
* Sets the content of this Button to be the given image, i.e. contacts photo. Any
* previously added content will be overridden.
*/
- @NonNull
- public Builder setImageContent(@NonNull String imageResourceId) {
+ public @NonNull Builder setImageContent(@NonNull String imageResourceId) {
resetContent();
this.mImage = imageResourceId;
this.mType = IMAGE;
@@ -294,9 +286,8 @@
}
/** Constructs and returns {@link Button} with the provided field and look. */
- @NonNull
@Override
- public Button build() {
+ public @NonNull Button build() {
androidx.wear.tiles.ModifiersBuilders.Modifiers.Builder modifiers =
new androidx.wear.tiles.ModifiersBuilders.Modifiers.Builder()
.setClickable(mClickable)
@@ -335,8 +326,8 @@
return new Button(element.build());
}
- @NonNull
- private androidx.wear.tiles.LayoutElementBuilders.LayoutElement getCorrectContent() {
+ private androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement
+ getCorrectContent() {
androidx.wear.tiles.LayoutElementBuilders.LayoutElement.Builder content;
switch (mType) {
case ICON:
@@ -399,7 +390,7 @@
}
private static @Typography.TypographyName int getDefaultTypographyForSize(
- @NonNull androidx.wear.tiles.DimensionBuilders.DpProp size) {
+ androidx.wear.tiles.DimensionBuilders.@NonNull DpProp size) {
if (size.getValue() == ButtonDefaults.LARGE_SIZE.getValue()) {
return Typography.TYPOGRAPHY_TITLE1;
} else if (size.getValue() == ButtonDefaults.EXTRA_LARGE_SIZE.getValue()) {
@@ -413,8 +404,7 @@
/**
* Returns the custom content of this Button if it has been added. Otherwise, it returns null.
*/
- @Nullable
- public androidx.wear.tiles.LayoutElementBuilders.LayoutElement getCustomContent() {
+ public androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement getCustomContent() {
if (!getMetadataTag().equals(METADATA_TAG_CUSTOM_CONTENT)) {
return null;
}
@@ -422,8 +412,7 @@
}
/** Returns the icon content of this Button if it has been added. Otherwise, it returns null. */
- @Nullable
- public String getIconContent() {
+ public @Nullable String getIconContent() {
androidx.wear.tiles.LayoutElementBuilders.Image icon = getIconContentObject();
return icon != null ? Helper.checkNotNull(icon.getResourceId()).getValue() : null;
}
@@ -431,42 +420,36 @@
/**
* Returns the image content of this Button if it has been added. Otherwise, it returns null.
*/
- @Nullable
- public String getImageContent() {
+ public @Nullable String getImageContent() {
androidx.wear.tiles.LayoutElementBuilders.Image image = getImageContentObject();
return image != null ? Helper.checkNotNull(image.getResourceId()).getValue() : null;
}
/** Returns the text content of this Button if it has been added. Otherwise, it returns null. */
- @Nullable
- public String getTextContent() {
+ public @Nullable String getTextContent() {
Text text = getTextContentObject();
return text != null ? text.getText() : null;
}
- @NonNull
- private androidx.wear.tiles.LayoutElementBuilders.LayoutElement getAnyContent() {
+ private androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement getAnyContent() {
return Helper.checkNotNull(mElement.getContents().get(0));
}
- @Nullable
- private androidx.wear.tiles.LayoutElementBuilders.Image getIconContentObject() {
+ private androidx.wear.tiles.LayoutElementBuilders.@Nullable Image getIconContentObject() {
if (!getMetadataTag().equals(METADATA_TAG_ICON)) {
return null;
}
return (androidx.wear.tiles.LayoutElementBuilders.Image) getAnyContent();
}
- @Nullable
- private Text getTextContentObject() {
+ private @Nullable Text getTextContentObject() {
if (!getMetadataTag().equals(METADATA_TAG_TEXT)) {
return null;
}
return Text.fromLayoutElement(getAnyContent());
}
- @Nullable
- private androidx.wear.tiles.LayoutElementBuilders.Image getImageContentObject() {
+ private androidx.wear.tiles.LayoutElementBuilders.@Nullable Image getImageContentObject() {
if (!getMetadataTag().equals(METADATA_TAG_IMAGE)) {
return null;
}
@@ -474,14 +457,12 @@
}
/** Returns click event action associated with this Button. */
- @NonNull
- public androidx.wear.tiles.ModifiersBuilders.Clickable getClickable() {
+ public androidx.wear.tiles.ModifiersBuilders.@NonNull Clickable getClickable() {
return Helper.checkNotNull(Helper.checkNotNull(mElement.getModifiers()).getClickable());
}
/** Returns content description for this Button. */
- @Nullable
- public CharSequence getContentDescription() {
+ public @Nullable CharSequence getContentDescription() {
androidx.wear.tiles.ModifiersBuilders.Semantics semantics =
Helper.checkNotNull(mElement.getModifiers()).getSemantics();
if (semantics == null) {
@@ -491,8 +472,7 @@
}
/** Returns size for this Button. */
- @NonNull
- public androidx.wear.tiles.DimensionBuilders.ContainerDimension getSize() {
+ public androidx.wear.tiles.DimensionBuilders.@NonNull ContainerDimension getSize() {
return Helper.checkNotNull(mElement.getWidth());
}
@@ -503,8 +483,7 @@
}
/** Returns button color of this Button. */
- @NonNull
- public ButtonColors getButtonColors() {
+ public @NonNull ButtonColors getButtonColors() {
androidx.wear.tiles.ColorBuilders.ColorProp backgroundColor = getBackgroundColor();
androidx.wear.tiles.ColorBuilders.ColorProp contentColor = null;
@@ -538,8 +517,7 @@
}
/** Returns metadata tag set to this Button. */
- @NonNull
- String getMetadataTag() {
+ @NonNull String getMetadataTag() {
return Helper.getMetadataTagName(
Helper.checkNotNull(Helper.checkNotNull(mElement.getModifiers()).getMetadata()));
}
@@ -550,9 +528,8 @@
* container.getContents().get(index)}) if that element can be converted to Button. Otherwise,
* it will return null.
*/
- @Nullable
- public static Button fromLayoutElement(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement element) {
+ public static @Nullable Button fromLayoutElement(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement element) {
if (element instanceof Button) {
return (Button) element;
}
@@ -568,17 +545,15 @@
return new Button(boxElement);
}
- @NonNull
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return Helper.checkNotNull(mElement.toLayoutElementProto());
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
@Override
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mElement.getFingerprint();
}
}
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ButtonColors.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ButtonColors.java
index 23face2..e48335b 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ButtonColors.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ButtonColors.java
@@ -17,7 +17,8 @@
package androidx.wear.tiles.material;
import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
+
+import org.jspecify.annotations.NonNull;
/**
* Represents the background and content colors used in a button Tiles component.
@@ -32,8 +33,8 @@
@Deprecated
@SuppressWarnings("deprecation")
public class ButtonColors {
- @NonNull private final androidx.wear.tiles.ColorBuilders.ColorProp mBackgroundColor;
- @NonNull private final androidx.wear.tiles.ColorBuilders.ColorProp mContentColor;
+ private final androidx.wear.tiles.ColorBuilders.@NonNull ColorProp mBackgroundColor;
+ private final androidx.wear.tiles.ColorBuilders.@NonNull ColorProp mContentColor;
/**
* Constructor for {@link ButtonColors} object.
@@ -55,8 +56,8 @@
* @param contentColor The content color or tint color to be used for a button.
*/
public ButtonColors(
- @NonNull androidx.wear.tiles.ColorBuilders.ColorProp backgroundColor,
- @NonNull androidx.wear.tiles.ColorBuilders.ColorProp contentColor) {
+ androidx.wear.tiles.ColorBuilders.@NonNull ColorProp backgroundColor,
+ androidx.wear.tiles.ColorBuilders.@NonNull ColorProp contentColor) {
mBackgroundColor = backgroundColor;
mContentColor = contentColor;
}
@@ -65,8 +66,7 @@
* Returns a {@link ButtonColors} object, using the current Primary colors from the given {@link
* Colors}.
*/
- @NonNull
- public static ButtonColors primaryButtonColors(@NonNull Colors colors) {
+ public static @NonNull ButtonColors primaryButtonColors(@NonNull Colors colors) {
return new ButtonColors(colors.getPrimary(), colors.getOnPrimary());
}
@@ -74,20 +74,17 @@
* Returns a {@link ButtonColors} object, using the current Surface colors from the given {@link
* Colors}.
*/
- @NonNull
- public static ButtonColors secondaryButtonColors(@NonNull Colors colors) {
+ public static @NonNull ButtonColors secondaryButtonColors(@NonNull Colors colors) {
return new ButtonColors(colors.getSurface(), colors.getOnSurface());
}
/** The background color to be used on a button Tiles components. */
- @NonNull
- public androidx.wear.tiles.ColorBuilders.ColorProp getBackgroundColor() {
+ public androidx.wear.tiles.ColorBuilders.@NonNull ColorProp getBackgroundColor() {
return mBackgroundColor;
}
/** The content or tint color to be used on a button Tiles components. */
- @NonNull
- public androidx.wear.tiles.ColorBuilders.ColorProp getContentColor() {
+ public androidx.wear.tiles.ColorBuilders.@NonNull ColorProp getContentColor() {
return mContentColor;
}
}
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ButtonDefaults.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ButtonDefaults.java
index 3fa5303..6a38829 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ButtonDefaults.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ButtonDefaults.java
@@ -19,7 +19,8 @@
import static androidx.annotation.Dimension.DP;
import androidx.annotation.Dimension;
-import androidx.annotation.NonNull;
+
+import org.jspecify.annotations.NonNull;
/**
* Contains the default values used by button Tiles components.
@@ -33,41 +34,34 @@
private ButtonDefaults() {}
/** The default size for standard {@link Button}. */
- @NonNull
- public static final androidx.wear.tiles.DimensionBuilders.DpProp DEFAULT_SIZE =
+ public static final androidx.wear.tiles.DimensionBuilders.@NonNull DpProp DEFAULT_SIZE =
androidx.wear.tiles.DimensionBuilders.dp(52);
/** The recommended size for large {@link Button}. */
- @NonNull
- public static final androidx.wear.tiles.DimensionBuilders.DpProp LARGE_SIZE =
+ public static final androidx.wear.tiles.DimensionBuilders.@NonNull DpProp LARGE_SIZE =
androidx.wear.tiles.DimensionBuilders.dp(60);
/** The recommended size for extra large {@link Button}. */
- @NonNull
- public static final androidx.wear.tiles.DimensionBuilders.DpProp EXTRA_LARGE_SIZE =
+ public static final androidx.wear.tiles.DimensionBuilders.@NonNull DpProp EXTRA_LARGE_SIZE =
androidx.wear.tiles.DimensionBuilders.dp(88);
/** Returns the recommended icon size for the given size of a {@link Button}. */
- @NonNull
- public static androidx.wear.tiles.DimensionBuilders.DpProp recommendedIconSize(
- @NonNull androidx.wear.tiles.DimensionBuilders.DpProp buttonSize) {
+ public static androidx.wear.tiles.DimensionBuilders.@NonNull DpProp recommendedIconSize(
+ androidx.wear.tiles.DimensionBuilders.@NonNull DpProp buttonSize) {
return recommendedIconSize(buttonSize.getValue());
}
/** Returns the recommended icon size for the given size of a {@link Button}. */
- @NonNull
- public static androidx.wear.tiles.DimensionBuilders.DpProp recommendedIconSize(
+ public static androidx.wear.tiles.DimensionBuilders.@NonNull DpProp recommendedIconSize(
@Dimension(unit = DP) float buttonSize) {
return androidx.wear.tiles.DimensionBuilders.dp(buttonSize / 2);
}
/** The recommended colors for a primary {@link Button}. */
- @NonNull
- public static final ButtonColors PRIMARY_COLORS =
+ public static final @NonNull ButtonColors PRIMARY_COLORS =
ButtonColors.primaryButtonColors(Colors.DEFAULT);
/** The recommended colors for a secondary {@link Button}. */
- @NonNull
- public static final ButtonColors SECONDARY_COLORS =
+ public static final @NonNull ButtonColors SECONDARY_COLORS =
ButtonColors.secondaryButtonColors(Colors.DEFAULT);
}
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Chip.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Chip.java
index 741a1a2..bef10f1 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Chip.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Chip.java
@@ -22,13 +22,14 @@
import androidx.annotation.Dimension;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.HashMap;
@@ -91,9 +92,9 @@
*/
static final String METADATA_TAG_CUSTOM_CONTENT = "CSTCHP";
- @NonNull private final androidx.wear.tiles.LayoutElementBuilders.Box mElement;
+ private final androidx.wear.tiles.LayoutElementBuilders.@NonNull Box mElement;
- Chip(@NonNull androidx.wear.tiles.LayoutElementBuilders.Box element) {
+ Chip(androidx.wear.tiles.LayoutElementBuilders.@NonNull Box element) {
mElement = element;
}
@@ -110,19 +111,19 @@
@IntDef({NOT_SET, TEXT, ICON, CUSTOM_CONTENT})
@interface ChipType {}
- @NonNull private final Context mContext;
- @Nullable private androidx.wear.tiles.LayoutElementBuilders.LayoutElement mCustomContent;
- @Nullable private String mImageResourceId = null;
- @Nullable private String mPrimaryLabel = null;
- @Nullable private String mSecondaryLabel = null;
- @NonNull private final androidx.wear.tiles.ModifiersBuilders.Clickable mClickable;
- @NonNull private CharSequence mContentDescription = "";
- @NonNull private androidx.wear.tiles.DimensionBuilders.ContainerDimension mWidth;
+ private final @NonNull Context mContext;
+ private androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement mCustomContent;
+ private @Nullable String mImageResourceId = null;
+ private @Nullable String mPrimaryLabel = null;
+ private @Nullable String mSecondaryLabel = null;
+ private final androidx.wear.tiles.ModifiersBuilders.@NonNull Clickable mClickable;
+ private @NonNull CharSequence mContentDescription = "";
+ private androidx.wear.tiles.DimensionBuilders.@NonNull ContainerDimension mWidth;
- @NonNull
- private androidx.wear.tiles.DimensionBuilders.DpProp mHeight = ChipDefaults.DEFAULT_HEIGHT;
+ private androidx.wear.tiles.DimensionBuilders.@NonNull DpProp mHeight =
+ ChipDefaults.DEFAULT_HEIGHT;
- @NonNull private ChipColors mChipColors = ChipDefaults.PRIMARY_COLORS;
+ private @NonNull ChipColors mChipColors = ChipDefaults.PRIMARY_COLORS;
@androidx.wear.tiles.LayoutElementBuilders.HorizontalAlignment
private int mHorizontalAlign =
@@ -130,15 +131,14 @@
@Typography.TypographyName private int mPrimaryLabelTypography;
- @NonNull
- private androidx.wear.tiles.DimensionBuilders.DpProp mHorizontalPadding =
+ private androidx.wear.tiles.DimensionBuilders.@NonNull DpProp mHorizontalPadding =
ChipDefaults.HORIZONTAL_PADDING;
private boolean mIsScalable = true;
private int mMaxLines = 0; // 0 indicates that is not set.
- @NonNull private String mMetadataTag = "";
+ private @NonNull String mMetadataTag = "";
- @NonNull static final Map<Integer, String> TYPE_TO_TAG = new HashMap<>();
+ static final @NonNull Map<Integer, String> TYPE_TO_TAG = new HashMap<>();
static {
TYPE_TO_TAG.put(ICON, METADATA_TAG_ICON);
@@ -157,10 +157,9 @@
*/
public Builder(
@NonNull Context context,
- @NonNull androidx.wear.tiles.ModifiersBuilders.Clickable clickable,
- @NonNull
- androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
- deviceParameters) {
+ androidx.wear.tiles.ModifiersBuilders.@NonNull Clickable clickable,
+ androidx.wear.tiles.DeviceParametersBuilders.@NonNull DeviceParameters
+ deviceParameters) {
mContext = context;
mClickable = clickable;
mWidth =
@@ -174,9 +173,8 @@
/**
* Sets the width of {@link Chip}. If not set, default value will be set to fill the screen.
*/
- @NonNull
- public Builder setWidth(
- @NonNull androidx.wear.tiles.DimensionBuilders.ContainerDimension width) {
+ public @NonNull Builder setWidth(
+ androidx.wear.tiles.DimensionBuilders.@NonNull ContainerDimension width) {
mWidth = width;
return this;
}
@@ -185,8 +183,7 @@
* Sets the width of {@link TitleChip}. If not set, default value will be set to fill the
* screen.
*/
- @NonNull
- public Builder setWidth(@Dimension(unit = DP) float width) {
+ public @NonNull Builder setWidth(@Dimension(unit = DP) float width) {
mWidth = androidx.wear.tiles.DimensionBuilders.dp(width);
return this;
}
@@ -195,9 +192,8 @@
* Sets the custom content for the {@link Chip}. Any previously added content will be
* overridden.
*/
- @NonNull
- public Builder setCustomContent(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement content) {
+ public @NonNull Builder setCustomContent(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement content) {
this.mCustomContent = content;
this.mPrimaryLabel = "";
this.mSecondaryLabel = "";
@@ -209,8 +205,7 @@
* Sets the content description for the {@link Chip}. It is highly recommended to provide
* this for chip containing icon.
*/
- @NonNull
- public Builder setContentDescription(@NonNull CharSequence contentDescription) {
+ public @NonNull Builder setContentDescription(@NonNull CharSequence contentDescription) {
this.mContentDescription = contentDescription;
return this;
}
@@ -220,8 +215,7 @@
* overridden. Primary label can be on 1 or 2 lines, depending on the length and existence
* of secondary label.
*/
- @NonNull
- public Builder setPrimaryLabelContent(@NonNull String primaryLabel) {
+ public @NonNull Builder setPrimaryLabelContent(@NonNull String primaryLabel) {
this.mPrimaryLabel = primaryLabel;
this.mCustomContent = null;
return this;
@@ -232,8 +226,7 @@
*
* <p>Sets the font for the primary label and should only be used internally.
*/
- @NonNull
- Builder setPrimaryLabelTypography(@Typography.TypographyName int typography) {
+ @NonNull Builder setPrimaryLabelTypography(@Typography.TypographyName int typography) {
this.mPrimaryLabelTypography = typography;
return this;
}
@@ -243,8 +236,7 @@
*
* <p>Sets whether the font for the primary label is scalable.
*/
- @NonNull
- Builder setIsPrimaryLabelScalable(boolean isScalable) {
+ @NonNull Builder setIsPrimaryLabelScalable(boolean isScalable) {
this.mIsScalable = isScalable;
return this;
}
@@ -254,8 +246,7 @@
* be overridden. If secondary label is set, primary label must be set too with {@link
* #setPrimaryLabelContent}.
*/
- @NonNull
- public Builder setSecondaryLabelContent(@NonNull String secondaryLabel) {
+ public @NonNull Builder setSecondaryLabelContent(@NonNull String secondaryLabel) {
this.mSecondaryLabel = secondaryLabel;
this.mCustomContent = null;
return this;
@@ -267,8 +258,7 @@
* ChipColors}. This icon should be image with chosen alpha channel and not an actual image.
* If icon is set, primary label must be set too with {@link #setPrimaryLabelContent}.
*/
- @NonNull
- public Builder setIconContent(@NonNull String imageResourceId) {
+ public @NonNull Builder setIconContent(@NonNull String imageResourceId) {
this.mImageResourceId = imageResourceId;
this.mCustomContent = null;
return this;
@@ -281,8 +271,7 @@
* ChipColors#getIconColor()} will be used as color for the icon itself. If not set, {@link
* ChipDefaults#PRIMARY_COLORS} will be used.
*/
- @NonNull
- public Builder setChipColors(@NonNull ChipColors chipColors) {
+ public @NonNull Builder setChipColors(@NonNull ChipColors chipColors) {
mChipColors = chipColors;
return this;
}
@@ -295,8 +284,7 @@
* androidx.wear.tiles.LayoutElementBuilders.HorizontalAlignment#HORIZONTAL_ALIGN_START}
* will be used.
*/
- @NonNull
- public Builder setHorizontalAlignment(
+ public @NonNull Builder setHorizontalAlignment(
@androidx.wear.tiles.LayoutElementBuilders.HorizontalAlignment
int horizontalAlignment) {
mHorizontalAlign = horizontalAlignment;
@@ -304,38 +292,33 @@
}
/** Used for creating CompactChip and TitleChip. */
- @NonNull
- Builder setHorizontalPadding(
- @NonNull androidx.wear.tiles.DimensionBuilders.DpProp horizontalPadding) {
+ @NonNull Builder setHorizontalPadding(
+ androidx.wear.tiles.DimensionBuilders.@NonNull DpProp horizontalPadding) {
this.mHorizontalPadding = horizontalPadding;
return this;
}
/** Used for creating CompactChip and TitleChip. */
- @NonNull
- Builder setHeight(@NonNull androidx.wear.tiles.DimensionBuilders.DpProp height) {
+ @NonNull Builder setHeight(androidx.wear.tiles.DimensionBuilders.@NonNull DpProp height) {
this.mHeight = height;
return this;
}
/** Used for creating CompactChip and TitleChip. */
- @NonNull
- Builder setMaxLines(int maxLines) {
+ @NonNull Builder setMaxLines(int maxLines) {
this.mMaxLines = maxLines;
return this;
}
/** Used for setting the correct tag in CompactChip and TitleChip. */
- @NonNull
- Builder setMetadataTag(@NonNull String metadataTag) {
+ @NonNull Builder setMetadataTag(@NonNull String metadataTag) {
this.mMetadataTag = metadataTag;
return this;
}
/** Constructs and returns {@link Chip} with the provided content and look. */
- @NonNull
@Override
- public Chip build() {
+ public @NonNull Chip build() {
androidx.wear.tiles.ModifiersBuilders.Modifiers.Builder modifiers =
new androidx.wear.tiles.ModifiersBuilders.Modifiers.Builder()
.setClickable(mClickable)
@@ -374,8 +357,7 @@
return new Chip(element.build());
}
- @NonNull
- private String getCorrectContentDescription() {
+ private @NonNull String getCorrectContentDescription() {
if (mContentDescription.length() == 0) {
mContentDescription = "";
if (mPrimaryLabel != null) {
@@ -414,8 +396,8 @@
return METADATA_TAG_TEXT;
}
- @NonNull
- private androidx.wear.tiles.LayoutElementBuilders.LayoutElement getCorrectContent() {
+ private androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement
+ getCorrectContent() {
if (mCustomContent != null) {
return mCustomContent;
}
@@ -493,41 +475,36 @@
}
private androidx.wear.tiles.LayoutElementBuilders.Box.Builder putLayoutInBox(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement element) {
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement element) {
// Wrapped and centered content are default.
return new androidx.wear.tiles.LayoutElementBuilders.Box.Builder().addContent(element);
}
}
/** Returns height of this Chip. */
- @NonNull
- public androidx.wear.tiles.DimensionBuilders.ContainerDimension getHeight() {
+ public androidx.wear.tiles.DimensionBuilders.@NonNull ContainerDimension getHeight() {
return Helper.checkNotNull(mElement.getHeight());
}
/** Returns width of this Chip. */
- @NonNull
- public androidx.wear.tiles.DimensionBuilders.ContainerDimension getWidth() {
+ public androidx.wear.tiles.DimensionBuilders.@NonNull ContainerDimension getWidth() {
return Helper.checkNotNull(mElement.getWidth());
}
/** Returns click event action associated with this Chip. */
- @NonNull
- public androidx.wear.tiles.ModifiersBuilders.Clickable getClickable() {
+ public androidx.wear.tiles.ModifiersBuilders.@NonNull Clickable getClickable() {
return Helper.checkNotNull(Helper.checkNotNull(mElement.getModifiers()).getClickable());
}
/** Returns background color of this Chip. */
- @NonNull
- private androidx.wear.tiles.ColorBuilders.ColorProp getBackgroundColor() {
+ private androidx.wear.tiles.ColorBuilders.@NonNull ColorProp getBackgroundColor() {
return Helper.checkNotNull(
Helper.checkNotNull(Helper.checkNotNull(mElement.getModifiers()).getBackground())
.getColor());
}
/** Returns chip colors of this Chip. */
- @NonNull
- public ChipColors getChipColors() {
+ public @NonNull ChipColors getChipColors() {
androidx.wear.tiles.ColorBuilders.ColorProp backgroundColor = getBackgroundColor();
androidx.wear.tiles.ColorBuilders.ColorProp contentColor = null;
androidx.wear.tiles.ColorBuilders.ColorProp secondaryContentColor = null;
@@ -563,8 +540,7 @@
}
/** Returns content description of this Chip. */
- @Nullable
- public CharSequence getContentDescription() {
+ public @Nullable CharSequence getContentDescription() {
androidx.wear.tiles.ModifiersBuilders.Semantics semantics =
Helper.checkNotNull(mElement.getModifiers()).getSemantics();
if (semantics == null) {
@@ -574,8 +550,7 @@
}
/** Returns custom content from this Chip if it has been added. Otherwise, it returns null. */
- @Nullable
- public androidx.wear.tiles.LayoutElementBuilders.LayoutElement getCustomContent() {
+ public androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement getCustomContent() {
if (getMetadataTag().equals(METADATA_TAG_CUSTOM_CONTENT)) {
return Helper.checkNotNull(Helper.checkNotNull(mElement.getContents()).get(0));
}
@@ -583,38 +558,32 @@
}
/** Returns primary label from this Chip if it has been added. Otherwise, it returns null. */
- @Nullable
- public String getPrimaryLabelContent() {
+ public @Nullable String getPrimaryLabelContent() {
Text primaryLabel = getPrimaryLabelContentObject();
return primaryLabel != null ? primaryLabel.getText() : null;
}
/** Returns secondary label from this Chip if it has been added. Otherwise, it returns null. */
- @Nullable
- public String getSecondaryLabelContent() {
+ public @Nullable String getSecondaryLabelContent() {
Text label = getSecondaryLabelContentObject();
return label != null ? label.getText() : null;
}
/** Returns icon id from this Chip if it has been added. Otherwise, it returns null. */
- @Nullable
- public String getIconContent() {
+ public @Nullable String getIconContent() {
androidx.wear.tiles.LayoutElementBuilders.Image icon = getIconContentObject();
return icon != null ? Helper.checkNotNull(icon.getResourceId()).getValue() : null;
}
- @Nullable
- private Text getPrimaryLabelContentObject() {
+ private @Nullable Text getPrimaryLabelContentObject() {
return getPrimaryOrSecondaryLabelContent(0);
}
- @Nullable
- private Text getSecondaryLabelContentObject() {
+ private @Nullable Text getSecondaryLabelContentObject() {
return getPrimaryOrSecondaryLabelContent(1);
}
- @Nullable
- private androidx.wear.tiles.LayoutElementBuilders.Image getIconContentObject() {
+ private androidx.wear.tiles.LayoutElementBuilders.@Nullable Image getIconContentObject() {
if (!getMetadataTag().equals(METADATA_TAG_ICON)) {
return null;
}
@@ -624,8 +593,7 @@
.get(0));
}
- @Nullable
- private Text getPrimaryOrSecondaryLabelContent(int index) {
+ private @Nullable Text getPrimaryOrSecondaryLabelContent(int index) {
String metadataTag = getMetadataTag();
if (metadataTag.equals(METADATA_TAG_CUSTOM_CONTENT)) {
return null;
@@ -669,8 +637,7 @@
}
/** Returns metadata tag set to this Chip. */
- @NonNull
- String getMetadataTag() {
+ @NonNull String getMetadataTag() {
return Helper.getMetadataTagName(
Helper.checkNotNull(Helper.checkNotNull(mElement.getModifiers()).getMetadata()));
}
@@ -681,9 +648,8 @@
* container.getContents().get(index)}) if that element can be converted to Chip. Otherwise, it
* will return null.
*/
- @Nullable
- public static Chip fromLayoutElement(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement element) {
+ public static @Nullable Chip fromLayoutElement(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement element) {
if (element instanceof Chip) {
return (Chip) element;
}
@@ -699,17 +665,15 @@
return new Chip(boxElement);
}
- @NonNull
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mElement.toLayoutElementProto();
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
@Override
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mElement.getFingerprint();
}
}
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ChipColors.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ChipColors.java
index 18ae16e..8eb19b4 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ChipColors.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ChipColors.java
@@ -17,7 +17,8 @@
package androidx.wear.tiles.material;
import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
+
+import org.jspecify.annotations.NonNull;
/**
* Represents the background and content colors used in a chip Tiles component.
@@ -32,10 +33,10 @@
@Deprecated
@SuppressWarnings("deprecation")
public class ChipColors {
- @NonNull private final androidx.wear.tiles.ColorBuilders.ColorProp mBackgroundColor;
- @NonNull private final androidx.wear.tiles.ColorBuilders.ColorProp mIconColor;
- @NonNull private final androidx.wear.tiles.ColorBuilders.ColorProp mContentColor;
- @NonNull private final androidx.wear.tiles.ColorBuilders.ColorProp mSecondaryContentColor;
+ private final androidx.wear.tiles.ColorBuilders.@NonNull ColorProp mBackgroundColor;
+ private final androidx.wear.tiles.ColorBuilders.@NonNull ColorProp mIconColor;
+ private final androidx.wear.tiles.ColorBuilders.@NonNull ColorProp mContentColor;
+ private final androidx.wear.tiles.ColorBuilders.@NonNull ColorProp mSecondaryContentColor;
/**
* Constructor for the {@link ChipColors} object.
@@ -85,10 +86,10 @@
* component.
*/
public ChipColors(
- @NonNull androidx.wear.tiles.ColorBuilders.ColorProp backgroundColor,
- @NonNull androidx.wear.tiles.ColorBuilders.ColorProp iconColor,
- @NonNull androidx.wear.tiles.ColorBuilders.ColorProp contentColor,
- @NonNull androidx.wear.tiles.ColorBuilders.ColorProp secondaryContentColor) {
+ androidx.wear.tiles.ColorBuilders.@NonNull ColorProp backgroundColor,
+ androidx.wear.tiles.ColorBuilders.@NonNull ColorProp iconColor,
+ androidx.wear.tiles.ColorBuilders.@NonNull ColorProp contentColor,
+ androidx.wear.tiles.ColorBuilders.@NonNull ColorProp secondaryContentColor) {
mBackgroundColor = backgroundColor;
mIconColor = iconColor;
mContentColor = contentColor;
@@ -102,8 +103,8 @@
* @param contentColor The content color to be used for all items inside a chip Tiles component.
*/
public ChipColors(
- @NonNull androidx.wear.tiles.ColorBuilders.ColorProp backgroundColor,
- @NonNull androidx.wear.tiles.ColorBuilders.ColorProp contentColor) {
+ androidx.wear.tiles.ColorBuilders.@NonNull ColorProp backgroundColor,
+ androidx.wear.tiles.ColorBuilders.@NonNull ColorProp contentColor) {
mBackgroundColor = backgroundColor;
mIconColor = contentColor;
mContentColor = contentColor;
@@ -114,8 +115,7 @@
* Returns a {@link ChipColors} object, using the current Primary colors from the given {@link
* Colors}.
*/
- @NonNull
- public static ChipColors primaryChipColors(@NonNull Colors colors) {
+ public static @NonNull ChipColors primaryChipColors(@NonNull Colors colors) {
return new ChipColors(colors.getPrimary(), colors.getOnPrimary());
}
@@ -123,32 +123,27 @@
* Returns a {@link ChipColors} object, using the current Surface colors from the given {@link
* Colors}.
*/
- @NonNull
- public static ChipColors secondaryChipColors(@NonNull Colors colors) {
+ public static @NonNull ChipColors secondaryChipColors(@NonNull Colors colors) {
return new ChipColors(colors.getSurface(), colors.getOnSurface());
}
/** The background color to be used on a chip Tiles components. */
- @NonNull
- public androidx.wear.tiles.ColorBuilders.ColorProp getBackgroundColor() {
+ public androidx.wear.tiles.ColorBuilders.@NonNull ColorProp getBackgroundColor() {
return mBackgroundColor;
}
/** The icon color to be used on a chip Tiles components. */
- @NonNull
- public androidx.wear.tiles.ColorBuilders.ColorProp getIconColor() {
+ public androidx.wear.tiles.ColorBuilders.@NonNull ColorProp getIconColor() {
return mIconColor;
}
/** The main text color to be used on a chip Tiles components. */
- @NonNull
- public androidx.wear.tiles.ColorBuilders.ColorProp getContentColor() {
+ public androidx.wear.tiles.ColorBuilders.@NonNull ColorProp getContentColor() {
return mContentColor;
}
/** The label text color to be used on a chip Tiles components. */
- @NonNull
- public androidx.wear.tiles.ColorBuilders.ColorProp getSecondaryContentColor() {
+ public androidx.wear.tiles.ColorBuilders.@NonNull ColorProp getSecondaryContentColor() {
return mSecondaryContentColor;
}
}
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ChipDefaults.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ChipDefaults.java
index ccdc94d..f848a1e 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ChipDefaults.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ChipDefaults.java
@@ -16,10 +16,11 @@
package androidx.wear.tiles.material;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
+import org.jspecify.annotations.NonNull;
+
/**
* Contains the default values used by chip Tiles components.
*
@@ -33,26 +34,22 @@
/** The default height for standard {@link Chip} */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final androidx.wear.tiles.DimensionBuilders.DpProp DEFAULT_HEIGHT =
+ public static final androidx.wear.tiles.DimensionBuilders.@NonNull DpProp DEFAULT_HEIGHT =
androidx.wear.tiles.DimensionBuilders.dp(52);
/** The default height for standard {@link CompactChip} */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final androidx.wear.tiles.DimensionBuilders.DpProp COMPACT_HEIGHT =
+ public static final androidx.wear.tiles.DimensionBuilders.@NonNull DpProp COMPACT_HEIGHT =
androidx.wear.tiles.DimensionBuilders.dp(32);
/** The default height of tappable area for standard {@link CompactChip} */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final androidx.wear.tiles.DimensionBuilders.DpProp COMPACT_HEIGHT_TAPPABLE =
- androidx.wear.tiles.DimensionBuilders.dp(48);
+ public static final androidx.wear.tiles.DimensionBuilders.@NonNull DpProp
+ COMPACT_HEIGHT_TAPPABLE = androidx.wear.tiles.DimensionBuilders.dp(48);
/** The default height for standard {@link TitleChip} */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final androidx.wear.tiles.DimensionBuilders.DpProp TITLE_HEIGHT =
+ public static final androidx.wear.tiles.DimensionBuilders.@NonNull DpProp TITLE_HEIGHT =
androidx.wear.tiles.DimensionBuilders.dp(60);
/** The recommended horizontal margin used for width for standard {@link Chip} */
@@ -61,60 +58,50 @@
/** The recommended horizontal padding for standard {@link Chip} */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final androidx.wear.tiles.DimensionBuilders.DpProp HORIZONTAL_PADDING =
+ public static final androidx.wear.tiles.DimensionBuilders.@NonNull DpProp HORIZONTAL_PADDING =
androidx.wear.tiles.DimensionBuilders.dp(14);
/** The recommended horizontal padding for standard {@link CompactChip} */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final androidx.wear.tiles.DimensionBuilders.DpProp COMPACT_HORIZONTAL_PADDING =
- androidx.wear.tiles.DimensionBuilders.dp(12);
+ public static final androidx.wear.tiles.DimensionBuilders.@NonNull DpProp
+ COMPACT_HORIZONTAL_PADDING = androidx.wear.tiles.DimensionBuilders.dp(12);
/** The recommended horizontal padding for standard {@link TitleChip} */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final androidx.wear.tiles.DimensionBuilders.DpProp TITLE_HORIZONTAL_PADDING =
- androidx.wear.tiles.DimensionBuilders.dp(16);
+ public static final androidx.wear.tiles.DimensionBuilders.@NonNull DpProp
+ TITLE_HORIZONTAL_PADDING = androidx.wear.tiles.DimensionBuilders.dp(16);
/** The recommended vertical space between icon and text in standard {@link Chip} */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final androidx.wear.tiles.DimensionBuilders.DpProp ICON_SPACER_WIDTH =
+ public static final androidx.wear.tiles.DimensionBuilders.@NonNull DpProp ICON_SPACER_WIDTH =
androidx.wear.tiles.DimensionBuilders.dp(6);
/** The icon size used in standard {@link Chip} */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final androidx.wear.tiles.DimensionBuilders.DpProp ICON_SIZE =
+ public static final androidx.wear.tiles.DimensionBuilders.@NonNull DpProp ICON_SIZE =
androidx.wear.tiles.DimensionBuilders.dp(24);
/** The recommended colors for a primary {@link Chip}. */
- @NonNull
- public static final ChipColors PRIMARY_COLORS = ChipColors.primaryChipColors(Colors.DEFAULT);
+ public static final @NonNull ChipColors PRIMARY_COLORS =
+ ChipColors.primaryChipColors(Colors.DEFAULT);
/** The recommended colors for a secondary {@link Chip}. */
- @NonNull
- public static final ChipColors SECONDARY_COLORS =
+ public static final @NonNull ChipColors SECONDARY_COLORS =
ChipColors.secondaryChipColors(Colors.DEFAULT);
/** The recommended colors for a primary {@link CompactChip}. */
- @NonNull
- public static final ChipColors COMPACT_PRIMARY_COLORS =
+ public static final @NonNull ChipColors COMPACT_PRIMARY_COLORS =
ChipColors.primaryChipColors(Colors.DEFAULT);
/** The recommended colors for a secondary {@link CompactChip}. */
- @NonNull
- public static final ChipColors COMPACT_SECONDARY_COLORS =
+ public static final @NonNull ChipColors COMPACT_SECONDARY_COLORS =
ChipColors.secondaryChipColors(Colors.DEFAULT);
/** The recommended colors for a primary {@link TitleChip}. */
- @NonNull
- public static final ChipColors TITLE_PRIMARY_COLORS =
+ public static final @NonNull ChipColors TITLE_PRIMARY_COLORS =
ChipColors.primaryChipColors(Colors.DEFAULT);
/** The recommended colors for a secondary {@link TitleChip}. */
- @NonNull
- public static final ChipColors TITLE_SECONDARY_COLORS =
+ public static final @NonNull ChipColors TITLE_SECONDARY_COLORS =
ChipColors.secondaryChipColors(Colors.DEFAULT);
}
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/CircularProgressIndicator.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/CircularProgressIndicator.java
index 4e83a9a..a417faf 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/CircularProgressIndicator.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/CircularProgressIndicator.java
@@ -20,13 +20,14 @@
import androidx.annotation.Dimension;
import androidx.annotation.FloatRange;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Tiles component {@link CircularProgressIndicator} that represents circular progress indicator
* which supports a gap in the circular track between startAngle and endAngle. [Progress Indicator
@@ -76,11 +77,11 @@
*/
static final String METADATA_TAG = "CPI";
- @NonNull private final androidx.wear.tiles.LayoutElementBuilders.Arc mElement;
- @NonNull private final androidx.wear.tiles.LayoutElementBuilders.ArcLine mProgress;
- @NonNull private final androidx.wear.tiles.LayoutElementBuilders.ArcLine mBackground;
+ private final androidx.wear.tiles.LayoutElementBuilders.@NonNull Arc mElement;
+ private final androidx.wear.tiles.LayoutElementBuilders.@NonNull ArcLine mProgress;
+ private final androidx.wear.tiles.LayoutElementBuilders.@NonNull ArcLine mBackground;
- CircularProgressIndicator(@NonNull androidx.wear.tiles.LayoutElementBuilders.Arc element) {
+ CircularProgressIndicator(androidx.wear.tiles.LayoutElementBuilders.@NonNull Arc element) {
this.mElement = element;
this.mBackground =
(androidx.wear.tiles.LayoutElementBuilders.ArcLine) element.getContents().get(0);
@@ -91,23 +92,19 @@
/** Builder class for {@link CircularProgressIndicator} */
public static final class Builder
implements androidx.wear.tiles.LayoutElementBuilders.LayoutElement.Builder {
- @NonNull
- private ProgressIndicatorColors mCircularProgressIndicatorColors =
+ private @NonNull ProgressIndicatorColors mCircularProgressIndicatorColors =
ProgressIndicatorDefaults.DEFAULT_COLORS;
- @NonNull
- private androidx.wear.tiles.DimensionBuilders.DpProp mStrokeWidth =
+ private androidx.wear.tiles.DimensionBuilders.@NonNull DpProp mStrokeWidth =
ProgressIndicatorDefaults.DEFAULT_STROKE_WIDTH;
- @NonNull private CharSequence mContentDescription = "";
+ private @NonNull CharSequence mContentDescription = "";
- @NonNull
- private androidx.wear.tiles.DimensionBuilders.DegreesProp mStartAngle =
+ private androidx.wear.tiles.DimensionBuilders.@NonNull DegreesProp mStartAngle =
androidx.wear.tiles.DimensionBuilders.degrees(
ProgressIndicatorDefaults.DEFAULT_START_ANGLE);
- @NonNull
- private androidx.wear.tiles.DimensionBuilders.DegreesProp mEndAngle =
+ private androidx.wear.tiles.DimensionBuilders.@NonNull DegreesProp mEndAngle =
androidx.wear.tiles.DimensionBuilders.degrees(
ProgressIndicatorDefaults.DEFAULT_END_ANGLE);
@@ -122,8 +119,8 @@
* from 0 to 1. Progress will be colored in {@link ProgressIndicatorColors#getTrackColor}.
* If not set, 0 will be used.
*/
- @NonNull
- public Builder setProgress(@FloatRange(from = 0, to = 1) float progressPercentage) {
+ public @NonNull Builder setProgress(
+ @FloatRange(from = 0, to = 1) float progressPercentage) {
this.mProgress = progressPercentage;
return this;
}
@@ -134,8 +131,7 @@
* start arc from the 9 o'clock. If not set 0 will be used and the indicator will have full
* length.
*/
- @NonNull
- public Builder setStartAngle(float startAngle) {
+ public @NonNull Builder setStartAngle(float startAngle) {
this.mStartAngle = androidx.wear.tiles.DimensionBuilders.degrees(startAngle);
return this;
}
@@ -145,8 +141,7 @@
* 0 is 12 o'clock. End angle doesn't need to be within 0-360 range, but it must be larger
* than start angle. If not set 360 will be used and the indicator will have full length.
*/
- @NonNull
- public Builder setEndAngle(float endAngle) {
+ public @NonNull Builder setEndAngle(float endAngle) {
this.mEndAngle = androidx.wear.tiles.DimensionBuilders.degrees(endAngle);
return this;
}
@@ -155,8 +150,7 @@
* Sets the content description of the {@link CircularProgressIndicator} to be used for
* accessibility support.
*/
- @NonNull
- public Builder setContentDescription(@NonNull CharSequence contentDescription) {
+ public @NonNull Builder setContentDescription(@NonNull CharSequence contentDescription) {
this.mContentDescription = contentDescription;
return this;
}
@@ -167,8 +161,7 @@
* made, while {@link ProgressIndicatorColors#getTrackColor()} will be used for a background
* full size arc. If not set, {@link ProgressIndicatorDefaults#DEFAULT_COLORS} will be used.
*/
- @NonNull
- public Builder setCircularProgressIndicatorColors(
+ public @NonNull Builder setCircularProgressIndicatorColors(
@NonNull ProgressIndicatorColors circularProgressIndicatorColors) {
this.mCircularProgressIndicatorColors = circularProgressIndicatorColors;
return this;
@@ -178,9 +171,8 @@
* Sets the stroke width of the {@link CircularProgressIndicator}. Strongly recommended
* value is {@link ProgressIndicatorDefaults#DEFAULT_STROKE_WIDTH}.
*/
- @NonNull
- public Builder setStrokeWidth(
- @NonNull androidx.wear.tiles.DimensionBuilders.DpProp strokeWidth) {
+ public @NonNull Builder setStrokeWidth(
+ androidx.wear.tiles.DimensionBuilders.@NonNull DpProp strokeWidth) {
this.mStrokeWidth = strokeWidth;
return this;
}
@@ -189,8 +181,7 @@
* Sets the stroke width of the {@link CircularProgressIndicator}. Strongly recommended
* value is {@link ProgressIndicatorDefaults#DEFAULT_STROKE_WIDTH}.
*/
- @NonNull
- public Builder setStrokeWidth(@Dimension(unit = DP) float strokeWidth) {
+ public @NonNull Builder setStrokeWidth(@Dimension(unit = DP) float strokeWidth) {
this.mStrokeWidth = androidx.wear.tiles.DimensionBuilders.dp(strokeWidth);
return this;
}
@@ -199,9 +190,8 @@
* Constructs and returns {@link CircularProgressIndicator} with the provided field and
* look.
*/
- @NonNull
@Override
- public CircularProgressIndicator build() {
+ public @NonNull CircularProgressIndicator build() {
checkAngles();
androidx.wear.tiles.DimensionBuilders.DegreesProp length = getLength();
@@ -268,8 +258,7 @@
}
}
- @NonNull
- private androidx.wear.tiles.DimensionBuilders.DegreesProp getLength() {
+ private androidx.wear.tiles.DimensionBuilders.@NonNull DegreesProp getLength() {
float startAngle = mStartAngle.getValue();
float endAngle = mEndAngle.getValue();
if (endAngle <= startAngle) {
@@ -280,26 +269,22 @@
}
/** Returns angle representing progressed part of this CircularProgressIndicator. */
- @NonNull
- public androidx.wear.tiles.DimensionBuilders.DegreesProp getProgress() {
+ public androidx.wear.tiles.DimensionBuilders.@NonNull DegreesProp getProgress() {
return androidx.wear.tiles.material.Helper.checkNotNull(mProgress.getLength());
}
/** Returns stroke width of this CircularProgressIndicator. */
- @NonNull
- public androidx.wear.tiles.DimensionBuilders.DpProp getStrokeWidth() {
+ public androidx.wear.tiles.DimensionBuilders.@NonNull DpProp getStrokeWidth() {
return androidx.wear.tiles.material.Helper.checkNotNull(mProgress.getThickness());
}
/** Returns start angle of this CircularProgressIndicator. */
- @NonNull
- public androidx.wear.tiles.DimensionBuilders.DegreesProp getStartAngle() {
+ public androidx.wear.tiles.DimensionBuilders.@NonNull DegreesProp getStartAngle() {
return androidx.wear.tiles.material.Helper.checkNotNull(mElement.getAnchorAngle());
}
/** Returns start angle of this CircularProgressIndicator. */
- @NonNull
- public androidx.wear.tiles.DimensionBuilders.DegreesProp getEndAngle() {
+ public androidx.wear.tiles.DimensionBuilders.@NonNull DegreesProp getEndAngle() {
float backArcLength =
androidx.wear.tiles.material.Helper.checkNotNull(mBackground.getLength())
.getValue();
@@ -308,16 +293,14 @@
}
/** Returns main arc color of this CircularProgressIndicator. */
- @NonNull
- public ProgressIndicatorColors getCircularProgressIndicatorColors() {
+ public @NonNull ProgressIndicatorColors getCircularProgressIndicatorColors() {
return new ProgressIndicatorColors(
androidx.wear.tiles.material.Helper.checkNotNull(mProgress.getColor()),
androidx.wear.tiles.material.Helper.checkNotNull(mBackground.getColor()));
}
/** Returns content description of this CircularProgressIndicator. */
- @Nullable
- public CharSequence getContentDescription() {
+ public @Nullable CharSequence getContentDescription() {
androidx.wear.tiles.ModifiersBuilders.Semantics semantics =
androidx.wear.tiles.material.Helper.checkNotNull(mElement.getModifiers())
.getSemantics();
@@ -331,8 +314,7 @@
* Returns metadata tag set to this CircularProgressIndicator, which should be {@link
* #METADATA_TAG}.
*/
- @NonNull
- String getMetadataTag() {
+ @NonNull String getMetadataTag() {
return androidx.wear.tiles.material.Helper.getMetadataTagName(
androidx.wear.tiles.material.Helper.checkNotNull(
androidx.wear.tiles.material.Helper.checkNotNull(mElement.getModifiers())
@@ -345,9 +327,8 @@
* container's content with {@code container.getContents().get(index)}) if that element can be
* converted to CircularProgressIndicator. Otherwise, it will return null.
*/
- @Nullable
- public static CircularProgressIndicator fromLayoutElement(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement element) {
+ public static @Nullable CircularProgressIndicator fromLayoutElement(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement element) {
if (element instanceof CircularProgressIndicator) {
return (CircularProgressIndicator) element;
}
@@ -364,17 +345,15 @@
return new CircularProgressIndicator(arcElement);
}
- @NonNull
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mElement.toLayoutElementProto();
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
@Override
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mElement.getFingerprint();
}
}
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Colors.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Colors.java
index f638b1f..63af19d 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Colors.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Colors.java
@@ -17,10 +17,11 @@
package androidx.wear.tiles.material;
import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
+import org.jspecify.annotations.NonNull;
+
/**
* Represent the container for default color scheme in your Tile, that can be used to create color
* objects for all Material components.
@@ -55,8 +56,8 @@
public static final int ON_SURFACE = 0xFFFFFFFF;
/** The default color scheme to be used in Tiles Material components. */
- @NonNull
- public static final Colors DEFAULT = new Colors(PRIMARY, ON_PRIMARY, SURFACE, ON_SURFACE);
+ public static final @NonNull Colors DEFAULT =
+ new Colors(PRIMARY, ON_PRIMARY, SURFACE, ON_SURFACE);
private @ColorInt final int mPrimary;
private @ColorInt final int mOnPrimary;
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/CompactChip.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/CompactChip.java
index ef9e6ba..bde902d 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/CompactChip.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/CompactChip.java
@@ -18,13 +18,14 @@
import android.content.Context;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Tiles component {@link CompactChip} that represents clickable object with the text.
*
@@ -67,10 +68,10 @@
*/
static final String METADATA_TAG = "CMPCHP";
- @NonNull private final androidx.wear.tiles.LayoutElementBuilders.Box mImpl;
- @NonNull private final Chip mElement;
+ private final androidx.wear.tiles.LayoutElementBuilders.@NonNull Box mImpl;
+ private final @NonNull Chip mElement;
- CompactChip(@NonNull androidx.wear.tiles.LayoutElementBuilders.Box element) {
+ CompactChip(androidx.wear.tiles.LayoutElementBuilders.@NonNull Box element) {
this.mImpl = element;
// We know for sure that content of the androidx.wear.tiles.LayoutElementBuilders.Box is
// Chip.
@@ -83,15 +84,14 @@
/** Builder class for {@link androidx.wear.tiles.material.CompactChip}. */
public static final class Builder
implements androidx.wear.tiles.LayoutElementBuilders.LayoutElement.Builder {
- @NonNull private final Context mContext;
- @NonNull private final String mText;
- @NonNull private final androidx.wear.tiles.ModifiersBuilders.Clickable mClickable;
+ private final @NonNull Context mContext;
+ private final @NonNull String mText;
+ private final androidx.wear.tiles.ModifiersBuilders.@NonNull Clickable mClickable;
- @NonNull
- private final androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
+ private final androidx.wear.tiles.DeviceParametersBuilders.@NonNull DeviceParameters
mDeviceParameters;
- @NonNull private ChipColors mChipColors = ChipDefaults.COMPACT_PRIMARY_COLORS;
+ private @NonNull ChipColors mChipColors = ChipDefaults.COMPACT_PRIMARY_COLORS;
/**
* Creates a builder for the {@link CompactChip} with associated action and the given text
@@ -105,9 +105,8 @@
public Builder(
@NonNull Context context,
@NonNull String text,
- @NonNull androidx.wear.tiles.ModifiersBuilders.Clickable clickable,
- @NonNull
- androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
+ androidx.wear.tiles.ModifiersBuilders.@NonNull Clickable clickable,
+ androidx.wear.tiles.DeviceParametersBuilders.@NonNull DeviceParameters
deviceParameters) {
this.mContext = context;
this.mText = text;
@@ -121,16 +120,14 @@
* ChipColors#getContentColor()} for the text. If not set, {@link
* ChipDefaults#COMPACT_PRIMARY_COLORS} will be used.
*/
- @NonNull
- public Builder setChipColors(@NonNull ChipColors chipColors) {
+ public @NonNull Builder setChipColors(@NonNull ChipColors chipColors) {
mChipColors = chipColors;
return this;
}
/** Constructs and returns {@link CompactChip} with the provided content and look. */
- @NonNull
@Override
- public CompactChip build() {
+ public @NonNull CompactChip build() {
Chip.Builder chipBuilder =
new Chip.Builder(mContext, mClickable, mDeviceParameters)
.setMetadataTag(METADATA_TAG)
@@ -173,26 +170,22 @@
}
/** Returns click event action associated with this Chip. */
- @NonNull
- public androidx.wear.tiles.ModifiersBuilders.Clickable getClickable() {
+ public androidx.wear.tiles.ModifiersBuilders.@NonNull Clickable getClickable() {
return mElement.getClickable();
}
/** Returns chip color of this Chip. */
- @NonNull
- public ChipColors getChipColors() {
+ public @NonNull ChipColors getChipColors() {
return mElement.getChipColors();
}
/** Returns text content of this Chip. */
- @NonNull
- public String getText() {
+ public @NonNull String getText() {
return androidx.wear.tiles.material.Helper.checkNotNull(mElement.getPrimaryLabelContent());
}
/** Returns metadata tag set to this CompactChip, which should be {@link #METADATA_TAG}. */
- @NonNull
- String getMetadataTag() {
+ @NonNull String getMetadataTag() {
return mElement.getMetadataTag();
}
@@ -202,9 +195,8 @@
* container's content with {@code container.getContents().get(index)}) if that element can be
* converted to CompactChip. Otherwise, it will return null.
*/
- @Nullable
- public static CompactChip fromLayoutElement(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement element) {
+ public static @Nullable CompactChip fromLayoutElement(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement element) {
if (element instanceof CompactChip) {
return (CompactChip) element;
}
@@ -236,16 +228,14 @@
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
@Override
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mImpl.toLayoutElementProto();
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
@Override
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mImpl.getFingerprint();
}
}
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Helper.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Helper.java
index d81e33f..8253cba 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Helper.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Helper.java
@@ -16,11 +16,12 @@
package androidx.wear.tiles.material;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
@@ -39,8 +40,7 @@
/** Returns given value if not null or throws {@code NullPointerException} otherwise. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static <T> T checkNotNull(@Nullable T value) {
+ public static <T> @NonNull T checkNotNull(@Nullable T value) {
if (value == null) {
throw new NullPointerException();
}
@@ -50,8 +50,7 @@
/**
* Returns radius in {@link androidx.wear.tiles.DimensionBuilders.DpProp} of the given diameter.
*/
- @NonNull
- static androidx.wear.tiles.DimensionBuilders.DpProp radiusOf(
+ static androidx.wear.tiles.DimensionBuilders.@NonNull DpProp radiusOf(
androidx.wear.tiles.DimensionBuilders.DpProp diameter) {
return androidx.wear.tiles.DimensionBuilders.dp(diameter.getValue() / 2);
}
@@ -62,8 +61,7 @@
*/
@RestrictTo(Scope.LIBRARY_GROUP)
public static boolean isRoundDevice(
- @NonNull
- androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
+ androidx.wear.tiles.DeviceParametersBuilders.@NonNull DeviceParameters
deviceParameters) {
return deviceParameters.getScreenShape()
== androidx.wear.tiles.DeviceParametersBuilders.SCREEN_SHAPE_ROUND;
@@ -71,15 +69,13 @@
/** Returns String representation of tag from byte array. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static String getTagName(@NonNull byte[] tagData) {
+ public static @NonNull String getTagName(byte @NonNull [] tagData) {
return new String(tagData, StandardCharsets.UTF_8);
}
/** Returns byte array representation of tag from String. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static byte[] getTagBytes(@NonNull String tagName) {
+ public static byte @NonNull [] getTagBytes(@NonNull String tagName) {
return tagName.getBytes(StandardCharsets.UTF_8);
}
@@ -87,9 +83,8 @@
* Returns the String representation of metadata tag from the given
* androidx.wear.tiles.ModifiersBuilders.ElementMetadata.
*/
- @NonNull
- public static String getMetadataTagName(
- @NonNull androidx.wear.tiles.ModifiersBuilders.ElementMetadata metadata) {
+ public static @NonNull String getMetadataTagName(
+ androidx.wear.tiles.ModifiersBuilders.@NonNull ElementMetadata metadata) {
return getTagName(getMetadataTagBytes(metadata));
}
@@ -97,9 +92,8 @@
* Returns the metadata tag from the given
* androidx.wear.tiles.ModifiersBuilders.ElementMetadata.
*/
- @NonNull
- public static byte[] getMetadataTagBytes(
- @NonNull androidx.wear.tiles.ModifiersBuilders.ElementMetadata metadata) {
+ public static byte @NonNull [] getMetadataTagBytes(
+ androidx.wear.tiles.ModifiersBuilders.@NonNull ElementMetadata metadata) {
return checkNotNull(metadata).getTagData();
}
@@ -108,7 +102,7 @@
* set to the given String value.
*/
public static boolean checkTag(
- @Nullable androidx.wear.tiles.ModifiersBuilders.Modifiers modifiers,
+ androidx.wear.tiles.ModifiersBuilders.@Nullable Modifiers modifiers,
@NonNull String validTag) {
return modifiers != null
&& modifiers.getMetadata() != null
@@ -120,7 +114,7 @@
* set to any of the value in the given String collection.
*/
public static boolean checkTag(
- @Nullable androidx.wear.tiles.ModifiersBuilders.Modifiers modifiers,
+ androidx.wear.tiles.ModifiersBuilders.@Nullable Modifiers modifiers,
@NonNull Collection<String> validTags) {
return modifiers != null
&& modifiers.getMetadata() != null
@@ -132,9 +126,9 @@
* set with prefix that is equal to the given String and its length is of the given base array.
*/
public static boolean checkTag(
- @Nullable androidx.wear.tiles.ModifiersBuilders.Modifiers modifiers,
+ androidx.wear.tiles.ModifiersBuilders.@Nullable Modifiers modifiers,
@NonNull String validPrefix,
- @NonNull byte[] validBase) {
+ byte @NonNull [] validBase) {
if (modifiers == null || modifiers.getMetadata() == null) {
return false;
}
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ProgressIndicatorColors.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ProgressIndicatorColors.java
index 079f675f..04af668 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ProgressIndicatorColors.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ProgressIndicatorColors.java
@@ -17,7 +17,8 @@
package androidx.wear.tiles.material;
import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
+
+import org.jspecify.annotations.NonNull;
/**
* Represents the indicator and track colors used in a progress indicator Tiles component.
@@ -31,8 +32,8 @@
@Deprecated
@SuppressWarnings("deprecation")
public class ProgressIndicatorColors {
- @NonNull private final androidx.wear.tiles.ColorBuilders.ColorProp mIndicatorColor;
- @NonNull private final androidx.wear.tiles.ColorBuilders.ColorProp mTrackColor;
+ private final androidx.wear.tiles.ColorBuilders.@NonNull ColorProp mIndicatorColor;
+ private final androidx.wear.tiles.ColorBuilders.@NonNull ColorProp mTrackColor;
/**
* Constructor for {@link ProgressIndicatorColors} object.
@@ -43,8 +44,8 @@
* component.
*/
public ProgressIndicatorColors(
- @NonNull androidx.wear.tiles.ColorBuilders.ColorProp indicatorColor,
- @NonNull androidx.wear.tiles.ColorBuilders.ColorProp trackColor) {
+ androidx.wear.tiles.ColorBuilders.@NonNull ColorProp indicatorColor,
+ androidx.wear.tiles.ColorBuilders.@NonNull ColorProp trackColor) {
this.mIndicatorColor = indicatorColor;
this.mTrackColor = trackColor;
}
@@ -67,20 +68,17 @@
* indicator color and the current Surface color for the track color from the given {@link
* Colors}.
*/
- @NonNull
- public static ProgressIndicatorColors progressIndicatorColors(@NonNull Colors colors) {
+ public static @NonNull ProgressIndicatorColors progressIndicatorColors(@NonNull Colors colors) {
return new ProgressIndicatorColors(colors.getPrimary(), colors.getSurface());
}
/** The indicator color to be used for a progress indicator Tiles component. */
- @NonNull
- public androidx.wear.tiles.ColorBuilders.ColorProp getIndicatorColor() {
+ public androidx.wear.tiles.ColorBuilders.@NonNull ColorProp getIndicatorColor() {
return mIndicatorColor;
}
/** The background track color to be used for a progress indicator Tiles component. */
- @NonNull
- public androidx.wear.tiles.ColorBuilders.ColorProp getTrackColor() {
+ public androidx.wear.tiles.ColorBuilders.@NonNull ColorProp getTrackColor() {
return mTrackColor;
}
}
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ProgressIndicatorDefaults.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ProgressIndicatorDefaults.java
index ef92913..54c2c5b 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ProgressIndicatorDefaults.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/ProgressIndicatorDefaults.java
@@ -16,10 +16,11 @@
package androidx.wear.tiles.material;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
+import org.jspecify.annotations.NonNull;
+
/**
* Contains the default values used by {@link CircularProgressIndicator} Tiles components.
*
@@ -33,19 +34,16 @@
private ProgressIndicatorDefaults() {}
/** The default stroke width for {@link CircularProgressIndicator} */
- @NonNull
- public static final androidx.wear.tiles.DimensionBuilders.DpProp DEFAULT_STROKE_WIDTH =
+ public static final androidx.wear.tiles.DimensionBuilders.@NonNull DpProp DEFAULT_STROKE_WIDTH =
androidx.wear.tiles.DimensionBuilders.dp(8);
/** The default padding for {@link CircularProgressIndicator} */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static final androidx.wear.tiles.DimensionBuilders.DpProp DEFAULT_PADDING =
+ public static final androidx.wear.tiles.DimensionBuilders.@NonNull DpProp DEFAULT_PADDING =
androidx.wear.tiles.DimensionBuilders.dp(6);
/** The recommended colors for {@link CircularProgressIndicator}. */
- @NonNull
- public static final ProgressIndicatorColors DEFAULT_COLORS =
+ public static final @NonNull ProgressIndicatorColors DEFAULT_COLORS =
ProgressIndicatorColors.progressIndicatorColors(Colors.DEFAULT);
static final float DEFAULT_GAP_LENGTH = 47.8f;
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Text.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Text.java
index 2819794..ed5b641 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Text.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Text.java
@@ -19,14 +19,15 @@
import android.content.Context;
import androidx.annotation.IntRange;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.LayoutElementProto;
import androidx.wear.protolayout.proto.ModifiersProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Tiles component {@link Text} that represents text object holding any information.
*
@@ -64,20 +65,19 @@
*/
static final String METADATA_TAG = "TXT";
- @NonNull private final androidx.wear.tiles.LayoutElementBuilders.Text mText;
+ private final androidx.wear.tiles.LayoutElementBuilders.@NonNull Text mText;
- Text(@NonNull androidx.wear.tiles.LayoutElementBuilders.Text mText) {
+ Text(androidx.wear.tiles.LayoutElementBuilders.@NonNull Text mText) {
this.mText = mText;
}
/** Builder class for {@link Text}. */
public static final class Builder
implements androidx.wear.tiles.LayoutElementBuilders.LayoutElement.Builder {
- @NonNull private final Context mContext;
- @NonNull private String mTextContent = "";
+ private final @NonNull Context mContext;
+ private @NonNull String mTextContent = "";
- @NonNull
- private androidx.wear.tiles.ColorBuilders.ColorProp mColor =
+ private androidx.wear.tiles.ColorBuilders.@NonNull ColorProp mColor =
androidx.wear.tiles.ColorBuilders.argb(Colors.DEFAULT.getOnPrimary());
private @Typography.TypographyName int mTypographyName = Typography.TYPOGRAPHY_DISPLAY1;
@@ -89,14 +89,13 @@
private int mMultilineAlignment =
androidx.wear.tiles.LayoutElementBuilders.TEXT_ALIGN_CENTER;
- @NonNull
- private androidx.wear.tiles.ModifiersBuilders.Modifiers mModifiers =
+ private androidx.wear.tiles.ModifiersBuilders.@NonNull Modifiers mModifiers =
new androidx.wear.tiles.ModifiersBuilders.Modifiers.Builder().build();
private @androidx.wear.tiles.LayoutElementBuilders.TextOverflow int mOverflow =
androidx.wear.tiles.LayoutElementBuilders.TEXT_OVERFLOW_ELLIPSIZE_END;
private boolean mIsScalable = true;
- @Nullable private Integer mCustomWeight = null;
+ private @Nullable Integer mCustomWeight = null;
/**
* Creates a builder for {@link Text}.
@@ -113,12 +112,11 @@
* Sets the typography for the {@link Text}. If not set, {@link
* Typography#TYPOGRAPHY_DISPLAY1} will be used.
*/
- @NonNull
@SuppressWarnings("MissingGetterMatchingBuilder")
// There is getFontStyle matching getter for this setter as the serialized format of the
// Tiles do not allow for a direct reconstruction of the all arguments, but it has
// androidx.wear.tiles.LayoutElementBuilders.FontStyle object of that text.
- public Builder setTypography(@Typography.TypographyName int typography) {
+ public @NonNull Builder setTypography(@Typography.TypographyName int typography) {
this.mTypographyName = typography;
return this;
}
@@ -136,29 +134,26 @@
* Sets the color for the {@link Text}. If not set, onPrimary color from the {@link
* Colors#DEFAULT} will be used.
*/
- @NonNull
- public Builder setColor(@NonNull androidx.wear.tiles.ColorBuilders.ColorProp color) {
+ public @NonNull Builder setColor(
+ androidx.wear.tiles.ColorBuilders.@NonNull ColorProp color) {
this.mColor = color;
return this;
}
/** Sets the text to be italic. If not set, false will be used. */
- @NonNull
- public Builder setItalic(boolean italic) {
+ public @NonNull Builder setItalic(boolean italic) {
this.mItalic = italic;
return this;
}
/** Sets the text to be underlined. If not set, false will be used. */
- @NonNull
- public Builder setUnderline(boolean underline) {
+ public @NonNull Builder setUnderline(boolean underline) {
this.mUnderline = underline;
return this;
}
/** Sets the maximum lines of text. If not set, 1 will be used. */
- @NonNull
- public Builder setMaxLines(@IntRange(from = 1) int maxLines) {
+ public @NonNull Builder setMaxLines(@IntRange(from = 1) int maxLines) {
this.mMaxLines = maxLines;
return this;
}
@@ -169,17 +164,15 @@
* container should be used. If not set, {@link
* androidx.wear.tiles.LayoutElementBuilders.TextAlignment#TEXT_ALIGN_CENTER} will be used.
*/
- @NonNull
- public Builder setMultilineAlignment(
+ public @NonNull Builder setMultilineAlignment(
@androidx.wear.tiles.LayoutElementBuilders.TextAlignment int multilineAlignment) {
this.mMultilineAlignment = multilineAlignment;
return this;
}
/** Sets the modifiers of text. */
- @NonNull
- public Builder setModifiers(
- @NonNull androidx.wear.tiles.ModifiersBuilders.Modifiers modifiers) {
+ public @NonNull Builder setModifiers(
+ androidx.wear.tiles.ModifiersBuilders.@NonNull Modifiers modifiers) {
this.mModifiers = modifiers;
return this;
}
@@ -189,8 +182,7 @@
* androidx.wear.tiles.LayoutElementBuilders.TextAlignment#TEXT_OVERFLOW_ELLIPSIZE_END} will
* be used.
*/
- @NonNull
- public Builder setOverflow(
+ public @NonNull Builder setOverflow(
@androidx.wear.tiles.LayoutElementBuilders.TextOverflow int overflow) {
this.mOverflow = overflow;
return this;
@@ -200,16 +192,15 @@
* Sets the weight of the font. If not set, default weight for the chosen Typography will be
* used.
*/
- @NonNull
- public Builder setWeight(@androidx.wear.tiles.LayoutElementBuilders.FontWeight int weight) {
+ public @NonNull Builder setWeight(
+ @androidx.wear.tiles.LayoutElementBuilders.FontWeight int weight) {
this.mCustomWeight = weight;
return this;
}
/** Constructs and returns {@link Text} with the provided content and look. */
- @NonNull
@Override
- public Text build() {
+ public @NonNull Text build() {
androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder fontStyleBuilder =
Typography.getFontStyleBuilder(mTypographyName, mContext, mIsScalable)
.setColor(mColor)
@@ -231,8 +222,7 @@
return new Text(text.build());
}
- @NonNull
- static androidx.wear.tiles.ModifiersBuilders.Modifiers addTagToModifiers(
+ static androidx.wear.tiles.ModifiersBuilders.@NonNull Modifiers addTagToModifiers(
androidx.wear.tiles.ModifiersBuilders.Modifiers modifiers) {
return androidx.wear.tiles.ModifiersBuilders.Modifiers.fromProto(
ModifiersProto.Modifiers.newBuilder(modifiers.toProto())
@@ -250,22 +240,19 @@
}
/** Returns the text of this Text element. */
- @NonNull
- public String getText() {
+ public @NonNull String getText() {
return androidx.wear.tiles.material.Helper.checkNotNull(
androidx.wear.tiles.material.Helper.checkNotNull(mText.getText()).getValue());
}
/** Returns the color of this Text element. */
- @NonNull
- public androidx.wear.tiles.ColorBuilders.ColorProp getColor() {
+ public androidx.wear.tiles.ColorBuilders.@NonNull ColorProp getColor() {
return androidx.wear.tiles.material.Helper.checkNotNull(
androidx.wear.tiles.material.Helper.checkNotNull(mText.getFontStyle()).getColor());
}
/** Returns the font style of this Text element. */
- @NonNull
- public androidx.wear.tiles.LayoutElementBuilders.FontStyle getFontStyle() {
+ public androidx.wear.tiles.LayoutElementBuilders.@NonNull FontStyle getFontStyle() {
return androidx.wear.tiles.material.Helper.checkNotNull(mText.getFontStyle());
}
@@ -287,8 +274,7 @@
}
/** Returns the modifiers of this Text element. */
- @NonNull
- public androidx.wear.tiles.ModifiersBuilders.Modifiers getModifiers() {
+ public androidx.wear.tiles.ModifiersBuilders.@NonNull Modifiers getModifiers() {
return androidx.wear.tiles.material.Helper.checkNotNull(mText.getModifiers());
}
@@ -324,8 +310,7 @@
}
/** Returns metadata tag set to this Text, which should be {@link #METADATA_TAG}. */
- @NonNull
- String getMetadataTag() {
+ @NonNull String getMetadataTag() {
return androidx.wear.tiles.material.Helper.getMetadataTagName(
androidx.wear.tiles.material.Helper.checkNotNull(
androidx.wear.tiles.material.Helper.checkNotNull(getModifiers())
@@ -338,9 +323,8 @@
* container's content with {@code container.getContents().get(index)}) if that element can be
* converted to Material Text. Otherwise, it will return null.
*/
- @Nullable
- public static Text fromLayoutElement(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement element) {
+ public static @Nullable Text fromLayoutElement(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement element) {
if (element instanceof Text) {
return (Text) element;
}
@@ -357,17 +341,15 @@
return new Text(textElement);
}
- @NonNull
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mText.toLayoutElementProto();
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
@Override
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mText.getFingerprint();
}
}
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/TitleChip.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/TitleChip.java
index 18cd2a1..3622bb2 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/TitleChip.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/TitleChip.java
@@ -21,13 +21,14 @@
import android.content.Context;
import androidx.annotation.Dimension;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Tiles component {@link TitleChip} that represents clickable object with the text.
*
@@ -71,7 +72,7 @@
*/
static final String METADATA_TAG = "TTLCHP";
- @NonNull private final Chip mElement;
+ private final @NonNull Chip mElement;
TitleChip(@NonNull Chip element) {
this.mElement = element;
@@ -80,15 +81,14 @@
/** Builder class for {@link TitleChip}. */
public static final class Builder
implements androidx.wear.tiles.LayoutElementBuilders.LayoutElement.Builder {
- @NonNull private final Context mContext;
- @NonNull private final String mText;
- @NonNull private final androidx.wear.tiles.ModifiersBuilders.Clickable mClickable;
+ private final @NonNull Context mContext;
+ private final @NonNull String mText;
+ private final androidx.wear.tiles.ModifiersBuilders.@NonNull Clickable mClickable;
- @NonNull
- private final androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
+ private final androidx.wear.tiles.DeviceParametersBuilders.@NonNull DeviceParameters
mDeviceParameters;
- @NonNull private ChipColors mChipColors = ChipDefaults.TITLE_PRIMARY_COLORS;
+ private @NonNull ChipColors mChipColors = ChipDefaults.TITLE_PRIMARY_COLORS;
@androidx.wear.tiles.LayoutElementBuilders.HorizontalAlignment
private int mHorizontalAlign =
@@ -96,7 +96,7 @@
// Indicates that the width isn't set, so it will be automatically set by Chip.Builder
// constructor.
- @Nullable private androidx.wear.tiles.DimensionBuilders.ContainerDimension mWidth = null;
+ private androidx.wear.tiles.DimensionBuilders.@Nullable ContainerDimension mWidth = null;
/**
* Creates a builder for the {@link TitleChip} with associated action and the given text
@@ -111,9 +111,8 @@
public Builder(
@NonNull Context context,
@NonNull String text,
- @NonNull androidx.wear.tiles.ModifiersBuilders.Clickable clickable,
- @NonNull
- androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
+ androidx.wear.tiles.ModifiersBuilders.@NonNull Clickable clickable,
+ androidx.wear.tiles.DeviceParametersBuilders.@NonNull DeviceParameters
deviceParameters) {
this.mContext = context;
this.mText = text;
@@ -127,15 +126,13 @@
* ChipColors#getContentColor()} for the text. If not set, {@link
* ChipDefaults#TITLE_PRIMARY_COLORS} will be used.
*/
- @NonNull
- public Builder setChipColors(@NonNull ChipColors chipColors) {
+ public @NonNull Builder setChipColors(@NonNull ChipColors chipColors) {
mChipColors = chipColors;
return this;
}
/** Sets the horizontal alignment in the chip. If not set, content will be centered. */
- @NonNull
- public Builder setHorizontalAlignment(
+ public @NonNull Builder setHorizontalAlignment(
@androidx.wear.tiles.LayoutElementBuilders.HorizontalAlignment
int horizontalAlignment) {
mHorizontalAlign = horizontalAlignment;
@@ -146,9 +143,8 @@
* Sets the width of {@link TitleChip}. If not set, default value will be set to fill the
* screen.
*/
- @NonNull
- public Builder setWidth(
- @NonNull androidx.wear.tiles.DimensionBuilders.ContainerDimension width) {
+ public @NonNull Builder setWidth(
+ androidx.wear.tiles.DimensionBuilders.@NonNull ContainerDimension width) {
mWidth = width;
return this;
}
@@ -157,16 +153,14 @@
* Sets the width of {@link TitleChip}. If not set, default value will be set to fill the
* screen.
*/
- @NonNull
- public Builder setWidth(@Dimension(unit = DP) float width) {
+ public @NonNull Builder setWidth(@Dimension(unit = DP) float width) {
mWidth = androidx.wear.tiles.DimensionBuilders.dp(width);
return this;
}
/** Constructs and returns {@link TitleChip} with the provided content and look. */
- @NonNull
@Override
- public TitleChip build() {
+ public @NonNull TitleChip build() {
Chip.Builder chipBuilder =
new Chip.Builder(mContext, mClickable, mDeviceParameters)
.setMetadataTag(METADATA_TAG)
@@ -189,26 +183,22 @@
}
/** Returns width of this Chip. */
- @NonNull
- public androidx.wear.tiles.DimensionBuilders.ContainerDimension getWidth() {
+ public androidx.wear.tiles.DimensionBuilders.@NonNull ContainerDimension getWidth() {
return mElement.getWidth();
}
/** Returns click event action associated with this Chip. */
- @NonNull
- public androidx.wear.tiles.ModifiersBuilders.Clickable getClickable() {
+ public androidx.wear.tiles.ModifiersBuilders.@NonNull Clickable getClickable() {
return mElement.getClickable();
}
/** Returns chip color of this Chip. */
- @NonNull
- public ChipColors getChipColors() {
+ public @NonNull ChipColors getChipColors() {
return mElement.getChipColors();
}
/** Returns text content of this Chip. */
- @NonNull
- public String getText() {
+ public @NonNull String getText() {
return androidx.wear.tiles.material.Helper.checkNotNull(mElement.getPrimaryLabelContent());
}
@@ -219,8 +209,7 @@
}
/** Returns metadata tag set to this TitleChip, which should be {@link #METADATA_TAG}. */
- @NonNull
- String getMetadataTag() {
+ @NonNull String getMetadataTag() {
return mElement.getMetadataTag();
}
@@ -230,9 +219,8 @@
* container's content with {@code container.getContents().get(index)}) if that element can be
* converted to TitleChip. Otherwise, it will return null.
*/
- @Nullable
- public static TitleChip fromLayoutElement(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement element) {
+ public static @Nullable TitleChip fromLayoutElement(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement element) {
if (element instanceof TitleChip) {
return (TitleChip) element;
}
@@ -250,16 +238,14 @@
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
@Override
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mElement.toLayoutElementProto();
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
@Override
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mElement.getFingerprint();
}
}
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Typography.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Typography.java
index dd937c9..623b894 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Typography.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/Typography.java
@@ -25,9 +25,10 @@
import androidx.annotation.Dimension;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.HashMap;
@@ -97,8 +98,8 @@
@interface TypographyName {}
/** Mapping for line height for different typography. */
- @NonNull
- private static final Map<Integer, Float> TYPOGRAPHY_TO_LINE_HEIGHT_SP = new HashMap<>();
+ private static final @NonNull Map<Integer, Float> TYPOGRAPHY_TO_LINE_HEIGHT_SP =
+ new HashMap<>();
static {
TYPOGRAPHY_TO_LINE_HEIGHT_SP.put(TYPOGRAPHY_DISPLAY1, 46f);
@@ -120,8 +121,7 @@
* androidx.wear.tiles.LayoutElementBuilders.FontStyle code with the recommended size, weight
* and letter spacing. Font will be scalable.
*/
- @NonNull
- static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder getFontStyleBuilder(
+ static androidx.wear.tiles.LayoutElementBuilders.FontStyle.@NonNull Builder getFontStyleBuilder(
@TypographyName int fontStyleCode, @NonNull Context context) {
return getFontStyleBuilder(fontStyleCode, context, true);
}
@@ -133,8 +133,7 @@
* Typography code with the recommended size, weight and letter spacing, with the option to make
* this font not scalable.
*/
- @NonNull
- static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder getFontStyleBuilder(
+ static androidx.wear.tiles.LayoutElementBuilders.FontStyle.@NonNull Builder getFontStyleBuilder(
@TypographyName int typographyCode, @NonNull Context context, boolean isScalable) {
switch (typographyCode) {
case TYPOGRAPHY_BODY1:
@@ -172,8 +171,7 @@
* Returns the recommended line height for the given Typography to be added to the Text
* component.
*/
- @NonNull
- static androidx.wear.tiles.DimensionBuilders.SpProp getLineHeightForTypography(
+ static androidx.wear.tiles.DimensionBuilders.@NonNull SpProp getLineHeightForTypography(
@TypographyName int typography) {
if (!TYPOGRAPHY_TO_LINE_HEIGHT_SP.containsKey(typography)) {
throw new IllegalArgumentException("Typography " + typography + " doesn't exist.");
@@ -184,7 +182,6 @@
.intValue());
}
- @NonNull
@SuppressLint("ResourceType")
// This is a helper function to make the font not scalable. It should interpret in value as DP
// and convert it to SP which is needed to be passed in as a font size. However, we will pass an
@@ -192,7 +189,7 @@
// size on device in 1, so the DP is equal to SP.
// TODO(b/267744228): Remove the warning suppression.
@SuppressWarnings("deprecation")
- private static androidx.wear.tiles.DimensionBuilders.SpProp dpToSp(
+ private static androidx.wear.tiles.DimensionBuilders.@NonNull SpProp dpToSp(
@NonNull Context context, @Dimension(unit = DP) float valueDp) {
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
float scaledSp = (valueDp / metrics.scaledDensity) * metrics.density;
@@ -222,8 +219,7 @@
}
/** Font style for large display text. */
- @NonNull
- private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display1(
+ private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.@NonNull Builder display1(
boolean isScalable, @NonNull Context context) {
return createFontStyleBuilder(
40,
@@ -235,8 +231,7 @@
}
/** Font style for medium display text. */
- @NonNull
- private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display2(
+ private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.@NonNull Builder display2(
boolean isScalable, @NonNull Context context) {
return createFontStyleBuilder(
34,
@@ -248,8 +243,7 @@
}
/** Font style for small display text. */
- @NonNull
- private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder display3(
+ private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.@NonNull Builder display3(
boolean isScalable, @NonNull Context context) {
return createFontStyleBuilder(
30,
@@ -261,8 +255,7 @@
}
/** Font style for large title text. */
- @NonNull
- private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title1(
+ private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.@NonNull Builder title1(
boolean isScalable, @NonNull Context context) {
return createFontStyleBuilder(
24,
@@ -274,8 +267,7 @@
}
/** Font style for medium title text. */
- @NonNull
- private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title2(
+ private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.@NonNull Builder title2(
boolean isScalable, @NonNull Context context) {
return createFontStyleBuilder(
20,
@@ -287,8 +279,7 @@
}
/** Font style for small title text. */
- @NonNull
- private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder title3(
+ private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.@NonNull Builder title3(
boolean isScalable, @NonNull Context context) {
return createFontStyleBuilder(
16,
@@ -300,8 +291,7 @@
}
/** Font style for normal body text. */
- @NonNull
- private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body1(
+ private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.@NonNull Builder body1(
boolean isScalable, @NonNull Context context) {
return createFontStyleBuilder(
16,
@@ -313,8 +303,7 @@
}
/** Font style for small body text. */
- @NonNull
- private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder body2(
+ private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.@NonNull Builder body2(
boolean isScalable, @NonNull Context context) {
return createFontStyleBuilder(
14,
@@ -326,8 +315,7 @@
}
/** Font style for bold button text. */
- @NonNull
- private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder button(
+ private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.@NonNull Builder button(
boolean isScalable, @NonNull Context context) {
return createFontStyleBuilder(
15,
@@ -339,8 +327,7 @@
}
/** Font style for large caption text. */
- @NonNull
- private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption1(
+ private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.@NonNull Builder caption1(
boolean isScalable, @NonNull Context context) {
return createFontStyleBuilder(
14,
@@ -352,8 +339,7 @@
}
/** Font style for medium caption text. */
- @NonNull
- private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption2(
+ private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.@NonNull Builder caption2(
boolean isScalable, @NonNull Context context) {
return createFontStyleBuilder(
12,
@@ -365,8 +351,7 @@
}
/** Font style for small caption text. */
- @NonNull
- private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.Builder caption3(
+ private static androidx.wear.tiles.LayoutElementBuilders.FontStyle.@NonNull Builder caption3(
boolean isScalable, @NonNull Context context) {
return createFontStyleBuilder(
10,
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/EdgeContentLayout.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/EdgeContentLayout.java
index 2f0c55c..c257513 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/EdgeContentLayout.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/EdgeContentLayout.java
@@ -17,13 +17,14 @@
package androidx.wear.tiles.material.layouts;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
@@ -123,16 +124,16 @@
})
@interface ContentBits {}
- @NonNull private final androidx.wear.tiles.LayoutElementBuilders.Box mImpl;
+ private final androidx.wear.tiles.LayoutElementBuilders.@NonNull Box mImpl;
// This contains inner columns and edge content.
- @NonNull private final List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement> mContents;
+ private final @NonNull List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement> mContents;
// This contains optional labels, spacers and main content.
- @NonNull
- private final List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement> mInnerColumn;
+ private final @NonNull List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement>
+ mInnerColumn;
- EdgeContentLayout(@NonNull androidx.wear.tiles.LayoutElementBuilders.Box layoutElement) {
+ EdgeContentLayout(androidx.wear.tiles.LayoutElementBuilders.@NonNull Box layoutElement) {
this.mImpl = layoutElement;
this.mContents = mImpl.getContents();
this.mInnerColumn =
@@ -146,20 +147,19 @@
/** Builder class for {@link EdgeContentLayout}. */
public static final class Builder
implements androidx.wear.tiles.LayoutElementBuilders.LayoutElement.Builder {
- @NonNull
- private final androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
+ private final androidx.wear.tiles.DeviceParametersBuilders.@NonNull DeviceParameters
mDeviceParameters;
- @Nullable
- private androidx.wear.tiles.LayoutElementBuilders.LayoutElement mEdgeContent = null;
+ private androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement mEdgeContent =
+ null;
- @Nullable
- private androidx.wear.tiles.LayoutElementBuilders.LayoutElement mPrimaryLabelText = null;
+ private androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
+ mPrimaryLabelText = null;
- @Nullable
- private androidx.wear.tiles.LayoutElementBuilders.LayoutElement mSecondaryLabelText = null;
+ private androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
+ mSecondaryLabelText = null;
- @Nullable private androidx.wear.tiles.LayoutElementBuilders.LayoutElement mContent = null;
+ private androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement mContent = null;
private byte mMetadataContentByte = 0;
/**
@@ -167,8 +167,7 @@
* later be set with ({@link #setContent}.
*/
public Builder(
- @NonNull
- androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
+ androidx.wear.tiles.DeviceParametersBuilders.@NonNull DeviceParameters
deviceParameters) {
this.mDeviceParameters = deviceParameters;
}
@@ -176,18 +175,16 @@
/**
* Sets the content to be around the edges. This can be {@link CircularProgressIndicator}.
*/
- @NonNull
- public Builder setEdgeContent(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement edgeContent) {
+ public @NonNull Builder setEdgeContent(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement edgeContent) {
this.mEdgeContent = edgeContent;
mMetadataContentByte = (byte) (mMetadataContentByte | EDGE_CONTENT_PRESENT);
return this;
}
/** Sets the content in the primary label slot which will be above the main content. */
- @NonNull
- public Builder setPrimaryLabelTextContent(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement primaryLabelText) {
+ public @NonNull Builder setPrimaryLabelTextContent(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement primaryLabelText) {
this.mPrimaryLabelText = primaryLabelText;
mMetadataContentByte = (byte) (mMetadataContentByte | PRIMARY_LABEL_PRESENT);
return this;
@@ -197,10 +194,8 @@
* Sets the content in the secondary label slot which will be below the main content. It is
* highly recommended to have primary label set when having secondary label.
*/
- @NonNull
- public Builder setSecondaryLabelTextContent(
- @NonNull
- androidx.wear.tiles.LayoutElementBuilders.LayoutElement
+ public @NonNull Builder setSecondaryLabelTextContent(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement
secondaryLabelText) {
this.mSecondaryLabelText = secondaryLabelText;
mMetadataContentByte = (byte) (mMetadataContentByte | SECONDARY_LABEL_PRESENT);
@@ -208,18 +203,16 @@
}
/** Sets the additional content to this layout, inside of the screen. */
- @NonNull
- public Builder setContent(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement content) {
+ public @NonNull Builder setContent(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement content) {
this.mContent = content;
mMetadataContentByte = (byte) (mMetadataContentByte | CONTENT_PRESENT);
return this;
}
/** Constructs and returns {@link EdgeContentLayout} with the provided content and look. */
- @NonNull
@Override
- public EdgeContentLayout build() {
+ public @NonNull EdgeContentLayout build() {
float thicknessDp =
mEdgeContent instanceof androidx.wear.tiles.material.CircularProgressIndicator
? ((androidx.wear.tiles.material.CircularProgressIndicator)
@@ -345,8 +338,7 @@
}
/** Returns metadata tag set to this EdgeContentLayout. */
- @NonNull
- byte[] getMetadataTag() {
+ byte @NonNull [] getMetadataTag() {
return androidx.wear.tiles.material.Helper.getMetadataTagBytes(
androidx.wear.tiles.material.Helper.checkNotNull(
androidx.wear.tiles.material.Helper.checkNotNull(mImpl.getModifiers())
@@ -354,8 +346,7 @@
}
/** Returns the inner content from this layout. */
- @Nullable
- public androidx.wear.tiles.LayoutElementBuilders.LayoutElement getContent() {
+ public androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement getContent() {
if (!areElementsPresent(CONTENT_PRESENT)) {
return null;
}
@@ -368,8 +359,8 @@
}
/** Get the primary label content from this layout. */
- @Nullable
- public androidx.wear.tiles.LayoutElementBuilders.LayoutElement getPrimaryLabelTextContent() {
+ public androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
+ getPrimaryLabelTextContent() {
if (!areElementsPresent(PRIMARY_LABEL_PRESENT)) {
return null;
}
@@ -378,8 +369,8 @@
}
/** Get the secondary label content from this layout. */
- @Nullable
- public androidx.wear.tiles.LayoutElementBuilders.LayoutElement getSecondaryLabelTextContent() {
+ public androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
+ getSecondaryLabelTextContent() {
if (!areElementsPresent(SECONDARY_LABEL_PRESENT)) {
return null;
}
@@ -388,8 +379,7 @@
}
/** Returns the edge content from this layout. */
- @Nullable
- public androidx.wear.tiles.LayoutElementBuilders.LayoutElement getEdgeContent() {
+ public androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement getEdgeContent() {
if (areElementsPresent(EDGE_CONTENT_PRESENT)) {
return mContents.get(1);
}
@@ -402,9 +392,8 @@
* container's content with {@code container.getContents().get(index)}) if that element can be
* converted to EdgeContentLayout. Otherwise, it will return null.
*/
- @Nullable
- public static EdgeContentLayout fromLayoutElement(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement element) {
+ public static @Nullable EdgeContentLayout fromLayoutElement(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement element) {
if (element instanceof EdgeContentLayout) {
return (EdgeContentLayout) element;
}
@@ -421,17 +410,15 @@
return new EdgeContentLayout(boxElement);
}
- @NonNull
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mImpl.toLayoutElementProto();
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
@Override
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mImpl.getFingerprint();
}
}
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/LayoutDefaults.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/LayoutDefaults.java
index 40b9cb8..883114d 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/LayoutDefaults.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/LayoutDefaults.java
@@ -16,7 +16,7 @@
package androidx.wear.tiles.material.layouts;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* Contains the default values used by layout templates for Tiles.
@@ -110,13 +110,11 @@
public static final float EDGE_CONTENT_LAYOUT_PADDING_BELOW_MAIN_CONTENT_DP = 8;
/** The default spacer width for slots in a {@link MultiSlotLayout}. */
- @NonNull
- public static final androidx.wear.tiles.DimensionBuilders.DpProp
+ public static final androidx.wear.tiles.DimensionBuilders.@NonNull DpProp
MULTI_SLOT_LAYOUT_HORIZONTAL_SPACER_WIDTH = androidx.wear.tiles.DimensionBuilders.dp(8);
/** The recommended space between the main content and additional labels in layouts. */
- @NonNull
- public static final androidx.wear.tiles.DimensionBuilders.DpProp
+ public static final androidx.wear.tiles.DimensionBuilders.@NonNull DpProp
DEFAULT_VERTICAL_SPACER_HEIGHT = androidx.wear.tiles.DimensionBuilders.dp(8);
/** The maximum number of button that can be added to the {@link MultiButtonLayout}. */
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/MultiButtonLayout.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/MultiButtonLayout.java
index 4f521ce..f476080 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/MultiButtonLayout.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/MultiButtonLayout.java
@@ -17,13 +17,14 @@
package androidx.wear.tiles.material.layouts;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
@@ -81,17 +82,16 @@
@IntDef({FIVE_BUTTON_DISTRIBUTION_TOP_HEAVY, FIVE_BUTTON_DISTRIBUTION_BOTTOM_HEAVY})
public @interface ButtonDistribution {}
- @NonNull private final androidx.wear.tiles.LayoutElementBuilders.Box mElement;
+ private final androidx.wear.tiles.LayoutElementBuilders.@NonNull Box mElement;
- MultiButtonLayout(@NonNull androidx.wear.tiles.LayoutElementBuilders.Box mElement) {
+ MultiButtonLayout(androidx.wear.tiles.LayoutElementBuilders.@NonNull Box mElement) {
this.mElement = mElement;
}
/** Builder class for {@link MultiButtonLayout}. */
public static final class Builder
implements androidx.wear.tiles.LayoutElementBuilders.LayoutElement.Builder {
- @NonNull
- private final List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement>
+ private final @NonNull List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement>
mButtonsContent = new ArrayList<>();
private @ButtonDistribution int mFiveButtonDistribution =
@@ -109,12 +109,11 @@
* to add a {@link Button} as the layout is optimized for it. Any button added after {@link
* LayoutDefaults#MULTI_BUTTON_MAX_NUMBER} is reached will be discarded.
*/
- @NonNull
@SuppressWarnings("MissingGetterMatchingBuilder")
// There is no direct matching getter for this setter, but there is a getter that gets all
// added buttons.
- public Builder addButtonContent(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement buttonContent) {
+ public @NonNull Builder addButtonContent(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement buttonContent) {
mButtonsContent.add(buttonContent);
return this;
}
@@ -124,16 +123,15 @@
* there is 5 buttons in the layout to determine whether the 3 buttons row is at the top or
* bottom.
*/
- @NonNull
- public Builder setFiveButtonDistribution(@ButtonDistribution int fiveButtonDistribution) {
+ public @NonNull Builder setFiveButtonDistribution(
+ @ButtonDistribution int fiveButtonDistribution) {
this.mFiveButtonDistribution = fiveButtonDistribution;
return this;
}
/** Constructs and returns {@link MultiButtonLayout} with the provided content and look. */
- @NonNull
@Override
- public MultiButtonLayout build() {
+ public @NonNull MultiButtonLayout build() {
int buttonNum = mButtonsContent.size();
if (buttonNum > LayoutDefaults.MULTI_BUTTON_MAX_NUMBER) {
throw new IllegalArgumentException(
@@ -162,8 +160,7 @@
return new MultiButtonLayout(elementBuilder.build());
}
- @NonNull
- private androidx.wear.tiles.LayoutElementBuilders.LayoutElement buildButtons(
+ private androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement buildButtons(
int buttonNum) {
switch (buttonNum) {
case 1:
@@ -255,11 +252,10 @@
return new androidx.wear.tiles.LayoutElementBuilders.Box.Builder().build();
}
- @NonNull
- private androidx.wear.tiles.LayoutElementBuilders.Row build3ButtonRow(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement button1,
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement button2,
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement button3) {
+ private androidx.wear.tiles.LayoutElementBuilders.@NonNull Row build3ButtonRow(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement button1,
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement button2,
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement button3) {
return new androidx.wear.tiles.LayoutElementBuilders.Row.Builder()
.setWidth(androidx.wear.tiles.DimensionBuilders.wrap())
.setHeight(androidx.wear.tiles.DimensionBuilders.wrap())
@@ -271,11 +267,10 @@
.build();
}
- @NonNull
- private androidx.wear.tiles.LayoutElementBuilders.Row build2ButtonRow(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement button1,
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement button2,
- @NonNull androidx.wear.tiles.DimensionBuilders.DpProp size) {
+ private androidx.wear.tiles.LayoutElementBuilders.@NonNull Row build2ButtonRow(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement button1,
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement button2,
+ androidx.wear.tiles.DimensionBuilders.@NonNull DpProp size) {
return new androidx.wear.tiles.LayoutElementBuilders.Row.Builder()
.setWidth(androidx.wear.tiles.DimensionBuilders.wrap())
.setHeight(androidx.wear.tiles.DimensionBuilders.wrap())
@@ -285,24 +280,21 @@
.build();
}
- @NonNull
- private androidx.wear.tiles.LayoutElementBuilders.Spacer buildHorizontalSpacer() {
+ private androidx.wear.tiles.LayoutElementBuilders.@NonNull Spacer buildHorizontalSpacer() {
return new androidx.wear.tiles.LayoutElementBuilders.Spacer.Builder()
.setWidth(LayoutDefaults.MULTI_BUTTON_SPACER_WIDTH)
.build();
}
- @NonNull
- private androidx.wear.tiles.LayoutElementBuilders.Spacer buildVerticalSpacer() {
+ private androidx.wear.tiles.LayoutElementBuilders.@NonNull Spacer buildVerticalSpacer() {
return new androidx.wear.tiles.LayoutElementBuilders.Spacer.Builder()
.setHeight(LayoutDefaults.MULTI_BUTTON_SPACER_HEIGHT)
.build();
}
- @NonNull
- private androidx.wear.tiles.LayoutElementBuilders.Box wrapButton(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement button,
- @NonNull androidx.wear.tiles.DimensionBuilders.DpProp size) {
+ private androidx.wear.tiles.LayoutElementBuilders.@NonNull Box wrapButton(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement button,
+ androidx.wear.tiles.DimensionBuilders.@NonNull DpProp size) {
return new androidx.wear.tiles.LayoutElementBuilders.Box.Builder()
.setWidth(size)
.setHeight(size)
@@ -312,8 +304,8 @@
}
/** Gets the content from this layout, containing all buttons that were added. */
- @NonNull
- public List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement> getButtonContents() {
+ public @NonNull List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement>
+ getButtonContents() {
List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement> buttons = new ArrayList<>();
List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement> contents =
mElement.getContents();
@@ -343,8 +335,7 @@
}
/** Returns metadata tag set to this MultiButtonLayouts. */
- @NonNull
- String getMetadataTag() {
+ @NonNull String getMetadataTag() {
return androidx.wear.tiles.material.Helper.getMetadataTagName(
androidx.wear.tiles.material.Helper.checkNotNull(
androidx.wear.tiles.material.Helper.checkNotNull(mElement.getModifiers())
@@ -405,9 +396,8 @@
* container's content with {@code container.getContents().get(index)}) if that element can be
* converted to MultiButtonLayout. Otherwise, it will return null.
*/
- @Nullable
- public static MultiButtonLayout fromLayoutElement(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement element) {
+ public static @Nullable MultiButtonLayout fromLayoutElement(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement element) {
if (element instanceof MultiButtonLayout) {
return (MultiButtonLayout) element;
}
@@ -424,17 +414,15 @@
return new MultiButtonLayout(boxElement);
}
- @NonNull
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mElement.toLayoutElementProto();
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
@Override
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mElement.getFingerprint();
}
}
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/MultiSlotLayout.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/MultiSlotLayout.java
index 104e75e..7e8fe36d 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/MultiSlotLayout.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/MultiSlotLayout.java
@@ -21,13 +21,14 @@
import android.annotation.SuppressLint;
import androidx.annotation.Dimension;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.List;
@@ -73,9 +74,9 @@
*/
static final String METADATA_TAG = "MSL";
- @NonNull private final androidx.wear.tiles.LayoutElementBuilders.Row mElement;
+ private final androidx.wear.tiles.LayoutElementBuilders.@NonNull Row mElement;
- MultiSlotLayout(@NonNull androidx.wear.tiles.LayoutElementBuilders.Row mElement) {
+ MultiSlotLayout(androidx.wear.tiles.LayoutElementBuilders.@NonNull Row mElement) {
this.mElement = mElement;
}
@@ -83,12 +84,10 @@
public static final class Builder
implements androidx.wear.tiles.LayoutElementBuilders.LayoutElement.Builder {
- @NonNull
- private final List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement> mSlotsContent =
- new ArrayList<>();
+ private final @NonNull List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement>
+ mSlotsContent = new ArrayList<>();
- @NonNull
- private androidx.wear.tiles.DimensionBuilders.DpProp mHorizontalSpacerWidth =
+ private androidx.wear.tiles.DimensionBuilders.@NonNull DpProp mHorizontalSpacerWidth =
LayoutDefaults.MULTI_SLOT_LAYOUT_HORIZONTAL_SPACER_WIDTH;
/**
@@ -98,12 +97,11 @@
public Builder() {}
/** Add one new slot to the layout with the given content inside. */
- @NonNull
@SuppressWarnings("MissingGetterMatchingBuilder")
// There is no direct matching getter for this setter, but there is a getter that gets all
// added slots.
- public Builder addSlotContent(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement slotContent) {
+ public @NonNull Builder addSlotContent(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement slotContent) {
mSlotsContent.add(slotContent);
return this;
}
@@ -113,20 +111,18 @@
* than one slot. If not set, {@link
* LayoutDefaults#MULTI_SLOT_LAYOUT_HORIZONTAL_SPACER_WIDTH} will be used.
*/
- @NonNull
- public Builder setHorizontalSpacerWidth(@Dimension(unit = DP) float width) {
+ public @NonNull Builder setHorizontalSpacerWidth(@Dimension(unit = DP) float width) {
this.mHorizontalSpacerWidth = androidx.wear.tiles.DimensionBuilders.dp(width);
return this;
}
/** Constructs and returns {@link MultiSlotLayout} with the provided content and look. */
- @NonNull
@Override
// The @Dimension(unit = DP) on mVerticalSpacerHeight.getValue() is seemingly being ignored,
// so lint complains that we're passing PX to something expecting DP. Just suppress the
// warning for now.
@SuppressLint("ResourceType")
- public MultiSlotLayout build() {
+ public @NonNull MultiSlotLayout build() {
androidx.wear.tiles.LayoutElementBuilders.Row.Builder rowBuilder =
new androidx.wear.tiles.LayoutElementBuilders.Row.Builder()
.setHeight(androidx.wear.tiles.DimensionBuilders.wrap())
@@ -170,8 +166,8 @@
}
/** Gets the content from this layout, containing all slots that were added. */
- @NonNull
- public List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement> getSlotContents() {
+ public @NonNull List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement>
+ getSlotContents() {
List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement> slots = new ArrayList<>();
for (androidx.wear.tiles.LayoutElementBuilders.LayoutElement slot :
mElement.getContents()) {
@@ -206,8 +202,7 @@
}
/** Returns metadata tag set to this MultiSlotLayout. */
- @NonNull
- String getMetadataTag() {
+ @NonNull String getMetadataTag() {
return androidx.wear.tiles.material.Helper.getMetadataTagName(
androidx.wear.tiles.material.Helper.checkNotNull(
androidx.wear.tiles.material.Helper.checkNotNull(mElement.getModifiers())
@@ -220,9 +215,8 @@
* container's content with {@code container.getContents().get(index)}) if that element can be
* converted to MultiSlotLayout. Otherwise, it will return null.
*/
- @Nullable
- public static MultiSlotLayout fromLayoutElement(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement element) {
+ public static @Nullable MultiSlotLayout fromLayoutElement(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement element) {
if (element instanceof MultiSlotLayout) {
return (MultiSlotLayout) element;
}
@@ -239,17 +233,15 @@
return new MultiSlotLayout(rowElement);
}
- @NonNull
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mElement.toLayoutElementProto();
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
@Override
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mElement.getFingerprint();
}
}
diff --git a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/PrimaryLayout.java b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/PrimaryLayout.java
index 037ba46..f3f0e86 100644
--- a/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/PrimaryLayout.java
+++ b/wear/tiles/tiles-material/src/main/java/androidx/wear/tiles/material/layouts/PrimaryLayout.java
@@ -22,13 +22,14 @@
import androidx.annotation.Dimension;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.LayoutElementProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
@@ -131,22 +132,21 @@
value = {CHIP_PRESENT, PRIMARY_LABEL_PRESENT, SECONDARY_LABEL_PRESENT, CONTENT_PRESENT})
@interface ContentBits {}
- @NonNull private final androidx.wear.tiles.LayoutElementBuilders.Box mImpl;
+ private final androidx.wear.tiles.LayoutElementBuilders.@NonNull Box mImpl;
// This contains inner columns and primary chip.
- @NonNull
- private final List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement> mAllContent;
+ private final @NonNull List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement>
+ mAllContent;
// This contains optional labels, spacers and main content.
- @NonNull
- private final List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement> mPrimaryLabel;
+ private final @NonNull List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement>
+ mPrimaryLabel;
// This contains optional labels, spacers and main content.
- @NonNull
- private final List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement>
+ private final @NonNull List<androidx.wear.tiles.LayoutElementBuilders.LayoutElement>
mContentAndSecondaryLabel;
- PrimaryLayout(@NonNull androidx.wear.tiles.LayoutElementBuilders.Box layoutElement) {
+ PrimaryLayout(androidx.wear.tiles.LayoutElementBuilders.@NonNull Box layoutElement) {
this.mImpl = layoutElement;
this.mAllContent =
((androidx.wear.tiles.LayoutElementBuilders.Column)
@@ -170,25 +170,22 @@
/** Builder class for {@link PrimaryLayout}. */
public static final class Builder
implements androidx.wear.tiles.LayoutElementBuilders.LayoutElement.Builder {
- @NonNull
- private final androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
+ private final androidx.wear.tiles.DeviceParametersBuilders.@NonNull DeviceParameters
mDeviceParameters;
- @Nullable
- private androidx.wear.tiles.LayoutElementBuilders.LayoutElement mPrimaryChip = null;
+ private androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement mPrimaryChip =
+ null;
- @Nullable
- private androidx.wear.tiles.LayoutElementBuilders.LayoutElement mPrimaryLabelText = null;
+ private androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
+ mPrimaryLabelText = null;
- @Nullable
- private androidx.wear.tiles.LayoutElementBuilders.LayoutElement mSecondaryLabelText = null;
+ private androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
+ mSecondaryLabelText = null;
- @NonNull
- private androidx.wear.tiles.LayoutElementBuilders.LayoutElement mContent =
+ private androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement mContent =
new androidx.wear.tiles.LayoutElementBuilders.Box.Builder().build();
- @NonNull
- private androidx.wear.tiles.DimensionBuilders.DpProp mVerticalSpacerHeight =
+ private androidx.wear.tiles.DimensionBuilders.@NonNull DpProp mVerticalSpacerHeight =
LayoutDefaults.DEFAULT_VERTICAL_SPACER_HEIGHT;
private byte mMetadataContentByte = 0;
@@ -199,8 +196,7 @@
* #setPrimaryLabelTextContent} and {@link #setSecondaryLabelTextContent}.
*/
public Builder(
- @NonNull
- androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
+ androidx.wear.tiles.DeviceParametersBuilders.@NonNull DeviceParameters
deviceParameters) {
this.mDeviceParameters = deviceParameters;
}
@@ -211,18 +207,16 @@
* but it is strongly recommended to add a {@link CompactChip} as the layout is optimized
* for it.
*/
- @NonNull
- public Builder setPrimaryChipContent(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement compactChip) {
+ public @NonNull Builder setPrimaryChipContent(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement compactChip) {
this.mPrimaryChip = compactChip;
mMetadataContentByte = (byte) (mMetadataContentByte | CHIP_PRESENT);
return this;
}
/** Sets the content in the primary label slot which will be above the main content. */
- @NonNull
- public Builder setPrimaryLabelTextContent(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement primaryLabelText) {
+ public @NonNull Builder setPrimaryLabelTextContent(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement primaryLabelText) {
this.mPrimaryLabelText = primaryLabelText;
mMetadataContentByte = (byte) (mMetadataContentByte | PRIMARY_LABEL_PRESENT);
return this;
@@ -232,10 +226,8 @@
* Sets the content in the primary label slot which will be below the main content. It is
* highly recommended to have primary label set when having secondary label.
*/
- @NonNull
- public Builder setSecondaryLabelTextContent(
- @NonNull
- androidx.wear.tiles.LayoutElementBuilders.LayoutElement
+ public @NonNull Builder setSecondaryLabelTextContent(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement
secondaryLabelText) {
this.mSecondaryLabelText = secondaryLabelText;
mMetadataContentByte = (byte) (mMetadataContentByte | SECONDARY_LABEL_PRESENT);
@@ -252,9 +244,8 @@
* set to {@code expand} to use all the available space, rather than an explicit width which
* may lead to clipping.
*/
- @NonNull
- public Builder setContent(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement content) {
+ public @NonNull Builder setContent(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement content) {
this.mContent = content;
mMetadataContentByte = (byte) (mMetadataContentByte | CONTENT_PRESENT);
return this;
@@ -265,11 +256,10 @@
* secondary label if there is any. If not set, {@link
* LayoutDefaults#DEFAULT_VERTICAL_SPACER_HEIGHT} will be used.
*/
- @NonNull
// The @Dimension(unit = DP) on dp() is seemingly being ignored, so lint complains that
// we're passing PX to something expecting DP. Just suppress the warning for now.
@SuppressLint("ResourceType")
- public Builder setVerticalSpacerHeight(@Dimension(unit = DP) float height) {
+ public @NonNull Builder setVerticalSpacerHeight(@Dimension(unit = DP) float height) {
this.mVerticalSpacerHeight = androidx.wear.tiles.DimensionBuilders.dp(height);
return this;
}
@@ -278,9 +268,8 @@
// The @Dimension(unit = DP) on dp() is seemingly being ignored, so lint complains that
// we're passing DP to something expecting PX. Just suppress the warning for now.
@SuppressLint("ResourceType")
- @NonNull
@Override
- public PrimaryLayout build() {
+ public @NonNull PrimaryLayout build() {
float topPadding = getTopPadding();
float bottomPadding = getBottomPadding();
float horizontalPadding = getHorizontalPadding();
@@ -497,8 +486,8 @@
}
/** Returns the spacer height to be placed above primary label to accommodate Tile icon. */
- @NonNull
- private androidx.wear.tiles.DimensionBuilders.DpProp getPrimaryLabelTopSpacerHeight() {
+ private androidx.wear.tiles.DimensionBuilders.@NonNull DpProp
+ getPrimaryLabelTopSpacerHeight() {
return androidx.wear.tiles.material.Helper.isRoundDevice(mDeviceParameters)
? LayoutDefaults.PRIMARY_LAYOUT_PRIMARY_LABEL_SPACER_HEIGHT_ROUND_DP
: LayoutDefaults.PRIMARY_LAYOUT_PRIMARY_LABEL_SPACER_HEIGHT_SQUARE_DP;
@@ -506,8 +495,8 @@
}
/** Get the primary label content from this layout. */
- @Nullable
- public androidx.wear.tiles.LayoutElementBuilders.LayoutElement getPrimaryLabelTextContent() {
+ public androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
+ getPrimaryLabelTextContent() {
if (!areElementsPresent(PRIMARY_LABEL_PRESENT)) {
return null;
}
@@ -515,8 +504,8 @@
}
/** Get the secondary label content from this layout. */
- @Nullable
- public androidx.wear.tiles.LayoutElementBuilders.LayoutElement getSecondaryLabelTextContent() {
+ public androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
+ getSecondaryLabelTextContent() {
if (!areElementsPresent(SECONDARY_LABEL_PRESENT)) {
return null;
}
@@ -525,8 +514,7 @@
}
/** Get the inner content from this layout. */
- @Nullable
- public androidx.wear.tiles.LayoutElementBuilders.LayoutElement getContent() {
+ public androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement getContent() {
if (!areElementsPresent(CONTENT_PRESENT)) {
return null;
}
@@ -537,8 +525,8 @@
}
/** Get the primary chip content from this layout. */
- @Nullable
- public androidx.wear.tiles.LayoutElementBuilders.LayoutElement getPrimaryChipContent() {
+ public androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
+ getPrimaryChipContent() {
if (areElementsPresent(CHIP_PRESENT)) {
return ((androidx.wear.tiles.LayoutElementBuilders.Box)
mAllContent.get(PRIMARY_CHIP_POSITION))
@@ -573,8 +561,7 @@
}
/** Returns metadata tag set to this PrimaryLayout. */
- @NonNull
- byte[] getMetadataTag() {
+ byte @NonNull [] getMetadataTag() {
return androidx.wear.tiles.material.Helper.getMetadataTagBytes(
androidx.wear.tiles.material.Helper.checkNotNull(
androidx.wear.tiles.material.Helper.checkNotNull(mImpl.getModifiers())
@@ -587,9 +574,8 @@
* container's content with {@code container.getContents().get(index)}) if that element can be
* converted to PrimaryLayout. Otherwise, it will return null.
*/
- @Nullable
- public static PrimaryLayout fromLayoutElement(
- @NonNull androidx.wear.tiles.LayoutElementBuilders.LayoutElement element) {
+ public static @Nullable PrimaryLayout fromLayoutElement(
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull LayoutElement element) {
if (element instanceof PrimaryLayout) {
return (PrimaryLayout) element;
}
@@ -606,17 +592,15 @@
return new PrimaryLayout(boxElement);
}
- @NonNull
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return mImpl.toLayoutElementProto();
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
@Override
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mImpl.getFingerprint();
}
}
diff --git a/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/ButtonTest.java b/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/ButtonTest.java
index 81ac645..7bc6c6a 100644
--- a/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/ButtonTest.java
+++ b/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/ButtonTest.java
@@ -22,11 +22,11 @@
import android.content.Context;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.internal.DoNotInstrument;
@@ -232,15 +232,15 @@
private void assertButton(
@NonNull Button actualButton,
- @NonNull androidx.wear.tiles.DimensionBuilders.DpProp expectedSize,
+ androidx.wear.tiles.DimensionBuilders.@NonNull DpProp expectedSize,
@NonNull ButtonColors expectedButtonColors,
@Nullable String expectedContentDescription,
@NonNull String expectedMetadataTag,
@Nullable String expectedTextContent,
@Nullable String expectedIconContent,
@Nullable String expectedImageContent,
- @Nullable
- androidx.wear.tiles.LayoutElementBuilders.LayoutElement expectedCustomContent) {
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
+ expectedCustomContent) {
assertButtonIsEqual(
actualButton,
expectedSize,
@@ -268,15 +268,15 @@
private void assertButtonIsEqual(
@NonNull Button actualButton,
- @NonNull androidx.wear.tiles.DimensionBuilders.DpProp expectedSize,
+ androidx.wear.tiles.DimensionBuilders.@NonNull DpProp expectedSize,
@NonNull ButtonColors expectedButtonColors,
@Nullable String expectedContentDescription,
@NonNull String expectedMetadataTag,
@Nullable String expectedTextContent,
@Nullable String expectedIconContent,
@Nullable String expectedImageContent,
- @Nullable
- androidx.wear.tiles.LayoutElementBuilders.LayoutElement expectedCustomContent) {
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
+ expectedCustomContent) {
// Mandatory
assertThat(actualButton.getMetadataTag()).isEqualTo(expectedMetadataTag);
assertThat(actualButton.getClickable().toProto()).isEqualTo(CLICKABLE.toProto());
@@ -323,15 +323,15 @@
private void assertFromLayoutElementButtonIsEqual(
@NonNull Button button,
- @NonNull androidx.wear.tiles.DimensionBuilders.DpProp expectedSize,
+ androidx.wear.tiles.DimensionBuilders.@NonNull DpProp expectedSize,
@NonNull ButtonColors expectedButtonColors,
@Nullable String expectedContentDescription,
@NonNull String expectedMetadataTag,
@Nullable String expectedTextContent,
@Nullable String expectedIconContent,
@Nullable String expectedImageContent,
- @Nullable
- androidx.wear.tiles.LayoutElementBuilders.LayoutElement expectedCustomContent) {
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
+ expectedCustomContent) {
androidx.wear.tiles.LayoutElementBuilders.Box box =
new androidx.wear.tiles.LayoutElementBuilders.Box.Builder()
.addContent(button)
diff --git a/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/ChipTest.java b/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/ChipTest.java
index 3e96246..808ba0b 100644
--- a/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/ChipTest.java
+++ b/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/ChipTest.java
@@ -23,11 +23,11 @@
import android.content.Context;
import android.graphics.Color;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.internal.DoNotInstrument;
@@ -176,8 +176,8 @@
@Nullable String expectedPrimaryText,
@Nullable String expectedLabel,
@Nullable String expectedIcon,
- @Nullable
- androidx.wear.tiles.LayoutElementBuilders.LayoutElement expectedCustomContent) {
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
+ expectedCustomContent) {
assertChipIsEqual(
actualChip,
hAlign,
@@ -245,8 +245,8 @@
@Nullable String expectedPrimaryText,
@Nullable String expectedLabel,
@Nullable String expectedIcon,
- @Nullable
- androidx.wear.tiles.LayoutElementBuilders.LayoutElement expectedCustomContent) {
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
+ expectedCustomContent) {
androidx.wear.tiles.LayoutElementBuilders.Box box =
new androidx.wear.tiles.LayoutElementBuilders.Box.Builder()
.addContent(chip)
@@ -276,8 +276,8 @@
@Nullable String expectedPrimaryText,
@Nullable String expectedLabel,
@Nullable String expectedIcon,
- @Nullable
- androidx.wear.tiles.LayoutElementBuilders.LayoutElement expectedCustomContent) {
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
+ expectedCustomContent) {
assertThat(actualChip.getMetadataTag()).isEqualTo(expectedMetadata);
assertThat(actualChip.getClickable().toProto()).isEqualTo(CLICKABLE.toProto());
assertThat(actualChip.getWidth().toContainerDimensionProto())
diff --git a/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/CircularProgressIndicatorTest.java b/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/CircularProgressIndicatorTest.java
index f6b33f8..738ccf4e 100644
--- a/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/CircularProgressIndicatorTest.java
+++ b/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/CircularProgressIndicatorTest.java
@@ -22,10 +22,10 @@
import android.graphics.Color;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.internal.DoNotInstrument;
diff --git a/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/layouts/EdgeContentLayoutTest.java b/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/layouts/EdgeContentLayoutTest.java
index f1b5e00..61f0949 100644
--- a/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/layouts/EdgeContentLayoutTest.java
+++ b/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/layouts/EdgeContentLayoutTest.java
@@ -22,11 +22,11 @@
import android.content.Context;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.internal.DoNotInstrument;
@@ -148,13 +148,11 @@
private void assertLayout(
@NonNull EdgeContentLayout actualLayout,
- @Nullable
- androidx.wear.tiles.LayoutElementBuilders.LayoutElement
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
expectedProgressIndicator,
- @Nullable androidx.wear.tiles.LayoutElementBuilders.LayoutElement expectedContent,
- @Nullable androidx.wear.tiles.LayoutElementBuilders.LayoutElement expectedPrimaryLabel,
- @Nullable
- androidx.wear.tiles.LayoutElementBuilders.LayoutElement
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement expectedContent,
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement expectedPrimaryLabel,
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
expectedSecondaryLabel) {
assertLayoutIsEqual(
actualLayout,
@@ -183,13 +181,11 @@
private void assertLayoutIsEqual(
@NonNull EdgeContentLayout actualLayout,
- @Nullable
- androidx.wear.tiles.LayoutElementBuilders.LayoutElement
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
expectedProgressIndicator,
- @Nullable androidx.wear.tiles.LayoutElementBuilders.LayoutElement expectedContent,
- @Nullable androidx.wear.tiles.LayoutElementBuilders.LayoutElement expectedPrimaryLabel,
- @Nullable
- androidx.wear.tiles.LayoutElementBuilders.LayoutElement
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement expectedContent,
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement expectedPrimaryLabel,
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
expectedSecondaryLabel) {
byte[] expectedMetadata = EdgeContentLayout.METADATA_TAG_BASE.clone();
diff --git a/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/layouts/PrimaryLayoutTest.java b/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/layouts/PrimaryLayoutTest.java
index f2e689f..67eb223 100644
--- a/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/layouts/PrimaryLayoutTest.java
+++ b/wear/tiles/tiles-material/src/test/java/androidx/wear/tiles/material/layouts/PrimaryLayoutTest.java
@@ -22,11 +22,11 @@
import android.content.Context;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.internal.DoNotInstrument;
@@ -194,11 +194,10 @@
private void assertLayout(
float height,
@NonNull PrimaryLayout actualLayout,
- @Nullable androidx.wear.tiles.LayoutElementBuilders.LayoutElement expectedContent,
- @Nullable androidx.wear.tiles.LayoutElementBuilders.LayoutElement expectedPrimaryChip,
- @Nullable androidx.wear.tiles.LayoutElementBuilders.LayoutElement expectedPrimaryLabel,
- @Nullable
- androidx.wear.tiles.LayoutElementBuilders.LayoutElement
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement expectedContent,
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement expectedPrimaryChip,
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement expectedPrimaryLabel,
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
expectedSecondaryLabel) {
assertLayoutIsEqual(
height,
@@ -230,11 +229,10 @@
private void assertLayoutIsEqual(
float height,
@NonNull PrimaryLayout actualLayout,
- @Nullable androidx.wear.tiles.LayoutElementBuilders.LayoutElement expectedContent,
- @Nullable androidx.wear.tiles.LayoutElementBuilders.LayoutElement expectedPrimaryChip,
- @Nullable androidx.wear.tiles.LayoutElementBuilders.LayoutElement expectedPrimaryLabel,
- @Nullable
- androidx.wear.tiles.LayoutElementBuilders.LayoutElement
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement expectedContent,
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement expectedPrimaryChip,
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement expectedPrimaryLabel,
+ androidx.wear.tiles.LayoutElementBuilders.@Nullable LayoutElement
expectedSecondaryLabel) {
byte[] expectedMetadata = PrimaryLayout.METADATA_TAG_BASE.clone();
diff --git a/wear/tiles/tiles-renderer/build.gradle b/wear/tiles/tiles-renderer/build.gradle
index 5c78299..8c21683 100644
--- a/wear/tiles/tiles-renderer/build.gradle
+++ b/wear/tiles/tiles-renderer/build.gradle
@@ -33,6 +33,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.annotation:annotation:1.8.1")
api(libs.guavaListenableFuture)
diff --git a/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/client/TileClient.java b/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/client/TileClient.java
index bb730a1..cf7f642 100644
--- a/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/client/TileClient.java
+++ b/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/client/TileClient.java
@@ -18,7 +18,6 @@
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
-import androidx.annotation.NonNull;
import androidx.wear.protolayout.ResourceBuilders;
import androidx.wear.tiles.RequestBuilders;
import androidx.wear.tiles.TileBuilders;
@@ -26,22 +25,21 @@
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.ListenableFuture;
+import org.jspecify.annotations.NonNull;
+
/** Client to connect and interact with a TileService. */
public interface TileClient {
/** Gets the API version supported by the connected TileService. */
- @NonNull
- ListenableFuture<Integer> requestApiVersion();
+ @NonNull ListenableFuture<Integer> requestApiVersion();
/** Request a tile payload from the connected TileService. */
- @NonNull
- ListenableFuture<TileBuilders.Tile> requestTile(
- @NonNull RequestBuilders.TileRequest requestParams);
+ @NonNull ListenableFuture<TileBuilders.Tile> requestTile(
+ RequestBuilders.@NonNull TileRequest requestParams);
/** Request a resource bundle from the connected TileService. */
- @NonNull
@SuppressWarnings("deprecation") // For backward compatibility
- default ListenableFuture<ResourceBuilders.Resources> requestTileResourcesAsync(
- @NonNull RequestBuilders.ResourcesRequest requestParams) {
+ default @NonNull ListenableFuture<ResourceBuilders.Resources> requestTileResourcesAsync(
+ RequestBuilders.@NonNull ResourcesRequest requestParams) {
return FluentFuture.from(requestResources(requestParams))
.transform(
res -> ResourceBuilders.Resources.fromProto(res.toProto()),
@@ -53,24 +51,19 @@
*
* @deprecated Use {@link #requestTileResourcesAsync(RequestBuilders.ResourcesRequest)} instead.
*/
- @NonNull
@Deprecated
- ListenableFuture<androidx.wear.tiles.ResourceBuilders.Resources> requestResources(
- @NonNull RequestBuilders.ResourcesRequest requestParams);
+ @NonNull ListenableFuture<androidx.wear.tiles.ResourceBuilders.Resources> requestResources(
+ RequestBuilders.@NonNull ResourcesRequest requestParams);
/** Send a Tile Added notification to the connected TileService. */
- @NonNull
- ListenableFuture<Void> sendOnTileAddedEvent();
+ @NonNull ListenableFuture<Void> sendOnTileAddedEvent();
/** Send a Tile Removed notification to the connected TileService. */
- @NonNull
- ListenableFuture<Void> sendOnTileRemovedEvent();
+ @NonNull ListenableFuture<Void> sendOnTileRemovedEvent();
/** Send a Tile Enter notification to the connected TileService. */
- @NonNull
- ListenableFuture<Void> sendOnTileEnterEvent();
+ @NonNull ListenableFuture<Void> sendOnTileEnterEvent();
/** Send a Tile Leave notification to the connected TileService. */
- @NonNull
- ListenableFuture<Void> sendOnTileLeaveEvent();
+ @NonNull ListenableFuture<Void> sendOnTileLeaveEvent();
}
diff --git a/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/renderer/TileRenderer.java b/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/renderer/TileRenderer.java
index 89f6230..084841d 100644
--- a/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/renderer/TileRenderer.java
+++ b/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/renderer/TileRenderer.java
@@ -23,8 +23,6 @@
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.StyleRes;
import androidx.wear.protolayout.LayoutElementBuilders;
@@ -49,6 +47,9 @@
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -81,24 +82,23 @@
*
* @param nextState The state that the next tile should be in.
*/
- void onClick(@NonNull androidx.wear.tiles.StateBuilders.State nextState);
+ void onClick(androidx.wear.tiles.StateBuilders.@NonNull State nextState);
}
- @NonNull private final Context mUiContext;
- @NonNull private final Executor mLoadActionExecutor;
- @NonNull private final Consumer<StateBuilders.State> mLoadActionListener;
+ private final @NonNull Context mUiContext;
+ private final @NonNull Executor mLoadActionExecutor;
+ private final @NonNull Consumer<StateBuilders.State> mLoadActionListener;
@StyleRes int mTilesTheme = 0; // Default theme.
- @NonNull
- private final Map<PlatformDataProvider, Set<PlatformDataKey<?>>> mPlatformDataProviders =
- new ArrayMap<>();
+ private final @NonNull Map<PlatformDataProvider, Set<PlatformDataKey<?>>>
+ mPlatformDataProviders = new ArrayMap<>();
- @NonNull private final ProtoLayoutViewInstance mInstance;
- @Nullable private final LayoutElementProto.Layout mLayout;
- @Nullable private final ResourceProto.Resources mResources;
- @NonNull private final ListeningExecutorService mUiExecutor;
- @NonNull private final StateStore mStateStore = new StateStore(ImmutableMap.of());
+ private final @NonNull ProtoLayoutViewInstance mInstance;
+ private final LayoutElementProto.@Nullable Layout mLayout;
+ private final ResourceProto.@Nullable Resources mResources;
+ private final @NonNull ListeningExecutorService mUiExecutor;
+ private final @NonNull StateStore mStateStore = new StateStore(ImmutableMap.of());
/**
* Default constructor.
@@ -115,8 +115,8 @@
@Deprecated
public TileRenderer(
@NonNull Context uiContext,
- @NonNull androidx.wear.tiles.LayoutElementBuilders.Layout layout,
- @NonNull androidx.wear.tiles.ResourceBuilders.Resources resources,
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull Layout layout,
+ androidx.wear.tiles.ResourceBuilders.@NonNull Resources resources,
@NonNull Executor loadActionExecutor,
@NonNull LoadActionListener loadActionListener) {
this(
@@ -146,9 +146,9 @@
@Deprecated
public TileRenderer(
@NonNull Context uiContext,
- @NonNull androidx.wear.tiles.LayoutElementBuilders.Layout layout,
+ androidx.wear.tiles.LayoutElementBuilders.@NonNull Layout layout,
@StyleRes int tilesTheme,
- @NonNull androidx.wear.tiles.ResourceBuilders.Resources resources,
+ androidx.wear.tiles.ResourceBuilders.@NonNull Resources resources,
@NonNull Executor loadActionExecutor,
@NonNull LoadActionListener loadActionListener) {
this(
@@ -189,8 +189,8 @@
@StyleRes int tilesTheme,
@NonNull Executor loadActionExecutor,
@NonNull Consumer<StateBuilders.State> loadActionListener,
- @Nullable LayoutElementProto.Layout layout,
- @Nullable ResourceProto.Resources resources,
+ LayoutElementProto.@Nullable Layout layout,
+ ResourceProto.@Nullable Resources resources,
@Nullable Map<PlatformDataProvider, Set<PlatformDataKey<?>>> platformDataProviders) {
this.mUiContext = uiContext;
@@ -227,9 +227,8 @@
this.mInstance = new ProtoLayoutViewInstance(config.build());
}
- @NonNull
@SuppressWarnings("deprecation") // For backward compatibility
- private static Consumer<StateBuilders.State> toStateConsumer(
+ private static @NonNull Consumer<StateBuilders.State> toStateConsumer(
@NonNull LoadActionListener loadActionListener) {
return nextState ->
loadActionListener.onClick(
@@ -253,8 +252,7 @@
* deprecated constructors that accept Layout and Resources.
*/
@Deprecated
- @Nullable
- public View inflate(@NonNull ViewGroup parent) {
+ public @Nullable View inflate(@NonNull ViewGroup parent) {
String errorMessage =
"This method only works with the deprecated constructors that accept Layout and"
+ " Resources.";
@@ -298,38 +296,33 @@
* empty or the top-level LayoutElement has no inner set, or the top-level LayoutElement
* contains an unsupported inner type.
*/
- @NonNull
- public ListenableFuture<View> inflateAsync(
- @NonNull LayoutElementBuilders.Layout layout,
- @NonNull ResourceBuilders.Resources resources,
+ public @NonNull ListenableFuture<View> inflateAsync(
+ LayoutElementBuilders.@NonNull Layout layout,
+ ResourceBuilders.@NonNull Resources resources,
@NonNull ViewGroup parent) {
return inflateLayout(layout.toProto(), resources.toProto(), parent);
}
- @NonNull
- private ListenableFuture<View> inflateLayout(
- @NonNull LayoutElementProto.Layout layout,
- @NonNull ResourceProto.Resources resources,
+ private @NonNull ListenableFuture<View> inflateLayout(
+ LayoutElementProto.@NonNull Layout layout,
+ ResourceProto.@NonNull Resources resources,
@NonNull ViewGroup parent) {
ListenableFuture<Void> result = mInstance.renderAndAttach(layout, resources, parent);
return FluentFuture.from(result).transform(ignored -> parent.getChildAt(0), mUiExecutor);
}
/** Returns the {@link Context} suitable for interacting with the UI. */
- @NonNull
- public Context getUiContext() {
+ public @NonNull Context getUiContext() {
return mUiContext;
}
/** Returns the {@link Executor} for {@code loadActionListener}. */
- @NonNull
- public Executor getLoadActionExecutor() {
+ public @NonNull Executor getLoadActionExecutor() {
return mLoadActionExecutor;
}
/** Returns the Listener for clicks that will cause the contents to be reloaded. */
- @NonNull
- public Consumer<StateBuilders.State> getLoadActionListener() {
+ public @NonNull Consumer<StateBuilders.State> getLoadActionListener() {
return mLoadActionListener;
}
@@ -343,22 +336,20 @@
}
/** Returns the platform data providers that will be registered for this Tile instance. */
- @NonNull
- public Map<PlatformDataProvider, Set<PlatformDataKey<?>>> getPlatformDataProviders() {
+ public @NonNull Map<PlatformDataProvider, Set<PlatformDataKey<?>>> getPlatformDataProviders() {
return Collections.unmodifiableMap(mPlatformDataProviders);
}
/** Builder for {@link TileRenderer}. */
public static final class Builder {
- @NonNull private final Context mUiContext;
- @NonNull private final Executor mLoadActionExecutor;
- @NonNull private final Consumer<StateBuilders.State> mLoadActionListener;
+ private final @NonNull Context mUiContext;
+ private final @NonNull Executor mLoadActionExecutor;
+ private final @NonNull Consumer<StateBuilders.State> mLoadActionListener;
@StyleRes int mTilesTheme = 0; // Default theme.
- @NonNull
- private final Map<PlatformDataProvider, Set<PlatformDataKey<?>>> mPlatformDataProviders =
- new ArrayMap<>();
+ private final @NonNull Map<PlatformDataProvider, Set<PlatformDataKey<?>>>
+ mPlatformDataProviders = new ArrayMap<>();
/**
* Builder for the {@link TileRenderer} class.
@@ -381,8 +372,7 @@
* Sets the theme to use for this Tile instance. This can be used to customise things like
* the default font family. If not set, zero (default theme) will be used.
*/
- @NonNull
- public Builder setTilesTheme(@StyleRes int tilesTheme) {
+ public @NonNull Builder setTilesTheme(@StyleRes int tilesTheme) {
mTilesTheme = tilesTheme;
return this;
}
@@ -392,18 +382,16 @@
* supportedKeys}. Adding the same {@link PlatformDataProvider} several times will override
* previous entries instead of adding multiple entries.
*/
- @NonNull
- public Builder addPlatformDataProvider(
+ public @NonNull Builder addPlatformDataProvider(
@NonNull PlatformDataProvider platformDataProvider,
- @NonNull PlatformDataKey<?>... supportedKeys) {
+ PlatformDataKey<?> @NonNull ... supportedKeys) {
this.mPlatformDataProviders.put(
platformDataProvider, ImmutableSet.copyOf(supportedKeys));
return this;
}
/** Builds {@link TileRenderer} object. */
- @NonNull
- public TileRenderer build() {
+ public @NonNull TileRenderer build() {
return new TileRenderer(
mUiContext,
mTilesTheme,
diff --git a/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/timeline/TilesTimelineCache.java b/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/timeline/TilesTimelineCache.java
index edfd08b..8592cae 100644
--- a/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/timeline/TilesTimelineCache.java
+++ b/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/timeline/TilesTimelineCache.java
@@ -17,12 +17,13 @@
package androidx.wear.tiles.timeline;
import androidx.annotation.MainThread;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.wear.protolayout.TimelineBuilders;
import androidx.wear.protolayout.proto.TimelineProto.TimelineEntry;
import androidx.wear.tiles.timeline.internal.TilesTimelineCacheInternal;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Timeline cache for Wear Tiles. This will take in a full timeline, and return the appropriate
* entry for the given time from {@code findTimelineEntryForTime}.
@@ -36,12 +37,12 @@
* @deprecated Use {@link #TilesTimelineCache(TimelineBuilders.Timeline)} instead.
*/
@Deprecated
- public TilesTimelineCache(@NonNull androidx.wear.tiles.TimelineBuilders.Timeline timeline) {
+ public TilesTimelineCache(androidx.wear.tiles.TimelineBuilders.@NonNull Timeline timeline) {
mCache = new TilesTimelineCacheInternal(timeline.toProto());
}
/** Default constructor. */
- public TilesTimelineCache(@NonNull TimelineBuilders.Timeline timeline) {
+ public TilesTimelineCache(TimelineBuilders.@NonNull Timeline timeline) {
mCache = new TilesTimelineCacheInternal(timeline.toProto());
}
@@ -58,8 +59,7 @@
*/
@Deprecated
@MainThread
- @Nullable
- public androidx.wear.tiles.TimelineBuilders.TimelineEntry findTimelineEntryForTime(
+ public androidx.wear.tiles.TimelineBuilders.@Nullable TimelineEntry findTimelineEntryForTime(
long timeMillis) {
TimelineEntry entry = mCache.findTimelineEntryForTime(timeMillis);
@@ -81,8 +81,7 @@
* none are valid.
*/
@MainThread
- @Nullable
- public TimelineBuilders.TimelineEntry findTileTimelineEntryForTime(long timeMillis) {
+ public TimelineBuilders.@Nullable TimelineEntry findTileTimelineEntryForTime(long timeMillis) {
TimelineEntry entry = mCache.findTimelineEntryForTime(timeMillis);
if (entry == null) {
@@ -107,9 +106,8 @@
* @deprecated Use {@link #findClosestTileTimelineEntry(long)} instead.
*/
@MainThread
- @Nullable
@Deprecated
- public androidx.wear.tiles.TimelineBuilders.TimelineEntry findClosestTimelineEntry(
+ public androidx.wear.tiles.TimelineBuilders.@Nullable TimelineEntry findClosestTimelineEntry(
long timeMillis) {
TimelineEntry entry = mCache.findClosestTimelineEntry(timeMillis);
@@ -134,8 +132,7 @@
* @return The timeline entry with validity period closest to {@code timeMillis}.
*/
@MainThread
- @Nullable
- public TimelineBuilders.TimelineEntry findClosestTileTimelineEntry(long timeMillis) {
+ public TimelineBuilders.@Nullable TimelineEntry findClosestTileTimelineEntry(long timeMillis) {
TimelineEntry entry = mCache.findClosestTimelineEntry(timeMillis);
if (entry == null) {
@@ -161,7 +158,7 @@
@Deprecated
@MainThread
public long findCurrentTimelineEntryExpiry(
- @NonNull androidx.wear.tiles.TimelineBuilders.TimelineEntry entry,
+ androidx.wear.tiles.TimelineBuilders.@NonNull TimelineEntry entry,
long fromTimeMillis) {
return mCache.findCurrentTimelineEntryExpiry(entry.toProto(), fromTimeMillis);
}
@@ -179,7 +176,7 @@
*/
@MainThread
public long findCurrentTimelineEntryExpiry(
- @NonNull TimelineBuilders.TimelineEntry entry, long fromTimeMillis) {
+ TimelineBuilders.@NonNull TimelineEntry entry, long fromTimeMillis) {
return mCache.findCurrentTimelineEntryExpiry(entry.toProto(), fromTimeMillis);
}
}
diff --git a/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/timeline/TilesTimelineManager.java b/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/timeline/TilesTimelineManager.java
index d3ad277..85e601f 100644
--- a/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/timeline/TilesTimelineManager.java
+++ b/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/timeline/TilesTimelineManager.java
@@ -18,12 +18,13 @@
import android.app.AlarmManager;
-import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.wear.protolayout.LayoutElementBuilders;
import androidx.wear.protolayout.TimelineBuilders;
import androidx.wear.tiles.timeline.internal.TilesTimelineManagerInternal;
+import org.jspecify.annotations.NonNull;
+
import java.util.concurrent.Executor;
/**
@@ -61,7 +62,7 @@
*/
@Deprecated
void onLayoutUpdate(
- int token, @NonNull androidx.wear.tiles.LayoutElementBuilders.Layout layout);
+ int token, androidx.wear.tiles.LayoutElementBuilders.@NonNull Layout layout);
}
/** Type to listen for layout updates from a given timeline. */
@@ -73,7 +74,7 @@
* @param token The token originally passed to {@link TilesTimelineManager}.
* @param layout The new layout to use.
*/
- void onLayoutUpdate(int token, @NonNull LayoutElementBuilders.Layout layout);
+ void onLayoutUpdate(int token, LayoutElementBuilders.@NonNull Layout layout);
}
private final TilesTimelineManagerInternal mManager;
@@ -96,7 +97,7 @@
public TilesTimelineManager(
@NonNull AlarmManager alarmManager,
@NonNull Clock clock,
- @NonNull androidx.wear.tiles.TimelineBuilders.Timeline timeline,
+ androidx.wear.tiles.TimelineBuilders.@NonNull Timeline timeline,
int token,
@NonNull Executor listenerExecutor,
@NonNull Listener listener) {
@@ -128,7 +129,7 @@
public TilesTimelineManager(
@NonNull AlarmManager alarmManager,
@NonNull Clock clock,
- @NonNull TimelineBuilders.Timeline timeline,
+ TimelineBuilders.@NonNull Timeline timeline,
int token,
@NonNull Executor listenerExecutor,
@NonNull LayoutUpdateListener listener) {
diff --git a/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/timeline/internal/TilesTimelineCacheInternal.java b/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/timeline/internal/TilesTimelineCacheInternal.java
index 4571ad5..fa20027 100644
--- a/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/timeline/internal/TilesTimelineCacheInternal.java
+++ b/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/timeline/internal/TilesTimelineCacheInternal.java
@@ -17,12 +17,13 @@
package androidx.wear.tiles.timeline.internal;
import androidx.annotation.MainThread;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.wear.protolayout.proto.TimelineProto.TimeInterval;
import androidx.wear.protolayout.proto.TimelineProto.Timeline;
import androidx.wear.protolayout.proto.TimelineProto.TimelineEntry;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Timeline cache for Tiles. This will take in a full timeline, and return the appropriate entry for
* the given time from {@code findTimelineEntryForTime}.
@@ -45,8 +46,7 @@
* none are valid.
*/
@MainThread
- @Nullable
- public TimelineEntry findTimelineEntryForTime(long timeMillis) {
+ public @Nullable TimelineEntry findTimelineEntryForTime(long timeMillis) {
TimelineEntry currentEntry = null;
long currentEntryLength = Long.MAX_VALUE;
@@ -93,8 +93,7 @@
* @return The timeline entry with validity period closest to {@code timeMillis}.
*/
@MainThread
- @Nullable
- public TimelineEntry findClosestTimelineEntry(long timeMillis) {
+ public @Nullable TimelineEntry findClosestTimelineEntry(long timeMillis) {
long currentEntryError = Long.MAX_VALUE;
TimelineEntry currentEntry = null;
diff --git a/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/timeline/internal/TilesTimelineManagerInternal.java b/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/timeline/internal/TilesTimelineManagerInternal.java
index d25e42d..4dc70ac 100644
--- a/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/timeline/internal/TilesTimelineManagerInternal.java
+++ b/wear/tiles/tiles-renderer/src/main/java/androidx/wear/tiles/timeline/internal/TilesTimelineManagerInternal.java
@@ -23,11 +23,12 @@
import android.app.AlarmManager.OnAlarmListener;
import android.util.Log;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.wear.protolayout.proto.TimelineProto.Timeline;
import androidx.wear.protolayout.proto.TimelineProto.TimelineEntry;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.concurrent.Executor;
/**
@@ -65,7 +66,7 @@
private final Executor mListenerExecutor;
private final Listener mListener;
private final int mToken;
- @Nullable private OnAlarmListener mAlarmListener = null;
+ private @Nullable OnAlarmListener mAlarmListener = null;
/**
* Default constructor.
diff --git a/wear/tiles/tiles-renderer/src/test/java/androidx/wear/tiles/connection/DefaultTileClientTest.kt b/wear/tiles/tiles-renderer/src/test/java/androidx/wear/tiles/connection/DefaultTileClientTest.kt
index 12d39a7d..91bc67c 100644
--- a/wear/tiles/tiles-renderer/src/test/java/androidx/wear/tiles/connection/DefaultTileClientTest.kt
+++ b/wear/tiles/tiles-renderer/src/test/java/androidx/wear/tiles/connection/DefaultTileClientTest.kt
@@ -33,6 +33,7 @@
import androidx.wear.tiles.TileCallback
import androidx.wear.tiles.TileData
import androidx.wear.tiles.TileEnterEventData
+import androidx.wear.tiles.TileInteractionEventData
import androidx.wear.tiles.TileLeaveEventData
import androidx.wear.tiles.TileProvider
import androidx.wear.tiles.TileRemoveEventData
@@ -371,5 +372,9 @@
override fun onTileLeaveEvent(requestData: TileLeaveEventData?) {
onTileLeaveCalled = true
}
+
+ override fun processRecentInteractionEvents(
+ events: MutableList<TileInteractionEventData>?
+ ) {}
}
}
diff --git a/wear/tiles/tiles-renderer/src/test/java/androidx/wear/tiles/connection/TilesConnectionBinderTest.kt b/wear/tiles/tiles-renderer/src/test/java/androidx/wear/tiles/connection/TilesConnectionBinderTest.kt
index 43fc218..df06d7e 100644
--- a/wear/tiles/tiles-renderer/src/test/java/androidx/wear/tiles/connection/TilesConnectionBinderTest.kt
+++ b/wear/tiles/tiles-renderer/src/test/java/androidx/wear/tiles/connection/TilesConnectionBinderTest.kt
@@ -26,6 +26,7 @@
import androidx.wear.tiles.TileAddEventData
import androidx.wear.tiles.TileCallback
import androidx.wear.tiles.TileEnterEventData
+import androidx.wear.tiles.TileInteractionEventData
import androidx.wear.tiles.TileLeaveEventData
import androidx.wear.tiles.TileProvider
import androidx.wear.tiles.TileRemoveEventData
@@ -322,5 +323,11 @@
override fun onTileLeaveEvent(requestData: TileLeaveEventData?) {
TODO("Not yet implemented")
}
+
+ override fun processRecentInteractionEvents(
+ events: MutableList<TileInteractionEventData>?
+ ) {
+ TODO("Not yet implemented")
+ }
}
}
diff --git a/wear/tiles/tiles-renderer/src/test/java/androidx/wear/tiles/timeline/TilesTimelineCacheTest.java b/wear/tiles/tiles-renderer/src/test/java/androidx/wear/tiles/timeline/TilesTimelineCacheTest.java
index e7a1782..5ef39ef 100644
--- a/wear/tiles/tiles-renderer/src/test/java/androidx/wear/tiles/timeline/TilesTimelineCacheTest.java
+++ b/wear/tiles/tiles-renderer/src/test/java/androidx/wear/tiles/timeline/TilesTimelineCacheTest.java
@@ -18,13 +18,13 @@
import static com.google.common.truth.Truth.assertThat;
-import androidx.annotation.Nullable;
import androidx.wear.protolayout.LayoutElementBuilders;
import androidx.wear.protolayout.TimelineBuilders;
import androidx.wear.tiles.TilesTestRunner;
import com.google.common.truth.Expect;
+import org.jspecify.annotations.Nullable;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -552,8 +552,8 @@
}
private void expectTimelineEntryEqual(
- @Nullable TimelineBuilders.TimelineEntry actual,
- @Nullable TimelineBuilders.TimelineEntry expected) {
+ TimelineBuilders.@Nullable TimelineEntry actual,
+ TimelineBuilders.@Nullable TimelineEntry expected) {
if (expected == null) {
expect.that(actual).isNull();
} else {
diff --git a/wear/tiles/tiles/api/current.txt b/wear/tiles/tiles/api/current.txt
index 7cd96a0..70ff7e7 100644
--- a/wear/tiles/tiles/api/current.txt
+++ b/wear/tiles/tiles/api/current.txt
@@ -1047,11 +1047,12 @@
method public android.os.IBinder? onBind(android.content.Intent);
method @Deprecated @MainThread protected com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.ResourceBuilders.Resources!> onResourcesRequest(androidx.wear.tiles.RequestBuilders.ResourcesRequest);
method @MainThread protected void onTileAddEvent(androidx.wear.tiles.EventBuilders.TileAddEvent);
- method @MainThread protected void onTileEnterEvent(androidx.wear.tiles.EventBuilders.TileEnterEvent);
- method @MainThread protected void onTileLeaveEvent(androidx.wear.tiles.EventBuilders.TileLeaveEvent);
+ method @Deprecated @MainThread protected void onTileEnterEvent(androidx.wear.tiles.EventBuilders.TileEnterEvent);
+ method @Deprecated @MainThread protected void onTileLeaveEvent(androidx.wear.tiles.EventBuilders.TileLeaveEvent);
method @MainThread protected void onTileRemoveEvent(androidx.wear.tiles.EventBuilders.TileRemoveEvent);
method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.TileBuilders.Tile!> onTileRequest(androidx.wear.tiles.RequestBuilders.TileRequest);
method @MainThread protected com.google.common.util.concurrent.ListenableFuture<androidx.wear.protolayout.ResourceBuilders.Resources!> onTileResourcesRequest(androidx.wear.tiles.RequestBuilders.ResourcesRequest);
+ method @MainThread protected void processRecentInteractionEvents(java.util.List<androidx.wear.tiles.EventBuilders.TileInteractionEvent!>);
field public static final String ACTION_BIND_TILE_PROVIDER = "androidx.wear.tiles.action.BIND_TILE_PROVIDER";
field public static final String EXTRA_CLICKABLE_ID = "androidx.wear.tiles.extra.CLICKABLE_ID";
field public static final String METADATA_PREVIEW_KEY = "androidx.wear.tiles.PREVIEW";
diff --git a/wear/tiles/tiles/api/restricted_current.txt b/wear/tiles/tiles/api/restricted_current.txt
index 7cd96a0..70ff7e7 100644
--- a/wear/tiles/tiles/api/restricted_current.txt
+++ b/wear/tiles/tiles/api/restricted_current.txt
@@ -1047,11 +1047,12 @@
method public android.os.IBinder? onBind(android.content.Intent);
method @Deprecated @MainThread protected com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.ResourceBuilders.Resources!> onResourcesRequest(androidx.wear.tiles.RequestBuilders.ResourcesRequest);
method @MainThread protected void onTileAddEvent(androidx.wear.tiles.EventBuilders.TileAddEvent);
- method @MainThread protected void onTileEnterEvent(androidx.wear.tiles.EventBuilders.TileEnterEvent);
- method @MainThread protected void onTileLeaveEvent(androidx.wear.tiles.EventBuilders.TileLeaveEvent);
+ method @Deprecated @MainThread protected void onTileEnterEvent(androidx.wear.tiles.EventBuilders.TileEnterEvent);
+ method @Deprecated @MainThread protected void onTileLeaveEvent(androidx.wear.tiles.EventBuilders.TileLeaveEvent);
method @MainThread protected void onTileRemoveEvent(androidx.wear.tiles.EventBuilders.TileRemoveEvent);
method @MainThread protected abstract com.google.common.util.concurrent.ListenableFuture<androidx.wear.tiles.TileBuilders.Tile!> onTileRequest(androidx.wear.tiles.RequestBuilders.TileRequest);
method @MainThread protected com.google.common.util.concurrent.ListenableFuture<androidx.wear.protolayout.ResourceBuilders.Resources!> onTileResourcesRequest(androidx.wear.tiles.RequestBuilders.ResourcesRequest);
+ method @MainThread protected void processRecentInteractionEvents(java.util.List<androidx.wear.tiles.EventBuilders.TileInteractionEvent!>);
field public static final String ACTION_BIND_TILE_PROVIDER = "androidx.wear.tiles.action.BIND_TILE_PROVIDER";
field public static final String EXTRA_CLICKABLE_ID = "androidx.wear.tiles.extra.CLICKABLE_ID";
field public static final String METADATA_PREVIEW_KEY = "androidx.wear.tiles.PREVIEW";
diff --git a/wear/tiles/tiles/build.gradle b/wear/tiles/tiles/build.gradle
index 316a1fa..a69618c 100644
--- a/wear/tiles/tiles/build.gradle
+++ b/wear/tiles/tiles/build.gradle
@@ -29,6 +29,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.annotation:annotation:1.8.1")
api(project(":wear:protolayout:protolayout"))
api(project(":wear:protolayout:protolayout-expression"))
diff --git a/lifecycle/lifecycle-viewmodel-testing/src/nonJvmCommonMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.nonJvm.kt b/wear/tiles/tiles/src/main/aidl/androidx/wear/tiles/TileInteractionEventData.aidl
similarity index 70%
rename from lifecycle/lifecycle-viewmodel-testing/src/nonJvmCommonMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.nonJvm.kt
rename to wear/tiles/tiles/src/main/aidl/androidx/wear/tiles/TileInteractionEventData.aidl
index e220c67..0c492cd 100644
--- a/lifecycle/lifecycle-viewmodel-testing/src/nonJvmCommonMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.nonJvm.kt
+++ b/wear/tiles/tiles/src/main/aidl/androidx/wear/tiles/TileInteractionEventData.aidl
@@ -13,10 +13,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-package androidx.lifecycle.viewmodel.testing
-
-import androidx.lifecycle.viewmodel.CreationExtras
-import androidx.lifecycle.viewmodel.CreationExtras.Empty
-
-@Suppress("FunctionName") public actual fun DefaultCreationExtras(): CreationExtras = Empty
+package androidx.wear.tiles;
+parcelable TileInteractionEventData;
diff --git a/wear/tiles/tiles/src/main/aidl/androidx/wear/tiles/TileProvider.aidl b/wear/tiles/tiles/src/main/aidl/androidx/wear/tiles/TileProvider.aidl
index b86756f..7ef39bbb 100644
--- a/wear/tiles/tiles/src/main/aidl/androidx/wear/tiles/TileProvider.aidl
+++ b/wear/tiles/tiles/src/main/aidl/androidx/wear/tiles/TileProvider.aidl
@@ -20,6 +20,7 @@
import androidx.wear.tiles.TileCallback;
import androidx.wear.tiles.TileAddEventData;
import androidx.wear.tiles.TileEnterEventData;
+import androidx.wear.tiles.TileInteractionEventData;
import androidx.wear.tiles.TileLeaveEventData;
import androidx.wear.tiles.TileRequestData;
import androidx.wear.tiles.TileRemoveEventData;
@@ -33,8 +34,7 @@
*/
@JavaPassthrough(annotation="@androidx.annotation.RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY)")
interface TileProvider {
-
- const int API_VERSION = 1;
+ const int API_VERSION = 3;
/**
* Gets the version of this TileProvider interface implemented by this
@@ -92,4 +92,11 @@
* @since version 1
*/
oneway void onTileLeaveEvent(in TileLeaveEventData requestData) = 8;
+
+ /**
+ * Called daily when the renderer sends batched Tile interaction events.
+ *
+ * @since version 3
+ */
+ oneway void processRecentInteractionEvents(in List<TileInteractionEventData> events) = 10;
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ActionBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ActionBuilders.java
index 37ad14f..85f81af 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ActionBuilders.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ActionBuilders.java
@@ -22,13 +22,14 @@
import android.annotation.SuppressLint;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.ActionProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Collections;
import java.util.Map;
@@ -42,39 +43,34 @@
private ActionBuilders() {}
/** Shortcut for building an {@link AndroidStringExtra}. */
- @NonNull
- public static AndroidStringExtra stringExtra(@NonNull String value) {
+ public static @NonNull AndroidStringExtra stringExtra(@NonNull String value) {
return new AndroidStringExtra.Builder().setValue(value).build();
}
/** Shortcut for building an {@link AndroidIntExtra}. */
- @NonNull
- public static AndroidIntExtra intExtra(int value) {
+ public static @NonNull AndroidIntExtra intExtra(int value) {
return new AndroidIntExtra.Builder().setValue(value).build();
}
/** Shortcut for building an {@link AndroidLongExtra}. */
- @NonNull
- public static AndroidLongExtra longExtra(long value) {
+ public static @NonNull AndroidLongExtra longExtra(long value) {
return new AndroidLongExtra.Builder().setValue(value).build();
}
/** Shortcut for building an {@link AndroidDoubleExtra}. */
- @NonNull
- public static AndroidDoubleExtra doubleExtra(double value) {
+ public static @NonNull AndroidDoubleExtra doubleExtra(double value) {
return new AndroidDoubleExtra.Builder().setValue(value).build();
}
/** Shortcut for building an {@link AndroidBooleanExtra}. */
- @NonNull
- public static AndroidBooleanExtra booleanExtra(boolean value) {
+ public static @NonNull AndroidBooleanExtra booleanExtra(boolean value) {
return new AndroidBooleanExtra.Builder().setValue(value).build();
}
/** A string value that can be added to an Android intent's extras. */
public static final class AndroidStringExtra implements AndroidExtra {
private final ActionProto.AndroidStringExtra mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AndroidStringExtra(ActionProto.AndroidStringExtra impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -82,32 +78,28 @@
}
/** Gets the value. Intended for testing purposes only. */
- @NonNull
- public String getValue() {
+ public @NonNull String getValue() {
return mImpl.getValue();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static AndroidStringExtra fromProto(@NonNull ActionProto.AndroidStringExtra proto) {
+ static @NonNull AndroidStringExtra fromProto(
+ ActionProto.@NonNull AndroidStringExtra proto) {
return new AndroidStringExtra(proto, null);
}
- @NonNull
- ActionProto.AndroidStringExtra toProto() {
+ ActionProto.@NonNull AndroidStringExtra toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ActionProto.AndroidExtra toAndroidExtraProto() {
+ public ActionProto.@NonNull AndroidExtra toAndroidExtraProto() {
return ActionProto.AndroidExtra.newBuilder().setStringVal(mImpl).build();
}
@@ -120,16 +112,14 @@
public Builder() {}
/** Sets the value. */
- @NonNull
- public Builder setValue(@NonNull String value) {
+ public @NonNull Builder setValue(@NonNull String value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, value.hashCode());
return this;
}
@Override
- @NonNull
- public AndroidStringExtra build() {
+ public @NonNull AndroidStringExtra build() {
return new AndroidStringExtra(mImpl.build(), mFingerprint);
}
}
@@ -138,7 +128,7 @@
/** An integer value that can be added to an Android intent's extras. */
public static final class AndroidIntExtra implements AndroidExtra {
private final ActionProto.AndroidIntExtra mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AndroidIntExtra(ActionProto.AndroidIntExtra impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -152,25 +142,21 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static AndroidIntExtra fromProto(@NonNull ActionProto.AndroidIntExtra proto) {
+ static @NonNull AndroidIntExtra fromProto(ActionProto.@NonNull AndroidIntExtra proto) {
return new AndroidIntExtra(proto, null);
}
- @NonNull
- ActionProto.AndroidIntExtra toProto() {
+ ActionProto.@NonNull AndroidIntExtra toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ActionProto.AndroidExtra toAndroidExtraProto() {
+ public ActionProto.@NonNull AndroidExtra toAndroidExtraProto() {
return ActionProto.AndroidExtra.newBuilder().setIntVal(mImpl).build();
}
@@ -183,16 +169,14 @@
public Builder() {}
/** Sets the value. */
- @NonNull
- public Builder setValue(int value) {
+ public @NonNull Builder setValue(int value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
@Override
- @NonNull
- public AndroidIntExtra build() {
+ public @NonNull AndroidIntExtra build() {
return new AndroidIntExtra(mImpl.build(), mFingerprint);
}
}
@@ -201,7 +185,7 @@
/** A long value that can be added to an Android intent's extras. */
public static final class AndroidLongExtra implements AndroidExtra {
private final ActionProto.AndroidLongExtra mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AndroidLongExtra(ActionProto.AndroidLongExtra impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -215,25 +199,21 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static AndroidLongExtra fromProto(@NonNull ActionProto.AndroidLongExtra proto) {
+ static @NonNull AndroidLongExtra fromProto(ActionProto.@NonNull AndroidLongExtra proto) {
return new AndroidLongExtra(proto, null);
}
- @NonNull
- ActionProto.AndroidLongExtra toProto() {
+ ActionProto.@NonNull AndroidLongExtra toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ActionProto.AndroidExtra toAndroidExtraProto() {
+ public ActionProto.@NonNull AndroidExtra toAndroidExtraProto() {
return ActionProto.AndroidExtra.newBuilder().setLongVal(mImpl).build();
}
@@ -246,16 +226,14 @@
public Builder() {}
/** Sets the value. */
- @NonNull
- public Builder setValue(long value) {
+ public @NonNull Builder setValue(long value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, Long.hashCode(value));
return this;
}
@Override
- @NonNull
- public AndroidLongExtra build() {
+ public @NonNull AndroidLongExtra build() {
return new AndroidLongExtra(mImpl.build(), mFingerprint);
}
}
@@ -264,7 +242,7 @@
/** A double value that can be added to an Android intent's extras. */
public static final class AndroidDoubleExtra implements AndroidExtra {
private final ActionProto.AndroidDoubleExtra mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AndroidDoubleExtra(ActionProto.AndroidDoubleExtra impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -278,25 +256,22 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static AndroidDoubleExtra fromProto(@NonNull ActionProto.AndroidDoubleExtra proto) {
+ static @NonNull AndroidDoubleExtra fromProto(
+ ActionProto.@NonNull AndroidDoubleExtra proto) {
return new AndroidDoubleExtra(proto, null);
}
- @NonNull
- ActionProto.AndroidDoubleExtra toProto() {
+ ActionProto.@NonNull AndroidDoubleExtra toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ActionProto.AndroidExtra toAndroidExtraProto() {
+ public ActionProto.@NonNull AndroidExtra toAndroidExtraProto() {
return ActionProto.AndroidExtra.newBuilder().setDoubleVal(mImpl).build();
}
@@ -309,16 +284,14 @@
public Builder() {}
/** Sets the value. */
- @NonNull
- public Builder setValue(double value) {
+ public @NonNull Builder setValue(double value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, Double.hashCode(value));
return this;
}
@Override
- @NonNull
- public AndroidDoubleExtra build() {
+ public @NonNull AndroidDoubleExtra build() {
return new AndroidDoubleExtra(mImpl.build(), mFingerprint);
}
}
@@ -327,7 +300,7 @@
/** A boolean value that can be added to an Android intent's extras. */
public static final class AndroidBooleanExtra implements AndroidExtra {
private final ActionProto.AndroidBooleanExtra mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AndroidBooleanExtra(
ActionProto.AndroidBooleanExtra impl, @Nullable Fingerprint fingerprint) {
@@ -342,25 +315,22 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static AndroidBooleanExtra fromProto(@NonNull ActionProto.AndroidBooleanExtra proto) {
+ static @NonNull AndroidBooleanExtra fromProto(
+ ActionProto.@NonNull AndroidBooleanExtra proto) {
return new AndroidBooleanExtra(proto, null);
}
- @NonNull
- ActionProto.AndroidBooleanExtra toProto() {
+ ActionProto.@NonNull AndroidBooleanExtra toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ActionProto.AndroidExtra toAndroidExtraProto() {
+ public ActionProto.@NonNull AndroidExtra toAndroidExtraProto() {
return ActionProto.AndroidExtra.newBuilder().setBooleanVal(mImpl).build();
}
@@ -374,16 +344,14 @@
/** Sets the value. */
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setValue(boolean value) {
+ public @NonNull Builder setValue(boolean value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, Boolean.hashCode(value));
return this;
}
@Override
- @NonNull
- public AndroidBooleanExtra build() {
+ public @NonNull AndroidBooleanExtra build() {
return new AndroidBooleanExtra(mImpl.build(), mFingerprint);
}
}
@@ -396,29 +364,25 @@
public interface AndroidExtra {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- ActionProto.AndroidExtra toAndroidExtraProto();
+ ActionProto.@NonNull AndroidExtra toAndroidExtraProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link AndroidExtra} objects. */
@SuppressLint("StaticFinalBuilder")
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- AndroidExtra build();
+ @NonNull AndroidExtra build();
}
}
/**
* Return an instance of one of this object's subtypes, from the protocol buffer representation.
*/
- @NonNull
- static AndroidExtra androidExtraFromProto(@NonNull ActionProto.AndroidExtra proto) {
+ static @NonNull AndroidExtra androidExtraFromProto(ActionProto.@NonNull AndroidExtra proto) {
if (proto.hasStringVal()) {
return AndroidStringExtra.fromProto(proto.getStringVal());
}
@@ -440,7 +404,7 @@
/** A launch action to send an intent to an Android activity. */
public static final class AndroidActivity {
private final ActionProto.AndroidActivity mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
AndroidActivity(ActionProto.AndroidActivity impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -451,8 +415,7 @@
* Gets the package name to send the intent to, for example, "com.google.weather". Intended
* for testing purposes only.
*/
- @NonNull
- public String getPackageName() {
+ public @NonNull String getPackageName() {
return mImpl.getPackageName();
}
@@ -461,14 +424,12 @@
* example, "com.google.weather.WeatherOverviewActivity". Intended for testing purposes
* only.
*/
- @NonNull
- public String getClassName() {
+ public @NonNull String getClassName() {
return mImpl.getClassName();
}
/** Gets the extras to be included in the intent. Intended for testing purposes only. */
- @NonNull
- public Map<String, AndroidExtra> getKeyToExtraMapping() {
+ public @NonNull Map<String, AndroidExtra> getKeyToExtraMapping() {
return Collections.unmodifiableMap(
mImpl.getKeyToExtraMap().entrySet().stream()
.collect(
@@ -479,18 +440,15 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static AndroidActivity fromProto(@NonNull ActionProto.AndroidActivity proto) {
+ static @NonNull AndroidActivity fromProto(ActionProto.@NonNull AndroidActivity proto) {
return new AndroidActivity(proto, null);
}
- @NonNull
- ActionProto.AndroidActivity toProto() {
+ ActionProto.@NonNull AndroidActivity toProto() {
return mImpl;
}
@@ -503,8 +461,7 @@
public Builder() {}
/** Sets the package name to send the intent to, for example, "com.google.weather". */
- @NonNull
- public Builder setPackageName(@NonNull String packageName) {
+ public @NonNull Builder setPackageName(@NonNull String packageName) {
mImpl.setPackageName(packageName);
mFingerprint.recordPropertyUpdate(1, packageName.hashCode());
return this;
@@ -514,8 +471,7 @@
* Sets the fully qualified class name (including the package) to send the intent to,
* for example, "com.google.weather.WeatherOverviewActivity".
*/
- @NonNull
- public Builder setClassName(@NonNull String className) {
+ public @NonNull Builder setClassName(@NonNull String className) {
mImpl.setClassName(className);
mFingerprint.recordPropertyUpdate(2, className.hashCode());
return this;
@@ -523,8 +479,8 @@
/** Adds an entry into the extras to be included in the intent. */
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addKeyToExtraMapping(@NonNull String key, @NonNull AndroidExtra extra) {
+ public @NonNull Builder addKeyToExtraMapping(@NonNull String key,
+ @NonNull AndroidExtra extra) {
mImpl.putKeyToExtra(key, extra.toAndroidExtraProto());
mFingerprint.recordPropertyUpdate(
key.hashCode(), checkNotNull(extra.getFingerprint()).aggregateValueAsInt());
@@ -532,8 +488,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public AndroidActivity build() {
+ public @NonNull AndroidActivity build() {
return new AndroidActivity(mImpl.build(), mFingerprint);
}
}
@@ -546,7 +501,7 @@
*/
public static final class LaunchAction implements Action {
private final ActionProto.LaunchAction mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
LaunchAction(ActionProto.LaunchAction impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -554,8 +509,7 @@
}
/** Gets an action to launch an Android activity. Intended for testing purposes only. */
- @Nullable
- public AndroidActivity getAndroidActivity() {
+ public @Nullable AndroidActivity getAndroidActivity() {
if (mImpl.hasAndroidActivity()) {
return AndroidActivity.fromProto(mImpl.getAndroidActivity());
} else {
@@ -565,25 +519,21 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static LaunchAction fromProto(@NonNull ActionProto.LaunchAction proto) {
+ static @NonNull LaunchAction fromProto(ActionProto.@NonNull LaunchAction proto) {
return new LaunchAction(proto, null);
}
- @NonNull
- ActionProto.LaunchAction toProto() {
+ ActionProto.@NonNull LaunchAction toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ActionProto.Action toActionProto() {
+ public ActionProto.@NonNull Action toActionProto() {
return ActionProto.Action.newBuilder().setLaunchAction(mImpl).build();
}
@@ -596,8 +546,7 @@
public Builder() {}
/** Sets an action to launch an Android activity. */
- @NonNull
- public Builder setAndroidActivity(@NonNull AndroidActivity androidActivity) {
+ public @NonNull Builder setAndroidActivity(@NonNull AndroidActivity androidActivity) {
mImpl.setAndroidActivity(androidActivity.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(androidActivity.getFingerprint()).aggregateValueAsInt());
@@ -605,8 +554,7 @@
}
@Override
- @NonNull
- public LaunchAction build() {
+ public @NonNull LaunchAction build() {
return new LaunchAction(mImpl.build(), mFingerprint);
}
}
@@ -615,7 +563,7 @@
/** An action used to load (or reload) the tile contents. */
public static final class LoadAction implements Action {
private final ActionProto.LoadAction mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
LoadAction(ActionProto.LoadAction impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -628,8 +576,7 @@
* {@link androidx.wear.tiles.ModifiersBuilders.Clickable}. Intended for testing purposes
* only.
*/
- @Nullable
- public StateBuilders.State getRequestState() {
+ public StateBuilders.@Nullable State getRequestState() {
if (mImpl.hasRequestState()) {
return StateBuilders.State.fromProto(mImpl.getRequestState());
} else {
@@ -639,25 +586,21 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static LoadAction fromProto(@NonNull ActionProto.LoadAction proto) {
+ static @NonNull LoadAction fromProto(ActionProto.@NonNull LoadAction proto) {
return new LoadAction(proto, null);
}
- @NonNull
- ActionProto.LoadAction toProto() {
+ ActionProto.@NonNull LoadAction toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ActionProto.Action toActionProto() {
+ public ActionProto.@NonNull Action toActionProto() {
return ActionProto.Action.newBuilder().setLoadAction(mImpl).build();
}
@@ -674,8 +617,7 @@
* androidx.wear.tiles.RequestBuilders.TileRequest} sent after this action is invoked by
* a {@link androidx.wear.tiles.ModifiersBuilders.Clickable}.
*/
- @NonNull
- public Builder setRequestState(@NonNull StateBuilders.State requestState) {
+ public @NonNull Builder setRequestState(StateBuilders.@NonNull State requestState) {
mImpl.setRequestState(requestState.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(requestState.getFingerprint()).aggregateValueAsInt());
@@ -683,8 +625,7 @@
}
@Override
- @NonNull
- public LoadAction build() {
+ public @NonNull LoadAction build() {
return new LoadAction(mImpl.build(), mFingerprint);
}
}
@@ -694,29 +635,25 @@
public interface Action {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- ActionProto.Action toActionProto();
+ ActionProto.@NonNull Action toActionProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link Action} objects. */
@SuppressLint("StaticFinalBuilder")
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- Action build();
+ @NonNull Action build();
}
}
/**
* Return an instance of one of this object's subtypes, from the protocol buffer representation.
*/
- @NonNull
- static Action actionFromProto(@NonNull ActionProto.Action proto) {
+ static @NonNull Action actionFromProto(ActionProto.@NonNull Action proto) {
if (proto.hasLaunchAction()) {
return LaunchAction.fromProto(proto.getLaunchAction());
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ActiveTileIdentifier.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ActiveTileIdentifier.java
index 419d8f9..9d53721 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ActiveTileIdentifier.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ActiveTileIdentifier.java
@@ -18,7 +18,7 @@
import android.content.ComponentName;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* Tile information containing the tile instance ID and component name for identifying a tile
@@ -34,8 +34,7 @@
}
/** Component name of the tile provider. */
- @NonNull
- public ComponentName getComponentName() {
+ public @NonNull ComponentName getComponentName() {
return mComponentName;
}
@@ -53,8 +52,7 @@
* represented as the tileId, concatenated with a ':' and then the component name flattened
* to string.
*/
- @NonNull
- String flattenToString() {
+ @NonNull String flattenToString() {
return mInstanceId + ":" + mComponentName.flattenToString();
}
@@ -67,8 +65,7 @@
* @return Returns a new ActiveTileIdentifier containing the tile id and component name that
* were encoded in {@code string}.
*/
- @NonNull
- static ActiveTileIdentifier unflattenFromString(@NonNull String string) {
+ static @NonNull ActiveTileIdentifier unflattenFromString(@NonNull String string) {
int delimiterIndex = string.indexOf(":");
return new ActiveTileIdentifier(
ComponentName.unflattenFromString(string.substring(delimiterIndex + 1)),
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ColorBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ColorBuilders.java
index dd34db9..3e0526a 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ColorBuilders.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ColorBuilders.java
@@ -17,13 +17,14 @@
package androidx.wear.tiles;
import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.ColorProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Builders for color utilities for layout elements.
*
@@ -34,15 +35,14 @@
private ColorBuilders() {}
/** Shortcut for building a {@link ColorProp} using an ARGB value. */
- @NonNull
- public static ColorProp argb(@ColorInt int colorArgb) {
+ public static @NonNull ColorProp argb(@ColorInt int colorArgb) {
return new ColorProp.Builder().setArgb(colorArgb).build();
}
/** A property defining a color. */
public static final class ColorProp {
private final ColorProto.ColorProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ColorProp(ColorProto.ColorProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -57,18 +57,15 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static ColorProp fromProto(@NonNull ColorProto.ColorProp proto) {
+ static @NonNull ColorProp fromProto(ColorProto.@NonNull ColorProp proto) {
return new ColorProp(proto, null);
}
- @NonNull
- ColorProto.ColorProp toProto() {
+ ColorProto.@NonNull ColorProp toProto() {
return mImpl;
}
@@ -80,16 +77,14 @@
public Builder() {}
/** Sets the color value, in ARGB format. */
- @NonNull
- public Builder setArgb(@ColorInt int argb) {
+ public @NonNull Builder setArgb(@ColorInt int argb) {
mImpl.setArgb(argb);
mFingerprint.recordPropertyUpdate(1, argb);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public ColorProp build() {
+ public @NonNull ColorProp build() {
return new ColorProp(mImpl.build(), mFingerprint);
}
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/CompositeTileUpdateRequester.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/CompositeTileUpdateRequester.java
index 2233b74..3ac0640 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/CompositeTileUpdateRequester.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/CompositeTileUpdateRequester.java
@@ -16,7 +16,7 @@
package androidx.wear.tiles;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
import java.util.List;
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/DeviceParametersBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/DeviceParametersBuilders.java
index 662d045..fbd4755 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/DeviceParametersBuilders.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/DeviceParametersBuilders.java
@@ -21,10 +21,11 @@
import androidx.annotation.Dimension;
import androidx.annotation.FloatRange;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.wear.protolayout.proto.DeviceParametersProto;
+import org.jspecify.annotations.NonNull;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -108,13 +109,12 @@
return mImpl.getScreenShape().getNumber();
}
- @NonNull
- static DeviceParameters fromProto(@NonNull DeviceParametersProto.DeviceParameters proto) {
+ static @NonNull DeviceParameters fromProto(
+ DeviceParametersProto.@NonNull DeviceParameters proto) {
return new DeviceParameters(proto);
}
- @NonNull
- DeviceParametersProto.DeviceParameters toProto() {
+ DeviceParametersProto.@NonNull DeviceParameters toProto() {
return mImpl;
}
@@ -126,15 +126,13 @@
public Builder() {}
/** Sets width of the device's screen in DP. */
- @NonNull
- public Builder setScreenWidthDp(@Dimension(unit = DP) int screenWidthDp) {
+ public @NonNull Builder setScreenWidthDp(@Dimension(unit = DP) int screenWidthDp) {
mImpl.setScreenWidthDp(screenWidthDp);
return this;
}
/** Sets height of the device's screen in DP. */
- @NonNull
- public Builder setScreenHeightDp(@Dimension(unit = DP) int screenHeightDp) {
+ public @NonNull Builder setScreenHeightDp(@Dimension(unit = DP) int screenHeightDp) {
mImpl.setScreenHeightDp(screenHeightDp);
return this;
}
@@ -143,8 +141,7 @@
* Sets density of the display. This value is the scaling factor to get from DP to
* Pixels (px = dp * density).
*/
- @NonNull
- public Builder setScreenDensity(
+ public @NonNull Builder setScreenDensity(
@FloatRange(from = 0.0, fromInclusive = false, toInclusive = false)
float screenDensity) {
mImpl.setScreenDensity(screenDensity);
@@ -152,23 +149,20 @@
}
/** Sets the platform of the device. */
- @NonNull
- public Builder setDevicePlatform(@DevicePlatform int devicePlatform) {
+ public @NonNull Builder setDevicePlatform(@DevicePlatform int devicePlatform) {
mImpl.setDevicePlatform(
DeviceParametersProto.DevicePlatform.forNumber(devicePlatform));
return this;
}
/** Sets the shape of the device's screen. */
- @NonNull
- public Builder setScreenShape(@ScreenShape int screenShape) {
+ public @NonNull Builder setScreenShape(@ScreenShape int screenShape) {
mImpl.setScreenShape(DeviceParametersProto.ScreenShape.forNumber(screenShape));
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public DeviceParameters build() {
+ public @NonNull DeviceParameters build() {
return DeviceParameters.fromProto(mImpl.build());
}
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/DimensionBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/DimensionBuilders.java
index e054a94..050de79 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/DimensionBuilders.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/DimensionBuilders.java
@@ -23,13 +23,14 @@
import androidx.annotation.Dimension;
import androidx.annotation.IntRange;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.DimensionProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Builders for dimensions for layout elements.
*
@@ -43,32 +44,27 @@
private static final WrappedDimensionProp WRAP = new WrappedDimensionProp.Builder().build();
/** Shortcut for building a {@link DpProp} using a measurement in DP. */
- @NonNull
- public static DpProp dp(@Dimension(unit = DP) float valueDp) {
+ public static @NonNull DpProp dp(@Dimension(unit = DP) float valueDp) {
return new DpProp.Builder().setValue(valueDp).build();
}
/** Shortcut for building a {@link SpProp} using a measurement in SP. */
- @NonNull
- public static SpProp sp(@Dimension(unit = SP) float valueSp) {
+ public static @NonNull SpProp sp(@Dimension(unit = SP) float valueSp) {
return new SpProp.Builder().setValue(valueSp).build();
}
/** Shortcut for building a {@link EmProp} using a measurement in EM. */
- @NonNull
- public static EmProp em(int valueEm) {
+ public static @NonNull EmProp em(int valueEm) {
return new EmProp.Builder().setValue(valueEm).build();
}
/** Shortcut for building a {@link EmProp} using a measurement in EM. */
- @NonNull
- public static EmProp em(float valueEm) {
+ public static @NonNull EmProp em(float valueEm) {
return new EmProp.Builder().setValue(valueEm).build();
}
/** Shortcut for building an {@link DegreesProp} using a measurement in degrees. */
- @NonNull
- public static DegreesProp degrees(float valueDegrees) {
+ public static @NonNull DegreesProp degrees(float valueDegrees) {
return new DegreesProp.Builder().setValue(valueDegrees).build();
}
@@ -76,8 +72,7 @@
* Shortcut for building an {@link ExpandedDimensionProp} that will expand to the size of its
* parent.
*/
- @NonNull
- public static ExpandedDimensionProp expand() {
+ public static @NonNull ExpandedDimensionProp expand() {
return EXPAND;
}
@@ -85,8 +80,7 @@
* Shortcut for building an {@link WrappedDimensionProp} that will shrink to the size of its
* children.
*/
- @NonNull
- public static WrappedDimensionProp wrap() {
+ public static @NonNull WrappedDimensionProp wrap() {
return WRAP;
}
@@ -94,7 +88,7 @@
public static final class DpProp
implements ContainerDimension, ImageDimension, SpacerDimension {
private final DimensionProto.DpProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
DpProp(DimensionProto.DpProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -109,39 +103,33 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static DpProp fromProto(@NonNull DimensionProto.DpProp proto) {
+ static @NonNull DpProp fromProto(DimensionProto.@NonNull DpProp proto) {
return new DpProp(proto, null);
}
- @NonNull
- DimensionProto.DpProp toProto() {
+ DimensionProto.@NonNull DpProp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.ContainerDimension toContainerDimensionProto() {
+ public DimensionProto.@NonNull ContainerDimension toContainerDimensionProto() {
return DimensionProto.ContainerDimension.newBuilder().setLinearDimension(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.ImageDimension toImageDimensionProto() {
+ public DimensionProto.@NonNull ImageDimension toImageDimensionProto() {
return DimensionProto.ImageDimension.newBuilder().setLinearDimension(mImpl).build();
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.SpacerDimension toSpacerDimensionProto() {
+ public DimensionProto.@NonNull SpacerDimension toSpacerDimensionProto() {
return DimensionProto.SpacerDimension.newBuilder().setLinearDimension(mImpl).build();
}
@@ -156,16 +144,14 @@
public Builder() {}
/** Sets the value, in dp. */
- @NonNull
- public Builder setValue(@Dimension(unit = DP) float value) {
+ public @NonNull Builder setValue(@Dimension(unit = DP) float value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, Float.floatToIntBits(value));
return this;
}
@Override
- @NonNull
- public DpProp build() {
+ public @NonNull DpProp build() {
return new DpProp(mImpl.build(), mFingerprint);
}
}
@@ -174,7 +160,7 @@
/** A type for font sizes, measured in sp. */
public static final class SpProp {
private final DimensionProto.SpProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
SpProp(DimensionProto.SpProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -189,18 +175,15 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static SpProp fromProto(@NonNull DimensionProto.SpProp proto) {
+ static @NonNull SpProp fromProto(DimensionProto.@NonNull SpProp proto) {
return new SpProp(proto, null);
}
- @NonNull
- DimensionProto.SpProp toProto() {
+ DimensionProto.@NonNull SpProp toProto() {
return mImpl;
}
@@ -212,16 +195,14 @@
public Builder() {}
/** Sets the value, in sp. */
- @NonNull
- public Builder setValue(@Dimension(unit = SP) float value) {
+ public @NonNull Builder setValue(@Dimension(unit = SP) float value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(2, Float.floatToIntBits(value));
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public SpProp build() {
+ public @NonNull SpProp build() {
return new SpProp(mImpl.build(), mFingerprint);
}
}
@@ -230,7 +211,7 @@
/** A type for font spacing, measured in em. */
public static final class EmProp {
private final DimensionProto.EmProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
EmProp(DimensionProto.EmProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -244,18 +225,15 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static EmProp fromProto(@NonNull DimensionProto.EmProp proto) {
+ static @NonNull EmProp fromProto(DimensionProto.@NonNull EmProp proto) {
return new EmProp(proto, null);
}
- @NonNull
- DimensionProto.EmProp toProto() {
+ DimensionProto.@NonNull EmProp toProto() {
return mImpl;
}
@@ -267,16 +245,14 @@
public Builder() {}
/** Sets the value, in em. */
- @NonNull
- public Builder setValue(float value) {
+ public @NonNull Builder setValue(float value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, Float.floatToIntBits(value));
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public EmProp build() {
+ public @NonNull EmProp build() {
return new EmProp(mImpl.build(), mFingerprint);
}
}
@@ -285,7 +261,7 @@
/** A type for angular dimensions, measured in degrees. */
public static final class DegreesProp {
private final DimensionProto.DegreesProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
DegreesProp(DimensionProto.DegreesProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -299,18 +275,15 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static DegreesProp fromProto(@NonNull DimensionProto.DegreesProp proto) {
+ static @NonNull DegreesProp fromProto(DimensionProto.@NonNull DegreesProp proto) {
return new DegreesProp(proto, null);
}
- @NonNull
- DimensionProto.DegreesProp toProto() {
+ DimensionProto.@NonNull DegreesProp toProto() {
return mImpl;
}
@@ -323,16 +296,14 @@
public Builder() {}
/** Sets the value, in degrees. */
- @NonNull
- public Builder setValue(float value) {
+ public @NonNull Builder setValue(float value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, Float.floatToIntBits(value));
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public DegreesProp build() {
+ public @NonNull DegreesProp build() {
return new DegreesProp(mImpl.build(), mFingerprint);
}
}
@@ -344,7 +315,7 @@
*/
public static final class ExpandedDimensionProp implements ContainerDimension, ImageDimension {
private final DimensionProto.ExpandedDimensionProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ExpandedDimensionProp(
DimensionProto.ExpandedDimensionProp impl, @Nullable Fingerprint fingerprint) {
@@ -354,26 +325,22 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static ExpandedDimensionProp fromProto(
- @NonNull DimensionProto.ExpandedDimensionProp proto) {
+ static @NonNull ExpandedDimensionProp fromProto(
+ DimensionProto.@NonNull ExpandedDimensionProp proto) {
return new ExpandedDimensionProp(proto, null);
}
- @NonNull
- DimensionProto.ExpandedDimensionProp toProto() {
+ DimensionProto.@NonNull ExpandedDimensionProp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.ContainerDimension toContainerDimensionProto() {
+ public DimensionProto.@NonNull ContainerDimension toContainerDimensionProto() {
return DimensionProto.ContainerDimension.newBuilder()
.setExpandedDimension(mImpl)
.build();
@@ -381,8 +348,7 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.ImageDimension toImageDimensionProto() {
+ public DimensionProto.@NonNull ImageDimension toImageDimensionProto() {
return DimensionProto.ImageDimension.newBuilder().setExpandedDimension(mImpl).build();
}
@@ -396,8 +362,7 @@
public Builder() {}
@Override
- @NonNull
- public ExpandedDimensionProp build() {
+ public @NonNull ExpandedDimensionProp build() {
return new ExpandedDimensionProp(mImpl.build(), mFingerprint);
}
}
@@ -409,7 +374,7 @@
*/
public static final class WrappedDimensionProp implements ContainerDimension {
private final DimensionProto.WrappedDimensionProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
WrappedDimensionProp(
DimensionProto.WrappedDimensionProp impl, @Nullable Fingerprint fingerprint) {
@@ -419,25 +384,22 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static WrappedDimensionProp fromProto(@NonNull DimensionProto.WrappedDimensionProp proto) {
+ static @NonNull WrappedDimensionProp fromProto(
+ DimensionProto.@NonNull WrappedDimensionProp proto) {
return new WrappedDimensionProp(proto, null);
}
- @NonNull
- DimensionProto.WrappedDimensionProp toProto() {
+ DimensionProto.@NonNull WrappedDimensionProp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.ContainerDimension toContainerDimensionProto() {
+ public DimensionProto.@NonNull ContainerDimension toContainerDimensionProto() {
return DimensionProto.ContainerDimension.newBuilder()
.setWrappedDimension(mImpl)
.build();
@@ -452,8 +414,7 @@
public Builder() {}
@Override
- @NonNull
- public WrappedDimensionProp build() {
+ public @NonNull WrappedDimensionProp build() {
return new WrappedDimensionProp(mImpl.build(), mFingerprint);
}
}
@@ -470,7 +431,7 @@
*/
public static final class ProportionalDimensionProp implements ImageDimension {
private final DimensionProto.ProportionalDimensionProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ProportionalDimensionProp(
DimensionProto.ProportionalDimensionProp impl, @Nullable Fingerprint fingerprint) {
@@ -498,26 +459,22 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static ProportionalDimensionProp fromProto(
- @NonNull DimensionProto.ProportionalDimensionProp proto) {
+ static @NonNull ProportionalDimensionProp fromProto(
+ DimensionProto.@NonNull ProportionalDimensionProp proto) {
return new ProportionalDimensionProp(proto, null);
}
- @NonNull
- DimensionProto.ProportionalDimensionProp toProto() {
+ DimensionProto.@NonNull ProportionalDimensionProp toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public DimensionProto.ImageDimension toImageDimensionProto() {
+ public DimensionProto.@NonNull ImageDimension toImageDimensionProto() {
return DimensionProto.ImageDimension.newBuilder()
.setProportionalDimension(mImpl)
.build();
@@ -532,24 +489,22 @@
public Builder() {}
/** Sets the width to be used when calculating the aspect ratio to preserve. */
- @NonNull
- public Builder setAspectRatioWidth(@IntRange(from = 0) int aspectRatioWidth) {
+ public @NonNull Builder setAspectRatioWidth(@IntRange(from = 0) int aspectRatioWidth) {
mImpl.setAspectRatioWidth(aspectRatioWidth);
mFingerprint.recordPropertyUpdate(1, aspectRatioWidth);
return this;
}
/** Sets the height to be used when calculating the aspect ratio ratio to preserve. */
- @NonNull
- public Builder setAspectRatioHeight(@IntRange(from = 0) int aspectRatioHeight) {
+ public @NonNull Builder setAspectRatioHeight(
+ @IntRange(from = 0) int aspectRatioHeight) {
mImpl.setAspectRatioHeight(aspectRatioHeight);
mFingerprint.recordPropertyUpdate(2, aspectRatioHeight);
return this;
}
@Override
- @NonNull
- public ProportionalDimensionProp build() {
+ public @NonNull ProportionalDimensionProp build() {
return new ProportionalDimensionProp(mImpl.build(), mFingerprint);
}
}
@@ -559,30 +514,26 @@
public interface ContainerDimension {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DimensionProto.ContainerDimension toContainerDimensionProto();
+ DimensionProto.@NonNull ContainerDimension toContainerDimensionProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link ContainerDimension} objects. */
@SuppressLint("StaticFinalBuilder")
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- ContainerDimension build();
+ @NonNull ContainerDimension build();
}
}
/**
* Return an instance of one of this object's subtypes, from the protocol buffer representation.
*/
- @NonNull
- static ContainerDimension containerDimensionFromProto(
- @NonNull DimensionProto.ContainerDimension proto) {
+ static @NonNull ContainerDimension containerDimensionFromProto(
+ DimensionProto.@NonNull ContainerDimension proto) {
if (proto.hasLinearDimension()) {
return DpProp.fromProto(proto.getLinearDimension());
}
@@ -600,29 +551,26 @@
public interface ImageDimension {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DimensionProto.ImageDimension toImageDimensionProto();
+ DimensionProto.@NonNull ImageDimension toImageDimensionProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link ImageDimension} objects. */
@SuppressLint("StaticFinalBuilder")
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- ImageDimension build();
+ @NonNull ImageDimension build();
}
}
/**
* Return an instance of one of this object's subtypes, from the protocol buffer representation.
*/
- @NonNull
- static ImageDimension imageDimensionFromProto(@NonNull DimensionProto.ImageDimension proto) {
+ static @NonNull ImageDimension imageDimensionFromProto(
+ DimensionProto.@NonNull ImageDimension proto) {
if (proto.hasLinearDimension()) {
return DpProp.fromProto(proto.getLinearDimension());
}
@@ -639,26 +587,23 @@
public interface SpacerDimension {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- DimensionProto.SpacerDimension toSpacerDimensionProto();
+ DimensionProto.@NonNull SpacerDimension toSpacerDimensionProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link SpacerDimension} objects. */
@SuppressLint("StaticFinalBuilder")
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- SpacerDimension build();
+ @NonNull SpacerDimension build();
}
}
- @NonNull
- static SpacerDimension spacerDimensionFromProto(@NonNull DimensionProto.SpacerDimension proto) {
+ static @NonNull SpacerDimension spacerDimensionFromProto(
+ DimensionProto.@NonNull SpacerDimension proto) {
if (proto.hasLinearDimension()) {
return DpProp.fromProto(proto.getLinearDimension());
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/DiskAccessAllowedPrefs.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/DiskAccessAllowedPrefs.java
index 7928651..884becd 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/DiskAccessAllowedPrefs.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/DiskAccessAllowedPrefs.java
@@ -21,18 +21,19 @@
import android.os.StrictMode;
import android.os.StrictMode.ThreadPolicy;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Map;
/** Get versions of shared prefs that ignore strict mode and allows disk reads and writes. */
@RestrictTo(Scope.LIBRARY_GROUP)
final class DiskAccessAllowedPrefs {
- @NonNull private final SharedPreferences preferences;
+ private final @NonNull SharedPreferences preferences;
private DiskAccessAllowedPrefs(@NonNull SharedPreferences preferences) {
this.preferences = preferences;
@@ -42,8 +43,7 @@
* Returns a simplified version of {@link SharedPreferences} wrapped to ignore disk read and
* write StrictMode violations.
*/
- @Nullable
- static DiskAccessAllowedPrefs wrap(@NonNull Context context, @NonNull String name) {
+ static @Nullable DiskAccessAllowedPrefs wrap(@NonNull Context context, @NonNull String name) {
ThreadPolicy policy = StrictMode.allowThreadDiskReads();
try {
SharedPreferences sharedPref = context.getSharedPreferences(name, Context.MODE_PRIVATE);
@@ -53,8 +53,7 @@
}
}
- @Nullable
- Map<String, ?> getAll() {
+ @Nullable Map<String, ?> getAll() {
ThreadPolicy policy = StrictMode.allowThreadDiskReads();
try {
return preferences.getAll();
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/EventBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/EventBuilders.java
index 7e72ffb..0e71b08 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/EventBuilders.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/EventBuilders.java
@@ -17,13 +17,14 @@
package androidx.wear.tiles;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.annotation.VisibleForTesting;
import androidx.wear.protolayout.expression.RequiresSchemaVersion;
import androidx.wear.tiles.proto.EventProto;
+import org.jspecify.annotations.NonNull;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.time.Instant;
@@ -52,21 +53,18 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static TileAddEvent fromProto(@NonNull EventProto.TileAddEvent proto) {
+ public static @NonNull TileAddEvent fromProto(EventProto.@NonNull TileAddEvent proto) {
return new TileAddEvent(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public EventProto.TileAddEvent toProto() {
+ public EventProto.@NonNull TileAddEvent toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "TileAddEvent{" + "tileId=" + getTileId() + "}";
}
@@ -84,15 +82,13 @@
* carousel. This ID will remain the same for this tile instance as long it is not
* removed from the carousel.
*/
- @NonNull
- public Builder setTileId(int tileId) {
+ public @NonNull Builder setTileId(int tileId) {
mImpl.setTileId(tileId);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public TileAddEvent build() {
+ public @NonNull TileAddEvent build() {
return TileAddEvent.fromProto(mImpl.build());
}
}
@@ -118,21 +114,19 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static TileRemoveEvent fromProto(@NonNull EventProto.TileRemoveEvent proto) {
+ public static @NonNull TileRemoveEvent fromProto(
+ EventProto.@NonNull TileRemoveEvent proto) {
return new TileRemoveEvent(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public EventProto.TileRemoveEvent toProto() {
+ public EventProto.@NonNull TileRemoveEvent toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "TileRemoveEvent{" + "tileId=" + getTileId() + "}";
}
@@ -149,15 +143,13 @@
* Sets instance ID of the removed tile, allocated when the tile instance was added to
* the carousel.
*/
- @NonNull
- public Builder setTileId(int tileId) {
+ public @NonNull Builder setTileId(int tileId) {
mImpl.setTileId(tileId);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public TileRemoveEvent build() {
+ public @NonNull TileRemoveEvent build() {
return TileRemoveEvent.fromProto(mImpl.build());
}
}
@@ -183,21 +175,18 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static TileEnterEvent fromProto(@NonNull EventProto.TileEnterEvent proto) {
+ public static @NonNull TileEnterEvent fromProto(EventProto.@NonNull TileEnterEvent proto) {
return new TileEnterEvent(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public EventProto.TileEnterEvent toProto() {
+ public EventProto.@NonNull TileEnterEvent toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "TileEnterEvent{" + "tileId=" + getTileId() + "}";
}
@@ -215,15 +204,13 @@
* carousel. This ID will remain the same for this tile instance as long it is not
* removed from the carousel.
*/
- @NonNull
- public Builder setTileId(int tileId) {
+ public @NonNull Builder setTileId(int tileId) {
mImpl.setTileId(tileId);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public TileEnterEvent build() {
+ public @NonNull TileEnterEvent build() {
return TileEnterEvent.fromProto(mImpl.build());
}
}
@@ -252,21 +239,18 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static TileLeaveEvent fromProto(@NonNull EventProto.TileLeaveEvent proto) {
+ public static @NonNull TileLeaveEvent fromProto(EventProto.@NonNull TileLeaveEvent proto) {
return new TileLeaveEvent(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public EventProto.TileLeaveEvent toProto() {
+ public EventProto.@NonNull TileLeaveEvent toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "TileLeaveEvent{" + "tileId=" + getTileId() + "}";
}
@@ -284,15 +268,13 @@
* carousel. This ID will remain the same for this tile instance as long it is not
* removed from the carousel.
*/
- @NonNull
- public Builder setTileId(int tileId) {
+ public @NonNull Builder setTileId(int tileId) {
mImpl.setTileId(tileId);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public TileLeaveEvent build() {
+ public @NonNull TileLeaveEvent build() {
return TileLeaveEvent.fromProto(mImpl.build());
}
}
@@ -347,29 +329,25 @@
* Instant#now()} (Created at the time of {@link
* TileInteractionEvent.Builder#Builder(int,int)} constructor call) if not provided.
*/
- @NonNull
- public Instant getTimestamp() {
+ public @NonNull Instant getTimestamp() {
return Instant.ofEpochMilli(mImpl.getTimestampEpochMillis());
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static TileInteractionEvent fromProto(
- @NonNull EventProto.TileInteractionEvent proto) {
+ public static @NonNull TileInteractionEvent fromProto(
+ EventProto.@NonNull TileInteractionEvent proto) {
return new TileInteractionEvent(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public EventProto.TileInteractionEvent toProto() {
+ public EventProto.@NonNull TileInteractionEvent toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "TileInteractionEvent{"
+ "tileId="
+ getTileId()
@@ -382,8 +360,7 @@
/** Builder for {@link TileInteractionEvent} */
public static final class Builder {
- @NonNull
- private final EventProto.TileInteractionEvent.Builder mImpl =
+ private final EventProto.TileInteractionEvent.@NonNull Builder mImpl =
EventProto.TileInteractionEvent.newBuilder();
/** Interface so this Builder can retrieve the current time. */
@@ -441,15 +418,13 @@
* call) if not provided.
*/
@RequiresSchemaVersion(major = 1, minor = 400)
- @NonNull
- public Builder setTimestamp(@NonNull Instant instant) {
+ public @NonNull Builder setTimestamp(@NonNull Instant instant) {
mImpl.setTimestampEpochMillis(instant.toEpochMilli());
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public TileInteractionEvent build() {
+ public @NonNull TileInteractionEvent build() {
return TileInteractionEvent.fromProto(mImpl.build());
}
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/LayoutElementBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/LayoutElementBuilders.java
index 259bddf..eca36c9 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/LayoutElementBuilders.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/LayoutElementBuilders.java
@@ -24,8 +24,6 @@
import androidx.annotation.IntDef;
import androidx.annotation.IntRange;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.OptIn;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
@@ -38,6 +36,9 @@
import androidx.wear.protolayout.proto.TypesProto;
import androidx.wear.protolayout.protobuf.InvalidProtocolBufferException;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Collections;
@@ -316,7 +317,7 @@
/** An extensible {@code HorizontalAlignment} property. */
public static final class HorizontalAlignmentProp {
private final AlignmentProto.HorizontalAlignmentProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
private HorizontalAlignmentProp(
AlignmentProto.HorizontalAlignmentProp impl, @Nullable Fingerprint fingerprint) {
@@ -332,19 +333,16 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static HorizontalAlignmentProp fromProto(
- @NonNull AlignmentProto.HorizontalAlignmentProp proto) {
+ static @NonNull HorizontalAlignmentProp fromProto(
+ AlignmentProto.@NonNull HorizontalAlignmentProp proto) {
return new HorizontalAlignmentProp(proto, null);
}
- @NonNull
- AlignmentProto.HorizontalAlignmentProp toProto() {
+ AlignmentProto.@NonNull HorizontalAlignmentProp toProto() {
return mImpl;
}
@@ -357,16 +355,14 @@
public Builder() {}
/** Sets the value. */
- @NonNull
- public Builder setValue(@HorizontalAlignment int value) {
+ public @NonNull Builder setValue(@HorizontalAlignment int value) {
mImpl.setValue(AlignmentProto.HorizontalAlignment.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public HorizontalAlignmentProp build() {
+ public @NonNull HorizontalAlignmentProp build() {
return HorizontalAlignmentProp.fromProto(mImpl.build());
}
}
@@ -375,7 +371,7 @@
/** An extensible {@code VerticalAlignment} property. */
public static final class VerticalAlignmentProp {
private final AlignmentProto.VerticalAlignmentProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
VerticalAlignmentProp(
AlignmentProto.VerticalAlignmentProp impl, @Nullable Fingerprint fingerprint) {
@@ -391,19 +387,16 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static VerticalAlignmentProp fromProto(
- @NonNull AlignmentProto.VerticalAlignmentProp proto) {
+ static @NonNull VerticalAlignmentProp fromProto(
+ AlignmentProto.@NonNull VerticalAlignmentProp proto) {
return new VerticalAlignmentProp(proto, null);
}
- @NonNull
- AlignmentProto.VerticalAlignmentProp toProto() {
+ AlignmentProto.@NonNull VerticalAlignmentProp toProto() {
return mImpl;
}
@@ -416,16 +409,14 @@
public Builder() {}
/** Sets the value. */
- @NonNull
- public Builder setValue(@VerticalAlignment int value) {
+ public @NonNull Builder setValue(@VerticalAlignment int value) {
mImpl.setValue(AlignmentProto.VerticalAlignment.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public VerticalAlignmentProp build() {
+ public @NonNull VerticalAlignmentProp build() {
return new VerticalAlignmentProp(mImpl.build(), mFingerprint);
}
}
@@ -434,7 +425,7 @@
/** An extensible {@code FontWeight} property. */
public static final class FontWeightProp {
private final LayoutElementProto.FontWeightProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FontWeightProp(LayoutElementProto.FontWeightProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -449,18 +440,15 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static FontWeightProp fromProto(@NonNull LayoutElementProto.FontWeightProp proto) {
+ static @NonNull FontWeightProp fromProto(LayoutElementProto.@NonNull FontWeightProp proto) {
return new FontWeightProp(proto, null);
}
- @NonNull
- LayoutElementProto.FontWeightProp toProto() {
+ LayoutElementProto.@NonNull FontWeightProp toProto() {
return mImpl;
}
@@ -473,16 +461,14 @@
public Builder() {}
/** Sets the value. */
- @NonNull
- public Builder setValue(@FontWeight int value) {
+ public @NonNull Builder setValue(@FontWeight int value) {
mImpl.setValue(LayoutElementProto.FontWeight.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public FontWeightProp build() {
+ public @NonNull FontWeightProp build() {
return new FontWeightProp(mImpl.build(), mFingerprint);
}
}
@@ -492,7 +478,7 @@
@TilesExperimental
public static final class FontVariantProp {
private final LayoutElementProto.FontVariantProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FontVariantProp(
LayoutElementProto.FontVariantProp impl, @Nullable Fingerprint fingerprint) {
@@ -508,18 +494,16 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static FontVariantProp fromProto(@NonNull LayoutElementProto.FontVariantProp proto) {
+ static @NonNull FontVariantProp fromProto(
+ LayoutElementProto.@NonNull FontVariantProp proto) {
return new FontVariantProp(proto, null);
}
- @NonNull
- LayoutElementProto.FontVariantProp toProto() {
+ LayoutElementProto.@NonNull FontVariantProp toProto() {
return mImpl;
}
@@ -532,16 +516,14 @@
public Builder() {}
/** Sets the value. */
- @NonNull
- public Builder setValue(@FontVariant int value) {
+ public @NonNull Builder setValue(@FontVariant int value) {
mImpl.setValue(LayoutElementProto.FontVariant.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public FontVariantProp build() {
+ public @NonNull FontVariantProp build() {
return new FontVariantProp(mImpl.build(), mFingerprint);
}
}
@@ -550,7 +532,7 @@
/** An extensible {@code SpanVerticalAlignment} property. */
public static final class SpanVerticalAlignmentProp {
private final LayoutElementProto.SpanVerticalAlignmentProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
SpanVerticalAlignmentProp(
LayoutElementProto.SpanVerticalAlignmentProp impl,
@@ -567,19 +549,16 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static SpanVerticalAlignmentProp fromProto(
- @NonNull LayoutElementProto.SpanVerticalAlignmentProp proto) {
+ static @NonNull SpanVerticalAlignmentProp fromProto(
+ LayoutElementProto.@NonNull SpanVerticalAlignmentProp proto) {
return new SpanVerticalAlignmentProp(proto, null);
}
- @NonNull
- LayoutElementProto.SpanVerticalAlignmentProp toProto() {
+ LayoutElementProto.@NonNull SpanVerticalAlignmentProp toProto() {
return mImpl;
}
@@ -592,16 +571,14 @@
public Builder() {}
/** Sets the value. */
- @NonNull
- public Builder setValue(@SpanVerticalAlignment int value) {
+ public @NonNull Builder setValue(@SpanVerticalAlignment int value) {
mImpl.setValue(LayoutElementProto.SpanVerticalAlignment.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public SpanVerticalAlignmentProp build() {
+ public @NonNull SpanVerticalAlignmentProp build() {
return new SpanVerticalAlignmentProp(mImpl.build(), mFingerprint);
}
}
@@ -610,7 +587,7 @@
/** The styling of a font (e.g. font size, and metrics). */
public static final class FontStyle {
private final LayoutElementProto.FontStyle mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FontStyle(LayoutElementProto.FontStyle impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -621,8 +598,7 @@
* Gets the size of the font, in scaled pixels (sp). If not specified, defaults to the size
* of the system's "body" font. Intended for testing purposes only.
*/
- @Nullable
- public DimensionBuilders.SpProp getSize() {
+ public DimensionBuilders.@Nullable SpProp getSize() {
List<DimensionProto.SpProp> sizes = mImpl.getSizeList();
if (!sizes.isEmpty()) {
return DimensionBuilders.SpProp.fromProto(sizes.get(0));
@@ -635,8 +611,7 @@
* Gets whether the text should be rendered in a italic typeface. If not specified, defaults
* to "false". Intended for testing purposes only.
*/
- @Nullable
- public TypeBuilders.BoolProp getItalic() {
+ public TypeBuilders.@Nullable BoolProp getItalic() {
if (mImpl.hasItalic()) {
return TypeBuilders.BoolProp.fromProto(mImpl.getItalic());
} else {
@@ -648,8 +623,7 @@
* Gets whether the text should be rendered with an underline. If not specified, defaults to
* "false". Intended for testing purposes only.
*/
- @Nullable
- public TypeBuilders.BoolProp getUnderline() {
+ public TypeBuilders.@Nullable BoolProp getUnderline() {
if (mImpl.hasUnderline()) {
return TypeBuilders.BoolProp.fromProto(mImpl.getUnderline());
} else {
@@ -661,8 +635,7 @@
* Gets the text color. If not defined, defaults to white. Intended for testing purposes
* only.
*/
- @Nullable
- public ColorBuilders.ColorProp getColor() {
+ public ColorBuilders.@Nullable ColorProp getColor() {
if (mImpl.hasColor()) {
return ColorBuilders.ColorProp.fromProto(mImpl.getColor());
} else {
@@ -675,8 +648,7 @@
* nearest supported value will be used. If not defined, or when set to an invalid value,
* defaults to "normal". Intended for testing purposes only.
*/
- @Nullable
- public FontWeightProp getWeight() {
+ public @Nullable FontWeightProp getWeight() {
if (mImpl.hasWeight()) {
return FontWeightProp.fromProto(mImpl.getWeight());
} else {
@@ -689,8 +661,7 @@
* negative numbers tighten the space. If not specified, defaults to 0. Intended for testing
* purposes only.
*/
- @Nullable
- public DimensionBuilders.EmProp getLetterSpacing() {
+ public DimensionBuilders.@Nullable EmProp getLetterSpacing() {
if (mImpl.hasLetterSpacing()) {
return DimensionBuilders.EmProp.fromProto(mImpl.getLetterSpacing());
} else {
@@ -704,8 +675,7 @@
* Intended for testing purposes only.
*/
@TilesExperimental
- @Nullable
- public FontVariantProp getVariant() {
+ public @Nullable FontVariantProp getVariant() {
if (mImpl.hasVariant()) {
return FontVariantProp.fromProto(mImpl.getVariant());
} else {
@@ -715,20 +685,17 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static FontStyle fromProto(@NonNull LayoutElementProto.FontStyle proto) {
+ static @NonNull FontStyle fromProto(LayoutElementProto.@NonNull FontStyle proto) {
return new FontStyle(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.FontStyle toProto() {
+ public LayoutElementProto.@NonNull FontStyle toProto() {
return mImpl;
}
@@ -744,8 +711,7 @@
* Sets the size of the font, in scaled pixels (sp). If not specified, defaults to the
* size of the system's "body" font.
*/
- @NonNull
- public Builder setSize(@NonNull DimensionBuilders.SpProp size) {
+ public @NonNull Builder setSize(DimensionBuilders.@NonNull SpProp size) {
mImpl.clearSize();
mImpl.addSize(size.toProto());
mFingerprint.recordPropertyUpdate(
@@ -757,8 +723,7 @@
* Sets whether the text should be rendered in a italic typeface. If not specified,
* defaults to "false".
*/
- @NonNull
- public Builder setItalic(@NonNull TypeBuilders.BoolProp italic) {
+ public @NonNull Builder setItalic(TypeBuilders.@NonNull BoolProp italic) {
mImpl.setItalic(italic.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(italic.getFingerprint()).aggregateValueAsInt());
@@ -770,8 +735,7 @@
* defaults to "false".
*/
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setItalic(boolean italic) {
+ public @NonNull Builder setItalic(boolean italic) {
mImpl.setItalic(TypesProto.BoolProp.newBuilder().setValue(italic));
mFingerprint.recordPropertyUpdate(2, Boolean.hashCode(italic));
return this;
@@ -781,8 +745,7 @@
* Sets whether the text should be rendered with an underline. If not specified,
* defaults to "false".
*/
- @NonNull
- public Builder setUnderline(@NonNull TypeBuilders.BoolProp underline) {
+ public @NonNull Builder setUnderline(TypeBuilders.@NonNull BoolProp underline) {
mImpl.setUnderline(underline.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(underline.getFingerprint()).aggregateValueAsInt());
@@ -794,16 +757,14 @@
* defaults to "false".
*/
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setUnderline(boolean underline) {
+ public @NonNull Builder setUnderline(boolean underline) {
mImpl.setUnderline(TypesProto.BoolProp.newBuilder().setValue(underline));
mFingerprint.recordPropertyUpdate(3, Boolean.hashCode(underline));
return this;
}
/** Sets the text color. If not defined, defaults to white. */
- @NonNull
- public Builder setColor(@NonNull ColorBuilders.ColorProp color) {
+ public @NonNull Builder setColor(ColorBuilders.@NonNull ColorProp color) {
mImpl.setColor(color.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(color.getFingerprint()).aggregateValueAsInt());
@@ -815,8 +776,7 @@
* the nearest supported value will be used. If not defined, or when set to an invalid
* value, defaults to "normal".
*/
- @NonNull
- public Builder setWeight(@NonNull FontWeightProp weight) {
+ public @NonNull Builder setWeight(@NonNull FontWeightProp weight) {
mImpl.setWeight(weight.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(weight.getFingerprint()).aggregateValueAsInt());
@@ -828,8 +788,7 @@
* the nearest supported value will be used. If not defined, or when set to an invalid
* value, defaults to "normal".
*/
- @NonNull
- public Builder setWeight(@FontWeight int weight) {
+ public @NonNull Builder setWeight(@FontWeight int weight) {
mImpl.setWeight(
LayoutElementProto.FontWeightProp.newBuilder()
.setValue(LayoutElementProto.FontWeight.forNumber(weight)));
@@ -841,8 +800,8 @@
* Sets the text letter-spacing. Positive numbers increase the space between letters
* while negative numbers tighten the space. If not specified, defaults to 0.
*/
- @NonNull
- public Builder setLetterSpacing(@NonNull DimensionBuilders.EmProp letterSpacing) {
+ public @NonNull Builder setLetterSpacing(
+ DimensionBuilders.@NonNull EmProp letterSpacing) {
mImpl.setLetterSpacing(letterSpacing.toProto());
mFingerprint.recordPropertyUpdate(
6, checkNotNull(letterSpacing.getFingerprint()).aggregateValueAsInt());
@@ -854,8 +813,7 @@
* text, which can be selected using this field. If not specified, defaults to "body".
*/
@TilesExperimental
- @NonNull
- public Builder setVariant(@NonNull FontVariantProp variant) {
+ public @NonNull Builder setVariant(@NonNull FontVariantProp variant) {
mImpl.setVariant(variant.toProto());
mFingerprint.recordPropertyUpdate(
7, checkNotNull(variant.getFingerprint()).aggregateValueAsInt());
@@ -867,8 +825,7 @@
* text, which can be selected using this field. If not specified, defaults to "body".
*/
@TilesExperimental
- @NonNull
- public Builder setVariant(@FontVariant int variant) {
+ public @NonNull Builder setVariant(@FontVariant int variant) {
mImpl.setVariant(
LayoutElementProto.FontVariantProp.newBuilder()
.setValue(LayoutElementProto.FontVariant.forNumber(variant)));
@@ -877,8 +834,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public FontStyle build() {
+ public @NonNull FontStyle build() {
return new FontStyle(mImpl.build(), mFingerprint);
}
}
@@ -887,7 +843,7 @@
/** An extensible {@code TextAlignment} property. */
public static final class TextAlignmentProp {
private final AlignmentProto.TextAlignmentProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
TextAlignmentProp(
AlignmentProto.TextAlignmentProp impl, @Nullable Fingerprint fingerprint) {
@@ -903,18 +859,16 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static TextAlignmentProp fromProto(@NonNull AlignmentProto.TextAlignmentProp proto) {
+ static @NonNull TextAlignmentProp fromProto(
+ AlignmentProto.@NonNull TextAlignmentProp proto) {
return new TextAlignmentProp(proto, null);
}
- @NonNull
- AlignmentProto.TextAlignmentProp toProto() {
+ AlignmentProto.@NonNull TextAlignmentProp toProto() {
return mImpl;
}
@@ -927,16 +881,14 @@
public Builder() {}
/** Sets the value. */
- @NonNull
- public Builder setValue(@TextAlignment int value) {
+ public @NonNull Builder setValue(@TextAlignment int value) {
mImpl.setValue(AlignmentProto.TextAlignment.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public TextAlignmentProp build() {
+ public @NonNull TextAlignmentProp build() {
return new TextAlignmentProp(mImpl.build(), mFingerprint);
}
}
@@ -945,7 +897,7 @@
/** An extensible {@code TextOverflow} property. */
public static final class TextOverflowProp {
private final LayoutElementProto.TextOverflowProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
TextOverflowProp(
LayoutElementProto.TextOverflowProp impl, @Nullable Fingerprint fingerprint) {
@@ -961,18 +913,16 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static TextOverflowProp fromProto(@NonNull LayoutElementProto.TextOverflowProp proto) {
+ static @NonNull TextOverflowProp fromProto(
+ LayoutElementProto.@NonNull TextOverflowProp proto) {
return new TextOverflowProp(proto, null);
}
- @NonNull
- LayoutElementProto.TextOverflowProp toProto() {
+ LayoutElementProto.@NonNull TextOverflowProp toProto() {
return mImpl;
}
@@ -985,16 +935,14 @@
public Builder() {}
/** Sets the value. */
- @NonNull
- public Builder setValue(@TextOverflow int value) {
+ public @NonNull Builder setValue(@TextOverflow int value) {
mImpl.setValue(LayoutElementProto.TextOverflow.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public TextOverflowProp build() {
+ public @NonNull TextOverflowProp build() {
return new TextOverflowProp(mImpl.build(), mFingerprint);
}
}
@@ -1003,7 +951,7 @@
/** An extensible {@code ArcAnchorType} property. */
public static final class ArcAnchorTypeProp {
private final AlignmentProto.ArcAnchorTypeProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ArcAnchorTypeProp(
AlignmentProto.ArcAnchorTypeProp impl, @Nullable Fingerprint fingerprint) {
@@ -1019,18 +967,16 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static ArcAnchorTypeProp fromProto(@NonNull AlignmentProto.ArcAnchorTypeProp proto) {
+ static @NonNull ArcAnchorTypeProp fromProto(
+ AlignmentProto.@NonNull ArcAnchorTypeProp proto) {
return new ArcAnchorTypeProp(proto, null);
}
- @NonNull
- AlignmentProto.ArcAnchorTypeProp toProto() {
+ AlignmentProto.@NonNull ArcAnchorTypeProp toProto() {
return mImpl;
}
@@ -1043,16 +989,14 @@
public Builder() {}
/** Sets the value. */
- @NonNull
- public Builder setValue(@ArcAnchorType int value) {
+ public @NonNull Builder setValue(@ArcAnchorType int value) {
mImpl.setValue(AlignmentProto.ArcAnchorType.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public ArcAnchorTypeProp build() {
+ public @NonNull ArcAnchorTypeProp build() {
return new ArcAnchorTypeProp(mImpl.build(), mFingerprint);
}
}
@@ -1061,7 +1005,7 @@
/** A text string. */
public static final class Text implements LayoutElement {
private final LayoutElementProto.Text mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Text(LayoutElementProto.Text impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -1069,8 +1013,7 @@
}
/** Gets the text to render. Intended for testing purposes only. */
- @Nullable
- public TypeBuilders.StringProp getText() {
+ public TypeBuilders.@Nullable StringProp getText() {
if (mImpl.hasText()) {
return TypeBuilders.StringProp.fromProto(mImpl.getText());
} else {
@@ -1082,8 +1025,7 @@
* Gets the style of font to use (size, bold etc). If not specified, defaults to the
* platform's default body font. Intended for testing purposes only.
*/
- @Nullable
- public FontStyle getFontStyle() {
+ public @Nullable FontStyle getFontStyle() {
if (mImpl.hasFontStyle()) {
return FontStyle.fromProto(mImpl.getFontStyle());
} else {
@@ -1095,8 +1037,7 @@
* Gets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. Intended
* for testing purposes only.
*/
- @Nullable
- public ModifiersBuilders.Modifiers getModifiers() {
+ public ModifiersBuilders.@Nullable Modifiers getModifiers() {
if (mImpl.hasModifiers()) {
return ModifiersBuilders.Modifiers.fromProto(mImpl.getModifiers());
} else {
@@ -1109,8 +1050,7 @@
* not defined, the {@link Text} element will be treated as a single-line element. Intended
* for testing purposes only.
*/
- @Nullable
- public TypeBuilders.Int32Prop getMaxLines() {
+ public TypeBuilders.@Nullable Int32Prop getMaxLines() {
if (mImpl.hasMaxLines()) {
return TypeBuilders.Int32Prop.fromProto(mImpl.getMaxLines());
} else {
@@ -1125,8 +1065,7 @@
* the alignment of lines relative to the {@link Text} element bounds. If not defined,
* defaults to TEXT_ALIGN_CENTER. Intended for testing purposes only.
*/
- @Nullable
- public TextAlignmentProp getMultilineAlignment() {
+ public @Nullable TextAlignmentProp getMultilineAlignment() {
if (mImpl.hasMultilineAlignment()) {
return TextAlignmentProp.fromProto(mImpl.getMultilineAlignment());
} else {
@@ -1141,8 +1080,7 @@
* which cannot fit inside its container will be truncated. If not defined, defaults to
* TEXT_OVERFLOW_TRUNCATE. Intended for testing purposes only.
*/
- @Nullable
- public TextOverflowProp getOverflow() {
+ public @Nullable TextOverflowProp getOverflow() {
if (mImpl.hasOverflow()) {
return TextOverflowProp.fromProto(mImpl.getOverflow());
} else {
@@ -1155,8 +1093,7 @@
* distance between subsequent baselines. If not specified, defaults the font's recommended
* interline spacing. Intended for testing purposes only.
*/
- @Nullable
- public DimensionBuilders.SpProp getLineHeight() {
+ public DimensionBuilders.@Nullable SpProp getLineHeight() {
if (mImpl.hasLineHeight()) {
return DimensionBuilders.SpProp.fromProto(mImpl.getLineHeight());
} else {
@@ -1166,26 +1103,22 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static Text fromProto(
- @NonNull LayoutElementProto.Text proto, @Nullable Fingerprint fingerprint) {
+ static @NonNull Text fromProto(
+ LayoutElementProto.@NonNull Text proto, @Nullable Fingerprint fingerprint) {
return new Text(proto, fingerprint);
}
- @NonNull
- LayoutElementProto.Text toProto() {
+ LayoutElementProto.@NonNull Text toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return LayoutElementProto.LayoutElement.newBuilder().setText(mImpl).build();
}
@@ -1198,8 +1131,7 @@
public Builder() {}
/** Sets the text to render. */
- @NonNull
- public Builder setText(@NonNull TypeBuilders.StringProp text) {
+ public @NonNull Builder setText(TypeBuilders.@NonNull StringProp text) {
mImpl.setText(text.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(text.getFingerprint()).aggregateValueAsInt());
@@ -1207,8 +1139,7 @@
}
/** Sets the text to render. */
- @NonNull
- public Builder setText(@NonNull String text) {
+ public @NonNull Builder setText(@NonNull String text) {
mImpl.mergeText(TypesProto.StringProp.newBuilder().setValue(text).build());
mFingerprint.recordPropertyUpdate(1, text.hashCode());
return this;
@@ -1218,8 +1149,7 @@
* Sets the style of font to use (size, bold etc). If not specified, defaults to the
* platform's default body font.
*/
- @NonNull
- public Builder setFontStyle(@NonNull FontStyle fontStyle) {
+ public @NonNull Builder setFontStyle(@NonNull FontStyle fontStyle) {
mImpl.setFontStyle(fontStyle.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(fontStyle.getFingerprint()).aggregateValueAsInt());
@@ -1227,8 +1157,7 @@
}
/** Sets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. */
- @NonNull
- public Builder setModifiers(@NonNull ModifiersBuilders.Modifiers modifiers) {
+ public @NonNull Builder setModifiers(ModifiersBuilders.@NonNull Modifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -1239,8 +1168,7 @@
* Sets the maximum number of lines that can be represented by the {@link Text} element.
* If not defined, the {@link Text} element will be treated as a single-line element.
*/
- @NonNull
- public Builder setMaxLines(@NonNull TypeBuilders.Int32Prop maxLines) {
+ public @NonNull Builder setMaxLines(TypeBuilders.@NonNull Int32Prop maxLines) {
mImpl.setMaxLines(maxLines.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(maxLines.getFingerprint()).aggregateValueAsInt());
@@ -1251,8 +1179,7 @@
* Sets the maximum number of lines that can be represented by the {@link Text} element.
* If not defined, the {@link Text} element will be treated as a single-line element.
*/
- @NonNull
- public Builder setMaxLines(@IntRange(from = 1) int maxLines) {
+ public @NonNull Builder setMaxLines(@IntRange(from = 1) int maxLines) {
mImpl.setMaxLines(TypesProto.Int32Prop.newBuilder().setValue(maxLines));
mFingerprint.recordPropertyUpdate(4, maxLines);
return this;
@@ -1265,8 +1192,8 @@
* will set the alignment of lines relative to the {@link Text} element bounds. If not
* defined, defaults to TEXT_ALIGN_CENTER.
*/
- @NonNull
- public Builder setMultilineAlignment(@NonNull TextAlignmentProp multilineAlignment) {
+ public @NonNull Builder setMultilineAlignment(
+ @NonNull TextAlignmentProp multilineAlignment) {
mImpl.setMultilineAlignment(multilineAlignment.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(multilineAlignment.getFingerprint()).aggregateValueAsInt());
@@ -1280,8 +1207,7 @@
* will set the alignment of lines relative to the {@link Text} element bounds. If not
* defined, defaults to TEXT_ALIGN_CENTER.
*/
- @NonNull
- public Builder setMultilineAlignment(@TextAlignment int multilineAlignment) {
+ public @NonNull Builder setMultilineAlignment(@TextAlignment int multilineAlignment) {
mImpl.setMultilineAlignment(
AlignmentProto.TextAlignmentProp.newBuilder()
.setValue(
@@ -1298,8 +1224,7 @@
* its text, the text which cannot fit inside its container will be truncated. If not
* defined, defaults to TEXT_OVERFLOW_TRUNCATE.
*/
- @NonNull
- public Builder setOverflow(@NonNull TextOverflowProp overflow) {
+ public @NonNull Builder setOverflow(@NonNull TextOverflowProp overflow) {
mImpl.setOverflow(overflow.toProto());
mFingerprint.recordPropertyUpdate(
6, checkNotNull(overflow.getFingerprint()).aggregateValueAsInt());
@@ -1313,8 +1238,7 @@
* its text, the text which cannot fit inside its container will be truncated. If not
* defined, defaults to TEXT_OVERFLOW_TRUNCATE.
*/
- @NonNull
- public Builder setOverflow(@TextOverflow int overflow) {
+ public @NonNull Builder setOverflow(@TextOverflow int overflow) {
mImpl.setOverflow(
LayoutElementProto.TextOverflowProp.newBuilder()
.setValue(LayoutElementProto.TextOverflow.forNumber(overflow)));
@@ -1327,8 +1251,7 @@
* distance between subsequent baselines. If not specified, defaults the font's
* recommended interline spacing.
*/
- @NonNull
- public Builder setLineHeight(@NonNull DimensionBuilders.SpProp lineHeight) {
+ public @NonNull Builder setLineHeight(DimensionBuilders.@NonNull SpProp lineHeight) {
mImpl.setLineHeight(lineHeight.toProto());
mFingerprint.recordPropertyUpdate(
7, checkNotNull(lineHeight.getFingerprint()).aggregateValueAsInt());
@@ -1336,8 +1259,7 @@
}
@Override
- @NonNull
- public Text build() {
+ public @NonNull Text build() {
return new Text(mImpl.build(), mFingerprint);
}
}
@@ -1346,7 +1268,7 @@
/** An extensible {@code ContentScaleMode} property. */
public static final class ContentScaleModeProp {
private final LayoutElementProto.ContentScaleModeProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ContentScaleModeProp(
LayoutElementProto.ContentScaleModeProp impl, @Nullable Fingerprint fingerprint) {
@@ -1362,19 +1284,16 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static ContentScaleModeProp fromProto(
- @NonNull LayoutElementProto.ContentScaleModeProp proto) {
+ static @NonNull ContentScaleModeProp fromProto(
+ LayoutElementProto.@NonNull ContentScaleModeProp proto) {
return new ContentScaleModeProp(proto, null);
}
- @NonNull
- LayoutElementProto.ContentScaleModeProp toProto() {
+ LayoutElementProto.@NonNull ContentScaleModeProp toProto() {
return mImpl;
}
@@ -1387,16 +1306,14 @@
public Builder() {}
/** Sets the value. */
- @NonNull
- public Builder setValue(@ContentScaleMode int value) {
+ public @NonNull Builder setValue(@ContentScaleMode int value) {
mImpl.setValue(LayoutElementProto.ContentScaleMode.forNumber(value));
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public ContentScaleModeProp build() {
+ public @NonNull ContentScaleModeProp build() {
return new ContentScaleModeProp(mImpl.build(), mFingerprint);
}
}
@@ -1405,7 +1322,7 @@
/** Filtering parameters used for images. This can be used to apply a color tint to images. */
public static final class ColorFilter {
private final LayoutElementProto.ColorFilter mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ColorFilter(LayoutElementProto.ColorFilter impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -1420,8 +1337,7 @@
* <p>Note that only Android image resources can be tinted; Inline images will not be
* tinted, and this property will have no effect. Intended for testing purposes only.
*/
- @Nullable
- public ColorBuilders.ColorProp getTint() {
+ public ColorBuilders.@Nullable ColorProp getTint() {
if (mImpl.hasTint()) {
return ColorBuilders.ColorProp.fromProto(mImpl.getTint());
} else {
@@ -1431,18 +1347,15 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static ColorFilter fromProto(@NonNull LayoutElementProto.ColorFilter proto) {
+ static @NonNull ColorFilter fromProto(LayoutElementProto.@NonNull ColorFilter proto) {
return new ColorFilter(proto, null);
}
- @NonNull
- LayoutElementProto.ColorFilter toProto() {
+ LayoutElementProto.@NonNull ColorFilter toProto() {
return mImpl;
}
@@ -1462,9 +1375,8 @@
* <p>Note that only Android image resources can be tinted; Inline images will not be
* tinted, and this property will have no effect.
*/
- @NonNull
- public LayoutElementBuilders.ColorFilter.Builder setTint(
- @NonNull ColorBuilders.ColorProp tint) {
+ public LayoutElementBuilders.ColorFilter.@NonNull Builder setTint(
+ ColorBuilders.@NonNull ColorProp tint) {
mImpl.setTint(tint.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(tint.getFingerprint()).aggregateValueAsInt());
@@ -1472,8 +1384,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public ColorFilter build() {
+ public @NonNull ColorFilter build() {
return new ColorFilter(mImpl.build(), mFingerprint);
}
}
@@ -1488,7 +1399,7 @@
*/
public static final class Image implements LayoutElement {
private final LayoutElementProto.Image mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Image(LayoutElementProto.Image impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -1499,8 +1410,7 @@
* Gets the resource_id of the image to render. This must exist in the supplied resource
* bundle. Intended for testing purposes only.
*/
- @Nullable
- public TypeBuilders.StringProp getResourceId() {
+ public TypeBuilders.@Nullable StringProp getResourceId() {
if (mImpl.hasResourceId()) {
return TypeBuilders.StringProp.fromProto(mImpl.getResourceId());
} else {
@@ -1512,8 +1422,7 @@
* Gets the width of this image. If not defined, the image will not be rendered. Intended
* for testing purposes only.
*/
- @Nullable
- public DimensionBuilders.ImageDimension getWidth() {
+ public DimensionBuilders.@Nullable ImageDimension getWidth() {
if (mImpl.hasWidth()) {
return DimensionBuilders.imageDimensionFromProto(mImpl.getWidth());
} else {
@@ -1525,8 +1434,7 @@
* Gets the height of this image. If not defined, the image will not be rendered. Intended
* for testing purposes only.
*/
- @Nullable
- public DimensionBuilders.ImageDimension getHeight() {
+ public DimensionBuilders.@Nullable ImageDimension getHeight() {
if (mImpl.hasHeight()) {
return DimensionBuilders.imageDimensionFromProto(mImpl.getHeight());
} else {
@@ -1539,8 +1447,7 @@
* size does not match those bounds. Defaults to CONTENT_SCALE_MODE_FIT. Intended for
* testing purposes only.
*/
- @Nullable
- public ContentScaleModeProp getContentScaleMode() {
+ public @Nullable ContentScaleModeProp getContentScaleMode() {
if (mImpl.hasContentScaleMode()) {
return ContentScaleModeProp.fromProto(mImpl.getContentScaleMode());
} else {
@@ -1552,8 +1459,7 @@
* Gets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. Intended
* for testing purposes only.
*/
- @Nullable
- public ModifiersBuilders.Modifiers getModifiers() {
+ public ModifiersBuilders.@Nullable Modifiers getModifiers() {
if (mImpl.hasModifiers()) {
return ModifiersBuilders.Modifiers.fromProto(mImpl.getModifiers());
} else {
@@ -1562,8 +1468,7 @@
}
/** Gets filtering parameters for this image. If not specified, defaults to no filtering. */
- @Nullable
- public ColorFilter getColorFilter() {
+ public @Nullable ColorFilter getColorFilter() {
if (mImpl.hasColorFilter()) {
return ColorFilter.fromProto(mImpl.getColorFilter());
} else {
@@ -1573,26 +1478,22 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static Image fromProto(
- @NonNull LayoutElementProto.Image proto, @Nullable Fingerprint fingerprint) {
+ static @NonNull Image fromProto(
+ LayoutElementProto.@NonNull Image proto, @Nullable Fingerprint fingerprint) {
return new Image(proto, fingerprint);
}
- @NonNull
- LayoutElementProto.Image toProto() {
+ LayoutElementProto.@NonNull Image toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return LayoutElementProto.LayoutElement.newBuilder().setImage(mImpl).build();
}
@@ -1608,8 +1509,7 @@
* Sets the resource_id of the image to render. This must exist in the supplied resource
* bundle.
*/
- @NonNull
- public Builder setResourceId(@NonNull TypeBuilders.StringProp resourceId) {
+ public @NonNull Builder setResourceId(TypeBuilders.@NonNull StringProp resourceId) {
mImpl.setResourceId(resourceId.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(resourceId.getFingerprint()).aggregateValueAsInt());
@@ -1620,16 +1520,14 @@
* Sets the resource_id of the image to render. This must exist in the supplied resource
* bundle.
*/
- @NonNull
- public Builder setResourceId(@NonNull String resourceId) {
+ public @NonNull Builder setResourceId(@NonNull String resourceId) {
mImpl.setResourceId(TypesProto.StringProp.newBuilder().setValue(resourceId));
mFingerprint.recordPropertyUpdate(1, resourceId.hashCode());
return this;
}
/** Sets the width of this image. If not defined, the image will not be rendered. */
- @NonNull
- public Builder setWidth(@NonNull DimensionBuilders.ImageDimension width) {
+ public @NonNull Builder setWidth(DimensionBuilders.@NonNull ImageDimension width) {
mImpl.setWidth(width.toImageDimensionProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(width.getFingerprint()).aggregateValueAsInt());
@@ -1637,8 +1535,7 @@
}
/** Sets the height of this image. If not defined, the image will not be rendered. */
- @NonNull
- public Builder setHeight(@NonNull DimensionBuilders.ImageDimension height) {
+ public @NonNull Builder setHeight(DimensionBuilders.@NonNull ImageDimension height) {
mImpl.setHeight(height.toImageDimensionProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(height.getFingerprint()).aggregateValueAsInt());
@@ -1649,8 +1546,8 @@
* Sets how to scale the image resource inside the bounds specified by width/height if
* its size does not match those bounds. Defaults to CONTENT_SCALE_MODE_FIT.
*/
- @NonNull
- public Builder setContentScaleMode(@NonNull ContentScaleModeProp contentScaleMode) {
+ public @NonNull Builder setContentScaleMode(
+ @NonNull ContentScaleModeProp contentScaleMode) {
mImpl.setContentScaleMode(contentScaleMode.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(contentScaleMode.getFingerprint()).aggregateValueAsInt());
@@ -1661,8 +1558,7 @@
* Sets how to scale the image resource inside the bounds specified by width/height if
* its size does not match those bounds. Defaults to CONTENT_SCALE_MODE_FIT.
*/
- @NonNull
- public Builder setContentScaleMode(@ContentScaleMode int contentScaleMode) {
+ public @NonNull Builder setContentScaleMode(@ContentScaleMode int contentScaleMode) {
mImpl.setContentScaleMode(
LayoutElementProto.ContentScaleModeProp.newBuilder()
.setValue(
@@ -1673,8 +1569,7 @@
}
/** Sets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. */
- @NonNull
- public Builder setModifiers(@NonNull ModifiersBuilders.Modifiers modifiers) {
+ public @NonNull Builder setModifiers(ModifiersBuilders.@NonNull Modifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -1684,8 +1579,7 @@
/**
* Sets filtering parameters for this image. If not specified, defaults to no filtering.
*/
- @NonNull
- public Builder setColorFilter(@NonNull ColorFilter colorFilter) {
+ public @NonNull Builder setColorFilter(@NonNull ColorFilter colorFilter) {
mImpl.setColorFilter(colorFilter.toProto());
mFingerprint.recordPropertyUpdate(
6, checkNotNull(colorFilter.getFingerprint()).aggregateValueAsInt());
@@ -1693,8 +1587,7 @@
}
@Override
- @NonNull
- public Image build() {
+ public @NonNull Image build() {
return new Image(mImpl.build(), mFingerprint);
}
}
@@ -1703,7 +1596,7 @@
/** A simple spacer, typically used to provide padding between adjacent elements. */
public static final class Spacer implements LayoutElement {
private final LayoutElementProto.Spacer mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Spacer(LayoutElementProto.Spacer impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -1715,8 +1608,7 @@
* {@link Arc}, this must be specified as an angular dimension, otherwise a linear dimension
* must be used. If not defined, defaults to 0. Intended for testing purposes only.
*/
- @Nullable
- public DimensionBuilders.SpacerDimension getWidth() {
+ public DimensionBuilders.@Nullable SpacerDimension getWidth() {
if (mImpl.hasWidth()) {
return DimensionBuilders.spacerDimensionFromProto(mImpl.getWidth());
} else {
@@ -1728,8 +1620,7 @@
* Gets the height of this spacer. If not defined, defaults to 0. Intended for testing
* purposes only.
*/
- @Nullable
- public DimensionBuilders.SpacerDimension getHeight() {
+ public DimensionBuilders.@Nullable SpacerDimension getHeight() {
if (mImpl.hasHeight()) {
return DimensionBuilders.spacerDimensionFromProto(mImpl.getHeight());
} else {
@@ -1741,8 +1632,7 @@
* Gets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. Intended
* for testing purposes only.
*/
- @Nullable
- public ModifiersBuilders.Modifiers getModifiers() {
+ public ModifiersBuilders.@Nullable Modifiers getModifiers() {
if (mImpl.hasModifiers()) {
return ModifiersBuilders.Modifiers.fromProto(mImpl.getModifiers());
} else {
@@ -1752,26 +1642,22 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static Spacer fromProto(
- @NonNull LayoutElementProto.Spacer proto, @Nullable Fingerprint fingerprint) {
+ static @NonNull Spacer fromProto(
+ LayoutElementProto.@NonNull Spacer proto, @Nullable Fingerprint fingerprint) {
return new Spacer(proto, fingerprint);
}
- @NonNull
- LayoutElementProto.Spacer toProto() {
+ LayoutElementProto.@NonNull Spacer toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return LayoutElementProto.LayoutElement.newBuilder().setSpacer(mImpl).build();
}
@@ -1788,8 +1674,7 @@
* {@link Arc}, this must be specified as an angular dimension, otherwise a linear
* dimension must be used. If not defined, defaults to 0.
*/
- @NonNull
- public Builder setWidth(@NonNull DimensionBuilders.SpacerDimension width) {
+ public @NonNull Builder setWidth(DimensionBuilders.@NonNull SpacerDimension width) {
mImpl.setWidth(width.toSpacerDimensionProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(width.getFingerprint()).aggregateValueAsInt());
@@ -1797,8 +1682,7 @@
}
/** Sets the height of this spacer. If not defined, defaults to 0. */
- @NonNull
- public Builder setHeight(@NonNull DimensionBuilders.SpacerDimension height) {
+ public @NonNull Builder setHeight(DimensionBuilders.@NonNull SpacerDimension height) {
mImpl.setHeight(height.toSpacerDimensionProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(height.getFingerprint()).aggregateValueAsInt());
@@ -1806,8 +1690,7 @@
}
/** Sets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. */
- @NonNull
- public Builder setModifiers(@NonNull ModifiersBuilders.Modifiers modifiers) {
+ public @NonNull Builder setModifiers(ModifiersBuilders.@NonNull Modifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -1815,8 +1698,7 @@
}
@Override
- @NonNull
- public Spacer build() {
+ public @NonNull Spacer build() {
return new Spacer(mImpl.build(), mFingerprint);
}
}
@@ -1828,7 +1710,7 @@
*/
public static final class Box implements LayoutElement {
private final LayoutElementProto.Box mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Box(LayoutElementProto.Box impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -1836,8 +1718,7 @@
}
/** Gets the child element(s) to wrap. Intended for testing purposes only. */
- @NonNull
- public List<LayoutElement> getContents() {
+ public @NonNull List<LayoutElement> getContents() {
return Collections.unmodifiableList(
mImpl.getContentsList().stream()
.map(LayoutElementBuilders::layoutElementFromProto)
@@ -1848,8 +1729,7 @@
* Gets the height of this {@link Box}. If not defined, this will size itself to fit all of
* its children (i.e. a WrappedDimension). Intended for testing purposes only.
*/
- @Nullable
- public DimensionBuilders.ContainerDimension getHeight() {
+ public DimensionBuilders.@Nullable ContainerDimension getHeight() {
if (mImpl.hasHeight()) {
return DimensionBuilders.containerDimensionFromProto(mImpl.getHeight());
} else {
@@ -1861,8 +1741,7 @@
* Gets the width of this {@link Box}. If not defined, this will size itself to fit all of
* its children (i.e. a WrappedDimension). Intended for testing purposes only.
*/
- @Nullable
- public DimensionBuilders.ContainerDimension getWidth() {
+ public DimensionBuilders.@Nullable ContainerDimension getWidth() {
if (mImpl.hasWidth()) {
return DimensionBuilders.containerDimensionFromProto(mImpl.getWidth());
} else {
@@ -1874,8 +1753,7 @@
* Gets the horizontal alignment of the element inside this {@link Box}. If not defined,
* defaults to HORIZONTAL_ALIGN_CENTER. Intended for testing purposes only.
*/
- @Nullable
- public HorizontalAlignmentProp getHorizontalAlignment() {
+ public @Nullable HorizontalAlignmentProp getHorizontalAlignment() {
if (mImpl.hasHorizontalAlignment()) {
return HorizontalAlignmentProp.fromProto(mImpl.getHorizontalAlignment());
} else {
@@ -1887,8 +1765,7 @@
* Gets the vertical alignment of the element inside this {@link Box}. If not defined,
* defaults to VERTICAL_ALIGN_CENTER. Intended for testing purposes only.
*/
- @Nullable
- public VerticalAlignmentProp getVerticalAlignment() {
+ public @Nullable VerticalAlignmentProp getVerticalAlignment() {
if (mImpl.hasVerticalAlignment()) {
return VerticalAlignmentProp.fromProto(mImpl.getVerticalAlignment());
} else {
@@ -1900,8 +1777,7 @@
* Gets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. Intended
* for testing purposes only.
*/
- @Nullable
- public ModifiersBuilders.Modifiers getModifiers() {
+ public ModifiersBuilders.@Nullable Modifiers getModifiers() {
if (mImpl.hasModifiers()) {
return ModifiersBuilders.Modifiers.fromProto(mImpl.getModifiers());
} else {
@@ -1911,26 +1787,22 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static Box fromProto(
- @NonNull LayoutElementProto.Box proto, @Nullable Fingerprint fingerprint) {
+ static @NonNull Box fromProto(
+ LayoutElementProto.@NonNull Box proto, @Nullable Fingerprint fingerprint) {
return new Box(proto, fingerprint);
}
- @NonNull
- LayoutElementProto.Box toProto() {
+ LayoutElementProto.@NonNull Box toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return LayoutElementProto.LayoutElement.newBuilder().setBox(mImpl).build();
}
@@ -1943,8 +1815,7 @@
public Builder() {}
/** Adds one item to the child element(s) to wrap. */
- @NonNull
- public Builder addContent(@NonNull LayoutElement content) {
+ public @NonNull Builder addContent(@NonNull LayoutElement content) {
mImpl.addContents(content.toLayoutElementProto());
mFingerprint.addChildNode(checkNotNull(content.getFingerprint()));
return this;
@@ -1954,8 +1825,8 @@
* Sets the height of this {@link Box}. If not defined, this will size itself to fit all
* of its children (i.e. a WrappedDimension).
*/
- @NonNull
- public Builder setHeight(@NonNull DimensionBuilders.ContainerDimension height) {
+ public @NonNull Builder setHeight(
+ DimensionBuilders.@NonNull ContainerDimension height) {
mImpl.setHeight(height.toContainerDimensionProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(height.getFingerprint()).aggregateValueAsInt());
@@ -1966,8 +1837,7 @@
* Sets the width of this {@link Box}. If not defined, this will size itself to fit all
* of its children (i.e. a WrappedDimension).
*/
- @NonNull
- public Builder setWidth(@NonNull DimensionBuilders.ContainerDimension width) {
+ public @NonNull Builder setWidth(DimensionBuilders.@NonNull ContainerDimension width) {
mImpl.setWidth(width.toContainerDimensionProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(width.getFingerprint()).aggregateValueAsInt());
@@ -1978,8 +1848,7 @@
* Sets the horizontal alignment of the element inside this {@link Box}. If not defined,
* defaults to HORIZONTAL_ALIGN_CENTER.
*/
- @NonNull
- public Builder setHorizontalAlignment(
+ public @NonNull Builder setHorizontalAlignment(
@NonNull HorizontalAlignmentProp horizontalAlignment) {
mImpl.setHorizontalAlignment(horizontalAlignment.toProto());
mFingerprint.recordPropertyUpdate(
@@ -1992,8 +1861,8 @@
* Sets the horizontal alignment of the element inside this {@link Box}. If not defined,
* defaults to HORIZONTAL_ALIGN_CENTER.
*/
- @NonNull
- public Builder setHorizontalAlignment(@HorizontalAlignment int horizontalAlignment) {
+ public @NonNull Builder setHorizontalAlignment(
+ @HorizontalAlignment int horizontalAlignment) {
mImpl.setHorizontalAlignment(
AlignmentProto.HorizontalAlignmentProp.newBuilder()
.setValue(
@@ -2007,8 +1876,8 @@
* Sets the vertical alignment of the element inside this {@link Box}. If not defined,
* defaults to VERTICAL_ALIGN_CENTER.
*/
- @NonNull
- public Builder setVerticalAlignment(@NonNull VerticalAlignmentProp verticalAlignment) {
+ public @NonNull Builder setVerticalAlignment(
+ @NonNull VerticalAlignmentProp verticalAlignment) {
mImpl.setVerticalAlignment(verticalAlignment.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(verticalAlignment.getFingerprint()).aggregateValueAsInt());
@@ -2019,8 +1888,7 @@
* Sets the vertical alignment of the element inside this {@link Box}. If not defined,
* defaults to VERTICAL_ALIGN_CENTER.
*/
- @NonNull
- public Builder setVerticalAlignment(@VerticalAlignment int verticalAlignment) {
+ public @NonNull Builder setVerticalAlignment(@VerticalAlignment int verticalAlignment) {
mImpl.setVerticalAlignment(
AlignmentProto.VerticalAlignmentProp.newBuilder()
.setValue(
@@ -2031,8 +1899,7 @@
}
/** Sets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. */
- @NonNull
- public Builder setModifiers(@NonNull ModifiersBuilders.Modifiers modifiers) {
+ public @NonNull Builder setModifiers(ModifiersBuilders.@NonNull Modifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
6, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -2040,8 +1907,7 @@
}
@Override
- @NonNull
- public Box build() {
+ public @NonNull Box build() {
return new Box(mImpl.build(), mFingerprint);
}
}
@@ -2054,7 +1920,7 @@
*/
public static final class SpanText implements Span {
private final LayoutElementProto.SpanText mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
SpanText(LayoutElementProto.SpanText impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -2062,8 +1928,7 @@
}
/** Gets the text to render. Intended for testing purposes only. */
- @Nullable
- public TypeBuilders.StringProp getText() {
+ public TypeBuilders.@Nullable StringProp getText() {
if (mImpl.hasText()) {
return TypeBuilders.StringProp.fromProto(mImpl.getText());
} else {
@@ -2075,8 +1940,7 @@
* Gets the style of font to use (size, bold etc). If not specified, defaults to the
* platform's default body font. Intended for testing purposes only.
*/
- @Nullable
- public FontStyle getFontStyle() {
+ public @Nullable FontStyle getFontStyle() {
if (mImpl.hasFontStyle()) {
return FontStyle.fromProto(mImpl.getFontStyle());
} else {
@@ -2088,8 +1952,7 @@
* Gets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. Intended
* for testing purposes only.
*/
- @Nullable
- public ModifiersBuilders.SpanModifiers getModifiers() {
+ public ModifiersBuilders.@Nullable SpanModifiers getModifiers() {
if (mImpl.hasModifiers()) {
return ModifiersBuilders.SpanModifiers.fromProto(mImpl.getModifiers());
} else {
@@ -2099,25 +1962,21 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static SpanText fromProto(@NonNull LayoutElementProto.SpanText proto) {
+ static @NonNull SpanText fromProto(LayoutElementProto.@NonNull SpanText proto) {
return new SpanText(proto, null);
}
- @NonNull
- LayoutElementProto.SpanText toProto() {
+ LayoutElementProto.@NonNull SpanText toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.Span toSpanProto() {
+ public LayoutElementProto.@NonNull Span toSpanProto() {
return LayoutElementProto.Span.newBuilder().setText(mImpl).build();
}
@@ -2130,8 +1989,7 @@
public Builder() {}
/** Sets the text to render. */
- @NonNull
- public Builder setText(@NonNull TypeBuilders.StringProp text) {
+ public @NonNull Builder setText(TypeBuilders.@NonNull StringProp text) {
mImpl.setText(text.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(text.getFingerprint()).aggregateValueAsInt());
@@ -2139,8 +1997,7 @@
}
/** Sets the text to render. */
- @NonNull
- public Builder setText(@NonNull String text) {
+ public @NonNull Builder setText(@NonNull String text) {
mImpl.setText(TypesProto.StringProp.newBuilder().setValue(text));
mFingerprint.recordPropertyUpdate(1, text.hashCode());
return this;
@@ -2150,8 +2007,7 @@
* Sets the style of font to use (size, bold etc). If not specified, defaults to the
* platform's default body font.
*/
- @NonNull
- public Builder setFontStyle(@NonNull FontStyle fontStyle) {
+ public @NonNull Builder setFontStyle(@NonNull FontStyle fontStyle) {
mImpl.setFontStyle(fontStyle.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(fontStyle.getFingerprint()).aggregateValueAsInt());
@@ -2159,8 +2015,8 @@
}
/** Sets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. */
- @NonNull
- public Builder setModifiers(@NonNull ModifiersBuilders.SpanModifiers modifiers) {
+ public @NonNull Builder setModifiers(
+ ModifiersBuilders.@NonNull SpanModifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -2168,8 +2024,7 @@
}
@Override
- @NonNull
- public SpanText build() {
+ public @NonNull SpanText build() {
return new SpanText(mImpl.build(), mFingerprint);
}
}
@@ -2178,7 +2033,7 @@
/** An image which can be added to a {@link Span}. */
public static final class SpanImage implements Span {
private final LayoutElementProto.SpanImage mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
SpanImage(LayoutElementProto.SpanImage impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -2189,8 +2044,7 @@
* Gets the resource_id of the image to render. This must exist in the supplied resource
* bundle. Intended for testing purposes only.
*/
- @Nullable
- public TypeBuilders.StringProp getResourceId() {
+ public TypeBuilders.@Nullable StringProp getResourceId() {
if (mImpl.hasResourceId()) {
return TypeBuilders.StringProp.fromProto(mImpl.getResourceId());
} else {
@@ -2202,8 +2056,7 @@
* Gets the width of this image. If not defined, the image will not be rendered. Intended
* for testing purposes only.
*/
- @Nullable
- public DimensionBuilders.DpProp getWidth() {
+ public DimensionBuilders.@Nullable DpProp getWidth() {
if (mImpl.hasWidth()) {
return DimensionBuilders.DpProp.fromProto(mImpl.getWidth());
} else {
@@ -2215,8 +2068,7 @@
* Gets the height of this image. If not defined, the image will not be rendered. Intended
* for testing purposes only.
*/
- @Nullable
- public DimensionBuilders.DpProp getHeight() {
+ public DimensionBuilders.@Nullable DpProp getHeight() {
if (mImpl.hasHeight()) {
return DimensionBuilders.DpProp.fromProto(mImpl.getHeight());
} else {
@@ -2228,8 +2080,7 @@
* Gets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. Intended
* for testing purposes only.
*/
- @Nullable
- public ModifiersBuilders.SpanModifiers getModifiers() {
+ public ModifiersBuilders.@Nullable SpanModifiers getModifiers() {
if (mImpl.hasModifiers()) {
return ModifiersBuilders.SpanModifiers.fromProto(mImpl.getModifiers());
} else {
@@ -2241,8 +2092,7 @@
* Gets alignment of this image within the line height of the surrounding {@link Spannable}.
* If undefined, defaults to SPAN_VERTICAL_ALIGN_BOTTOM. Intended for testing purposes only.
*/
- @Nullable
- public SpanVerticalAlignmentProp getAlignment() {
+ public @Nullable SpanVerticalAlignmentProp getAlignment() {
if (mImpl.hasAlignment()) {
return SpanVerticalAlignmentProp.fromProto(mImpl.getAlignment());
} else {
@@ -2252,25 +2102,21 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static SpanImage fromProto(@NonNull LayoutElementProto.SpanImage proto) {
+ static @NonNull SpanImage fromProto(LayoutElementProto.@NonNull SpanImage proto) {
return new SpanImage(proto, null);
}
- @NonNull
- LayoutElementProto.SpanImage toProto() {
+ LayoutElementProto.@NonNull SpanImage toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.Span toSpanProto() {
+ public LayoutElementProto.@NonNull Span toSpanProto() {
return LayoutElementProto.Span.newBuilder().setImage(mImpl).build();
}
@@ -2286,8 +2132,7 @@
* Sets the resource_id of the image to render. This must exist in the supplied resource
* bundle.
*/
- @NonNull
- public Builder setResourceId(@NonNull TypeBuilders.StringProp resourceId) {
+ public @NonNull Builder setResourceId(TypeBuilders.@NonNull StringProp resourceId) {
mImpl.setResourceId(resourceId.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(resourceId.getFingerprint()).aggregateValueAsInt());
@@ -2298,16 +2143,14 @@
* Sets the resource_id of the image to render. This must exist in the supplied resource
* bundle.
*/
- @NonNull
- public Builder setResourceId(@NonNull String resourceId) {
+ public @NonNull Builder setResourceId(@NonNull String resourceId) {
mImpl.setResourceId(TypesProto.StringProp.newBuilder().setValue(resourceId));
mFingerprint.recordPropertyUpdate(1, resourceId.hashCode());
return this;
}
/** Sets the width of this image. If not defined, the image will not be rendered. */
- @NonNull
- public Builder setWidth(@NonNull DimensionBuilders.DpProp width) {
+ public @NonNull Builder setWidth(DimensionBuilders.@NonNull DpProp width) {
mImpl.setWidth(width.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(width.getFingerprint()).aggregateValueAsInt());
@@ -2315,8 +2158,7 @@
}
/** Sets the height of this image. If not defined, the image will not be rendered. */
- @NonNull
- public Builder setHeight(@NonNull DimensionBuilders.DpProp height) {
+ public @NonNull Builder setHeight(DimensionBuilders.@NonNull DpProp height) {
mImpl.setHeight(height.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(height.getFingerprint()).aggregateValueAsInt());
@@ -2324,8 +2166,8 @@
}
/** Sets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. */
- @NonNull
- public Builder setModifiers(@NonNull ModifiersBuilders.SpanModifiers modifiers) {
+ public @NonNull Builder setModifiers(
+ ModifiersBuilders.@NonNull SpanModifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -2336,8 +2178,7 @@
* Sets alignment of this image within the line height of the surrounding {@link
* Spannable}. If undefined, defaults to SPAN_VERTICAL_ALIGN_BOTTOM.
*/
- @NonNull
- public Builder setAlignment(@NonNull SpanVerticalAlignmentProp alignment) {
+ public @NonNull Builder setAlignment(@NonNull SpanVerticalAlignmentProp alignment) {
mImpl.setAlignment(alignment.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(alignment.getFingerprint()).aggregateValueAsInt());
@@ -2348,8 +2189,7 @@
* Sets alignment of this image within the line height of the surrounding {@link
* Spannable}. If undefined, defaults to SPAN_VERTICAL_ALIGN_BOTTOM.
*/
- @NonNull
- public Builder setAlignment(@SpanVerticalAlignment int alignment) {
+ public @NonNull Builder setAlignment(@SpanVerticalAlignment int alignment) {
mImpl.setAlignment(
LayoutElementProto.SpanVerticalAlignmentProp.newBuilder()
.setValue(
@@ -2360,8 +2200,7 @@
}
@Override
- @NonNull
- public SpanImage build() {
+ public @NonNull SpanImage build() {
return new SpanImage(mImpl.build(), mFingerprint);
}
}
@@ -2375,29 +2214,25 @@
public interface Span {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.Span toSpanProto();
+ LayoutElementProto.@NonNull Span toSpanProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link Span} objects. */
@SuppressLint("StaticFinalBuilder")
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- Span build();
+ @NonNull Span build();
}
}
/**
* Return an instance of one of this object's subtypes, from the protocol buffer representation.
*/
- @NonNull
- static Span spanFromProto(@NonNull LayoutElementProto.Span proto) {
+ static @NonNull Span spanFromProto(LayoutElementProto.@NonNull Span proto) {
if (proto.hasText()) {
return SpanText.fromProto(proto.getText());
}
@@ -2415,7 +2250,7 @@
*/
public static final class Spannable implements LayoutElement {
private final LayoutElementProto.Spannable mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Spannable(LayoutElementProto.Spannable impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -2426,8 +2261,7 @@
* Gets the {@link Span} elements that form this {@link Spannable}. Intended for testing
* purposes only.
*/
- @NonNull
- public List<Span> getSpans() {
+ public @NonNull List<Span> getSpans() {
return Collections.unmodifiableList(
mImpl.getSpansList().stream()
.map(LayoutElementBuilders::spanFromProto)
@@ -2438,8 +2272,7 @@
* Gets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. Intended
* for testing purposes only.
*/
- @Nullable
- public ModifiersBuilders.Modifiers getModifiers() {
+ public ModifiersBuilders.@Nullable Modifiers getModifiers() {
if (mImpl.hasModifiers()) {
return ModifiersBuilders.Modifiers.fromProto(mImpl.getModifiers());
} else {
@@ -2452,8 +2285,7 @@
* element. If not defined, the {@link Spannable} element will be treated as a single-line
* element. Intended for testing purposes only.
*/
- @Nullable
- public TypeBuilders.Int32Prop getMaxLines() {
+ public TypeBuilders.@Nullable Int32Prop getMaxLines() {
if (mImpl.hasMaxLines()) {
return TypeBuilders.Int32Prop.fromProto(mImpl.getMaxLines());
} else {
@@ -2469,8 +2301,7 @@
* element bounds. If not defined, defaults to TEXT_ALIGN_CENTER. Intended for testing
* purposes only.
*/
- @Nullable
- public HorizontalAlignmentProp getMultilineAlignment() {
+ public @Nullable HorizontalAlignmentProp getMultilineAlignment() {
if (mImpl.hasMultilineAlignment()) {
return HorizontalAlignmentProp.fromProto(mImpl.getMultilineAlignment());
} else {
@@ -2485,8 +2316,7 @@
* content, the content which cannot fit inside its container will be truncated. If not
* defined, defaults to TEXT_OVERFLOW_TRUNCATE. Intended for testing purposes only.
*/
- @Nullable
- public TextOverflowProp getOverflow() {
+ public @Nullable TextOverflowProp getOverflow() {
if (mImpl.hasOverflow()) {
return TextOverflowProp.fromProto(mImpl.getOverflow());
} else {
@@ -2499,8 +2329,7 @@
* distance between subsequent baselines. If not specified, defaults the font's recommended
* interline spacing. Intended for testing purposes only.
*/
- @Nullable
- public DimensionBuilders.SpProp getLineHeight() {
+ public DimensionBuilders.@Nullable SpProp getLineHeight() {
if (mImpl.hasLineHeight()) {
return DimensionBuilders.SpProp.fromProto(mImpl.getLineHeight());
} else {
@@ -2510,26 +2339,22 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static Spannable fromProto(
- @NonNull LayoutElementProto.Spannable proto, @Nullable Fingerprint fingerprint) {
+ static @NonNull Spannable fromProto(
+ LayoutElementProto.@NonNull Spannable proto, @Nullable Fingerprint fingerprint) {
return new Spannable(proto, fingerprint);
}
- @NonNull
- LayoutElementProto.Spannable toProto() {
+ LayoutElementProto.@NonNull Spannable toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return LayoutElementProto.LayoutElement.newBuilder().setSpannable(mImpl).build();
}
@@ -2542,8 +2367,7 @@
public Builder() {}
/** Adds one item to the {@link Span} elements that form this {@link Spannable}. */
- @NonNull
- public Builder addSpan(@NonNull Span span) {
+ public @NonNull Builder addSpan(@NonNull Span span) {
mImpl.addSpans(span.toSpanProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(span.getFingerprint()).aggregateValueAsInt());
@@ -2551,8 +2375,7 @@
}
/** Sets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. */
- @NonNull
- public Builder setModifiers(@NonNull ModifiersBuilders.Modifiers modifiers) {
+ public @NonNull Builder setModifiers(ModifiersBuilders.@NonNull Modifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -2564,8 +2387,7 @@
* element. If not defined, the {@link Spannable} element will be treated as a
* single-line element.
*/
- @NonNull
- public Builder setMaxLines(@NonNull TypeBuilders.Int32Prop maxLines) {
+ public @NonNull Builder setMaxLines(TypeBuilders.@NonNull Int32Prop maxLines) {
mImpl.setMaxLines(maxLines.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(maxLines.getFingerprint()).aggregateValueAsInt());
@@ -2577,8 +2399,7 @@
* element. If not defined, the {@link Spannable} element will be treated as a
* single-line element.
*/
- @NonNull
- public Builder setMaxLines(@IntRange(from = 1) int maxLines) {
+ public @NonNull Builder setMaxLines(@IntRange(from = 1) int maxLines) {
mImpl.setMaxLines(TypesProto.Int32Prop.newBuilder().setValue(maxLines));
mFingerprint.recordPropertyUpdate(3, maxLines);
return this;
@@ -2591,8 +2412,7 @@
* For multi-line content, however, this will set the alignment of lines relative to the
* {@link Spannable} element bounds. If not defined, defaults to TEXT_ALIGN_CENTER.
*/
- @NonNull
- public Builder setMultilineAlignment(
+ public @NonNull Builder setMultilineAlignment(
@NonNull HorizontalAlignmentProp multilineAlignment) {
mImpl.setMultilineAlignment(multilineAlignment.toProto());
mFingerprint.recordPropertyUpdate(
@@ -2607,8 +2427,8 @@
* For multi-line content, however, this will set the alignment of lines relative to the
* {@link Spannable} element bounds. If not defined, defaults to TEXT_ALIGN_CENTER.
*/
- @NonNull
- public Builder setMultilineAlignment(@HorizontalAlignment int multilineAlignment) {
+ public @NonNull Builder setMultilineAlignment(
+ @HorizontalAlignment int multilineAlignment) {
mImpl.setMultilineAlignment(
AlignmentProto.HorizontalAlignmentProp.newBuilder()
.setValue(
@@ -2625,8 +2445,7 @@
* render all of its content, the content which cannot fit inside its container will be
* truncated. If not defined, defaults to TEXT_OVERFLOW_TRUNCATE.
*/
- @NonNull
- public Builder setOverflow(@NonNull TextOverflowProp overflow) {
+ public @NonNull Builder setOverflow(@NonNull TextOverflowProp overflow) {
mImpl.setOverflow(overflow.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(overflow.getFingerprint()).aggregateValueAsInt());
@@ -2640,8 +2459,7 @@
* render all of its content, the content which cannot fit inside its container will be
* truncated. If not defined, defaults to TEXT_OVERFLOW_TRUNCATE.
*/
- @NonNull
- public Builder setOverflow(@TextOverflow int overflow) {
+ public @NonNull Builder setOverflow(@TextOverflow int overflow) {
mImpl.setOverflow(
LayoutElementProto.TextOverflowProp.newBuilder()
.setValue(LayoutElementProto.TextOverflow.forNumber(overflow)));
@@ -2654,8 +2472,7 @@
* distance between subsequent baselines. If not specified, defaults the font's
* recommended interline spacing.
*/
- @NonNull
- public Builder setLineHeight(@NonNull DimensionBuilders.SpProp lineHeight) {
+ public @NonNull Builder setLineHeight(DimensionBuilders.@NonNull SpProp lineHeight) {
mImpl.setLineHeight(lineHeight.toProto());
mFingerprint.recordPropertyUpdate(
7, checkNotNull(lineHeight.getFingerprint()).aggregateValueAsInt());
@@ -2663,8 +2480,7 @@
}
@Override
- @NonNull
- public Spannable build() {
+ public @NonNull Spannable build() {
return new Spannable(mImpl.build(), mFingerprint);
}
}
@@ -2682,7 +2498,7 @@
*/
public static final class Column implements LayoutElement {
private final LayoutElementProto.Column mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Column(LayoutElementProto.Column impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -2693,8 +2509,7 @@
* Gets the list of child elements to place inside this {@link Column}. Intended for testing
* purposes only.
*/
- @NonNull
- public List<LayoutElement> getContents() {
+ public @NonNull List<LayoutElement> getContents() {
return Collections.unmodifiableList(
mImpl.getContentsList().stream()
.map(LayoutElementBuilders::layoutElementFromProto)
@@ -2706,8 +2521,7 @@
* the resulting width of the column. If not defined, defaults to HORIZONTAL_ALIGN_CENTER.
* Intended for testing purposes only.
*/
- @Nullable
- public HorizontalAlignmentProp getHorizontalAlignment() {
+ public @Nullable HorizontalAlignmentProp getHorizontalAlignment() {
if (mImpl.hasHorizontalAlignment()) {
return HorizontalAlignmentProp.fromProto(mImpl.getHorizontalAlignment());
} else {
@@ -2719,8 +2533,7 @@
* Gets the width of this column. If not defined, this will size itself to fit all of its
* children (i.e. a WrappedDimension). Intended for testing purposes only.
*/
- @Nullable
- public DimensionBuilders.ContainerDimension getWidth() {
+ public DimensionBuilders.@Nullable ContainerDimension getWidth() {
if (mImpl.hasWidth()) {
return DimensionBuilders.containerDimensionFromProto(mImpl.getWidth());
} else {
@@ -2732,8 +2545,7 @@
* Gets the height of this column. If not defined, this will size itself to fit all of its
* children (i.e. a WrappedDimension). Intended for testing purposes only.
*/
- @Nullable
- public DimensionBuilders.ContainerDimension getHeight() {
+ public DimensionBuilders.@Nullable ContainerDimension getHeight() {
if (mImpl.hasHeight()) {
return DimensionBuilders.containerDimensionFromProto(mImpl.getHeight());
} else {
@@ -2745,8 +2557,7 @@
* Gets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. Intended
* for testing purposes only.
*/
- @Nullable
- public ModifiersBuilders.Modifiers getModifiers() {
+ public ModifiersBuilders.@Nullable Modifiers getModifiers() {
if (mImpl.hasModifiers()) {
return ModifiersBuilders.Modifiers.fromProto(mImpl.getModifiers());
} else {
@@ -2756,26 +2567,22 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static Column fromProto(
- @NonNull LayoutElementProto.Column proto, @Nullable Fingerprint fingerprint) {
+ static @NonNull Column fromProto(
+ LayoutElementProto.@NonNull Column proto, @Nullable Fingerprint fingerprint) {
return new Column(proto, fingerprint);
}
- @NonNull
- LayoutElementProto.Column toProto() {
+ LayoutElementProto.@NonNull Column toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return LayoutElementProto.LayoutElement.newBuilder().setColumn(mImpl).build();
}
@@ -2788,8 +2595,7 @@
public Builder() {}
/** Adds one item to the list of child elements to place inside this {@link Column}. */
- @NonNull
- public Builder addContent(@NonNull LayoutElement content) {
+ public @NonNull Builder addContent(@NonNull LayoutElement content) {
mImpl.addContents(content.toLayoutElementProto());
mFingerprint.addChildNode(checkNotNull(content.getFingerprint()));
return this;
@@ -2800,8 +2606,7 @@
* than the resulting width of the column. If not defined, defaults to
* HORIZONTAL_ALIGN_CENTER.
*/
- @NonNull
- public Builder setHorizontalAlignment(
+ public @NonNull Builder setHorizontalAlignment(
@NonNull HorizontalAlignmentProp horizontalAlignment) {
mImpl.setHorizontalAlignment(horizontalAlignment.toProto());
mFingerprint.recordPropertyUpdate(
@@ -2815,8 +2620,8 @@
* than the resulting width of the column. If not defined, defaults to
* HORIZONTAL_ALIGN_CENTER.
*/
- @NonNull
- public Builder setHorizontalAlignment(@HorizontalAlignment int horizontalAlignment) {
+ public @NonNull Builder setHorizontalAlignment(
+ @HorizontalAlignment int horizontalAlignment) {
mImpl.setHorizontalAlignment(
AlignmentProto.HorizontalAlignmentProp.newBuilder()
.setValue(
@@ -2830,8 +2635,7 @@
* Sets the width of this column. If not defined, this will size itself to fit all of
* its children (i.e. a WrappedDimension).
*/
- @NonNull
- public Builder setWidth(@NonNull DimensionBuilders.ContainerDimension width) {
+ public @NonNull Builder setWidth(DimensionBuilders.@NonNull ContainerDimension width) {
mImpl.setWidth(width.toContainerDimensionProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(width.getFingerprint()).aggregateValueAsInt());
@@ -2842,8 +2646,8 @@
* Sets the height of this column. If not defined, this will size itself to fit all of
* its children (i.e. a WrappedDimension).
*/
- @NonNull
- public Builder setHeight(@NonNull DimensionBuilders.ContainerDimension height) {
+ public @NonNull Builder setHeight(
+ DimensionBuilders.@NonNull ContainerDimension height) {
mImpl.setHeight(height.toContainerDimensionProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(height.getFingerprint()).aggregateValueAsInt());
@@ -2851,8 +2655,7 @@
}
/** Sets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. */
- @NonNull
- public Builder setModifiers(@NonNull ModifiersBuilders.Modifiers modifiers) {
+ public @NonNull Builder setModifiers(ModifiersBuilders.@NonNull Modifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -2860,8 +2663,7 @@
}
@Override
- @NonNull
- public Column build() {
+ public @NonNull Column build() {
return new Column(mImpl.build(), mFingerprint);
}
}
@@ -2879,7 +2681,7 @@
*/
public static final class Row implements LayoutElement {
private final LayoutElementProto.Row mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Row(LayoutElementProto.Row impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -2890,8 +2692,7 @@
* Gets the list of child elements to place inside this {@link Row}. Intended for testing
* purposes only.
*/
- @NonNull
- public List<LayoutElement> getContents() {
+ public @NonNull List<LayoutElement> getContents() {
return Collections.unmodifiableList(
mImpl.getContentsList().stream()
.map(LayoutElementBuilders::layoutElementFromProto)
@@ -2903,8 +2704,7 @@
* resulting height of the row. If not defined, defaults to VERTICAL_ALIGN_CENTER. Intended
* for testing purposes only.
*/
- @Nullable
- public VerticalAlignmentProp getVerticalAlignment() {
+ public @Nullable VerticalAlignmentProp getVerticalAlignment() {
if (mImpl.hasVerticalAlignment()) {
return VerticalAlignmentProp.fromProto(mImpl.getVerticalAlignment());
} else {
@@ -2916,8 +2716,7 @@
* Gets the width of this row. If not defined, this will size itself to fit all of its
* children (i.e. a WrappedDimension). Intended for testing purposes only.
*/
- @Nullable
- public DimensionBuilders.ContainerDimension getWidth() {
+ public DimensionBuilders.@Nullable ContainerDimension getWidth() {
if (mImpl.hasWidth()) {
return DimensionBuilders.containerDimensionFromProto(mImpl.getWidth());
} else {
@@ -2929,8 +2728,7 @@
* Gets the height of this row. If not defined, this will size itself to fit all of its
* children (i.e. a WrappedDimension). Intended for testing purposes only.
*/
- @Nullable
- public DimensionBuilders.ContainerDimension getHeight() {
+ public DimensionBuilders.@Nullable ContainerDimension getHeight() {
if (mImpl.hasHeight()) {
return DimensionBuilders.containerDimensionFromProto(mImpl.getHeight());
} else {
@@ -2942,8 +2740,7 @@
* Gets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. Intended
* for testing purposes only.
*/
- @Nullable
- public ModifiersBuilders.Modifiers getModifiers() {
+ public ModifiersBuilders.@Nullable Modifiers getModifiers() {
if (mImpl.hasModifiers()) {
return ModifiersBuilders.Modifiers.fromProto(mImpl.getModifiers());
} else {
@@ -2953,26 +2750,22 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static Row fromProto(
- @NonNull LayoutElementProto.Row proto, @Nullable Fingerprint fingerprint) {
+ static @NonNull Row fromProto(
+ LayoutElementProto.@NonNull Row proto, @Nullable Fingerprint fingerprint) {
return new Row(proto, fingerprint);
}
- @NonNull
- LayoutElementProto.Row toProto() {
+ LayoutElementProto.@NonNull Row toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return LayoutElementProto.LayoutElement.newBuilder().setRow(mImpl).build();
}
@@ -2985,8 +2778,7 @@
public Builder() {}
/** Adds one item to the list of child elements to place inside this {@link Row}. */
- @NonNull
- public Builder addContent(@NonNull LayoutElement content) {
+ public @NonNull Builder addContent(@NonNull LayoutElement content) {
mImpl.addContents(content.toLayoutElementProto());
mFingerprint.addChildNode(checkNotNull(content.getFingerprint()));
return this;
@@ -2996,8 +2788,8 @@
* Sets the vertical alignment of elements inside this row, if they are narrower than
* the resulting height of the row. If not defined, defaults to VERTICAL_ALIGN_CENTER.
*/
- @NonNull
- public Builder setVerticalAlignment(@NonNull VerticalAlignmentProp verticalAlignment) {
+ public @NonNull Builder setVerticalAlignment(
+ @NonNull VerticalAlignmentProp verticalAlignment) {
mImpl.setVerticalAlignment(verticalAlignment.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(verticalAlignment.getFingerprint()).aggregateValueAsInt());
@@ -3008,8 +2800,7 @@
* Sets the vertical alignment of elements inside this row, if they are narrower than
* the resulting height of the row. If not defined, defaults to VERTICAL_ALIGN_CENTER.
*/
- @NonNull
- public Builder setVerticalAlignment(@VerticalAlignment int verticalAlignment) {
+ public @NonNull Builder setVerticalAlignment(@VerticalAlignment int verticalAlignment) {
mImpl.setVerticalAlignment(
AlignmentProto.VerticalAlignmentProp.newBuilder()
.setValue(
@@ -3023,8 +2814,7 @@
* Sets the width of this row. If not defined, this will size itself to fit all of its
* children (i.e. a WrappedDimension).
*/
- @NonNull
- public Builder setWidth(@NonNull DimensionBuilders.ContainerDimension width) {
+ public @NonNull Builder setWidth(DimensionBuilders.@NonNull ContainerDimension width) {
mImpl.setWidth(width.toContainerDimensionProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(width.getFingerprint()).aggregateValueAsInt());
@@ -3035,8 +2825,8 @@
* Sets the height of this row. If not defined, this will size itself to fit all of its
* children (i.e. a WrappedDimension).
*/
- @NonNull
- public Builder setHeight(@NonNull DimensionBuilders.ContainerDimension height) {
+ public @NonNull Builder setHeight(
+ DimensionBuilders.@NonNull ContainerDimension height) {
mImpl.setHeight(height.toContainerDimensionProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(height.getFingerprint()).aggregateValueAsInt());
@@ -3044,8 +2834,7 @@
}
/** Sets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. */
- @NonNull
- public Builder setModifiers(@NonNull ModifiersBuilders.Modifiers modifiers) {
+ public @NonNull Builder setModifiers(ModifiersBuilders.@NonNull Modifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -3053,8 +2842,7 @@
}
@Override
- @NonNull
- public Row build() {
+ public @NonNull Row build() {
return new Row(mImpl.build(), mFingerprint);
}
}
@@ -3067,7 +2855,7 @@
*/
public static final class Arc implements LayoutElement {
private final LayoutElementProto.Arc mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Arc(LayoutElementProto.Arc impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -3075,8 +2863,7 @@
}
/** Gets contents of this container. Intended for testing purposes only. */
- @NonNull
- public List<ArcLayoutElement> getContents() {
+ public @NonNull List<ArcLayoutElement> getContents() {
return Collections.unmodifiableList(
mImpl.getContentsList().stream()
.map(LayoutElementBuilders::arcLayoutElementFromProto)
@@ -3092,8 +2879,7 @@
* sweep anti-clockwise (i.e. -90 degrees is equivalent to 270 degrees), and values >360
* will be be placed at X mod 360 degrees. Intended for testing purposes only.
*/
- @Nullable
- public DimensionBuilders.DegreesProp getAnchorAngle() {
+ public DimensionBuilders.@Nullable DegreesProp getAnchorAngle() {
if (mImpl.hasAnchorAngle()) {
return DimensionBuilders.DegreesProp.fromProto(mImpl.getAnchorAngle());
} else {
@@ -3105,8 +2891,7 @@
* Gets how to align the contents of this container relative to anchor_angle. If not
* defined, defaults to ARC_ANCHOR_CENTER. Intended for testing purposes only.
*/
- @Nullable
- public ArcAnchorTypeProp getAnchorType() {
+ public @Nullable ArcAnchorTypeProp getAnchorType() {
if (mImpl.hasAnchorType()) {
return ArcAnchorTypeProp.fromProto(mImpl.getAnchorType());
} else {
@@ -3120,8 +2905,7 @@
* should be drawn towards the inner or outer edge of the arc, or drawn in the center. If
* not defined, defaults to VERTICAL_ALIGN_CENTER. Intended for testing purposes only.
*/
- @Nullable
- public VerticalAlignmentProp getVerticalAlign() {
+ public @Nullable VerticalAlignmentProp getVerticalAlign() {
if (mImpl.hasVerticalAlign()) {
return VerticalAlignmentProp.fromProto(mImpl.getVerticalAlign());
} else {
@@ -3133,8 +2917,7 @@
* Gets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. Intended
* for testing purposes only.
*/
- @Nullable
- public ModifiersBuilders.Modifiers getModifiers() {
+ public ModifiersBuilders.@Nullable Modifiers getModifiers() {
if (mImpl.hasModifiers()) {
return ModifiersBuilders.Modifiers.fromProto(mImpl.getModifiers());
} else {
@@ -3144,26 +2927,22 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static Arc fromProto(
- @NonNull LayoutElementProto.Arc proto, @Nullable Fingerprint fingerprint) {
+ static @NonNull Arc fromProto(
+ LayoutElementProto.@NonNull Arc proto, @Nullable Fingerprint fingerprint) {
return new Arc(proto, fingerprint);
}
- @NonNull
- LayoutElementProto.Arc toProto() {
+ LayoutElementProto.@NonNull Arc toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.LayoutElement toLayoutElementProto() {
+ public LayoutElementProto.@NonNull LayoutElement toLayoutElementProto() {
return LayoutElementProto.LayoutElement.newBuilder().setArc(mImpl).build();
}
@@ -3176,8 +2955,7 @@
public Builder() {}
/** Adds one item to contents of this container. */
- @NonNull
- public Builder addContent(@NonNull ArcLayoutElement content) {
+ public @NonNull Builder addContent(@NonNull ArcLayoutElement content) {
mImpl.addContents(content.toArcLayoutElementProto());
mFingerprint.addChildNode(checkNotNull(content.getFingerprint()));
return this;
@@ -3192,8 +2970,8 @@
* will sweep anti-clockwise (i.e. -90 degrees is equivalent to 270 degrees), and values
* >360 will be be placed at X mod 360 degrees.
*/
- @NonNull
- public Builder setAnchorAngle(@NonNull DimensionBuilders.DegreesProp anchorAngle) {
+ public @NonNull Builder setAnchorAngle(
+ DimensionBuilders.@NonNull DegreesProp anchorAngle) {
mImpl.setAnchorAngle(anchorAngle.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(anchorAngle.getFingerprint()).aggregateValueAsInt());
@@ -3204,8 +2982,7 @@
* Sets how to align the contents of this container relative to anchor_angle. If not
* defined, defaults to ARC_ANCHOR_CENTER.
*/
- @NonNull
- public Builder setAnchorType(@NonNull ArcAnchorTypeProp anchorType) {
+ public @NonNull Builder setAnchorType(@NonNull ArcAnchorTypeProp anchorType) {
mImpl.setAnchorType(anchorType.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(anchorType.getFingerprint()).aggregateValueAsInt());
@@ -3216,8 +2993,7 @@
* Sets how to align the contents of this container relative to anchor_angle. If not
* defined, defaults to ARC_ANCHOR_CENTER.
*/
- @NonNull
- public Builder setAnchorType(@ArcAnchorType int anchorType) {
+ public @NonNull Builder setAnchorType(@ArcAnchorType int anchorType) {
mImpl.setAnchorType(
AlignmentProto.ArcAnchorTypeProp.newBuilder()
.setValue(AlignmentProto.ArcAnchorType.forNumber(anchorType)));
@@ -3231,8 +3007,7 @@
* element should be drawn towards the inner or outer edge of the arc, or drawn in the
* center. If not defined, defaults to VERTICAL_ALIGN_CENTER.
*/
- @NonNull
- public Builder setVerticalAlign(@NonNull VerticalAlignmentProp verticalAlign) {
+ public @NonNull Builder setVerticalAlign(@NonNull VerticalAlignmentProp verticalAlign) {
mImpl.setVerticalAlign(verticalAlign.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(verticalAlign.getFingerprint()).aggregateValueAsInt());
@@ -3245,8 +3020,7 @@
* element should be drawn towards the inner or outer edge of the arc, or drawn in the
* center. If not defined, defaults to VERTICAL_ALIGN_CENTER.
*/
- @NonNull
- public Builder setVerticalAlign(@VerticalAlignment int verticalAlign) {
+ public @NonNull Builder setVerticalAlign(@VerticalAlignment int verticalAlign) {
mImpl.setVerticalAlign(
AlignmentProto.VerticalAlignmentProp.newBuilder()
.setValue(
@@ -3256,8 +3030,7 @@
}
/** Sets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. */
- @NonNull
- public Builder setModifiers(@NonNull ModifiersBuilders.Modifiers modifiers) {
+ public @NonNull Builder setModifiers(ModifiersBuilders.@NonNull Modifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -3265,8 +3038,7 @@
}
@Override
- @NonNull
- public Arc build() {
+ public @NonNull Arc build() {
return new Arc(mImpl.build(), mFingerprint);
}
}
@@ -3275,7 +3047,7 @@
/** A text element that can be used in an {@link Arc}. */
public static final class ArcText implements ArcLayoutElement {
private final LayoutElementProto.ArcText mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ArcText(LayoutElementProto.ArcText impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -3283,8 +3055,7 @@
}
/** Gets the text to render. Intended for testing purposes only. */
- @Nullable
- public TypeBuilders.StringProp getText() {
+ public TypeBuilders.@Nullable StringProp getText() {
if (mImpl.hasText()) {
return TypeBuilders.StringProp.fromProto(mImpl.getText());
} else {
@@ -3296,8 +3067,7 @@
* Gets the style of font to use (size, bold etc). If not specified, defaults to the
* platform's default body font. Intended for testing purposes only.
*/
- @Nullable
- public FontStyle getFontStyle() {
+ public @Nullable FontStyle getFontStyle() {
if (mImpl.hasFontStyle()) {
return FontStyle.fromProto(mImpl.getFontStyle());
} else {
@@ -3309,8 +3079,7 @@
* Gets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. Intended
* for testing purposes only.
*/
- @Nullable
- public ModifiersBuilders.ArcModifiers getModifiers() {
+ public ModifiersBuilders.@Nullable ArcModifiers getModifiers() {
if (mImpl.hasModifiers()) {
return ModifiersBuilders.ArcModifiers.fromProto(mImpl.getModifiers());
} else {
@@ -3320,25 +3089,21 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static ArcText fromProto(@NonNull LayoutElementProto.ArcText proto) {
+ static @NonNull ArcText fromProto(LayoutElementProto.@NonNull ArcText proto) {
return new ArcText(proto, null);
}
- @NonNull
- LayoutElementProto.ArcText toProto() {
+ LayoutElementProto.@NonNull ArcText toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.ArcLayoutElement toArcLayoutElementProto() {
+ public LayoutElementProto.@NonNull ArcLayoutElement toArcLayoutElementProto() {
return LayoutElementProto.ArcLayoutElement.newBuilder().setText(mImpl).build();
}
@@ -3351,8 +3116,7 @@
public Builder() {}
/** Sets the text to render. */
- @NonNull
- public Builder setText(@NonNull TypeBuilders.StringProp text) {
+ public @NonNull Builder setText(TypeBuilders.@NonNull StringProp text) {
mImpl.setText(text.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(text.getFingerprint()).aggregateValueAsInt());
@@ -3360,8 +3124,7 @@
}
/** Sets the text to render. */
- @NonNull
- public Builder setText(@NonNull String text) {
+ public @NonNull Builder setText(@NonNull String text) {
mImpl.setText(TypesProto.StringProp.newBuilder().setValue(text));
mFingerprint.recordPropertyUpdate(1, text.hashCode());
return this;
@@ -3371,8 +3134,7 @@
* Sets the style of font to use (size, bold etc). If not specified, defaults to the
* platform's default body font.
*/
- @NonNull
- public Builder setFontStyle(@NonNull FontStyle fontStyle) {
+ public @NonNull Builder setFontStyle(@NonNull FontStyle fontStyle) {
mImpl.setFontStyle(fontStyle.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(fontStyle.getFingerprint()).aggregateValueAsInt());
@@ -3380,8 +3142,8 @@
}
/** Sets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. */
- @NonNull
- public Builder setModifiers(@NonNull ModifiersBuilders.ArcModifiers modifiers) {
+ public @NonNull Builder setModifiers(
+ ModifiersBuilders.@NonNull ArcModifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -3389,8 +3151,7 @@
}
@Override
- @NonNull
- public ArcText build() {
+ public @NonNull ArcText build() {
return new ArcText(mImpl.build(), mFingerprint);
}
}
@@ -3399,7 +3160,7 @@
/** A line that can be used in an {@link Arc} and renders as a round progress bar. */
public static final class ArcLine implements ArcLayoutElement {
private final LayoutElementProto.ArcLine mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ArcLine(LayoutElementProto.ArcLine impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -3410,8 +3171,7 @@
* Gets the length of this line, in degrees. If not defined, defaults to 0. Intended for
* testing purposes only.
*/
- @Nullable
- public DimensionBuilders.DegreesProp getLength() {
+ public DimensionBuilders.@Nullable DegreesProp getLength() {
if (mImpl.hasLength()) {
return DimensionBuilders.DegreesProp.fromProto(mImpl.getLength());
} else {
@@ -3423,8 +3183,7 @@
* Gets the thickness of this line. If not defined, defaults to 0. Intended for testing
* purposes only.
*/
- @Nullable
- public DimensionBuilders.DpProp getThickness() {
+ public DimensionBuilders.@Nullable DpProp getThickness() {
if (mImpl.hasThickness()) {
return DimensionBuilders.DpProp.fromProto(mImpl.getThickness());
} else {
@@ -3433,8 +3192,7 @@
}
/** Gets the color of this line. Intended for testing purposes only. */
- @Nullable
- public ColorBuilders.ColorProp getColor() {
+ public ColorBuilders.@Nullable ColorProp getColor() {
if (mImpl.hasColor()) {
return ColorBuilders.ColorProp.fromProto(mImpl.getColor());
} else {
@@ -3446,8 +3204,7 @@
* Gets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. Intended
* for testing purposes only.
*/
- @Nullable
- public ModifiersBuilders.ArcModifiers getModifiers() {
+ public ModifiersBuilders.@Nullable ArcModifiers getModifiers() {
if (mImpl.hasModifiers()) {
return ModifiersBuilders.ArcModifiers.fromProto(mImpl.getModifiers());
} else {
@@ -3457,25 +3214,21 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static ArcLine fromProto(@NonNull LayoutElementProto.ArcLine proto) {
+ static @NonNull ArcLine fromProto(LayoutElementProto.@NonNull ArcLine proto) {
return new ArcLine(proto, null);
}
- @NonNull
- LayoutElementProto.ArcLine toProto() {
+ LayoutElementProto.@NonNull ArcLine toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.ArcLayoutElement toArcLayoutElementProto() {
+ public LayoutElementProto.@NonNull ArcLayoutElement toArcLayoutElementProto() {
return LayoutElementProto.ArcLayoutElement.newBuilder().setLine(mImpl).build();
}
@@ -3488,8 +3241,7 @@
public Builder() {}
/** Sets the length of this line, in degrees. If not defined, defaults to 0. */
- @NonNull
- public Builder setLength(@NonNull DimensionBuilders.DegreesProp length) {
+ public @NonNull Builder setLength(DimensionBuilders.@NonNull DegreesProp length) {
mImpl.setLength(length.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(length.getFingerprint()).aggregateValueAsInt());
@@ -3497,8 +3249,7 @@
}
/** Sets the thickness of this line. If not defined, defaults to 0. */
- @NonNull
- public Builder setThickness(@NonNull DimensionBuilders.DpProp thickness) {
+ public @NonNull Builder setThickness(DimensionBuilders.@NonNull DpProp thickness) {
mImpl.setThickness(thickness.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(thickness.getFingerprint()).aggregateValueAsInt());
@@ -3506,8 +3257,7 @@
}
/** Sets the color of this line. */
- @NonNull
- public Builder setColor(@NonNull ColorBuilders.ColorProp color) {
+ public @NonNull Builder setColor(ColorBuilders.@NonNull ColorProp color) {
mImpl.setColor(color.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(color.getFingerprint()).aggregateValueAsInt());
@@ -3515,8 +3265,8 @@
}
/** Sets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. */
- @NonNull
- public Builder setModifiers(@NonNull ModifiersBuilders.ArcModifiers modifiers) {
+ public @NonNull Builder setModifiers(
+ ModifiersBuilders.@NonNull ArcModifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -3524,8 +3274,7 @@
}
@Override
- @NonNull
- public ArcLine build() {
+ public @NonNull ArcLine build() {
return new ArcLine(mImpl.build(), mFingerprint);
}
}
@@ -3534,7 +3283,7 @@
/** A simple spacer used to provide padding between adjacent elements in an {@link Arc}. */
public static final class ArcSpacer implements ArcLayoutElement {
private final LayoutElementProto.ArcSpacer mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ArcSpacer(LayoutElementProto.ArcSpacer impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -3545,8 +3294,7 @@
* Gets the length of this spacer, in degrees. If not defined, defaults to 0. Intended for
* testing purposes only.
*/
- @Nullable
- public DimensionBuilders.DegreesProp getLength() {
+ public DimensionBuilders.@Nullable DegreesProp getLength() {
if (mImpl.hasLength()) {
return DimensionBuilders.DegreesProp.fromProto(mImpl.getLength());
} else {
@@ -3558,8 +3306,7 @@
* Gets the thickness of this spacer, in DP. If not defined, defaults to 0. Intended for
* testing purposes only.
*/
- @Nullable
- public DimensionBuilders.DpProp getThickness() {
+ public DimensionBuilders.@Nullable DpProp getThickness() {
if (mImpl.hasThickness()) {
return DimensionBuilders.DpProp.fromProto(mImpl.getThickness());
} else {
@@ -3571,8 +3318,7 @@
* Gets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. Intended
* for testing purposes only.
*/
- @Nullable
- public ModifiersBuilders.ArcModifiers getModifiers() {
+ public ModifiersBuilders.@Nullable ArcModifiers getModifiers() {
if (mImpl.hasModifiers()) {
return ModifiersBuilders.ArcModifiers.fromProto(mImpl.getModifiers());
} else {
@@ -3582,25 +3328,21 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static ArcSpacer fromProto(@NonNull LayoutElementProto.ArcSpacer proto) {
+ static @NonNull ArcSpacer fromProto(LayoutElementProto.@NonNull ArcSpacer proto) {
return new ArcSpacer(proto, null);
}
- @NonNull
- LayoutElementProto.ArcSpacer toProto() {
+ LayoutElementProto.@NonNull ArcSpacer toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.ArcLayoutElement toArcLayoutElementProto() {
+ public LayoutElementProto.@NonNull ArcLayoutElement toArcLayoutElementProto() {
return LayoutElementProto.ArcLayoutElement.newBuilder().setSpacer(mImpl).build();
}
@@ -3613,8 +3355,7 @@
public Builder() {}
/** Sets the length of this spacer, in degrees. If not defined, defaults to 0. */
- @NonNull
- public Builder setLength(@NonNull DimensionBuilders.DegreesProp length) {
+ public @NonNull Builder setLength(DimensionBuilders.@NonNull DegreesProp length) {
mImpl.setLength(length.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(length.getFingerprint()).aggregateValueAsInt());
@@ -3622,8 +3363,7 @@
}
/** Sets the thickness of this spacer, in DP. If not defined, defaults to 0. */
- @NonNull
- public Builder setThickness(@NonNull DimensionBuilders.DpProp thickness) {
+ public @NonNull Builder setThickness(DimensionBuilders.@NonNull DpProp thickness) {
mFingerprint.recordPropertyUpdate(
2, checkNotNull(thickness.getFingerprint()).aggregateValueAsInt());
mImpl.setThickness(thickness.toProto());
@@ -3631,8 +3371,8 @@
}
/** Sets {@link androidx.wear.tiles.ModifiersBuilders.Modifiers} for this element. */
- @NonNull
- public Builder setModifiers(@NonNull ModifiersBuilders.ArcModifiers modifiers) {
+ public @NonNull Builder setModifiers(
+ ModifiersBuilders.@NonNull ArcModifiers modifiers) {
mImpl.setModifiers(modifiers.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(modifiers.getFingerprint()).aggregateValueAsInt());
@@ -3640,8 +3380,7 @@
}
@Override
- @NonNull
- public ArcSpacer build() {
+ public @NonNull ArcSpacer build() {
return new ArcSpacer(mImpl.build(), mFingerprint);
}
}
@@ -3650,7 +3389,7 @@
/** A container that allows a standard {@link LayoutElement} to be added to an {@link Arc}. */
public static final class ArcAdapter implements ArcLayoutElement {
private final LayoutElementProto.ArcAdapter mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ArcAdapter(LayoutElementProto.ArcAdapter impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -3658,8 +3397,7 @@
}
/** Gets the element to adapt to an {@link Arc}. Intended for testing purposes only. */
- @Nullable
- public LayoutElement getContent() {
+ public @Nullable LayoutElement getContent() {
if (mImpl.hasContent()) {
return LayoutElementBuilders.layoutElementFromProto(mImpl.getContent());
} else {
@@ -3676,8 +3414,7 @@
* will not be rotated. If not defined, defaults to false. Intended for testing purposes
* only.
*/
- @Nullable
- public TypeBuilders.BoolProp getRotateContents() {
+ public TypeBuilders.@Nullable BoolProp getRotateContents() {
if (mImpl.hasRotateContents()) {
return TypeBuilders.BoolProp.fromProto(mImpl.getRotateContents());
} else {
@@ -3687,25 +3424,21 @@
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static ArcAdapter fromProto(@NonNull LayoutElementProto.ArcAdapter proto) {
+ static @NonNull ArcAdapter fromProto(LayoutElementProto.@NonNull ArcAdapter proto) {
return new ArcAdapter(proto, null);
}
- @NonNull
- LayoutElementProto.ArcAdapter toProto() {
+ LayoutElementProto.@NonNull ArcAdapter toProto() {
return mImpl;
}
@Override
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.ArcLayoutElement toArcLayoutElementProto() {
+ public LayoutElementProto.@NonNull ArcLayoutElement toArcLayoutElementProto() {
return LayoutElementProto.ArcLayoutElement.newBuilder().setAdapter(mImpl).build();
}
@@ -3718,8 +3451,7 @@
public Builder() {}
/** Sets the element to adapt to an {@link Arc}. */
- @NonNull
- public Builder setContent(@NonNull LayoutElement content) {
+ public @NonNull Builder setContent(@NonNull LayoutElement content) {
mImpl.setContent(content.toLayoutElementProto());
mFingerprint.addChildNode(checkNotNull(content.getFingerprint()));
return this;
@@ -3733,8 +3465,8 @@
* degrees. If rotate_contents = false, the image will be placed at the 3 o clock
* position, but itself will not be rotated. If not defined, defaults to false.
*/
- @NonNull
- public Builder setRotateContents(@NonNull TypeBuilders.BoolProp rotateContents) {
+ public @NonNull Builder setRotateContents(
+ TypeBuilders.@NonNull BoolProp rotateContents) {
mImpl.setRotateContents(rotateContents.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(rotateContents.getFingerprint()).aggregateValueAsInt());
@@ -3750,16 +3482,14 @@
* position, but itself will not be rotated. If not defined, defaults to false.
*/
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setRotateContents(boolean rotateContents) {
+ public @NonNull Builder setRotateContents(boolean rotateContents) {
mImpl.setRotateContents(TypesProto.BoolProp.newBuilder().setValue(rotateContents));
mFingerprint.recordPropertyUpdate(2, Boolean.hashCode(rotateContents));
return this;
}
@Override
- @NonNull
- public ArcAdapter build() {
+ public @NonNull ArcAdapter build() {
return new ArcAdapter(mImpl.build(), mFingerprint);
}
}
@@ -3772,29 +3502,25 @@
public interface LayoutElement {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.LayoutElement toLayoutElementProto();
+ LayoutElementProto.@NonNull LayoutElement toLayoutElementProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link LayoutElement} objects. */
@SuppressLint("StaticFinalBuilder")
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- LayoutElement build();
+ @NonNull LayoutElement build();
}
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static LayoutElement layoutElementFromProto(
- @NonNull LayoutElementProto.LayoutElement proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull LayoutElement layoutElementFromProto(
+ LayoutElementProto.@NonNull LayoutElement proto, @Nullable Fingerprint fingerprint) {
if (proto.hasColumn()) {
return Column.fromProto(proto.getColumn(), fingerprint);
}
@@ -3822,8 +3548,8 @@
throw new IllegalStateException("Proto was not a recognised instance of LayoutElement");
}
- @NonNull
- static LayoutElement layoutElementFromProto(@NonNull LayoutElementProto.LayoutElement proto) {
+ static @NonNull LayoutElement layoutElementFromProto(
+ LayoutElementProto.@NonNull LayoutElement proto) {
return layoutElementFromProto(proto, null);
}
@@ -3834,27 +3560,23 @@
public interface ArcLayoutElement {
/** Get the protocol buffer representation of this object. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- LayoutElementProto.ArcLayoutElement toArcLayoutElementProto();
+ LayoutElementProto.@NonNull ArcLayoutElement toArcLayoutElementProto();
/** Get the fingerprint for this object or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- Fingerprint getFingerprint();
+ @Nullable Fingerprint getFingerprint();
/** Builder to create {@link ArcLayoutElement} objects. */
@SuppressLint("StaticFinalBuilder")
interface Builder {
/** Builds an instance with values accumulated in this Builder. */
- @NonNull
- ArcLayoutElement build();
+ @NonNull ArcLayoutElement build();
}
}
- @NonNull
- static ArcLayoutElement arcLayoutElementFromProto(
- @NonNull LayoutElementProto.ArcLayoutElement proto) {
+ static @NonNull ArcLayoutElement arcLayoutElementFromProto(
+ LayoutElementProto.@NonNull ArcLayoutElement proto) {
if (proto.hasText()) {
return ArcText.fromProto(proto.getText());
}
@@ -3879,8 +3601,7 @@
}
/** Gets the root element in the layout. Intended for testing purposes only. */
- @Nullable
- public LayoutElement getRoot() {
+ public @Nullable LayoutElement getRoot() {
if (mImpl.hasRoot()) {
return LayoutElementBuilders.layoutElementFromProto(mImpl.getRoot());
} else {
@@ -3889,35 +3610,30 @@
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Layout fromProto(@NonNull LayoutElementProto.Layout proto) {
+ public static @NonNull Layout fromProto(LayoutElementProto.@NonNull Layout proto) {
return new Layout(proto);
}
/** Creates a {@link Layout} object containing the given layout element. */
- @NonNull
- public static Layout fromLayoutElement(@NonNull LayoutElement layoutElement) {
+ public static @NonNull Layout fromLayoutElement(@NonNull LayoutElement layoutElement) {
return new Builder().setRoot(layoutElement).build();
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public LayoutElementProto.Layout toProto() {
+ public LayoutElementProto.@NonNull Layout toProto() {
return mImpl;
}
/** Converts to byte array representation. */
@TilesExperimental
- @NonNull
- public byte[] toByteArray() {
+ public byte @NonNull [] toByteArray() {
return mImpl.toByteArray();
}
/** Converts from byte array representation. */
@TilesExperimental
- @Nullable
- public static Layout fromByteArray(@NonNull byte[] byteArray) {
+ public static @Nullable Layout fromByteArray(byte @NonNull [] byteArray) {
try {
return fromProto(LayoutElementProto.Layout.parseFrom(byteArray));
} catch (InvalidProtocolBufferException e) {
@@ -3933,10 +3649,9 @@
public Builder() {}
/** Sets the root element in the layout. */
- @NonNull
- public Builder setRoot(@NonNull LayoutElement root) {
+ public @NonNull Builder setRoot(@NonNull LayoutElement root) {
mImpl.setRoot(root.toLayoutElementProto());
- @Nullable Fingerprint fingerprint = root.getFingerprint();
+ Fingerprint fingerprint = root.getFingerprint();
if (fingerprint != null) {
mImpl.setFingerprint(
TreeFingerprint.newBuilder().setRoot(fingerprintToProto(fingerprint)));
@@ -3964,8 +3679,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Layout build() {
+ public @NonNull Layout build() {
return Layout.fromProto(mImpl.build());
}
}
@@ -3978,101 +3692,90 @@
private FontStyles() {}
private static boolean isLargeScreen(
- @NonNull DeviceParametersBuilders.DeviceParameters deviceParameters) {
+ DeviceParametersBuilders.@NonNull DeviceParameters deviceParameters) {
return deviceParameters.getScreenWidthDp() >= LARGE_SCREEN_WIDTH_DP;
}
/** Font style for large display text. */
- @NonNull
- public static FontStyle.Builder display1(
- @NonNull DeviceParametersBuilders.DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder display1(
+ DeviceParametersBuilders.@NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setWeight(FONT_WEIGHT_BOLD)
.setSize(DimensionBuilders.sp(isLargeScreen(deviceParameters) ? 54 : 50));
}
/** Font style for medium display text. */
- @NonNull
- public static FontStyle.Builder display2(
- @NonNull DeviceParametersBuilders.DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder display2(
+ DeviceParametersBuilders.@NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setWeight(FONT_WEIGHT_BOLD)
.setSize(DimensionBuilders.sp(isLargeScreen(deviceParameters) ? 44 : 40));
}
/** Font style for small display text. */
- @NonNull
- public static FontStyle.Builder display3(
- @NonNull DeviceParametersBuilders.DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder display3(
+ DeviceParametersBuilders.@NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setWeight(FONT_WEIGHT_BOLD)
.setSize(DimensionBuilders.sp(isLargeScreen(deviceParameters) ? 34 : 30));
}
/** Font style for large title text. */
- @NonNull
- public static FontStyle.Builder title1(
- @NonNull DeviceParametersBuilders.DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder title1(
+ DeviceParametersBuilders.@NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setWeight(FONT_WEIGHT_BOLD)
.setSize(DimensionBuilders.sp(isLargeScreen(deviceParameters) ? 26 : 24));
}
/** Font style for medium title text. */
- @NonNull
- public static FontStyle.Builder title2(
- @NonNull DeviceParametersBuilders.DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder title2(
+ DeviceParametersBuilders.@NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setWeight(FONT_WEIGHT_BOLD)
.setSize(DimensionBuilders.sp(isLargeScreen(deviceParameters) ? 22 : 20));
}
/** Font style for small title text. */
- @NonNull
- public static FontStyle.Builder title3(
- @NonNull DeviceParametersBuilders.DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder title3(
+ DeviceParametersBuilders.@NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setWeight(FONT_WEIGHT_BOLD)
.setSize(DimensionBuilders.sp(isLargeScreen(deviceParameters) ? 18 : 16));
}
/** Font style for large body text. */
- @NonNull
- public static FontStyle.Builder body1(
- @NonNull DeviceParametersBuilders.DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder body1(
+ DeviceParametersBuilders.@NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setSize(DimensionBuilders.sp(isLargeScreen(deviceParameters) ? 18 : 16));
}
/** Font style for medium body text. */
- @NonNull
- public static FontStyle.Builder body2(
- @NonNull DeviceParametersBuilders.DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder body2(
+ DeviceParametersBuilders.@NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setSize(DimensionBuilders.sp(isLargeScreen(deviceParameters) ? 16 : 14));
}
/** Font style for button text. */
- @NonNull
- public static FontStyle.Builder button(
- @NonNull DeviceParametersBuilders.DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder button(
+ DeviceParametersBuilders.@NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setWeight(FONT_WEIGHT_BOLD)
.setSize(DimensionBuilders.sp(isLargeScreen(deviceParameters) ? 16 : 14));
}
/** Font style for large caption text. */
- @NonNull
- public static FontStyle.Builder caption1(
- @NonNull DeviceParametersBuilders.DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder caption1(
+ DeviceParametersBuilders.@NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setSize(DimensionBuilders.sp(isLargeScreen(deviceParameters) ? 16 : 14));
}
/** Font style for medium caption text. */
- @NonNull
- public static FontStyle.Builder caption2(
- @NonNull DeviceParametersBuilders.DeviceParameters deviceParameters) {
+ public static FontStyle.@NonNull Builder caption2(
+ DeviceParametersBuilders.@NonNull DeviceParameters deviceParameters) {
return new FontStyle.Builder()
.setSize(DimensionBuilders.sp(isLargeScreen(deviceParameters) ? 14 : 12));
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ModifiersBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ModifiersBuilders.java
index a92e6a1..c697106 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ModifiersBuilders.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ModifiersBuilders.java
@@ -20,8 +20,6 @@
import android.annotation.SuppressLint;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.Fingerprint;
@@ -29,6 +27,9 @@
import androidx.wear.protolayout.proto.TypesProto;
import androidx.wear.protolayout.protobuf.ByteString;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Arrays;
/**
@@ -46,7 +47,7 @@
*/
public static final class Clickable {
private final ModifiersProto.Clickable mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Clickable(ModifiersProto.Clickable impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -54,8 +55,7 @@
}
/** Gets the ID associated with this action. Intended for testing purposes only. */
- @NonNull
- public String getId() {
+ public @NonNull String getId() {
return mImpl.getId();
}
@@ -63,8 +63,7 @@
* Gets the action to perform when the element this modifier is attached to is clicked.
* Intended for testing purposes only.
*/
- @Nullable
- public ActionBuilders.Action getOnClick() {
+ public ActionBuilders.@Nullable Action getOnClick() {
if (mImpl.hasOnClick()) {
return ActionBuilders.actionFromProto(mImpl.getOnClick());
} else {
@@ -74,20 +73,17 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static Clickable fromProto(@NonNull ModifiersProto.Clickable proto) {
+ static @NonNull Clickable fromProto(ModifiersProto.@NonNull Clickable proto) {
return new Clickable(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.Clickable toProto() {
+ public ModifiersProto.@NonNull Clickable toProto() {
return mImpl;
}
@@ -100,8 +96,7 @@
public Builder() {}
/** Sets the ID associated with this action. */
- @NonNull
- public Builder setId(@NonNull String id) {
+ public @NonNull Builder setId(@NonNull String id) {
mImpl.setId(id);
mFingerprint.recordPropertyUpdate(1, id.hashCode());
return this;
@@ -110,8 +105,7 @@
/**
* Sets the action to perform when the element this modifier is attached to is clicked.
*/
- @NonNull
- public Builder setOnClick(@NonNull ActionBuilders.Action onClick) {
+ public @NonNull Builder setOnClick(ActionBuilders.@NonNull Action onClick) {
mImpl.setOnClick(onClick.toActionProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(onClick.getFingerprint()).aggregateValueAsInt());
@@ -119,8 +113,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Clickable build() {
+ public @NonNull Clickable build() {
return new Clickable(mImpl.build(), mFingerprint);
}
}
@@ -133,7 +126,7 @@
*/
public static final class Semantics {
private final ModifiersProto.Semantics mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Semantics(ModifiersProto.Semantics impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -144,25 +137,21 @@
* Gets the content description associated with this element. This will be dictated when the
* element is focused by the screen reader. Intended for testing purposes only.
*/
- @NonNull
- public String getContentDescription() {
+ public @NonNull String getContentDescription() {
return mImpl.getObsoleteContentDescription();
}
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static Semantics fromProto(@NonNull ModifiersProto.Semantics proto) {
+ static @NonNull Semantics fromProto(ModifiersProto.@NonNull Semantics proto) {
return new Semantics(proto, null);
}
- @NonNull
- ModifiersProto.Semantics toProto() {
+ ModifiersProto.@NonNull Semantics toProto() {
return mImpl;
}
@@ -178,18 +167,16 @@
* Sets the content description associated with this element. This will be dictated when
* the element is focused by the screen reader.
*/
- @NonNull
@SuppressWarnings(
"deprecation") // Updating a deprecated field for backward compatibility
- public Builder setContentDescription(@NonNull String contentDescription) {
+ public @NonNull Builder setContentDescription(@NonNull String contentDescription) {
mImpl.setObsoleteContentDescription(contentDescription);
mFingerprint.recordPropertyUpdate(4, contentDescription.hashCode());
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Semantics build() {
+ public @NonNull Semantics build() {
return new Semantics(mImpl.build(), mFingerprint);
}
}
@@ -198,7 +185,7 @@
/** A modifier to apply padding around an element. */
public static final class Padding {
private final ModifiersProto.Padding mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Padding(ModifiersProto.Padding impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -209,8 +196,7 @@
* Gets the padding on the end of the content, depending on the layout direction, in DP and
* the value of "rtl_aware". Intended for testing purposes only.
*/
- @Nullable
- public DimensionBuilders.DpProp getEnd() {
+ public DimensionBuilders.@Nullable DpProp getEnd() {
if (mImpl.hasEnd()) {
return DimensionBuilders.DpProp.fromProto(mImpl.getEnd());
} else {
@@ -222,8 +208,7 @@
* Gets the padding on the start of the content, depending on the layout direction, in DP
* and the value of "rtl_aware". Intended for testing purposes only.
*/
- @Nullable
- public DimensionBuilders.DpProp getStart() {
+ public DimensionBuilders.@Nullable DpProp getStart() {
if (mImpl.hasStart()) {
return DimensionBuilders.DpProp.fromProto(mImpl.getStart());
} else {
@@ -232,8 +217,7 @@
}
/** Gets the padding at the top, in DP. Intended for testing purposes only. */
- @Nullable
- public DimensionBuilders.DpProp getTop() {
+ public DimensionBuilders.@Nullable DpProp getTop() {
if (mImpl.hasTop()) {
return DimensionBuilders.DpProp.fromProto(mImpl.getTop());
} else {
@@ -242,8 +226,7 @@
}
/** Gets the padding at the bottom, in DP. Intended for testing purposes only. */
- @Nullable
- public DimensionBuilders.DpProp getBottom() {
+ public DimensionBuilders.@Nullable DpProp getBottom() {
if (mImpl.hasBottom()) {
return DimensionBuilders.DpProp.fromProto(mImpl.getBottom());
} else {
@@ -257,8 +240,7 @@
* of the container if the device is using an RTL locale). If false, start/end will always
* map to left/right, accordingly. Intended for testing purposes only.
*/
- @Nullable
- public TypeBuilders.BoolProp getRtlAware() {
+ public TypeBuilders.@Nullable BoolProp getRtlAware() {
if (mImpl.hasRtlAware()) {
return TypeBuilders.BoolProp.fromProto(mImpl.getRtlAware());
} else {
@@ -268,18 +250,15 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static Padding fromProto(@NonNull ModifiersProto.Padding proto) {
+ static @NonNull Padding fromProto(ModifiersProto.@NonNull Padding proto) {
return new Padding(proto, null);
}
- @NonNull
- ModifiersProto.Padding toProto() {
+ ModifiersProto.@NonNull Padding toProto() {
return mImpl;
}
@@ -295,8 +274,7 @@
* Sets the padding on the end of the content, depending on the layout direction, in DP
* and the value of "rtl_aware".
*/
- @NonNull
- public Builder setEnd(@NonNull DimensionBuilders.DpProp end) {
+ public @NonNull Builder setEnd(DimensionBuilders.@NonNull DpProp end) {
mImpl.setEnd(end.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(end.getFingerprint()).aggregateValueAsInt());
@@ -307,8 +285,7 @@
* Sets the padding on the start of the content, depending on the layout direction, in
* DP and the value of "rtl_aware".
*/
- @NonNull
- public Builder setStart(@NonNull DimensionBuilders.DpProp start) {
+ public @NonNull Builder setStart(DimensionBuilders.@NonNull DpProp start) {
mImpl.setStart(start.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(start.getFingerprint()).aggregateValueAsInt());
@@ -316,8 +293,7 @@
}
/** Sets the padding at the top, in DP. */
- @NonNull
- public Builder setTop(@NonNull DimensionBuilders.DpProp top) {
+ public @NonNull Builder setTop(DimensionBuilders.@NonNull DpProp top) {
mImpl.setTop(top.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(top.getFingerprint()).aggregateValueAsInt());
@@ -325,8 +301,7 @@
}
/** Sets the padding at the bottom, in DP. */
- @NonNull
- public Builder setBottom(@NonNull DimensionBuilders.DpProp bottom) {
+ public @NonNull Builder setBottom(DimensionBuilders.@NonNull DpProp bottom) {
mImpl.setBottom(bottom.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(bottom.getFingerprint()).aggregateValueAsInt());
@@ -339,8 +314,7 @@
* side of the container if the device is using an RTL locale). If false, start/end will
* always map to left/right, accordingly.
*/
- @NonNull
- public Builder setRtlAware(@NonNull TypeBuilders.BoolProp rtlAware) {
+ public @NonNull Builder setRtlAware(TypeBuilders.@NonNull BoolProp rtlAware) {
mImpl.setRtlAware(rtlAware.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(rtlAware.getFingerprint()).aggregateValueAsInt());
@@ -354,23 +328,20 @@
* always map to left/right, accordingly.
*/
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setRtlAware(boolean rtlAware) {
+ public @NonNull Builder setRtlAware(boolean rtlAware) {
mImpl.setRtlAware(TypesProto.BoolProp.newBuilder().setValue(rtlAware));
mFingerprint.recordPropertyUpdate(5, Boolean.hashCode(rtlAware));
return this;
}
/** Sets the padding for all sides of the content, in DP. */
- @NonNull
@SuppressLint("MissingGetterMatchingBuilder")
- public Builder setAll(@NonNull DimensionBuilders.DpProp value) {
+ public @NonNull Builder setAll(DimensionBuilders.@NonNull DpProp value) {
return setStart(value).setEnd(value).setTop(value).setBottom(value);
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Padding build() {
+ public @NonNull Padding build() {
return new Padding(mImpl.build(), mFingerprint);
}
}
@@ -379,7 +350,7 @@
/** A modifier to apply a border around an element. */
public static final class Border {
private final ModifiersProto.Border mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Border(ModifiersProto.Border impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -387,8 +358,7 @@
}
/** Gets the width of the border, in DP. Intended for testing purposes only. */
- @Nullable
- public DimensionBuilders.DpProp getWidth() {
+ public DimensionBuilders.@Nullable DpProp getWidth() {
if (mImpl.hasWidth()) {
return DimensionBuilders.DpProp.fromProto(mImpl.getWidth());
} else {
@@ -397,8 +367,7 @@
}
/** Gets the color of the border. Intended for testing purposes only. */
- @Nullable
- public ColorBuilders.ColorProp getColor() {
+ public ColorBuilders.@Nullable ColorProp getColor() {
if (mImpl.hasColor()) {
return ColorBuilders.ColorProp.fromProto(mImpl.getColor());
} else {
@@ -408,18 +377,15 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static Border fromProto(@NonNull ModifiersProto.Border proto) {
+ static @NonNull Border fromProto(ModifiersProto.@NonNull Border proto) {
return new Border(proto, null);
}
- @NonNull
- ModifiersProto.Border toProto() {
+ ModifiersProto.@NonNull Border toProto() {
return mImpl;
}
@@ -431,8 +397,7 @@
public Builder() {}
/** Sets the width of the border, in DP. */
- @NonNull
- public Builder setWidth(@NonNull DimensionBuilders.DpProp width) {
+ public @NonNull Builder setWidth(DimensionBuilders.@NonNull DpProp width) {
mImpl.setWidth(width.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(width.getFingerprint()).aggregateValueAsInt());
@@ -440,8 +405,7 @@
}
/** Sets the color of the border. */
- @NonNull
- public Builder setColor(@NonNull ColorBuilders.ColorProp color) {
+ public @NonNull Builder setColor(ColorBuilders.@NonNull ColorProp color) {
mImpl.setColor(color.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(color.getFingerprint()).aggregateValueAsInt());
@@ -449,8 +413,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Border build() {
+ public @NonNull Border build() {
return new Border(mImpl.build(), mFingerprint);
}
}
@@ -459,7 +422,7 @@
/** The corner of a {@link androidx.wear.tiles.LayoutElementBuilders.Box} element. */
public static final class Corner {
private final ModifiersProto.Corner mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Corner(ModifiersProto.Corner impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -467,8 +430,7 @@
}
/** Gets the radius of the corner in DP. Intended for testing purposes only. */
- @Nullable
- public DimensionBuilders.DpProp getRadius() {
+ public DimensionBuilders.@Nullable DpProp getRadius() {
if (mImpl.hasRadius()) {
return DimensionBuilders.DpProp.fromProto(mImpl.getRadius());
} else {
@@ -478,18 +440,15 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static Corner fromProto(@NonNull ModifiersProto.Corner proto) {
+ static @NonNull Corner fromProto(ModifiersProto.@NonNull Corner proto) {
return new Corner(proto, null);
}
- @NonNull
- ModifiersProto.Corner toProto() {
+ ModifiersProto.@NonNull Corner toProto() {
return mImpl;
}
@@ -501,8 +460,7 @@
public Builder() {}
/** Sets the radius of the corner in DP. */
- @NonNull
- public Builder setRadius(@NonNull DimensionBuilders.DpProp radius) {
+ public @NonNull Builder setRadius(DimensionBuilders.@NonNull DpProp radius) {
mImpl.setRadius(radius.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(radius.getFingerprint()).aggregateValueAsInt());
@@ -510,8 +468,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Corner build() {
+ public @NonNull Corner build() {
return new Corner(mImpl.build(), mFingerprint);
}
}
@@ -520,7 +477,7 @@
/** A modifier to apply a background to an element. */
public static final class Background {
private final ModifiersProto.Background mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Background(ModifiersProto.Background impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -531,8 +488,7 @@
* Gets the background color for this element. If not defined, defaults to being
* transparent. Intended for testing purposes only.
*/
- @Nullable
- public ColorBuilders.ColorProp getColor() {
+ public ColorBuilders.@Nullable ColorProp getColor() {
if (mImpl.hasColor()) {
return ColorBuilders.ColorProp.fromProto(mImpl.getColor());
} else {
@@ -545,8 +501,7 @@
* if it has a background color or border. If not defined, defaults to having a square
* corner. Intended for testing purposes only.
*/
- @Nullable
- public Corner getCorner() {
+ public @Nullable Corner getCorner() {
if (mImpl.hasCorner()) {
return Corner.fromProto(mImpl.getCorner());
} else {
@@ -556,18 +511,15 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static Background fromProto(@NonNull ModifiersProto.Background proto) {
+ static @NonNull Background fromProto(ModifiersProto.@NonNull Background proto) {
return new Background(proto, null);
}
- @NonNull
- ModifiersProto.Background toProto() {
+ ModifiersProto.@NonNull Background toProto() {
return mImpl;
}
@@ -583,8 +535,7 @@
* Sets the background color for this element. If not defined, defaults to being
* transparent.
*/
- @NonNull
- public Builder setColor(@NonNull ColorBuilders.ColorProp color) {
+ public @NonNull Builder setColor(ColorBuilders.@NonNull ColorProp color) {
mImpl.setColor(color.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(color.getFingerprint()).aggregateValueAsInt());
@@ -596,8 +547,7 @@
* element if it has a background color or border. If not defined, defaults to having a
* square corner.
*/
- @NonNull
- public Builder setCorner(@NonNull Corner corner) {
+ public @NonNull Builder setCorner(@NonNull Corner corner) {
mImpl.setCorner(corner.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(corner.getFingerprint()).aggregateValueAsInt());
@@ -605,8 +555,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Background build() {
+ public @NonNull Background build() {
return new Background(mImpl.build(), mFingerprint);
}
}
@@ -618,7 +567,7 @@
*/
public static final class ElementMetadata {
private final ModifiersProto.ElementMetadata mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ElementMetadata(ModifiersProto.ElementMetadata impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -629,27 +578,23 @@
* Gets property describing the element with which it is associated. For use by libraries
* building higher-level components only. This can be used to track component metadata.
*/
- @NonNull
- public byte[] getTagData() {
+ public byte @NonNull [] getTagData() {
return mImpl.getTagData().toByteArray();
}
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static ElementMetadata fromProto(@NonNull ModifiersProto.ElementMetadata proto) {
+ static @NonNull ElementMetadata fromProto(ModifiersProto.@NonNull ElementMetadata proto) {
return new ElementMetadata(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.ElementMetadata toProto() {
+ public ModifiersProto.@NonNull ElementMetadata toProto() {
return mImpl;
}
@@ -666,16 +611,14 @@
* libraries building higher-level components only. This can be used to track component
* metadata.
*/
- @NonNull
- public Builder setTagData(@NonNull byte[] tagData) {
+ public @NonNull Builder setTagData(byte @NonNull [] tagData) {
mImpl.setTagData(ByteString.copyFrom(tagData));
mFingerprint.recordPropertyUpdate(1, Arrays.hashCode(tagData));
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public ElementMetadata build() {
+ public @NonNull ElementMetadata build() {
return new ElementMetadata(mImpl.build(), mFingerprint);
}
}
@@ -688,7 +631,7 @@
*/
public static final class Modifiers {
private final ModifiersProto.Modifiers mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Modifiers(ModifiersProto.Modifiers impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -700,8 +643,7 @@
* have actions associated with it, which will be executed when the element is tapped.
* Intended for testing purposes only.
*/
- @Nullable
- public Clickable getClickable() {
+ public @Nullable Clickable getClickable() {
if (mImpl.hasClickable()) {
return Clickable.fromProto(mImpl.getClickable());
} else {
@@ -714,8 +656,7 @@
* modified element (eg. screen reader content descriptions). Intended for testing purposes
* only.
*/
- @Nullable
- public Semantics getSemantics() {
+ public @Nullable Semantics getSemantics() {
if (mImpl.hasSemantics()) {
return Semantics.fromProto(mImpl.getSemantics());
} else {
@@ -724,8 +665,7 @@
}
/** Gets the padding of the modified element. Intended for testing purposes only. */
- @Nullable
- public Padding getPadding() {
+ public @Nullable Padding getPadding() {
if (mImpl.hasPadding()) {
return Padding.fromProto(mImpl.getPadding());
} else {
@@ -734,8 +674,7 @@
}
/** Gets the border of the modified element. Intended for testing purposes only. */
- @Nullable
- public Border getBorder() {
+ public @Nullable Border getBorder() {
if (mImpl.hasBorder()) {
return Border.fromProto(mImpl.getBorder());
} else {
@@ -747,8 +686,7 @@
* Gets the background (with optional corner radius) of the modified element. Intended for
* testing purposes only.
*/
- @Nullable
- public Background getBackground() {
+ public @Nullable Background getBackground() {
if (mImpl.hasBackground()) {
return Background.fromProto(mImpl.getBackground());
} else {
@@ -760,8 +698,7 @@
* Gets metadata about an element. For use by libraries building higher-level components
* only. This can be used to track component metadata.
*/
- @Nullable
- public ElementMetadata getMetadata() {
+ public @Nullable ElementMetadata getMetadata() {
if (mImpl.hasMetadata()) {
return ElementMetadata.fromProto(mImpl.getMetadata());
} else {
@@ -771,16 +708,14 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Modifiers fromProto(
- @NonNull ModifiersProto.Modifiers proto, @Nullable Fingerprint fingerprint) {
+ public static @NonNull Modifiers fromProto(
+ ModifiersProto.@NonNull Modifiers proto, @Nullable Fingerprint fingerprint) {
return new Modifiers(proto, fingerprint);
}
@@ -789,15 +724,13 @@
* object created using this method can't be added to any other wrapper.
*/
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Modifiers fromProto(@NonNull ModifiersProto.Modifiers proto) {
+ public static @NonNull Modifiers fromProto(ModifiersProto.@NonNull Modifiers proto) {
return fromProto(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.Modifiers toProto() {
+ public ModifiersProto.@NonNull Modifiers toProto() {
return mImpl;
}
@@ -813,8 +746,7 @@
* Sets the clickable property of the modified element. It allows its wrapped element to
* have actions associated with it, which will be executed when the element is tapped.
*/
- @NonNull
- public Builder setClickable(@NonNull Clickable clickable) {
+ public @NonNull Builder setClickable(@NonNull Clickable clickable) {
mImpl.setClickable(clickable.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(clickable.getFingerprint()).aggregateValueAsInt());
@@ -825,8 +757,7 @@
* Sets the semantics of the modified element. This can be used to add metadata to the
* modified element (eg. screen reader content descriptions).
*/
- @NonNull
- public Builder setSemantics(@NonNull Semantics semantics) {
+ public @NonNull Builder setSemantics(@NonNull Semantics semantics) {
mImpl.setSemantics(semantics.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(semantics.getFingerprint()).aggregateValueAsInt());
@@ -834,8 +765,7 @@
}
/** Sets the padding of the modified element. */
- @NonNull
- public Builder setPadding(@NonNull Padding padding) {
+ public @NonNull Builder setPadding(@NonNull Padding padding) {
mImpl.setPadding(padding.toProto());
mFingerprint.recordPropertyUpdate(
3, checkNotNull(padding.getFingerprint()).aggregateValueAsInt());
@@ -843,8 +773,7 @@
}
/** Sets the border of the modified element. */
- @NonNull
- public Builder setBorder(@NonNull Border border) {
+ public @NonNull Builder setBorder(@NonNull Border border) {
mImpl.setBorder(border.toProto());
mFingerprint.recordPropertyUpdate(
4, checkNotNull(border.getFingerprint()).aggregateValueAsInt());
@@ -852,8 +781,7 @@
}
/** Sets the background (with optional corner radius) of the modified element. */
- @NonNull
- public Builder setBackground(@NonNull Background background) {
+ public @NonNull Builder setBackground(@NonNull Background background) {
mImpl.setBackground(background.toProto());
mFingerprint.recordPropertyUpdate(
5, checkNotNull(background.getFingerprint()).aggregateValueAsInt());
@@ -864,8 +792,7 @@
* Sets metadata about an element. For use by libraries building higher-level components
* only. This can be used to track component metadata.
*/
- @NonNull
- public Builder setMetadata(@NonNull ElementMetadata metadata) {
+ public @NonNull Builder setMetadata(@NonNull ElementMetadata metadata) {
mImpl.setMetadata(metadata.toProto());
mFingerprint.recordPropertyUpdate(
6, checkNotNull(metadata.getFingerprint()).aggregateValueAsInt());
@@ -873,8 +800,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Modifiers build() {
+ public @NonNull Modifiers build() {
return new Modifiers(mImpl.build(), mFingerprint);
}
}
@@ -886,7 +812,7 @@
*/
public static final class ArcModifiers {
private final ModifiersProto.ArcModifiers mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
ArcModifiers(ModifiersProto.ArcModifiers impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -897,8 +823,7 @@
* Gets allows its wrapped element to have actions associated with it, which will be
* executed when the element is tapped. Intended for testing purposes only.
*/
- @Nullable
- public Clickable getClickable() {
+ public @Nullable Clickable getClickable() {
if (mImpl.hasClickable()) {
return Clickable.fromProto(mImpl.getClickable());
} else {
@@ -910,8 +835,7 @@
* Gets adds metadata for the modified element, for example, screen reader content
* descriptions. Intended for testing purposes only.
*/
- @Nullable
- public Semantics getSemantics() {
+ public @Nullable Semantics getSemantics() {
if (mImpl.hasSemantics()) {
return Semantics.fromProto(mImpl.getSemantics());
} else {
@@ -921,20 +845,17 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static ArcModifiers fromProto(@NonNull ModifiersProto.ArcModifiers proto) {
+ static @NonNull ArcModifiers fromProto(ModifiersProto.@NonNull ArcModifiers proto) {
return new ArcModifiers(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.ArcModifiers toProto() {
+ public ModifiersProto.@NonNull ArcModifiers toProto() {
return mImpl;
}
@@ -950,8 +871,7 @@
* Sets allows its wrapped element to have actions associated with it, which will be
* executed when the element is tapped.
*/
- @NonNull
- public Builder setClickable(@NonNull Clickable clickable) {
+ public @NonNull Builder setClickable(@NonNull Clickable clickable) {
mImpl.setClickable(clickable.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(clickable.getFingerprint()).aggregateValueAsInt());
@@ -962,8 +882,7 @@
* Sets adds metadata for the modified element, for example, screen reader content
* descriptions.
*/
- @NonNull
- public Builder setSemantics(@NonNull Semantics semantics) {
+ public @NonNull Builder setSemantics(@NonNull Semantics semantics) {
mImpl.setSemantics(semantics.toProto());
mFingerprint.recordPropertyUpdate(
2, checkNotNull(semantics.getFingerprint()).aggregateValueAsInt());
@@ -971,8 +890,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public ArcModifiers build() {
+ public @NonNull ArcModifiers build() {
return new ArcModifiers(mImpl.build(), mFingerprint);
}
}
@@ -985,7 +903,7 @@
*/
public static final class SpanModifiers {
private final ModifiersProto.SpanModifiers mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
SpanModifiers(ModifiersProto.SpanModifiers impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -996,8 +914,7 @@
* Gets allows its wrapped element to have actions associated with it, which will be
* executed when the element is tapped. Intended for testing purposes only.
*/
- @Nullable
- public Clickable getClickable() {
+ public @Nullable Clickable getClickable() {
if (mImpl.hasClickable()) {
return Clickable.fromProto(mImpl.getClickable());
} else {
@@ -1007,20 +924,17 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static SpanModifiers fromProto(@NonNull ModifiersProto.SpanModifiers proto) {
+ static @NonNull SpanModifiers fromProto(ModifiersProto.@NonNull SpanModifiers proto) {
return new SpanModifiers(proto, null);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ModifiersProto.SpanModifiers toProto() {
+ public ModifiersProto.@NonNull SpanModifiers toProto() {
return mImpl;
}
@@ -1036,8 +950,7 @@
* Sets allows its wrapped element to have actions associated with it, which will be
* executed when the element is tapped.
*/
- @NonNull
- public Builder setClickable(@NonNull Clickable clickable) {
+ public @NonNull Builder setClickable(@NonNull Clickable clickable) {
mImpl.setClickable(clickable.toProto());
mFingerprint.recordPropertyUpdate(
1, checkNotNull(clickable.getFingerprint()).aggregateValueAsInt());
@@ -1045,8 +958,7 @@
}
/** Builds an instance from accumulated values. */
- @NonNull
- public SpanModifiers build() {
+ public @NonNull SpanModifiers build() {
return new SpanModifiers(mImpl.build(), mFingerprint);
}
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ProtoParcelable.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ProtoParcelable.java
index 04413bd..0b0acd8 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ProtoParcelable.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ProtoParcelable.java
@@ -20,9 +20,10 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.function.BiFunction;
@@ -57,14 +58,13 @@
};
}
- protected ProtoParcelable(@NonNull byte[] contents, int version) {
+ protected ProtoParcelable(byte @NonNull [] contents, int version) {
this.mContents = contents;
this.mVersion = version;
}
/** Get the payload contained within this ProtoParcelable. */
- @NonNull
- public byte[] getContents() {
+ public byte @NonNull [] getContents() {
return mContents;
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/RequestBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/RequestBuilders.java
index b12b8ff2..708bf5a 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/RequestBuilders.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/RequestBuilders.java
@@ -16,8 +16,6 @@
package androidx.wear.tiles;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters;
@@ -27,6 +25,9 @@
import androidx.wear.protolayout.proto.StateProto;
import androidx.wear.tiles.proto.RequestProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/** Builders for request messages used to fetch tiles and resources. */
@@ -50,8 +51,7 @@
* object describing the device requesting the tile update. If not set, a default empty
* instance is used.
*/
- @NonNull
- public DeviceParameters getDeviceConfiguration() {
+ public @NonNull DeviceParameters getDeviceConfiguration() {
if (mImpl.hasDeviceConfiguration()) {
return DeviceParameters.fromProto(mImpl.getDeviceConfiguration());
} else {
@@ -64,8 +64,7 @@
* Gets the {@link androidx.wear.protolayout.StateBuilders.State} that should be used when
* building the tile.
*/
- @NonNull
- public State getCurrentState() {
+ public @NonNull State getCurrentState() {
if (mImpl.hasCurrentState()) {
return State.fromProto(mImpl.getCurrentState());
} else {
@@ -89,9 +88,9 @@
* @deprecated Use {@link #getDeviceConfiguration()} instead.
*/
@Deprecated
- @Nullable
@SuppressWarnings("deprecation") // for backward compatibility
- public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters getDeviceParameters() {
+ public androidx.wear.tiles.DeviceParametersBuilders.@Nullable DeviceParameters
+ getDeviceParameters() {
if (mImpl.hasDeviceConfiguration()) {
return androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.fromProto(
mImpl.getDeviceConfiguration());
@@ -107,9 +106,8 @@
* @deprecated Use {@link #getCurrentState()} instead.
*/
@Deprecated
- @Nullable
@SuppressWarnings("deprecation") // for backward compatibility
- public androidx.wear.tiles.StateBuilders.State getState() {
+ public androidx.wear.tiles.StateBuilders.@Nullable State getState() {
if (mImpl.hasCurrentState()) {
return androidx.wear.tiles.StateBuilders.State.fromProto(mImpl.getCurrentState());
} else {
@@ -119,21 +117,18 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static TileRequest fromProto(@NonNull RequestProto.TileRequest proto) {
+ public static @NonNull TileRequest fromProto(RequestProto.@NonNull TileRequest proto) {
return new TileRequest(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public RequestProto.TileRequest toProto() {
+ public RequestProto.@NonNull TileRequest toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "TileRequest{"
+ "deviceConfiguration="
+ getDeviceConfiguration()
@@ -159,8 +154,8 @@
* instance is used.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setDeviceConfiguration(@NonNull DeviceParameters deviceConfiguration) {
+ public @NonNull Builder setDeviceConfiguration(
+ @NonNull DeviceParameters deviceConfiguration) {
mImpl.setDeviceConfiguration(deviceConfiguration.toProto());
return this;
}
@@ -170,16 +165,14 @@
* when building the tile.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setCurrentState(@NonNull State currentState) {
+ public @NonNull Builder setCurrentState(@NonNull State currentState) {
mImpl.setCurrentState(currentState.toProto());
return this;
}
/** Sets the ID of the tile being requested. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setTileId(int tileId) {
+ public @NonNull Builder setTileId(int tileId) {
mImpl.setTileId(tileId);
return this;
}
@@ -191,10 +184,8 @@
* @deprecated Use {@link setDeviceConfiguration(DeviceParameters)} instead.
*/
@Deprecated
- @NonNull
- public Builder setDeviceParameters(
- @NonNull
- androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
+ public @NonNull Builder setDeviceParameters(
+ androidx.wear.tiles.DeviceParametersBuilders.@NonNull DeviceParameters
deviceParameters) {
mImpl.setDeviceConfiguration(deviceParameters.toProto());
return this;
@@ -207,15 +198,14 @@
* @deprecated Use {@link setCurrentState(State)} instead.
*/
@Deprecated
- @NonNull
- public Builder setState(@NonNull androidx.wear.tiles.StateBuilders.State state) {
+ public @NonNull Builder setState(
+ androidx.wear.tiles.StateBuilders.@NonNull State state) {
mImpl.setCurrentState(state.toProto());
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public TileRequest build() {
+ public @NonNull TileRequest build() {
return TileRequest.fromProto(mImpl.build());
}
}
@@ -237,8 +227,7 @@
* Gets the version of the resources being fetched. This is the same as the requested
* resource version, passed in {@link androidx.wear.tiles.TileBuilders.Tile}.
*/
- @NonNull
- public String getVersion() {
+ public @NonNull String getVersion() {
return mImpl.getVersion();
}
@@ -251,8 +240,7 @@
* in {@link androidx.wear.protolayout.ResourceBuilders.Resources}.idToImage), not Android
* resource names or similar.
*/
- @NonNull
- public List<String> getResourceIds() {
+ public @NonNull List<String> getResourceIds() {
return mImpl.getResourceIdsList();
}
@@ -260,8 +248,7 @@
* Gets the {@link androidx.wear.protolayout.DeviceParametersBuilders.DeviceParameters}
* object describing the device requesting the resources.
*/
- @NonNull
- public DeviceParameters getDeviceConfiguration() {
+ public @NonNull DeviceParameters getDeviceConfiguration() {
if (mImpl.hasDeviceConfiguration()) {
return DeviceParameters.fromProto(mImpl.getDeviceConfiguration());
} else {
@@ -286,9 +273,9 @@
* @deprecated Use {@link #getDeviceConfiguration()} instead.
*/
@Deprecated
- @Nullable
@SuppressWarnings("deprecation") // for backward compatibility
- public androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters getDeviceParameters() {
+ public androidx.wear.tiles.DeviceParametersBuilders.@Nullable DeviceParameters
+ getDeviceParameters() {
if (mImpl.hasDeviceConfiguration()) {
return androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters.fromProto(
mImpl.getDeviceConfiguration());
@@ -299,21 +286,19 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static ResourcesRequest fromProto(@NonNull RequestProto.ResourcesRequest proto) {
+ public static @NonNull ResourcesRequest fromProto(
+ RequestProto.@NonNull ResourcesRequest proto) {
return new ResourcesRequest(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public RequestProto.ResourcesRequest toProto() {
+ public RequestProto.@NonNull ResourcesRequest toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ResourcesRequest{"
+ "version="
+ getVersion()
@@ -340,8 +325,7 @@
* resource version, passed in {@link androidx.wear.tiles.TileBuilders.Tile}.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setVersion(@NonNull String version) {
+ public @NonNull Builder setVersion(@NonNull String version) {
mImpl.setVersion(version);
return this;
}
@@ -357,8 +341,7 @@
* Android resource names or similar.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder addResourceId(@NonNull String resourceId) {
+ public @NonNull Builder addResourceId(@NonNull String resourceId) {
mImpl.addResourceIds(resourceId);
return this;
}
@@ -368,16 +351,15 @@
* object describing the device requesting the resources.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setDeviceConfiguration(@NonNull DeviceParameters deviceConfiguration) {
+ public @NonNull Builder setDeviceConfiguration(
+ @NonNull DeviceParameters deviceConfiguration) {
mImpl.setDeviceConfiguration(deviceConfiguration.toProto());
return this;
}
/** Sets the ID of the tile for which resources are being requested. */
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setTileId(int tileId) {
+ public @NonNull Builder setTileId(int tileId) {
mImpl.setTileId(tileId);
return this;
}
@@ -389,19 +371,16 @@
* @deprecated Use {@link setDeviceConfiguration(DeviceParameters)} instead.
*/
@Deprecated
- @NonNull
@SuppressWarnings("deprecation") // for backward compatibility
- public Builder setDeviceParameters(
- @NonNull
- androidx.wear.tiles.DeviceParametersBuilders.DeviceParameters
+ public @NonNull Builder setDeviceParameters(
+ androidx.wear.tiles.DeviceParametersBuilders.@NonNull DeviceParameters
deviceParameters) {
mImpl.setDeviceConfiguration(deviceParameters.toProto());
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public ResourcesRequest build() {
+ public @NonNull ResourcesRequest build() {
return ResourcesRequest.fromProto(mImpl.build());
}
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ResourceBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ResourceBuilders.java
index 8979d32..846cf7d 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ResourceBuilders.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ResourceBuilders.java
@@ -23,14 +23,15 @@
import androidx.annotation.Dimension;
import androidx.annotation.DrawableRes;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.proto.ResourceProto;
import androidx.wear.protolayout.protobuf.ByteString;
import androidx.wear.protolayout.protobuf.InvalidProtocolBufferException;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Collections;
@@ -79,14 +80,12 @@
return mImpl.getResourceId();
}
- @NonNull
- static AndroidImageResourceByResId fromProto(
- @NonNull ResourceProto.AndroidImageResourceByResId proto) {
+ static @NonNull AndroidImageResourceByResId fromProto(
+ ResourceProto.@NonNull AndroidImageResourceByResId proto) {
return new AndroidImageResourceByResId(proto);
}
- @NonNull
- ResourceProto.AndroidImageResourceByResId toProto() {
+ ResourceProto.@NonNull AndroidImageResourceByResId toProto() {
return mImpl;
}
@@ -101,15 +100,13 @@
* Sets the Android resource ID of this image. This must refer to a drawable under
* R.drawable.
*/
- @NonNull
- public Builder setResourceId(@DrawableRes int resourceId) {
+ public @NonNull Builder setResourceId(@DrawableRes int resourceId) {
mImpl.setResourceId(resourceId);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public AndroidImageResourceByResId build() {
+ public @NonNull AndroidImageResourceByResId build() {
return AndroidImageResourceByResId.fromProto(mImpl.build());
}
}
@@ -127,8 +124,7 @@
}
/** Gets the byte array representing the image. Intended for testing purposes only. */
- @NonNull
- public byte[] getData() {
+ public byte @NonNull [] getData() {
return mImpl.getData().toByteArray();
}
@@ -163,13 +159,12 @@
return mImpl.getFormat().getNumber();
}
- @NonNull
- static InlineImageResource fromProto(@NonNull ResourceProto.InlineImageResource proto) {
+ static @NonNull InlineImageResource fromProto(
+ ResourceProto.@NonNull InlineImageResource proto) {
return new InlineImageResource(proto);
}
- @NonNull
- ResourceProto.InlineImageResource toProto() {
+ ResourceProto.@NonNull InlineImageResource toProto() {
return mImpl;
}
@@ -181,8 +176,7 @@
public Builder() {}
/** Sets the byte array representing the image. */
- @NonNull
- public Builder setData(@NonNull byte[] data) {
+ public @NonNull Builder setData(byte @NonNull [] data) {
mImpl.setData(ByteString.copyFrom(data));
return this;
}
@@ -191,8 +185,7 @@
* Sets the native width of the image, in pixels. Only required for formats (e.g.
* IMAGE_FORMAT_RGB_565) where the image data does not include size.
*/
- @NonNull
- public Builder setWidthPx(@Dimension(unit = PX) int widthPx) {
+ public @NonNull Builder setWidthPx(@Dimension(unit = PX) int widthPx) {
mImpl.setWidthPx(widthPx);
return this;
}
@@ -201,8 +194,7 @@
* Sets the native height of the image, in pixels. Only required for formats (e.g.
* IMAGE_FORMAT_RGB_565) where the image data does not include size.
*/
- @NonNull
- public Builder setHeightPx(@Dimension(unit = PX) int heightPx) {
+ public @NonNull Builder setHeightPx(@Dimension(unit = PX) int heightPx) {
mImpl.setHeightPx(heightPx);
return this;
}
@@ -213,15 +205,13 @@
* to extract this from the raw image data. If the platform does not support the format,
* the image will not be decoded or displayed.
*/
- @NonNull
- public Builder setFormat(@ImageFormat int format) {
+ public @NonNull Builder setFormat(@ImageFormat int format) {
mImpl.setFormat(ResourceProto.ImageFormat.forNumber(format));
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public InlineImageResource build() {
+ public @NonNull InlineImageResource build() {
return InlineImageResource.fromProto(mImpl.build());
}
}
@@ -242,8 +232,7 @@
* Gets an image resource that maps to an Android drawable by resource ID. Intended for
* testing purposes only.
*/
- @Nullable
- public AndroidImageResourceByResId getAndroidResourceByResId() {
+ public @Nullable AndroidImageResourceByResId getAndroidResourceByResId() {
if (mImpl.hasAndroidResourceByResId()) {
return AndroidImageResourceByResId.fromProto(mImpl.getAndroidResourceByResId());
} else {
@@ -255,8 +244,7 @@
* Gets an image resource that contains the image data inline. Intended for testing purposes
* only.
*/
- @Nullable
- public InlineImageResource getInlineResource() {
+ public @Nullable InlineImageResource getInlineResource() {
if (mImpl.hasInlineResource()) {
return InlineImageResource.fromProto(mImpl.getInlineResource());
} else {
@@ -264,13 +252,11 @@
}
}
- @NonNull
- static ImageResource fromProto(@NonNull ResourceProto.ImageResource proto) {
+ static @NonNull ImageResource fromProto(ResourceProto.@NonNull ImageResource proto) {
return new ImageResource(proto);
}
- @NonNull
- ResourceProto.ImageResource toProto() {
+ ResourceProto.@NonNull ImageResource toProto() {
return mImpl;
}
@@ -282,23 +268,20 @@
public Builder() {}
/** Sets an image resource that maps to an Android drawable by resource ID. */
- @NonNull
- public Builder setAndroidResourceByResId(
+ public @NonNull Builder setAndroidResourceByResId(
@NonNull AndroidImageResourceByResId androidResourceByResId) {
mImpl.setAndroidResourceByResId(androidResourceByResId.toProto());
return this;
}
/** Sets an image resource that contains the image data inline. */
- @NonNull
- public Builder setInlineResource(@NonNull InlineImageResource inlineResource) {
+ public @NonNull Builder setInlineResource(@NonNull InlineImageResource inlineResource) {
mImpl.setInlineResource(inlineResource.toProto());
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public ImageResource build() {
+ public @NonNull ImageResource build() {
return ImageResource.fromProto(mImpl.build());
}
}
@@ -324,8 +307,7 @@
* androidx.wear.tiles.RequestBuilders.ResourcesRequest} which triggered this request.
* Intended for testing purposes only.
*/
- @NonNull
- public String getVersion() {
+ public @NonNull String getVersion() {
return mImpl.getVersion();
}
@@ -333,8 +315,7 @@
* Gets a map of resource_ids to images, which can be used by layouts. Intended for testing
* purposes only.
*/
- @NonNull
- public Map<String, ImageResource> getIdToImageMapping() {
+ public @NonNull Map<String, ImageResource> getIdToImageMapping() {
Map<String, ImageResource> map = new HashMap<>();
for (Entry<String, ResourceProto.ImageResource> entry :
mImpl.getIdToImageMap().entrySet()) {
@@ -344,17 +325,15 @@
}
/** Converts to byte array representation. */
- @NonNull
@TilesExperimental
- public byte[] toByteArray() {
+ public byte @NonNull [] toByteArray() {
return mImpl.toByteArray();
}
/** Converts from byte array representation. */
@SuppressWarnings("ProtoParseWithRegistry")
- @Nullable
@TilesExperimental
- public static Resources fromByteArray(@NonNull byte[] byteArray) {
+ public static @Nullable Resources fromByteArray(byte @NonNull [] byteArray) {
try {
return fromProto(ResourceProto.Resources.parseFrom(byteArray));
} catch (InvalidProtocolBufferException e) {
@@ -363,15 +342,13 @@
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Resources fromProto(@NonNull ResourceProto.Resources proto) {
+ public static @NonNull Resources fromProto(ResourceProto.@NonNull Resources proto) {
return new Resources(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public ResourceProto.Resources toProto() {
+ public ResourceProto.@NonNull Resources toProto() {
return mImpl;
}
@@ -393,23 +370,21 @@
* tile to render successfully, and must match the resource version specified in {@link
* androidx.wear.tiles.RequestBuilders.ResourcesRequest} which triggered this request.
*/
- @NonNull
- public Builder setVersion(@NonNull String version) {
+ public @NonNull Builder setVersion(@NonNull String version) {
mImpl.setVersion(version);
return this;
}
/** Adds an entry into a map of resource_ids to images, which can be used by layouts. */
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder addIdToImageMapping(@NonNull String id, @NonNull ImageResource image) {
+ public @NonNull Builder addIdToImageMapping(@NonNull String id,
+ @NonNull ImageResource image) {
mImpl.putIdToImage(id, image.toProto());
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Resources build() {
+ public @NonNull Resources build() {
return Resources.fromProto(mImpl.build());
}
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ResourcesData.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ResourcesData.java
index d103204..98839a0 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ResourcesData.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ResourcesData.java
@@ -16,9 +16,10 @@
package androidx.wear.tiles;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Holder for Tiles' Resources class, to be parceled and transferred to Wear.
*
@@ -31,7 +32,7 @@
public static final Creator<ResourcesData> CREATOR =
newCreator(ResourcesData.class, ResourcesData::new);
- public ResourcesData(@NonNull byte[] payload, int version) {
+ public ResourcesData(byte @NonNull [] payload, int version) {
super(payload, version);
}
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ResourcesRequestData.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ResourcesRequestData.java
index c314400..665d180 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ResourcesRequestData.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ResourcesRequestData.java
@@ -16,9 +16,10 @@
package androidx.wear.tiles;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Holder for Tiles' ResourceRequest class, to be parceled and transferred to a Tile Service.
*
@@ -30,7 +31,7 @@
public static final Creator<ResourcesRequestData> CREATOR =
newCreator(ResourcesRequestData.class, ResourcesRequestData::new);
- public ResourcesRequestData(@NonNull byte[] params, int version) {
+ public ResourcesRequestData(byte @NonNull [] params, int version) {
super(params, version);
}
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/StateBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/StateBuilders.java
index 3798263..48fa917 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/StateBuilders.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/StateBuilders.java
@@ -16,13 +16,14 @@
package androidx.wear.tiles;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.StateProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Builders for state of a tile.
*
@@ -35,7 +36,7 @@
/** {@link State} information. */
public static final class State {
private final StateProto.State mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
State(StateProto.State impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -43,27 +44,23 @@
}
/** Gets the ID of the clickable that was last clicked. */
- @NonNull
- public String getLastClickableId() {
+ public @NonNull String getLastClickableId() {
return mImpl.getLastClickableId();
}
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static State fromProto(@NonNull StateProto.State proto) {
+ public static @NonNull State fromProto(StateProto.@NonNull State proto) {
return new State(proto, null);
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public StateProto.State toProto() {
+ public StateProto.@NonNull State toProto() {
return mImpl;
}
@@ -75,8 +72,7 @@
public Builder() {}
/** Builds an instance from accumulated values. */
- @NonNull
- public State build() {
+ public @NonNull State build() {
return new State(mImpl.build(), mFingerprint);
}
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/SysUiTileUpdateRequester.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/SysUiTileUpdateRequester.java
index b2f3ab5..c24a580 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/SysUiTileUpdateRequester.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/SysUiTileUpdateRequester.java
@@ -35,8 +35,9 @@
import android.util.Log;
import androidx.annotation.GuardedBy;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.util.ArrayList;
import java.util.HashSet;
@@ -128,8 +129,7 @@
}
}
- @Nullable
- private Intent buildUpdateBindIntent() {
+ private @Nullable Intent buildUpdateBindIntent() {
Intent bindIntent = new Intent(ACTION_BIND_UPDATE_REQUESTER);
bindIntent.setPackage(getSysUiPackageName());
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileAddEventData.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileAddEventData.java
index 517a473..220c401 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileAddEventData.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileAddEventData.java
@@ -16,9 +16,10 @@
package androidx.wear.tiles;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Holder for Tiles' TileAddEvent class, to be parceled and transferred to a Tile Service.
*
@@ -30,7 +31,7 @@
public static final Creator<TileAddEventData> CREATOR =
newCreator(TileAddEventData.class, TileAddEventData::new);
- public TileAddEventData(@NonNull byte[] params, int version) {
+ public TileAddEventData(byte @NonNull [] params, int version) {
super(params, version);
}
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileBuilders.java
index bf1dcec..d8607e9 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileBuilders.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileBuilders.java
@@ -16,8 +16,6 @@
package androidx.wear.tiles;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.StateBuilders.State;
@@ -26,6 +24,9 @@
import androidx.wear.protolayout.expression.proto.VersionProto.VersionInfo;
import androidx.wear.tiles.proto.TileProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/** Builders for the components of a tile that can be rendered by a tile renderer. */
public final class TileBuilders {
private TileBuilders() {}
@@ -48,8 +49,7 @@
* androidx.wear.tiles.RequestBuilders.ResourcesRequest} if the system does not have a copy
* of the specified resource version.
*/
- @NonNull
- public String getResourcesVersion() {
+ public @NonNull String getResourcesVersion() {
return mImpl.getResourcesVersion();
}
@@ -57,8 +57,7 @@
* Gets the {@link androidx.wear.protolayout.TimelineBuilders.Timeline} containing the
* layouts for the tiles to show in the carousel, along with their validity periods.
*/
- @Nullable
- public Timeline getTileTimeline() {
+ public @Nullable Timeline getTileTimeline() {
if (mImpl.hasTileTimeline()) {
return Timeline.fromProto(mImpl.getTileTimeline());
} else {
@@ -84,8 +83,7 @@
}
/** Gets {@link androidx.wear.protolayout.StateBuilders.State} for this tile. */
- @Nullable
- public State getState() {
+ public @Nullable State getState() {
if (mImpl.hasState()) {
return State.fromProto(mImpl.getState());
} else {
@@ -100,9 +98,8 @@
* @deprecated Use {@link #getTileTimeline()} instead.
*/
@Deprecated
- @Nullable
@SuppressWarnings("deprecation") // for backward compatibility
- public androidx.wear.tiles.TimelineBuilders.Timeline getTimeline() {
+ public androidx.wear.tiles.TimelineBuilders.@Nullable Timeline getTimeline() {
if (mImpl.hasTileTimeline()) {
return androidx.wear.tiles.TimelineBuilders.Timeline.fromProto(
mImpl.getTileTimeline());
@@ -113,21 +110,18 @@
/** Creates a new wrapper instance from the proto. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Tile fromProto(@NonNull TileProto.Tile proto) {
+ public static @NonNull Tile fromProto(TileProto.@NonNull Tile proto) {
return new Tile(proto);
}
/** Returns the internal proto instance. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public TileProto.Tile toProto() {
+ public TileProto.@NonNull Tile toProto() {
return mImpl;
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "Tile{"
+ "resourcesVersion="
+ getResourcesVersion()
@@ -155,8 +149,7 @@
* copy of the specified resource version.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setResourcesVersion(@NonNull String resourcesVersion) {
+ public @NonNull Builder setResourcesVersion(@NonNull String resourcesVersion) {
mImpl.setResourcesVersion(resourcesVersion);
return this;
}
@@ -166,8 +159,7 @@
* layouts for the tiles to show in the carousel, along with their validity periods.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setTileTimeline(@NonNull Timeline tileTimeline) {
+ public @NonNull Builder setTileTimeline(@NonNull Timeline tileTimeline) {
mImpl.setTileTimeline(tileTimeline.toProto());
return this;
}
@@ -186,16 +178,14 @@
* due to system-level optimizations.
*/
@RequiresSchemaVersion(major = 1, minor = 0)
- @NonNull
- public Builder setFreshnessIntervalMillis(long freshnessIntervalMillis) {
+ public @NonNull Builder setFreshnessIntervalMillis(long freshnessIntervalMillis) {
mImpl.setFreshnessIntervalMillis(freshnessIntervalMillis);
return this;
}
/** Sets {@link androidx.wear.protolayout.StateBuilders.State} for this tile. */
@RequiresSchemaVersion(major = 1, minor = 200)
- @NonNull
- public Builder setState(@NonNull State state) {
+ public @NonNull Builder setState(@NonNull State state) {
mImpl.setState(state.toProto());
return this;
}
@@ -207,16 +197,14 @@
* @deprecated Use {@link #setTileTimeline(Timeline)} instead.
*/
@Deprecated
- @NonNull
- public Builder setTimeline(
- @NonNull androidx.wear.tiles.TimelineBuilders.Timeline timeline) {
+ public @NonNull Builder setTimeline(
+ androidx.wear.tiles.TimelineBuilders.@NonNull Timeline timeline) {
mImpl.setTileTimeline(timeline.toProto());
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Tile build() {
+ public @NonNull Tile build() {
return Tile.fromProto(mImpl.build());
}
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileData.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileData.java
index d6dbca0..beb1a7d 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileData.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileData.java
@@ -16,9 +16,10 @@
package androidx.wear.tiles;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Holder for Tiles' Tile class, to be parceled and transferred to Wear.
*
@@ -29,7 +30,7 @@
public static final int VERSION_PROTOBUF = 1;
public static final Creator<TileData> CREATOR = newCreator(TileData.class, TileData::new);
- public TileData(@NonNull byte[] tile, int version) {
+ public TileData(byte @NonNull [] tile, int version) {
super(tile, version);
}
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileEnterEventData.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileEnterEventData.java
index 052dd79..f2cba65 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileEnterEventData.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileEnterEventData.java
@@ -16,9 +16,10 @@
package androidx.wear.tiles;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Holder for Tiles' TileEnterEvent class, to be parceled and transferred to a Tile Service.
*
@@ -30,7 +31,7 @@
public static final Creator<TileEnterEventData> CREATOR =
newCreator(TileEnterEventData.class, TileEnterEventData::new);
- public TileEnterEventData(@NonNull byte[] params, int version) {
+ public TileEnterEventData(byte @NonNull [] params, int version) {
super(params, version);
}
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileInteractionEventData.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileInteractionEventData.java
new file mode 100644
index 0000000..2ca9682
--- /dev/null
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileInteractionEventData.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package androidx.wear.tiles;
+
+import androidx.annotation.RestrictTo;
+
+import org.jspecify.annotations.NonNull;
+
+/**
+ * Holder for Tiles' TileInteractionEvent class, to be parceled and transferred to a Tile Service.
+ *
+ * <p>All this does is to serialize TileInteractionEvent as a protobuf and transmit it.
+ */
+@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
+public final class TileInteractionEventData extends ProtoParcelable {
+ public static final int VERSION_PROTOBUF = 1;
+ public static final Creator<TileInteractionEventData> CREATOR =
+ newCreator(TileInteractionEventData.class, TileInteractionEventData::new);
+
+ public TileInteractionEventData(byte @NonNull [] params, int version) {
+ super(params, version);
+ }
+}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileLeaveEventData.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileLeaveEventData.java
index 476cd9a..0edd237 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileLeaveEventData.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileLeaveEventData.java
@@ -16,9 +16,10 @@
package androidx.wear.tiles;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Holder for Tiles' TileLeaveEvent class, to be parceled and transferred to a Tile Service.
*
@@ -30,7 +31,7 @@
public static final Creator<TileLeaveEventData> CREATOR =
newCreator(TileLeaveEventData.class, TileLeaveEventData::new);
- public TileLeaveEventData(@NonNull byte[] params, int version) {
+ public TileLeaveEventData(byte @NonNull [] params, int version) {
super(params, version);
}
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileRemoveEventData.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileRemoveEventData.java
index fc6152c..6d97a2c 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileRemoveEventData.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileRemoveEventData.java
@@ -16,9 +16,10 @@
package androidx.wear.tiles;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Holder for Tiles' TileRemoveEvent class, to be parceled and transferred to a Tile Service.
*
@@ -30,7 +31,7 @@
public static final Creator<TileRemoveEventData> CREATOR =
newCreator(TileRemoveEventData.class, TileRemoveEventData::new);
- public TileRemoveEventData(@NonNull byte[] params, int version) {
+ public TileRemoveEventData(byte @NonNull [] params, int version) {
super(params, version);
}
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileRequestData.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileRequestData.java
index e4d83ae..352e188 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileRequestData.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileRequestData.java
@@ -16,9 +16,10 @@
package androidx.wear.tiles;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Holder for Tiles' TileRequest class, to be parceled and transferred to a Tile Service.
*
@@ -30,7 +31,7 @@
public static final Creator<TileRequestData> CREATOR =
newCreator(TileRequestData.class, TileRequestData::new);
- public TileRequestData(@NonNull byte[] params, int version) {
+ public TileRequestData(byte @NonNull [] params, int version) {
super(params, version);
}
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileService.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileService.java
index 8c95192..37c203e 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileService.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileService.java
@@ -29,8 +29,6 @@
import android.util.Log;
import androidx.annotation.MainThread;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting;
import androidx.concurrent.futures.CallbackToFutureAdapter;
@@ -41,6 +39,7 @@
import androidx.wear.protolayout.protobuf.InvalidProtocolBufferException;
import androidx.wear.tiles.EventBuilders.TileAddEvent;
import androidx.wear.tiles.EventBuilders.TileEnterEvent;
+import androidx.wear.tiles.EventBuilders.TileInteractionEvent;
import androidx.wear.tiles.EventBuilders.TileLeaveEvent;
import androidx.wear.tiles.EventBuilders.TileRemoveEvent;
import androidx.wear.tiles.RequestBuilders.ResourcesRequest;
@@ -56,10 +55,14 @@
import com.google.wear.services.tiles.TileInstance;
import com.google.wear.services.tiles.TilesManager;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.ref.WeakReference;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
@@ -150,8 +153,8 @@
* @param requestParams Parameters about the request. See {@link TileRequest} for more info.
*/
@MainThread
- @NonNull
- protected abstract ListenableFuture<Tile> onTileRequest(@NonNull TileRequest requestParams);
+ protected abstract @NonNull ListenableFuture<Tile> onTileRequest(
+ @NonNull TileRequest requestParams);
/**
* Called when the system is requesting a resource bundle from this Tile Provider. The returned
@@ -165,10 +168,9 @@
* @deprecated Use {@link #onTileResourcesRequest} instead.
*/
@MainThread
- @NonNull
@Deprecated
- protected ListenableFuture<androidx.wear.tiles.ResourceBuilders.Resources> onResourcesRequest(
- @NonNull ResourcesRequest requestParams) {
+ protected @NonNull ListenableFuture<androidx.wear.tiles.ResourceBuilders.Resources>
+ onResourcesRequest(@NonNull ResourcesRequest requestParams) {
return ON_RESOURCES_REQUEST_NOT_IMPLEMENTED;
}
@@ -188,9 +190,8 @@
* info.
*/
@MainThread
- @NonNull
@SuppressWarnings({"AsyncSuffixFuture", "deprecation"}) // For backward compatibility
- protected ListenableFuture<Resources> onTileResourcesRequest(
+ protected @NonNull ListenableFuture<Resources> onTileResourcesRequest(
@NonNull ResourcesRequest requestParams) {
// We are offering a default implementation for onTileResourcesRequest for backward
// compatibility as older clients are overriding onResourcesRequest.
@@ -242,8 +243,10 @@
* <p>Note that this is called from your app's main thread, which is usually also the UI thread.
*
* @param requestParams Parameters about the request. See {@link TileEnterEvent} for more info.
+ * @deprecated use {@link #processRecentInteractionEvents(List)}.
*/
@MainThread
+ @Deprecated
protected void onTileEnterEvent(@NonNull TileEnterEvent requestParams) {}
/**
@@ -252,18 +255,31 @@
* <p>Note that this is called from your app's main thread, which is usually also the UI thread.
*
* @param requestParams Parameters about the request. See {@link TileLeaveEvent} for more info.
+ * @deprecated use {@link #processRecentInteractionEvents(List)}.
*/
@MainThread
+ @Deprecated
protected void onTileLeaveEvent(@NonNull TileLeaveEvent requestParams) {}
/**
+ * Called when the system sends a batch of Tile interaction events that happened since the last
+ * time this method was called. The time between calls to this method may vary, do not depend on
+ * it for time-sensitive or critical tasks.
+ *
+ * <p>This method is called from your app's main thread, which is usually also the UI thread.
+ *
+ * @param events A list of {@link TileInteractionEvent} representing interactions that occurred.
+ */
+ @MainThread
+ protected void processRecentInteractionEvents(@NonNull List<TileInteractionEvent> events) {}
+
+ /**
* Gets an instance of {@link TileUpdateRequester} to allow a Tile Provider to notify the tile's
* renderer that it should request a new Timeline from this {@link TileService}.
*
* @param context The application context.
*/
- @NonNull
- public static TileUpdateRequester getUpdater(@NonNull Context context) {
+ public static @NonNull TileUpdateRequester getUpdater(@NonNull Context context) {
List<TileUpdateRequester> requesters = new ArrayList<>();
requesters.add(new SysUiTileUpdateRequester(context));
@@ -295,8 +311,7 @@
* context} present in the carousel, or a value based on platform-specific fallback
* behavior.
*/
- @NonNull
- public static ListenableFuture<List<ActiveTileIdentifier>> getActiveTilesAsync(
+ public static @NonNull ListenableFuture<List<ActiveTileIdentifier>> getActiveTilesAsync(
@NonNull Context context, @NonNull Executor executor) {
if (useWearSdkImpl(context)
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
@@ -307,8 +322,7 @@
}
@VisibleForTesting
- @NonNull
- static ListenableFuture<List<ActiveTileIdentifier>> getActiveTilesAsyncLegacy(
+ static @NonNull ListenableFuture<List<ActiveTileIdentifier>> getActiveTilesAsyncLegacy(
@NonNull Context context,
@NonNull Executor executor,
@NonNull TimeSourceClock timeSourceClock) {
@@ -326,8 +340,7 @@
private TileProvider.Stub mBinder;
@Override
- @Nullable
- public IBinder onBind(@NonNull Intent intent) {
+ public @Nullable IBinder onBind(@NonNull Intent intent) {
if (ACTION_BIND_TILE_PROVIDER.equals(intent.getAction())) {
if (mBinder == null) {
mBinder = new TileProviderWrapper(this, new Handler(getMainLooper()));
@@ -600,7 +613,14 @@
EventProto.TileEnterEvent.parseFrom(
data.getContents()));
tileService.markTileAsActiveLegacy(evt.getTileId());
+
tileService.onTileEnterEvent(evt);
+ tileService.processRecentInteractionEvents(
+ List.of(
+ new TileInteractionEvent.Builder(
+ evt.getTileId(),
+ TileInteractionEvent.ENTER)
+ .build()));
} catch (InvalidProtocolBufferException ex) {
Log.e(TAG, "Error deserializing TileEnterEvent payload.", ex);
}
@@ -629,13 +649,60 @@
EventProto.TileLeaveEvent.parseFrom(
data.getContents()));
tileService.markTileAsActiveLegacy(evt.getTileId());
+
tileService.onTileLeaveEvent(evt);
+ tileService.processRecentInteractionEvents(
+ List.of(
+ new TileInteractionEvent.Builder(
+ evt.getTileId(),
+ TileInteractionEvent.LEAVE)
+ .build()));
} catch (InvalidProtocolBufferException ex) {
Log.e(TAG, "Error deserializing TileLeaveEvent payload.", ex);
}
}
});
}
+
+ @Override
+ public void processRecentInteractionEvents(List<TileInteractionEventData> data) {
+ mHandler.post(
+ () -> {
+ TileService tileService = mServiceRef.get();
+
+ if (data.isEmpty() || tileService == null) {
+ return;
+ }
+
+ if (data.get(0).getVersion() != TileInteractionEventData.VERSION_PROTOBUF) {
+ Log.e(
+ TAG,
+ "TileInteractionEventData had unexpected version: "
+ + data.get(0).getVersion());
+ return;
+ }
+
+ List<TileInteractionEvent> events =
+ data.stream()
+ .map(TileProviderWrapper::tileInteractionEventFromProto)
+ .filter(Optional::isPresent)
+ .map(Optional::get)
+ .collect(Collectors.toList());
+ tileService.processRecentInteractionEvents(events);
+ });
+ }
+
+ private static @NonNull Optional<TileInteractionEvent> tileInteractionEventFromProto(
+ TileInteractionEventData data) {
+ try {
+ return Optional.of(
+ TileInteractionEvent.fromProto(
+ EventProto.TileInteractionEvent.parseFrom(data.getContents())));
+ } catch (InvalidProtocolBufferException ex) {
+ Log.e(TAG, "Error deserializing TileInteractionEvent payload.", ex);
+ return Optional.empty();
+ }
+ }
}
static void updateResources(ResourcesCallback callback, byte[] resources) {
@@ -682,8 +749,7 @@
@RequiresApi(34)
private static class Api34Impl {
- @NonNull
- static ListenableFuture<List<ActiveTileIdentifier>> getActiveTilesAsync(
+ static @NonNull ListenableFuture<List<ActiveTileIdentifier>> getActiveTilesAsync(
@NonNull TilesManager tilesManager, @NonNull Executor executor) {
return CallbackToFutureAdapter.getFuture(
completer -> {
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileUpdateRequestData.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileUpdateRequestData.java
index 1907b70..d2e7c82 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileUpdateRequestData.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileUpdateRequestData.java
@@ -16,9 +16,10 @@
package androidx.wear.tiles;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Holder for parameters, used when a Tile update request is triggered. This is currently a
* placeholder to allow for future expansion, and should be filled in with an empty byte array.
@@ -30,7 +31,7 @@
public static final Creator<TileUpdateRequestData> CREATOR =
newCreator(TileUpdateRequestData.class, TileUpdateRequestData::new);
- private TileUpdateRequestData(@NonNull byte[] params, int version) {
+ private TileUpdateRequestData(byte @NonNull [] params, int version) {
super(params, version);
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileUpdateRequester.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileUpdateRequester.java
index 23f8def..bf0a573 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileUpdateRequester.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TileUpdateRequester.java
@@ -16,7 +16,7 @@
package androidx.wear.tiles;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* Interface used for a Tile Service to notify a Tile Renderer that it should fetch a new Timeline
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TimelineBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TimelineBuilders.java
index 9ec8f9e..d5da952 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TimelineBuilders.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TimelineBuilders.java
@@ -16,12 +16,13 @@
package androidx.wear.tiles;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.proto.TimelineProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -62,13 +63,11 @@
return mImpl.getEndMillis();
}
- @NonNull
- static TimeInterval fromProto(@NonNull TimelineProto.TimeInterval proto) {
+ static @NonNull TimeInterval fromProto(TimelineProto.@NonNull TimeInterval proto) {
return new TimeInterval(proto);
}
- @NonNull
- TimelineProto.TimeInterval toProto() {
+ TimelineProto.@NonNull TimeInterval toProto() {
return mImpl;
}
@@ -80,22 +79,19 @@
public Builder() {}
/** Sets starting point of the time interval, in milliseconds since the Unix epoch. */
- @NonNull
- public Builder setStartMillis(long startMillis) {
+ public @NonNull Builder setStartMillis(long startMillis) {
mImpl.setStartMillis(startMillis);
return this;
}
/** Sets end point of the time interval, in milliseconds since the Unix epoch. */
- @NonNull
- public Builder setEndMillis(long endMillis) {
+ public @NonNull Builder setEndMillis(long endMillis) {
mImpl.setEndMillis(endMillis);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public TimeInterval build() {
+ public @NonNull TimeInterval build() {
return TimeInterval.fromProto(mImpl.build());
}
}
@@ -110,8 +106,7 @@
}
/** Gets the validity period for this timeline entry. Intended for testing purposes only. */
- @Nullable
- public TimeInterval getValidity() {
+ public @Nullable TimeInterval getValidity() {
if (mImpl.hasValidity()) {
return TimeInterval.fromProto(mImpl.getValidity());
} else {
@@ -120,8 +115,7 @@
}
/** Gets the contents of this timeline entry. Intended for testing purposes only. */
- @Nullable
- public LayoutElementBuilders.Layout getLayout() {
+ public LayoutElementBuilders.@Nullable Layout getLayout() {
if (mImpl.hasLayout()) {
return LayoutElementBuilders.Layout.fromProto(mImpl.getLayout());
} else {
@@ -130,23 +124,20 @@
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static TimelineEntry fromProto(@NonNull TimelineProto.TimelineEntry proto) {
+ public static @NonNull TimelineEntry fromProto(TimelineProto.@NonNull TimelineEntry proto) {
return new TimelineEntry(proto);
}
/** Returns the {@link TimelineEntry} object containing the given layout element. */
- @NonNull
- public static TimelineEntry fromLayoutElement(
- @NonNull LayoutElementBuilders.LayoutElement layoutElement) {
+ public static @NonNull TimelineEntry fromLayoutElement(
+ LayoutElementBuilders.@NonNull LayoutElement layoutElement) {
return new Builder()
.setLayout(LayoutElementBuilders.Layout.fromLayoutElement(layoutElement))
.build();
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public TimelineProto.TimelineEntry toProto() {
+ public TimelineProto.@NonNull TimelineEntry toProto() {
return mImpl;
}
@@ -158,22 +149,19 @@
public Builder() {}
/** Sets the validity period for this timeline entry. */
- @NonNull
- public Builder setValidity(@NonNull TimeInterval validity) {
+ public @NonNull Builder setValidity(@NonNull TimeInterval validity) {
mImpl.setValidity(validity.toProto());
return this;
}
/** Sets the contents of this timeline entry. */
- @NonNull
- public Builder setLayout(@NonNull LayoutElementBuilders.Layout layout) {
+ public @NonNull Builder setLayout(LayoutElementBuilders.@NonNull Layout layout) {
mImpl.setLayout(layout.toProto());
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public TimelineEntry build() {
+ public @NonNull TimelineEntry build() {
return TimelineEntry.fromProto(mImpl.build());
}
}
@@ -201,8 +189,7 @@
}
/** Gets the entries in a timeline. Intended for testing purposes only. */
- @NonNull
- public List<TimelineEntry> getTimelineEntries() {
+ public @NonNull List<TimelineEntry> getTimelineEntries() {
List<TimelineEntry> list = new ArrayList<>();
for (TimelineProto.TimelineEntry item : mImpl.getTimelineEntriesList()) {
list.add(TimelineEntry.fromProto(item));
@@ -211,23 +198,20 @@
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public static Timeline fromProto(@NonNull TimelineProto.Timeline proto) {
+ public static @NonNull Timeline fromProto(TimelineProto.@NonNull Timeline proto) {
return new Timeline(proto);
}
/** Returns the {@link Timeline} object containing the given layout element. */
- @NonNull
- public static Timeline fromLayoutElement(
- @NonNull LayoutElementBuilders.LayoutElement layoutElement) {
+ public static @NonNull Timeline fromLayoutElement(
+ LayoutElementBuilders.@NonNull LayoutElement layoutElement) {
return new Builder()
.addTimelineEntry(TimelineEntry.fromLayoutElement(layoutElement))
.build();
}
@RestrictTo(Scope.LIBRARY_GROUP)
- @NonNull
- public TimelineProto.Timeline toProto() {
+ public TimelineProto.@NonNull Timeline toProto() {
return mImpl;
}
@@ -239,15 +223,13 @@
public Builder() {}
/** Adds one item to the entries in a timeline. */
- @NonNull
- public Builder addTimelineEntry(@NonNull TimelineEntry timelineEntry) {
+ public @NonNull Builder addTimelineEntry(@NonNull TimelineEntry timelineEntry) {
mImpl.addTimelineEntries(timelineEntry.toProto());
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Timeline build() {
+ public @NonNull Timeline build() {
return Timeline.fromProto(mImpl.build());
}
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TypeBuilders.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TypeBuilders.java
index 60c066c..a0f0a19 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TypeBuilders.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/TypeBuilders.java
@@ -18,13 +18,14 @@
import android.annotation.SuppressLint;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.RestrictTo.Scope;
import androidx.wear.protolayout.expression.Fingerprint;
import androidx.wear.protolayout.proto.TypesProto;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Builders for extensible primitive types used by layout elements.
*
@@ -37,7 +38,7 @@
/** An int32 type. */
public static final class Int32Prop {
private final TypesProto.Int32Prop mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
Int32Prop(TypesProto.Int32Prop impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -51,18 +52,15 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static Int32Prop fromProto(@NonNull TypesProto.Int32Prop proto) {
+ static @NonNull Int32Prop fromProto(TypesProto.@NonNull Int32Prop proto) {
return new Int32Prop(proto, null);
}
- @NonNull
- TypesProto.Int32Prop toProto() {
+ TypesProto.@NonNull Int32Prop toProto() {
return mImpl;
}
@@ -74,16 +72,14 @@
public Builder() {}
/** Sets the value. */
- @NonNull
- public Builder setValue(int value) {
+ public @NonNull Builder setValue(int value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, value);
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public Int32Prop build() {
+ public @NonNull Int32Prop build() {
return new Int32Prop(mImpl.build(), mFingerprint);
}
}
@@ -92,7 +88,7 @@
/** A string type. */
public static final class StringProp {
private final TypesProto.StringProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
StringProp(TypesProto.StringProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -100,25 +96,21 @@
}
/** Gets the value. Intended for testing purposes only. */
- @NonNull
- public String getValue() {
+ public @NonNull String getValue() {
return mImpl.getValue();
}
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static StringProp fromProto(@NonNull TypesProto.StringProp proto) {
+ static @NonNull StringProp fromProto(TypesProto.@NonNull StringProp proto) {
return new StringProp(proto, null);
}
- @NonNull
- TypesProto.StringProp toProto() {
+ TypesProto.@NonNull StringProp toProto() {
return mImpl;
}
@@ -130,16 +122,14 @@
public Builder() {}
/** Sets the value. */
- @NonNull
- public Builder setValue(@NonNull String value) {
+ public @NonNull Builder setValue(@NonNull String value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, value.hashCode());
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public StringProp build() {
+ public @NonNull StringProp build() {
return new StringProp(mImpl.build(), mFingerprint);
}
}
@@ -148,7 +138,7 @@
/** A float type. */
public static final class FloatProp {
private final TypesProto.FloatProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
FloatProp(TypesProto.FloatProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -162,18 +152,15 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static FloatProp fromProto(@NonNull TypesProto.FloatProp proto) {
+ static @NonNull FloatProp fromProto(TypesProto.@NonNull FloatProp proto) {
return new FloatProp(proto, null);
}
- @NonNull
- TypesProto.FloatProp toProto() {
+ TypesProto.@NonNull FloatProp toProto() {
return mImpl;
}
@@ -185,16 +172,14 @@
public Builder() {}
/** Sets the value. */
- @NonNull
- public Builder setValue(float value) {
+ public @NonNull Builder setValue(float value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, Float.floatToIntBits(value));
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public FloatProp build() {
+ public @NonNull FloatProp build() {
return new FloatProp(mImpl.build(), mFingerprint);
}
}
@@ -203,7 +188,7 @@
/** A boolean type. */
public static final class BoolProp {
private final TypesProto.BoolProp mImpl;
- @Nullable private final Fingerprint mFingerprint;
+ private final @Nullable Fingerprint mFingerprint;
BoolProp(TypesProto.BoolProp impl, @Nullable Fingerprint fingerprint) {
this.mImpl = impl;
@@ -217,18 +202,15 @@
/** Get the fingerprint for this object, or null if unknown. */
@RestrictTo(Scope.LIBRARY_GROUP)
- @Nullable
- public Fingerprint getFingerprint() {
+ public @Nullable Fingerprint getFingerprint() {
return mFingerprint;
}
- @NonNull
- static BoolProp fromProto(@NonNull TypesProto.BoolProp proto) {
+ static @NonNull BoolProp fromProto(TypesProto.@NonNull BoolProp proto) {
return new BoolProp(proto, null);
}
- @NonNull
- TypesProto.BoolProp toProto() {
+ TypesProto.@NonNull BoolProp toProto() {
return mImpl;
}
@@ -241,16 +223,14 @@
/** Sets the value. */
@SuppressLint("MissingGetterMatchingBuilder")
- @NonNull
- public Builder setValue(boolean value) {
+ public @NonNull Builder setValue(boolean value) {
mImpl.setValue(value);
mFingerprint.recordPropertyUpdate(1, Boolean.hashCode(value));
return this;
}
/** Builds an instance from accumulated values. */
- @NonNull
- public BoolProp build() {
+ public @NonNull BoolProp build() {
return new BoolProp(mImpl.build(), mFingerprint);
}
}
diff --git a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ViewerTileUpdateRequester.java b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ViewerTileUpdateRequester.java
index cffb82d..a18a073 100644
--- a/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ViewerTileUpdateRequester.java
+++ b/wear/tiles/tiles/src/main/java/androidx/wear/tiles/ViewerTileUpdateRequester.java
@@ -19,7 +19,7 @@
import android.content.Context;
import android.content.Intent;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* {@link TileUpdateRequester} which notifies the viewer that it should fetch a new version of the
diff --git a/wear/tiles/tiles/src/test/java/androidx/wear/tiles/CompositeTileUpdateRequesterTest.java b/wear/tiles/tiles/src/test/java/androidx/wear/tiles/CompositeTileUpdateRequesterTest.java
index 5c0133e..5d62133 100644
--- a/wear/tiles/tiles/src/test/java/androidx/wear/tiles/CompositeTileUpdateRequesterTest.java
+++ b/wear/tiles/tiles/src/test/java/androidx/wear/tiles/CompositeTileUpdateRequesterTest.java
@@ -21,8 +21,6 @@
import android.content.Intent;
import android.os.IBinder;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.concurrent.futures.ResolvableFuture;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.wear.protolayout.ResourceBuilders;
@@ -30,6 +28,8 @@
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -71,27 +71,24 @@
}
private static class FakeService extends TileService {
- @NonNull
@Override
- protected ListenableFuture<TileBuilders.Tile> onTileRequest(
- @NonNull RequestBuilders.TileRequest requestParams) {
+ protected @NonNull ListenableFuture<TileBuilders.Tile> onTileRequest(
+ RequestBuilders.@NonNull TileRequest requestParams) {
ResolvableFuture<TileBuilders.Tile> f = ResolvableFuture.create();
f.set(null);
return f;
}
- @NonNull
@Override
- protected ListenableFuture<ResourceBuilders.Resources> onTileResourcesRequest(
- @NonNull RequestBuilders.ResourcesRequest requestParams) {
+ protected @NonNull ListenableFuture<ResourceBuilders.Resources> onTileResourcesRequest(
+ RequestBuilders.@NonNull ResourcesRequest requestParams) {
ResolvableFuture<ResourceBuilders.Resources> f = ResolvableFuture.create();
f.set(null);
return f;
}
- @Nullable
@Override
- public IBinder onBind(Intent intent) {
+ public @Nullable IBinder onBind(Intent intent) {
return null;
}
}
diff --git a/wear/tiles/tiles/src/test/java/androidx/wear/tiles/ProtoParcelableTest.java b/wear/tiles/tiles/src/test/java/androidx/wear/tiles/ProtoParcelableTest.java
index d0032c7..92e0dc8 100644
--- a/wear/tiles/tiles/src/test/java/androidx/wear/tiles/ProtoParcelableTest.java
+++ b/wear/tiles/tiles/src/test/java/androidx/wear/tiles/ProtoParcelableTest.java
@@ -27,7 +27,6 @@
import org.junit.runner.RunWith;
import org.robolectric.annotation.internal.DoNotInstrument;
-
@RunWith(AndroidJUnit4.class)
@DoNotInstrument // See http://g/robolectric-users/fTi2FRXgyGA/m/PkB0wYuwBgAJ
public final class ProtoParcelableTest {
diff --git a/wear/tiles/tiles/src/test/java/androidx/wear/tiles/TileServiceTest.java b/wear/tiles/tiles/src/test/java/androidx/wear/tiles/TileServiceTest.java
index f4b6523..2b87fe2 100644
--- a/wear/tiles/tiles/src/test/java/androidx/wear/tiles/TileServiceTest.java
+++ b/wear/tiles/tiles/src/test/java/androidx/wear/tiles/TileServiceTest.java
@@ -39,8 +39,6 @@
import android.os.Looper;
import android.os.RemoteException;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.wear.protolayout.ResourceBuilders.Resources;
@@ -51,6 +49,7 @@
import androidx.wear.protolayout.protobuf.ExtensionRegistryLite;
import androidx.wear.tiles.EventBuilders.TileAddEvent;
import androidx.wear.tiles.EventBuilders.TileEnterEvent;
+import androidx.wear.tiles.EventBuilders.TileInteractionEvent;
import androidx.wear.tiles.EventBuilders.TileLeaveEvent;
import androidx.wear.tiles.EventBuilders.TileRemoveEvent;
import androidx.wear.tiles.RequestBuilders.ResourcesRequest;
@@ -65,6 +64,8 @@
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -81,6 +82,7 @@
import org.robolectric.shadows.ShadowSystemClock;
import java.time.Duration;
+import java.time.Instant;
import java.util.List;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
@@ -653,6 +655,24 @@
}
@Test
+ public void tileService_onTileEnter_callsProcessRecentInteractionEvents() throws Exception {
+ EventProto.TileEnterEvent enterRequest =
+ EventProto.TileEnterEvent.newBuilder().setTileId(TILE_ID).build();
+
+ mTileProviderServiceStub.onTileEnterEvent(
+ new TileEnterEventData(
+ enterRequest.toByteArray(), TileEnterEventData.VERSION_PROTOBUF));
+ shadowOf(Looper.getMainLooper()).idle();
+
+ expect.that(mFakeTileServiceController.get().mLastEventBatch).isNotEmpty();
+ TileInteractionEvent interactionEvent =
+ mFakeTileServiceController.get().mLastEventBatch.get(0);
+
+ expect.that(interactionEvent.getTileId()).isEqualTo(TILE_ID);
+ expect.that(interactionEvent.getEventType()).isEqualTo(TileInteractionEvent.ENTER);
+ }
+
+ @Test
public void tileService_onTileLeave() throws Exception {
EventProto.TileLeaveEvent leaveRequest =
EventProto.TileLeaveEvent.newBuilder().setTileId(TILE_ID).build();
@@ -667,6 +687,65 @@
}
@Test
+ public void tileService_onTileLeave_callsProcessRecentInteractionEvents() throws Exception {
+ EventProto.TileLeaveEvent leaveRequest =
+ EventProto.TileLeaveEvent.newBuilder().setTileId(TILE_ID).build();
+
+ mTileProviderServiceStub.onTileLeaveEvent(
+ new TileLeaveEventData(
+ leaveRequest.toByteArray(), TileLeaveEventData.VERSION_PROTOBUF));
+ shadowOf(Looper.getMainLooper()).idle();
+
+ expect.that(mFakeTileServiceController.get().mLastEventBatch).isNotEmpty();
+ TileInteractionEvent interactionEvent =
+ mFakeTileServiceController.get().mLastEventBatch.get(0);
+
+ expect.that(interactionEvent.getTileId()).isEqualTo(TILE_ID);
+ expect.that(interactionEvent.getEventType()).isEqualTo(TileInteractionEvent.LEAVE);
+ }
+
+ @Test
+ public void tileService_processRecentInteractionEvents() throws Exception {
+ long fakeTimestamp = 112233L;
+ ImmutableList<EventProto.TileInteractionEvent> eventProtos =
+ ImmutableList.of(
+ EventProto.TileInteractionEvent.newBuilder()
+ .setTileId(TILE_ID)
+ .setTimestampEpochMillis(fakeTimestamp)
+ .setEnter(EventProto.TileEnter.getDefaultInstance())
+ .build(),
+ EventProto.TileInteractionEvent.newBuilder()
+ .setTileId(TILE_ID)
+ .setTimestampEpochMillis(fakeTimestamp)
+ .setLeave(EventProto.TileLeave.getDefaultInstance())
+ .build());
+
+ mTileProviderServiceStub.processRecentInteractionEvents(
+ eventProtos.stream()
+ .map(
+ e ->
+ new TileInteractionEventData(
+ e.toByteArray(),
+ TileInteractionEventData.VERSION_PROTOBUF))
+ .collect(toImmutableList()));
+ shadowOf(Looper.getMainLooper()).idle();
+
+ List<TileInteractionEvent> receivedEvents =
+ mFakeTileServiceController.get().mLastEventBatch;
+ expect.that(receivedEvents).hasSize(2);
+
+ expect.that(receivedEvents.get(0).getTileId()).isEqualTo(TILE_ID);
+ expect.that(receivedEvents.get(0).getTimestamp())
+ .isEqualTo(Instant.ofEpochMilli(fakeTimestamp));
+ expect.that(receivedEvents.get(0).getEventType()).isEqualTo(TileInteractionEvent.ENTER);
+
+ expect.that(receivedEvents.get(1).getTileId()).isEqualTo(TILE_ID);
+ expect.that(receivedEvents.get(1).getTimestamp())
+ .isEqualTo(Instant.ofEpochMilli(fakeTimestamp));
+ expect.that(receivedEvents.get(1).getEventType()).isEqualTo(TileInteractionEvent.LEAVE);
+ }
+
+ @Test
public void tileService_tileRequest_setsTileId() throws Exception {
mTileProviderServiceStub.onTileRequest(
TILE_ID,
@@ -882,6 +961,7 @@
@Nullable ResourcesRequest mResourcesRequestParams = null;
@Nullable RuntimeException mRequestFailure = null;
int mTileId = -1;
+ List<TileInteractionEvent> mLastEventBatch;
@Override
TimeSourceClock getTimeSourceClock() {
@@ -901,20 +981,26 @@
}
@Override
+ @SuppressWarnings("deprecation") // Testing backward compatibility
protected void onTileEnterEvent(@NonNull TileEnterEvent requestParams) {
mOnTileEnterCalled = true;
mTileId = requestParams.getTileId();
}
@Override
+ @SuppressWarnings("deprecation") // Testing backward compatibility
protected void onTileLeaveEvent(@NonNull TileLeaveEvent requestParams) {
mOnTileLeaveCalled = true;
mTileId = requestParams.getTileId();
}
@Override
- @NonNull
- protected ListenableFuture<TileBuilders.Tile> onTileRequest(
+ protected void processRecentInteractionEvents(@NonNull List<TileInteractionEvent> events) {
+ mLastEventBatch = events;
+ }
+
+ @Override
+ protected @NonNull ListenableFuture<TileBuilders.Tile> onTileRequest(
@NonNull TileRequest requestParams) {
mTileRequestParams = requestParams;
mTileId = requestParams.getTileId();
@@ -925,8 +1011,7 @@
}
@Override
- @NonNull
- protected ListenableFuture<Resources> onTileResourcesRequest(
+ protected @NonNull ListenableFuture<Resources> onTileResourcesRequest(
@NonNull ResourcesRequest requestParams) {
mResourcesRequestParams = requestParams;
mTileId = requestParams.getTileId();
@@ -956,22 +1041,22 @@
protected void onTileRemoveEvent(@NonNull TileRemoveEvent requestParams) {}
@Override
+ @SuppressWarnings("deprecation") // Testing backward compatibility
protected void onTileEnterEvent(@NonNull TileEnterEvent requestParams) {}
@Override
+ @SuppressWarnings("deprecation") // Testing backward compatibility
protected void onTileLeaveEvent(@NonNull TileLeaveEvent requestParams) {}
@Override
- @NonNull
- protected ListenableFuture<TileBuilders.Tile> onTileRequest(
+ protected @NonNull ListenableFuture<TileBuilders.Tile> onTileRequest(
@NonNull TileRequest requestParams) {
return Futures.immediateFuture(DUMMY_TILE_TO_RETURN);
}
@Override
- @NonNull
@SuppressWarnings("deprecation") // for backward compatibility
- protected ListenableFuture<androidx.wear.tiles.ResourceBuilders.Resources>
+ protected @NonNull ListenableFuture<androidx.wear.tiles.ResourceBuilders.Resources>
onResourcesRequest(@NonNull ResourcesRequest requestParams) {
androidx.wear.tiles.ResourceBuilders.Resources resources =
new androidx.wear.tiles.ResourceBuilders.Resources.Builder()
diff --git a/wear/watchface/watchface-complications-data-source/build.gradle b/wear/watchface/watchface-complications-data-source/build.gradle
index b3db5e5..1ffd85c 100644
--- a/wear/watchface/watchface-complications-data-source/build.gradle
+++ b/wear/watchface/watchface-complications-data-source/build.gradle
@@ -30,6 +30,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.annotation:annotation:1.8.1")
api(project(":wear:watchface:watchface-complications"))
api(project(":wear:watchface:watchface-complications-data"))
diff --git a/wear/watchface/watchface-complications-data-source/src/test/java/androidx/wear/watchface/complications/datasource/ComplicationsTestRunner.java b/wear/watchface/watchface-complications-data-source/src/test/java/androidx/wear/watchface/complications/datasource/ComplicationsTestRunner.java
index 8bbd7ef..469f09a 100644
--- a/wear/watchface/watchface-complications-data-source/src/test/java/androidx/wear/watchface/complications/datasource/ComplicationsTestRunner.java
+++ b/wear/watchface/watchface-complications-data-source/src/test/java/androidx/wear/watchface/complications/datasource/ComplicationsTestRunner.java
@@ -16,8 +16,7 @@
package androidx.wear.watchface.complications.datasource;
-import androidx.annotation.NonNull;
-
+import org.jspecify.annotations.NonNull;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.robolectric.RobolectricTestRunner;
@@ -29,9 +28,9 @@
super(clazz);
}
- @NonNull
@Override
- protected InstrumentationConfiguration createClassLoaderConfig(FrameworkMethod method) {
+ protected @NonNull InstrumentationConfiguration createClassLoaderConfig(
+ FrameworkMethod method) {
return new InstrumentationConfiguration.Builder(super.createClassLoaderConfig(method))
.doNotInstrumentPackage("android.support.wearable.complications")
.doNotInstrumentPackage("android.support.wearable.watchface")
diff --git a/wear/watchface/watchface-complications-data-source/src/test/java/androidx/wear/watchface/complications/datasource/JavaCompatTest.java b/wear/watchface/watchface-complications-data-source/src/test/java/androidx/wear/watchface/complications/datasource/JavaCompatTest.java
index dca99c7..efc52c2 100644
--- a/wear/watchface/watchface-complications-data-source/src/test/java/androidx/wear/watchface/complications/datasource/JavaCompatTest.java
+++ b/wear/watchface/watchface-complications-data-source/src/test/java/androidx/wear/watchface/complications/datasource/JavaCompatTest.java
@@ -18,9 +18,10 @@
import android.os.RemoteException;
-import androidx.annotation.Nullable;
import androidx.wear.watchface.complications.data.ComplicationData;
+import org.jspecify.annotations.Nullable;
+
/** Tests that Java interfaces implementing kotlin interfaces with defaults compile. */
public class JavaCompatTest {
class ComplicationRequestListenerImpl
diff --git a/wear/watchface/watchface-complications-data/build.gradle b/wear/watchface/watchface-complications-data/build.gradle
index 47a9a5a..a9a309b 100644
--- a/wear/watchface/watchface-complications-data/build.gradle
+++ b/wear/watchface/watchface-complications-data/build.gradle
@@ -33,6 +33,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.annotation:annotation:1.8.1")
api("androidx.versionedparcelable:versionedparcelable:1.1.0")
api("androidx.wear.protolayout:protolayout-expression:1.0.0")
diff --git a/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/CharSequenceSerializableHelper.java b/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/CharSequenceSerializableHelper.java
index b2fe56e..6fedcba 100644
--- a/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/CharSequenceSerializableHelper.java
+++ b/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/CharSequenceSerializableHelper.java
@@ -18,10 +18,11 @@
import android.text.SpannableString;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.core.text.HtmlCompat;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
diff --git a/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/ComplicationProviderInfo.java b/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/ComplicationProviderInfo.java
index 4966615..8da766f 100644
--- a/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/ComplicationProviderInfo.java
+++ b/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/ComplicationProviderInfo.java
@@ -23,10 +23,11 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Holder of details of a complication provider, for use by watch faces (for example, to show the
* current provider in settings). A {@link
@@ -38,8 +39,7 @@
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public final class ComplicationProviderInfo implements Parcelable {
- @NonNull
- public static final Creator<ComplicationProviderInfo> CREATOR =
+ public static final @NonNull Creator<ComplicationProviderInfo> CREATOR =
new Creator<ComplicationProviderInfo>() {
@Override
public ComplicationProviderInfo createFromParcel(Parcel source) {
@@ -58,12 +58,12 @@
private static final String KEY_PROVIDER_ICON = "provider_icon";
private static final String KEY_PROVIDER_TYPE = "complication_type";
- @Nullable private String mAppName;
- @Nullable private String mProviderName;
- @Nullable private Icon mProviderIcon;
+ private @Nullable String mAppName;
+ private @Nullable String mProviderName;
+ private @Nullable Icon mProviderIcon;
@ComplicationData.ComplicationType private int mComplicationType;
/** This field is only populate in Android R and up and it is null otherwise. */
- @Nullable private ComponentName mProviderComponentName;
+ private @Nullable ComponentName mProviderComponentName;
/**
* Constructs a {@link ComplicationProviderInfo} with the details of a complication provider.
@@ -118,8 +118,7 @@
}
/** Returns the name of the application containing the complication provider. */
- @Nullable
- public String getAppName() {
+ public @Nullable String getAppName() {
return mAppName;
}
@@ -129,8 +128,7 @@
}
/** Returns the name of the complication provider. */
- @Nullable
- public String getProviderName() {
+ public @Nullable String getProviderName() {
return mProviderName;
}
@@ -140,8 +138,7 @@
}
/** Returns the icon for the complication provider. */
- @Nullable
- public Icon getProviderIcon() {
+ public @Nullable Icon getProviderIcon() {
return mProviderIcon;
}
@@ -175,9 +172,8 @@
return 0;
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
return "ComplicationProviderInfo{"
+ "appName='"
+ mAppName
diff --git a/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/ComplicationText.java b/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/ComplicationText.java
index 4043d36..3c81f89 100644
--- a/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/ComplicationText.java
+++ b/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/ComplicationText.java
@@ -33,11 +33,12 @@
import android.text.style.UnderlineSpan;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.wear.protolayout.expression.DynamicBuilders.DynamicString;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.IOException;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
@@ -114,9 +115,8 @@
: Arrays.hashCode(mDynamicText.toDynamicStringByteArray()));
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
return "ComplicationText{"
+ "mSurroundingText="
+ ComplicationData.maybeRedact(mSurroundingText)
@@ -257,18 +257,15 @@
private static final String KEY_FORMAT_STYLE = "format_style";
private static final String KEY_FORMAT_TIME_ZONE = "format_time_zone";
- @NonNull
- public static final Parcelable.Creator<ComplicationText> CREATOR =
+ public static final Parcelable.@NonNull Creator<ComplicationText> CREATOR =
new Parcelable.Creator<ComplicationText>() {
@Override
- @NonNull
- public ComplicationText createFromParcel(@NonNull Parcel in) {
+ public @NonNull ComplicationText createFromParcel(@NonNull Parcel in) {
return new ComplicationText(in);
}
@Override
- @NonNull
- public ComplicationText[] newArray(int size) {
+ public ComplicationText @NonNull [] newArray(int size) {
return new ComplicationText[size];
}
};
@@ -279,17 +276,17 @@
* #mTimeDependentText} is not null, getText will return this text with {@code ^1} replaced by
* the time-dependent string.
*/
- @Nullable private final CharSequence mSurroundingText;
+ private final @Nullable CharSequence mSurroundingText;
/**
* The time-dependent part of the complication text. If {@link #mSurroundingText} is null, this
* must be not null and {@link #getTextAt} will return just the time-dependent value relative to
* the given time.
*/
- @Nullable private final TimeDependentText mTimeDependentText;
+ private final @Nullable TimeDependentText mTimeDependentText;
/** A {@link DynamicString} which will be evaluated by the system on the WatchFace's behalf. */
- @Nullable private final DynamicString mDynamicText;
+ private final @Nullable DynamicString mDynamicText;
/** Used to replace occurrences of ^1 with time dependent text and ignore ^[2-9]. */
private final CharSequence[] mTemplateValues =
@@ -421,8 +418,7 @@
* Returns the {@link TimeUnit} with the provided {@code name}. Returns null if {@code name} is
* null, or is not a TimeUnit.
*/
- @Nullable
- private static TimeUnit timeUnitFromName(@Nullable String name) {
+ private static @Nullable TimeUnit timeUnitFromName(@Nullable String name) {
if (name == null) {
return null;
}
@@ -482,9 +478,8 @@
}
/** Returns the time-dependent part of the complication text. */
- @NonNull
@RestrictTo(RestrictTo.Scope.LIBRARY)
- public TimeDependentText getTimeDependentText() {
+ public @NonNull TimeDependentText getTimeDependentText() {
if (mDynamicText != null) {
throw new UnsupportedOperationException(
"getTimeDependentText not supported for DynamicText");
@@ -506,9 +501,8 @@
* @param dateTimeMillis milliseconds since epoch, e.g. from {@link System#currentTimeMillis}
* @return Text appropriate for the given date time.
*/
- @NonNull
@Override
- public CharSequence getTextAt(@NonNull Resources resources, long dateTimeMillis) {
+ public @NonNull CharSequence getTextAt(@NonNull Resources resources, long dateTimeMillis) {
if (mDynamicText != null && mTimeDependentText == null && mSurroundingText == null) {
throw new UnsupportedOperationException("getTextAt not supported for DynamicText");
}
@@ -536,14 +530,12 @@
}
/** Returns the text within which the time difference is displayed. */
- @Nullable
- public CharSequence getSurroundingText() {
+ public @Nullable CharSequence getSurroundingText() {
return mSurroundingText;
}
/** Returns the {@link DynamicString} to be evaluated to display this text. */
- @Nullable
- public DynamicString getDynamicValue() {
+ public @Nullable DynamicString getDynamicValue() {
return mDynamicText;
}
@@ -607,8 +599,7 @@
*
* @param text the text to be displayed
*/
- @NonNull
- public static ComplicationText plainText(@NonNull CharSequence text) {
+ public static @NonNull ComplicationText plainText(@NonNull CharSequence text) {
return new ComplicationText(text);
}
@@ -666,8 +657,8 @@
* since the epoch.
* @return this builder for chaining.
*/
- @NonNull
- public TimeDifferenceBuilder setReferencePeriodStartMillis(long refPeriodStartMillis) {
+ public @NonNull TimeDifferenceBuilder setReferencePeriodStartMillis(
+ long refPeriodStartMillis) {
if (refPeriodStartMillis < 0) {
throw new IllegalArgumentException("Reference period start cannot be negative");
}
@@ -683,8 +674,7 @@
* since the epoch.
* @return this builder for chaining.
*/
- @NonNull
- public TimeDifferenceBuilder setReferencePeriodEndMillis(long refPeriodEndMillis) {
+ public @NonNull TimeDifferenceBuilder setReferencePeriodEndMillis(long refPeriodEndMillis) {
if (refPeriodEndMillis < 0) {
throw new IllegalArgumentException("Reference period end cannot be negative");
}
@@ -702,8 +692,7 @@
* @see #DIFFERENCE_STYLE_STOPWATCH
* @see #DIFFERENCE_STYLE_WORDS_SINGLE_UNIT
*/
- @NonNull
- public TimeDifferenceBuilder setStyle(@TimeDifferenceStyle int style) {
+ public @NonNull TimeDifferenceBuilder setStyle(@TimeDifferenceStyle int style) {
mStyle = style;
return this;
}
@@ -727,8 +716,8 @@
* with {@code ^1} in place of the time difference.
* @return this builder for chaining.
*/
- @NonNull
- public TimeDifferenceBuilder setSurroundingText(@Nullable CharSequence surroundingText) {
+ public @NonNull TimeDifferenceBuilder setSurroundingText(
+ @Nullable CharSequence surroundingText) {
mSurroundingText = surroundingText;
return this;
}
@@ -740,8 +729,7 @@
*
* <p>The default is true for all styles except for {@link #DIFFERENCE_STYLE_STOPWATCH}.
*/
- @NonNull
- public TimeDifferenceBuilder setShowNowText(boolean showNowText) {
+ public @NonNull TimeDifferenceBuilder setShowNowText(boolean showNowText) {
mShowNowText = showNowText;
return this;
}
@@ -762,15 +750,13 @@
* #DIFFERENCE_STYLE_SHORT_SINGLE_UNIT}, then a minimum unit of {@link TimeUnit#SECONDS}
* will have no effect.
*/
- @NonNull
- public TimeDifferenceBuilder setMinimumUnit(@Nullable TimeUnit minimumUnit) {
+ public @NonNull TimeDifferenceBuilder setMinimumUnit(@Nullable TimeUnit minimumUnit) {
mMinimumUnit = minimumUnit;
return this;
}
/** Returns {@link ComplicationText} representing the time difference as specified. */
- @NonNull
- public ComplicationText build() {
+ public @NonNull ComplicationText build() {
if (mReferencePeriodEndMillis < mReferencePeriodStartMillis) {
throw new IllegalStateException("Reference period end must not be before start.");
}
@@ -806,8 +792,7 @@
* Sets the format that should be applied to the date. This should be a pattern as used by
* {@link java.text.SimpleDateFormat SimpleDateFormat}.
*/
- @NonNull
- public TimeFormatBuilder setFormat(@Nullable String format) {
+ public @NonNull TimeFormatBuilder setFormat(@Nullable String format) {
mFormat = format;
return this;
}
@@ -821,8 +806,7 @@
* @see #FORMAT_STYLE_UPPER_CASE
* @see #FORMAT_STYLE_LOWER_CASE
*/
- @NonNull
- public TimeFormatBuilder setStyle(@TimeFormatStyle int style) {
+ public @NonNull TimeFormatBuilder setStyle(@TimeFormatStyle int style) {
mStyle = style;
return this;
}
@@ -846,8 +830,8 @@
* with {@code ^1} in place of the time difference.
* @return this builder for chaining.
*/
- @NonNull
- public TimeFormatBuilder setSurroundingText(@Nullable CharSequence surroundingText) {
+ public @NonNull TimeFormatBuilder setSurroundingText(
+ @Nullable CharSequence surroundingText) {
mSurroundingText = surroundingText;
return this;
}
@@ -858,16 +842,14 @@
*
* @return this builder for chaining.
*/
- @NonNull
- public TimeFormatBuilder setTimeZone(
- @Nullable @SuppressWarnings("UseIcu") TimeZone timeZone) {
+ public @NonNull TimeFormatBuilder setTimeZone(
+ @SuppressWarnings("UseIcu") @Nullable TimeZone timeZone) {
mTimeZone = timeZone;
return this;
}
/** Returns {@link ComplicationText} including the formatted time as specified. */
- @NonNull
- public ComplicationText build() {
+ public @NonNull ComplicationText build() {
return new ComplicationText(
mSurroundingText, new TimeFormatText(mFormat, mStyle, mTimeZone));
}
diff --git a/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/ComplicationTextTemplate.java b/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/ComplicationTextTemplate.java
index 1e69fdf..e856af2 100644
--- a/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/ComplicationTextTemplate.java
+++ b/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/ComplicationTextTemplate.java
@@ -31,10 +31,11 @@
import android.text.style.TypefaceSpan;
import android.text.style.UnderlineSpan;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.IOException;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
@@ -55,14 +56,12 @@
public static final Creator<ComplicationTextTemplate> CREATOR =
new Creator<ComplicationTextTemplate>() {
@Override
- @NonNull
- public ComplicationTextTemplate createFromParcel(@NonNull Parcel in) {
+ public @NonNull ComplicationTextTemplate createFromParcel(@NonNull Parcel in) {
return new ComplicationTextTemplate(in);
}
@Override
- @NonNull
- public ComplicationTextTemplate[] newArray(int size) {
+ public ComplicationTextTemplate @NonNull [] newArray(int size) {
return new ComplicationTextTemplate[size];
}
};
@@ -77,7 +76,8 @@
private final ComplicationText[] mComplicationTexts;
ComplicationTextTemplate(
- @Nullable CharSequence surroundingText, @NonNull ComplicationText[] complicationTexts) {
+ @Nullable CharSequence surroundingText,
+ ComplicationText @NonNull [] complicationTexts) {
mSurroundingText = surroundingText;
mComplicationTexts = complicationTexts;
checkFields();
@@ -103,11 +103,11 @@
private static class SerializedForm implements Serializable {
@Nullable CharSequence mSurroundingText;
- @NonNull ComplicationText[] mComplicationTexts;
+ ComplicationText @NonNull [] mComplicationTexts;
SerializedForm(
@Nullable CharSequence surroundingText,
- @NonNull ComplicationText[] complicationTexts) {
+ ComplicationText @NonNull [] complicationTexts) {
mSurroundingText = surroundingText;
mComplicationTexts = complicationTexts;
}
@@ -150,9 +150,8 @@
out.writeBundle(bundle);
}
- @NonNull
@Override
- public CharSequence getTextAt(@NonNull Resources resources, long dateTimeMillis) {
+ public @NonNull CharSequence getTextAt(@NonNull Resources resources, long dateTimeMillis) {
final int len = mComplicationTexts.length;
if (len == 0) {
return mSurroundingText;
@@ -195,8 +194,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return "ComplicationTextTemplate{"
+ "surroundingText="
+ mSurroundingText
@@ -214,8 +212,7 @@
private final List<ComplicationText> mTexts = new ArrayList<>(2);
/** Adds a ComplicationText to be applied to the {@link #setSurroundingText} template. */
- @NonNull
- public Builder addComplicationText(@NonNull ComplicationText text) {
+ public @NonNull Builder addComplicationText(@NonNull ComplicationText text) {
mTexts.add(text);
return this;
}
@@ -239,8 +236,7 @@
* @param surroundingText string template
* @return this builder for chaining
*/
- @NonNull
- public Builder setSurroundingText(@Nullable CharSequence surroundingText) {
+ public @NonNull Builder setSurroundingText(@Nullable CharSequence surroundingText) {
mSurroundingText = surroundingText;
return this;
}
@@ -254,8 +250,7 @@
* Returns {@link ComplicationTextTemplate} including the ComplicationText objects formatted
* as specified.
*/
- @NonNull
- public ComplicationTextTemplate build() {
+ public @NonNull ComplicationTextTemplate build() {
if (mTexts.isEmpty()) {
throw new IllegalStateException("At least one text must be specified.");
}
diff --git a/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/IconSerializableHelper.java b/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/IconSerializableHelper.java
index acb56d7..af3d111 100644
--- a/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/IconSerializableHelper.java
+++ b/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/IconSerializableHelper.java
@@ -23,10 +23,11 @@
import android.os.Build;
import android.util.Log;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
@@ -43,16 +44,15 @@
private static final String TAG = "IconSerializableHelper";
- @Nullable
- static IconSerializableHelper create(@Nullable Icon icon) {
+ static @Nullable IconSerializableHelper create(@Nullable Icon icon) {
if (icon == null) {
return null;
}
return new IconSerializableHelper(icon);
}
- @Nullable
- static Icon read(@NonNull ObjectInputStream ois) throws IOException, ClassNotFoundException {
+ static @Nullable Icon read(@NonNull ObjectInputStream ois)
+ throws IOException, ClassNotFoundException {
IconSerializableHelper helper = (IconSerializableHelper) ois.readObject();
if (helper == null) {
return null;
@@ -93,8 +93,7 @@
}
}
- @Nullable
- Icon toIcon() {
+ @Nullable Icon toIcon() {
switch (mType) {
case Icon.TYPE_RESOURCE:
return Icon.createWithResource(mResourcePackage, mResourceId);
diff --git a/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/TimeDependentText.java b/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/TimeDependentText.java
index efd0b58..53df824 100644
--- a/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/TimeDependentText.java
+++ b/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/TimeDependentText.java
@@ -20,9 +20,10 @@
import android.content.res.Resources;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
import java.io.Serializable;
/**
@@ -37,8 +38,7 @@
* @param resources {@link Resources} from the current {@link Context}
* @param dateTimeMillis milliseconds since epoch, e.g. from {@link System#currentTimeMillis}
*/
- @NonNull
- CharSequence getTextAt(@NonNull Resources resources, long dateTimeMillis);
+ @NonNull CharSequence getTextAt(@NonNull Resources resources, long dateTimeMillis);
/**
* Returns true if the result of {@link #getTextAt} will be the same for both {@code
diff --git a/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/TimeDifferenceText.java b/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/TimeDifferenceText.java
index c2ac4fd..e491f80 100644
--- a/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/TimeDifferenceText.java
+++ b/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/TimeDifferenceText.java
@@ -20,11 +20,12 @@
import android.content.res.Resources;
import android.os.Parcel;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.wear.watchface.complications.data.R;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.Serializable;
@@ -54,7 +55,7 @@
private final boolean mShowNowText;
- @Nullable private final TimeUnit mMinimumUnit;
+ private final @Nullable TimeUnit mMinimumUnit;
public TimeDifferenceText(
long referencePeriodStart,
@@ -87,9 +88,8 @@
mReferencePeriodStart, mReferencePeriodEnd, mStyle, mShowNowText, mMinimumUnit);
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
if (ComplicationData.shouldRedact()) {
return "TimeDifferenceText{Redacted}";
}
@@ -144,9 +144,8 @@
throw new InvalidObjectException("Use SerializedForm");
}
- @NonNull
@Override
- public CharSequence getTextAt(@NonNull Resources resources, long dateTimeMillis) {
+ public @NonNull CharSequence getTextAt(@NonNull Resources resources, long dateTimeMillis) {
long timeDifference = getTimeDifference(dateTimeMillis);
if (timeDifference == 0 && mShowNowText) {
@@ -224,8 +223,7 @@
}
/** Returns the minimum unit specified, or {@code null} if none has been specified. */
- @Nullable
- public TimeUnit getMinimumUnit() {
+ public @Nullable TimeUnit getMinimumUnit() {
return mMinimumUnit;
}
@@ -493,15 +491,13 @@
public static final Creator<TimeDifferenceText> CREATOR =
new Creator<TimeDifferenceText>() {
- @NonNull
@Override
- public TimeDifferenceText createFromParcel(@NonNull Parcel source) {
+ public @NonNull TimeDifferenceText createFromParcel(@NonNull Parcel source) {
return new TimeDifferenceText(source);
}
- @NonNull
@Override
- public TimeDifferenceText[] newArray(int size) {
+ public TimeDifferenceText @NonNull [] newArray(int size) {
return new TimeDifferenceText[size];
}
};
diff --git a/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/TimeFormatText.java b/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/TimeFormatText.java
index 1ecdca3..f160cbd 100644
--- a/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/TimeFormatText.java
+++ b/wear/watchface/watchface-complications-data/src/main/java/android/support/wearable/complications/TimeFormatText.java
@@ -19,10 +19,11 @@
import android.content.res.Resources;
import android.os.Parcel;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
import java.io.Serializable;
@@ -57,9 +58,8 @@
return Objects.hash(mDateFormat, mStyle, mTimeZone, mTimePrecision);
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
if (ComplicationData.shouldRedact()) {
return "TimeFormatText{Redacted}";
}
@@ -158,8 +158,7 @@
}
@Override
- @NonNull
- public CharSequence getTextAt(@NonNull Resources resources, long dateTimeMillis) {
+ public @NonNull CharSequence getTextAt(@NonNull Resources resources, long dateTimeMillis) {
String formattedDate = mDateFormat.format(new Date(dateTimeMillis));
switch (mStyle) {
@@ -209,8 +208,7 @@
return mTimePrecision;
}
- @NonNull
- public String getFormatString() {
+ public @NonNull String getFormatString() {
return mDateFormat.toPattern();
}
@@ -218,8 +216,7 @@
return mStyle;
}
- @Nullable
- public TimeZone getTimeZone() {
+ public @Nullable TimeZone getTimeZone() {
return mTimeZone;
}
@@ -231,8 +228,7 @@
return mTimeZone.getRawOffset();
}
- @NonNull
- private String getDateFormatWithoutText(String format) {
+ private @NonNull String getDateFormatWithoutText(String format) {
StringBuilder result = new StringBuilder();
boolean isTextPart = false;
int index = 0;
@@ -277,14 +273,12 @@
public static final Creator<TimeFormatText> CREATOR =
new Creator<TimeFormatText>() {
@Override
- @NonNull
- public TimeFormatText createFromParcel(@NonNull Parcel source) {
+ public @NonNull TimeFormatText createFromParcel(@NonNull Parcel source) {
return new TimeFormatText(source);
}
@Override
- @NonNull
- public TimeFormatText[] newArray(int size) {
+ public TimeFormatText @NonNull [] newArray(int size) {
return new TimeFormatText[size];
}
};
diff --git a/wear/watchface/watchface-complications-data/src/main/java/androidx/wear/watchface/complications/data/DefaultComplicationDataSourcePolicyWireFormat.java b/wear/watchface/watchface-complications-data/src/main/java/androidx/wear/watchface/complications/data/DefaultComplicationDataSourcePolicyWireFormat.java
index f0c76c2..97a0a05 100644
--- a/wear/watchface/watchface-complications-data/src/main/java/androidx/wear/watchface/complications/data/DefaultComplicationDataSourcePolicyWireFormat.java
+++ b/wear/watchface/watchface-complications-data/src/main/java/androidx/wear/watchface/complications/data/DefaultComplicationDataSourcePolicyWireFormat.java
@@ -22,13 +22,14 @@
import android.os.Parcelable;
import android.support.wearable.complications.ComplicationData;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
import java.util.List;
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@@ -38,8 +39,7 @@
implements VersionedParcelable, Parcelable {
@ParcelField(1)
- @NonNull
- public List<ComponentName> mDefaultDataSourcesToTry;
+ public @NonNull List<ComponentName> mDefaultDataSourcesToTry;
@ParcelField(2)
public int mFallbackSystemDataSource;
diff --git a/wear/watchface/watchface-complications-rendering/build.gradle b/wear/watchface/watchface-complications-rendering/build.gradle
index 1d5e136a..25388ff 100644
--- a/wear/watchface/watchface-complications-rendering/build.gradle
+++ b/wear/watchface/watchface-complications-rendering/build.gradle
@@ -31,6 +31,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.annotation:annotation:1.8.1")
api(project(":wear:watchface:watchface-complications-data"))
api(project(":wear:watchface:watchface"))
diff --git a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/ComplicationRenderer.java b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/ComplicationRenderer.java
index 1e188f9..50b9b20 100644
--- a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/ComplicationRenderer.java
+++ b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/ComplicationRenderer.java
@@ -47,8 +47,6 @@
import android.text.Layout;
import android.text.TextPaint;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.wear.watchface.complications.data.ImageKt;
@@ -62,6 +60,9 @@
import androidx.wear.watchface.complications.rendering.utils.ShortTextLayoutHelper;
import androidx.wear.watchface.complications.rendering.utils.SmallImageLayoutHelper;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.time.Instant;
import java.util.Objects;
@@ -208,16 +209,16 @@
PaintSet mAmbientPaintSetLostTapAction = null;
// Paints for texts
- @Nullable private TextPaint mMainTextPaint = null;
- @Nullable private TextPaint mSubTextPaint = null;
+ private @Nullable TextPaint mMainTextPaint = null;
+ private @Nullable TextPaint mSubTextPaint = null;
// Styles for active and ambient modes.
private ComplicationStyle mActiveStyle;
private ComplicationStyle mAmbientStyle;
- @Nullable private Paint mDebugPaint;
+ private @Nullable Paint mDebugPaint;
- @Nullable private OnInvalidateListener mInvalidateListener;
+ private @Nullable OnInvalidateListener mInvalidateListener;
/**
* Initializes complication renderer.
@@ -1413,57 +1414,48 @@
}
}
- @NonNull
@VisibleForTesting
- public Rect getBounds() {
+ public @NonNull Rect getBounds() {
return mBounds;
}
- @NonNull
@VisibleForTesting
- public Rect getIconBounds() {
+ public @NonNull Rect getIconBounds() {
return mIconBounds;
}
- @Nullable
@VisibleForTesting
- public Drawable getIcon() {
+ public @Nullable Drawable getIcon() {
return mIcon;
}
- @Nullable
@VisibleForTesting
- public Drawable getSmallImage() {
+ public @Nullable Drawable getSmallImage() {
return mSmallImage;
}
- @Nullable
@VisibleForTesting
- public Drawable getBurnInProtectionIcon() {
+ public @Nullable Drawable getBurnInProtectionIcon() {
return mBurnInProtectionIcon;
}
- @Nullable
@VisibleForTesting
- public Drawable getBurnInProtectionSmallImage() {
+ public @Nullable Drawable getBurnInProtectionSmallImage() {
return mBurnInProtectionSmallImage;
}
- @Nullable
@VisibleForTesting
- public RoundedDrawable getRoundedSmallImage() {
+ public @Nullable RoundedDrawable getRoundedSmallImage() {
return mRoundedSmallImage;
}
- @NonNull
@VisibleForTesting
- public Rect getMainTextBounds() {
+ public @NonNull Rect getMainTextBounds() {
return mMainTextBounds;
}
- @NonNull
@VisibleForTesting
- public Rect getSubTextBounds() {
+ public @NonNull Rect getSubTextBounds() {
return mSubTextBounds;
}
@@ -1503,8 +1495,8 @@
* restricted to black, white or transparent. All text and icon colors in the returned style
* will be set to white.
*/
- @NonNull
- private static ComplicationStyle lowBitAmbientStyleFrom(@NonNull ComplicationStyle style) {
+ private static @NonNull ComplicationStyle lowBitAmbientStyleFrom(
+ @NonNull ComplicationStyle style) {
ComplicationStyle newStyle = new ComplicationStyle(style);
if (style.getBackgroundColor() != Color.BLACK) {
newStyle.setBackgroundColor(Color.TRANSPARENT);
diff --git a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/EmojiHelper.java b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/EmojiHelper.java
index 1bc7128..c7a4566 100644
--- a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/EmojiHelper.java
+++ b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/EmojiHelper.java
@@ -16,9 +16,10 @@
package androidx.wear.watchface.complications.rendering;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.Nullable;
+
/**
* Class to detect and replace emoji in CharSequences.
*
@@ -66,8 +67,7 @@
* Returns a String with all emoji replaced with the given character. This method will remove
* consequent emoji.
*/
- @Nullable
- static String replaceEmoji(@Nullable CharSequence text, int newCharacter) {
+ static @Nullable String replaceEmoji(@Nullable CharSequence text, int newCharacter) {
if (text == null) {
return null;
}
diff --git a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/RoundedDrawable.java b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/RoundedDrawable.java
index 242c1cc..a121626 100644
--- a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/RoundedDrawable.java
+++ b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/RoundedDrawable.java
@@ -27,11 +27,12 @@
import android.graphics.Shader;
import android.graphics.drawable.Drawable;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Objects;
/**
@@ -135,8 +136,7 @@
}
/** Converts a drawable to a bitmap of specified width and height. */
- @NonNull
- private Bitmap drawableToBitmap(@NonNull Drawable drawable, int width, int height) {
+ private @NonNull Bitmap drawableToBitmap(@NonNull Drawable drawable, int width, int height) {
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
@@ -159,9 +159,8 @@
return bitmap;
}
- @Nullable
@VisibleForTesting
- Drawable getDrawable() {
+ @Nullable Drawable getDrawable() {
return mDrawable;
}
}
diff --git a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/TextRenderer.java b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/TextRenderer.java
index 6ae3239c..7afe3af 100644
--- a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/TextRenderer.java
+++ b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/TextRenderer.java
@@ -37,11 +37,12 @@
import android.view.Gravity;
import android.view.View;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Renders text onto a canvas.
*
@@ -115,9 +116,9 @@
private final Rect mBounds = new Rect();
private TextPaint mPaint;
- @Nullable private String mAmbientModeText;
- @Nullable private CharSequence mOriginalText;
- @Nullable private CharSequence mText;
+ private @Nullable String mAmbientModeText;
+ private @Nullable CharSequence mOriginalText;
+ private @Nullable CharSequence mText;
private float mRelativePaddingStart;
private float mRelativePaddingEnd;
@@ -197,9 +198,8 @@
mNeedUpdateLayout = true;
}
- @NonNull
@VisibleForTesting
- CharSequence applySpanAllowlist(@NonNull CharSequence text) {
+ @NonNull CharSequence applySpanAllowlist(@NonNull CharSequence text) {
if (text instanceof Spanned) {
SpannableStringBuilder builder = new SpannableStringBuilder(text);
Object[] spans = builder.getSpans(0, text.length(), Object.class);
@@ -232,8 +232,7 @@
mNeedUpdateLayout = true;
}
- @NonNull
- public TextPaint getPaint() {
+ public @NonNull TextPaint getPaint() {
return mPaint;
}
@@ -310,7 +309,7 @@
*
* <p>Pass in {@code null} to cause text to be truncated but not ellipsized.
*/
- public void setEllipsize(@Nullable TextUtils.TruncateAt ellipsize) {
+ public void setEllipsize(TextUtils.@Nullable TruncateAt ellipsize) {
if (mEllipsize == ellipsize) {
return;
}
@@ -319,7 +318,7 @@
}
/** Sets the alignment of the text. */
- public void setAlignment(@Nullable Layout.Alignment alignment) {
+ public void setAlignment(Layout.@Nullable Alignment alignment) {
if (mAlignment == alignment) {
return;
}
diff --git a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/IconLayoutHelper.java b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/IconLayoutHelper.java
index 5d8af18..edcdcc6 100644
--- a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/IconLayoutHelper.java
+++ b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/IconLayoutHelper.java
@@ -21,9 +21,10 @@
import android.graphics.Rect;
import android.support.wearable.complications.ComplicationData;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Layout helper for {@link ComplicationData#TYPE_ICON}.
*
diff --git a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/LargeImageLayoutHelper.java b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/LargeImageLayoutHelper.java
index e7e646de..1e48a02 100644
--- a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/LargeImageLayoutHelper.java
+++ b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/LargeImageLayoutHelper.java
@@ -21,9 +21,10 @@
import android.graphics.Rect;
import android.support.wearable.complications.ComplicationData;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Layout helper for {@link ComplicationData#TYPE_LARGE_IMAGE}.
*
diff --git a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/LayoutHelper.java b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/LayoutHelper.java
index 6f57baf..0204e97 100644
--- a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/LayoutHelper.java
+++ b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/LayoutHelper.java
@@ -22,10 +22,11 @@
import android.text.Layout.Alignment;
import android.view.Gravity;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Common superclass for layout helpers. Layout helpers are used to calculate bounds for each
* element depending on width, height of the complication and complication data.
@@ -73,8 +74,7 @@
/**
* @return The {@link ComplicationData} associated with this {@link LayoutHelper}
*/
- @Nullable
- public ComplicationData getComplicationData() {
+ public @Nullable ComplicationData getComplicationData() {
return mComplicationData;
}
@@ -116,8 +116,7 @@
/**
* @return The {@link Layout.Alignment} to use with short text
*/
- @NonNull
- public Layout.Alignment getShortTextAlignment() {
+ public Layout.@NonNull Alignment getShortTextAlignment() {
return Alignment.ALIGN_CENTER;
}
@@ -138,8 +137,7 @@
/**
* @return The {@link Layout.Alignment} to use with short title text
*/
- @NonNull
- public Layout.Alignment getShortTitleAlignment() {
+ public Layout.@NonNull Alignment getShortTitleAlignment() {
return Alignment.ALIGN_CENTER;
}
@@ -160,8 +158,7 @@
/**
* @return The {@link Layout.Alignment} to use with long text
*/
- @NonNull
- public Layout.Alignment getLongTextAlignment() {
+ public Layout.@NonNull Alignment getLongTextAlignment() {
return Alignment.ALIGN_CENTER;
}
@@ -182,8 +179,7 @@
/**
* @return The {@link Layout.Alignment} to use with long title text
*/
- @NonNull
- public Layout.Alignment getLongTitleAlignment() {
+ public Layout.@NonNull Alignment getLongTitleAlignment() {
return Alignment.ALIGN_CENTER;
}
diff --git a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/LayoutUtils.java b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/LayoutUtils.java
index a147fe4..8c0a47f 100644
--- a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/LayoutUtils.java
+++ b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/LayoutUtils.java
@@ -18,9 +18,10 @@
import android.graphics.Rect;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Utilities for calculations related to bounds.
*
diff --git a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/LongTextLayoutHelper.java b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/LongTextLayoutHelper.java
index c4afab4..9b3cfb7 100644
--- a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/LongTextLayoutHelper.java
+++ b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/LongTextLayoutHelper.java
@@ -27,9 +27,10 @@
import android.text.Layout;
import android.view.Gravity;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Layout helper for {@link ComplicationData#TYPE_LONG_TEXT}.
*
@@ -91,9 +92,8 @@
}
}
- @NonNull
@Override
- public Layout.Alignment getLongTextAlignment() {
+ public Layout.@NonNull Alignment getLongTextAlignment() {
getBounds(mBounds);
if (shouldShowTextOnly(mBounds)) {
return Layout.Alignment.ALIGN_CENTER;
@@ -127,9 +127,8 @@
}
}
- @NonNull
@Override
- public Layout.Alignment getLongTitleAlignment() {
+ public Layout.@NonNull Alignment getLongTitleAlignment() {
return getLongTextAlignment();
}
diff --git a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/RangedValueLayoutHelper.java b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/RangedValueLayoutHelper.java
index ebf96ed..9ef17b5 100644
--- a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/RangedValueLayoutHelper.java
+++ b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/RangedValueLayoutHelper.java
@@ -29,10 +29,11 @@
import android.text.Layout;
import android.view.Gravity;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Layout helper for {@link ComplicationData#TYPE_RANGED_VALUE}.
*
@@ -139,9 +140,8 @@
}
}
- @NonNull
@Override
- public Layout.Alignment getShortTextAlignment() {
+ public Layout.@NonNull Alignment getShortTextAlignment() {
getBounds(mBounds);
if (isWideRectangle(mBounds)) {
return Layout.Alignment.ALIGN_NORMAL;
@@ -187,9 +187,8 @@
}
}
- @NonNull
@Override
- public Layout.Alignment getShortTitleAlignment() {
+ public Layout.@NonNull Alignment getShortTitleAlignment() {
return getShortTextAlignment();
}
diff --git a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/ShortTextLayoutHelper.java b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/ShortTextLayoutHelper.java
index 9a8c1e1..4c75f41 100644
--- a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/ShortTextLayoutHelper.java
+++ b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/ShortTextLayoutHelper.java
@@ -28,9 +28,10 @@
import android.text.Layout;
import android.view.Gravity;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Layout helper for {@link ComplicationData#TYPE_SHORT_TEXT}.
*
@@ -77,9 +78,8 @@
}
}
- @NonNull
@Override
- public Layout.Alignment getShortTextAlignment() {
+ public Layout.@NonNull Alignment getShortTextAlignment() {
getBounds(mBounds);
if (isWideRectangle(mBounds) && hasIcon()) {
// Wide rectangle with an icon available, align normal
@@ -120,9 +120,8 @@
// Text only, no-op here.
}
- @NonNull
@Override
- public Layout.Alignment getShortTitleAlignment() {
+ public Layout.@NonNull Alignment getShortTitleAlignment() {
return getShortTextAlignment();
}
diff --git a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/SmallImageLayoutHelper.java b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/SmallImageLayoutHelper.java
index af362ec..13f96db 100644
--- a/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/SmallImageLayoutHelper.java
+++ b/wear/watchface/watchface-complications-rendering/src/main/java/androidx/wear/watchface/complications/rendering/utils/SmallImageLayoutHelper.java
@@ -21,9 +21,10 @@
import android.graphics.Rect;
import android.support.wearable.complications.ComplicationData;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Layout helper for {@link ComplicationData#TYPE_SMALL_IMAGE}.
*
diff --git a/wear/watchface/watchface-complications-rendering/src/test/java/androidx/wear/watchface/complications/rendering/ComplicationDrawableTest.java b/wear/watchface/watchface-complications-rendering/src/test/java/androidx/wear/watchface/complications/rendering/ComplicationDrawableTest.java
index 1241de7..0c4ecf3 100644
--- a/wear/watchface/watchface-complications-rendering/src/test/java/androidx/wear/watchface/complications/rendering/ComplicationDrawableTest.java
+++ b/wear/watchface/watchface-complications-rendering/src/test/java/androidx/wear/watchface/complications/rendering/ComplicationDrawableTest.java
@@ -46,7 +46,6 @@
import android.support.wearable.complications.ComplicationText;
import android.view.SurfaceHolder;
-import androidx.annotation.NonNull;
import androidx.test.core.app.ApplicationProvider;
import androidx.wear.watchface.CanvasType;
import androidx.wear.watchface.ComplicationHelperActivity;
@@ -63,6 +62,7 @@
import kotlin.coroutines.Continuation;
import org.jetbrains.annotations.Nullable;
+import org.jspecify.annotations.NonNull;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
diff --git a/wear/watchface/watchface-complications-rendering/src/test/java/androidx/wear/watchface/complications/rendering/ComplicationsTestRunner.java b/wear/watchface/watchface-complications-rendering/src/test/java/androidx/wear/watchface/complications/rendering/ComplicationsTestRunner.java
index e318640..a4c5ddc 100644
--- a/wear/watchface/watchface-complications-rendering/src/test/java/androidx/wear/watchface/complications/rendering/ComplicationsTestRunner.java
+++ b/wear/watchface/watchface-complications-rendering/src/test/java/androidx/wear/watchface/complications/rendering/ComplicationsTestRunner.java
@@ -16,8 +16,7 @@
package androidx.wear.watchface.complications.rendering;
-import androidx.annotation.NonNull;
-
+import org.jspecify.annotations.NonNull;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.robolectric.RobolectricTestRunner;
@@ -29,9 +28,9 @@
super(clazz);
}
- @NonNull
@Override
- protected InstrumentationConfiguration createClassLoaderConfig(FrameworkMethod method) {
+ protected @NonNull InstrumentationConfiguration createClassLoaderConfig(
+ FrameworkMethod method) {
return new InstrumentationConfiguration.Builder(super.createClassLoaderConfig(method))
.doNotInstrumentPackage("android.support.wearable.complicationSlots")
.doNotInstrumentPackage("android.support.wearable.watchface")
diff --git a/wear/watchface/watchface-data/build.gradle b/wear/watchface/watchface-data/build.gradle
index dc4a433..3ba380a 100644
--- a/wear/watchface/watchface-data/build.gradle
+++ b/wear/watchface/watchface-data/build.gradle
@@ -30,6 +30,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.annotation:annotation:1.8.1")
api("androidx.versionedparcelable:versionedparcelable:1.1.0")
api(project(":wear:watchface:watchface-complications-data"))
diff --git a/wear/watchface/watchface-data/src/main/java/android/support/wearable/watchface/accessibility/AccessibilityUtils.java b/wear/watchface/watchface-data/src/main/java/android/support/wearable/watchface/accessibility/AccessibilityUtils.java
index 0396ef1..671b1db 100644
--- a/wear/watchface/watchface-data/src/main/java/android/support/wearable/watchface/accessibility/AccessibilityUtils.java
+++ b/wear/watchface/watchface-data/src/main/java/android/support/wearable/watchface/accessibility/AccessibilityUtils.java
@@ -20,9 +20,10 @@
import android.support.wearable.complications.ComplicationText;
import android.text.format.DateFormat;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/** Utilities for making watch faces and complications accessible. */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public class AccessibilityUtils {
@@ -33,8 +34,7 @@
* Returns a new {@link ComplicationText} that displays the current time in the default
* timezone.
*/
- @NonNull
- public static ComplicationText makeTimeAsComplicationText(@NonNull Context context) {
+ public static @NonNull ComplicationText makeTimeAsComplicationText(@NonNull Context context) {
final String format;
if (DateFormat.is24HourFormat(context)) {
format = "HH:mm";
diff --git a/wear/watchface/watchface-data/src/main/java/android/support/wearable/watchface/accessibility/ContentDescriptionLabel.java b/wear/watchface/watchface-data/src/main/java/android/support/wearable/watchface/accessibility/ContentDescriptionLabel.java
index 3b06491..eb0c00a 100644
--- a/wear/watchface/watchface-data/src/main/java/android/support/wearable/watchface/accessibility/ContentDescriptionLabel.java
+++ b/wear/watchface/watchface-data/src/main/java/android/support/wearable/watchface/accessibility/ContentDescriptionLabel.java
@@ -17,22 +17,18 @@
package android.support.wearable.watchface.accessibility;
import android.app.PendingIntent;
-import android.content.Context;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
-import android.support.wearable.complications.ComplicationData;
-import android.support.wearable.complications.ComplicationDataKt;
-import android.support.wearable.complications.ComplicationText;
-import android.support.wearable.complications.ComplicationTextTemplate;
import android.support.wearable.complications.TimeDependentText;
import android.support.wearable.watchface.Constants;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Objects;
/** Holds labels for screen regions which should respond to accessibility events. */
@@ -43,15 +39,13 @@
@SuppressWarnings("unused")
public static final Parcelable.Creator<ContentDescriptionLabel> CREATOR =
new Parcelable.Creator<ContentDescriptionLabel>() {
- @NonNull
@Override
- public ContentDescriptionLabel createFromParcel(@NonNull Parcel in) {
+ public @NonNull ContentDescriptionLabel createFromParcel(@NonNull Parcel in) {
return new ContentDescriptionLabel(in);
}
- @NonNull
@Override
- public ContentDescriptionLabel[] newArray(int size) {
+ public ContentDescriptionLabel @NonNull [] newArray(int size) {
return new ContentDescriptionLabel[size];
}
};
@@ -95,20 +89,17 @@
}
/** Returns the absolute coordinates of where this label should appear on the screen. */
- @NonNull
- public Rect getBounds() {
+ public @NonNull Rect getBounds() {
return mBounds;
}
/** Returns the {@link TimeDependentText} describing this label. */
- @NonNull
- public TimeDependentText getText() {
+ public @NonNull TimeDependentText getText() {
return mText;
}
/** Returns the optional {@link PendingIntent} to launch when this label is tapped. */
- @Nullable
- public PendingIntent getTapAction() {
+ public @Nullable PendingIntent getTapAction() {
return mTapAction;
}
@@ -146,9 +137,8 @@
dest.writeBundle(bundle);
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
return "ContentDescriptionLabel{text="
+ mText
+ ", bounds="
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/ComplicationRenderParams.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/ComplicationRenderParams.java
index ca6a2ab..687b3d0 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/ComplicationRenderParams.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/ComplicationRenderParams.java
@@ -21,8 +21,6 @@
import android.os.Parcelable;
import android.support.wearable.complications.ComplicationData;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
@@ -31,6 +29,9 @@
import androidx.wear.watchface.data.RenderParametersWireFormat;
import androidx.wear.watchface.style.data.UserStyleWireFormat;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Parameters for the various AIDL renderComplicationToBitmap commands.
*
@@ -46,8 +47,7 @@
/** The {@link RenderParametersWireFormat} to render with. */
@ParcelField(2)
- @NonNull
- RenderParametersWireFormat mRenderParametersWireFormats;
+ @NonNull RenderParametersWireFormat mRenderParametersWireFormats;
/** The UTC time in milliseconds since the epoch to render with. */
@ParcelField(4)
@@ -59,16 +59,14 @@
* complication.
*/
@ParcelField(5)
- @Nullable
- ComplicationData mComplicationData;
+ @Nullable ComplicationData mComplicationData;
/**
* The {@link UserStyleWireFormat} to render with. If null then interactive watch faces will
* render with the current style, and headless watch faces will render with the default style.
*/
@ParcelField(6)
- @Nullable
- UserStyleWireFormat mUserStyle;
+ @Nullable UserStyleWireFormat mUserStyle;
/** Used by VersionedParcelable. */
ComplicationRenderParams() {}
@@ -90,8 +88,7 @@
return mComplicationSlotId;
}
- @NonNull
- public RenderParametersWireFormat getRenderParametersWireFormat() {
+ public @NonNull RenderParametersWireFormat getRenderParametersWireFormat() {
return mRenderParametersWireFormats;
}
@@ -100,13 +97,11 @@
return mCalendarTimeMillis;
}
- @Nullable
- public ComplicationData getComplicationData() {
+ public @Nullable ComplicationData getComplicationData() {
return mComplicationData;
}
- @Nullable
- public UserStyleWireFormat getUserStyle() {
+ public @Nullable UserStyleWireFormat getUserStyle() {
return mUserStyle;
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/CrashInfoParcel.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/CrashInfoParcel.java
index 9963a3e..4ce759e 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/CrashInfoParcel.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/CrashInfoParcel.java
@@ -23,9 +23,10 @@
import android.os.Parcelable;
import android.util.StringBuilderPrinter;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Used for sending details of an exception over aidl.
*
@@ -33,7 +34,7 @@
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@SuppressLint("BanParcelableUsage")
public class CrashInfoParcel implements Parcelable {
- @NonNull public final CrashInfo crashInfo;
+ public final @NonNull CrashInfo crashInfo;
public CrashInfoParcel(@NonNull Throwable exception) {
crashInfo = new CrashInfo(exception);
@@ -66,9 +67,8 @@
}
};
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
StringBuilder sb = new StringBuilder();
StringBuilderPrinter pr = new StringBuilderPrinter(sb);
crashInfo.dump(pr, "");
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/DefaultProviderPoliciesParams.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/DefaultProviderPoliciesParams.java
index aedf178..21f6bcd 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/DefaultProviderPoliciesParams.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/DefaultProviderPoliciesParams.java
@@ -21,13 +21,14 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
/**
* Parameters for {@link IWatchFaceControlService#getDefaultProviderPolicies}.
*
@@ -39,8 +40,7 @@
/** The {@link ComponentName} of the watchface family to create. */
@ParcelField(1)
- @NonNull
- ComponentName mWatchFaceName;
+ @NonNull ComponentName mWatchFaceName;
/** Used by VersionedParcelable. */
DefaultProviderPoliciesParams() {}
@@ -49,8 +49,7 @@
mWatchFaceName = watchFaceName;
}
- @NonNull
- public ComponentName getWatchFaceName() {
+ public @NonNull ComponentName getWatchFaceName() {
return mWatchFaceName;
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/GetComplicationSlotMetadataParams.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/GetComplicationSlotMetadataParams.java
index 7e17477..25dd62c 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/GetComplicationSlotMetadataParams.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/GetComplicationSlotMetadataParams.java
@@ -21,13 +21,14 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
/**
* Parameters for {@link IWatchFaceControlService#getComplicationSlotMetadata}.
*
@@ -39,8 +40,7 @@
/** The {@link ComponentName} of the watchface family to create. */
@ParcelField(1)
- @NonNull
- ComponentName mWatchFaceName;
+ @NonNull ComponentName mWatchFaceName;
/** Used by VersionedParcelable. */
GetComplicationSlotMetadataParams() {}
@@ -49,8 +49,7 @@
mWatchFaceName = watchFaceName;
}
- @NonNull
- public ComponentName getWatchFaceName() {
+ public @NonNull ComponentName getWatchFaceName() {
return mWatchFaceName;
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/GetUserStyleFlavorsParams.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/GetUserStyleFlavorsParams.java
index e26642cde..e8a8661 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/GetUserStyleFlavorsParams.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/GetUserStyleFlavorsParams.java
@@ -21,13 +21,14 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
/**
* Parameters for {@link IWatchFaceControlService#GetUserStyleFlavors}.
*
@@ -39,8 +40,7 @@
/** The {@link ComponentName} of the watchface family to create. */
@ParcelField(1)
- @NonNull
- ComponentName mWatchFaceName;
+ @NonNull ComponentName mWatchFaceName;
/** Used by VersionedParcelable. */
GetUserStyleFlavorsParams() {}
@@ -49,8 +49,7 @@
mWatchFaceName = watchFaceName;
}
- @NonNull
- public ComponentName getWatchFaceName() {
+ public @NonNull ComponentName getWatchFaceName() {
return mWatchFaceName;
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/GetUserStyleSchemaParams.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/GetUserStyleSchemaParams.java
index 776922b..57a4a19 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/GetUserStyleSchemaParams.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/GetUserStyleSchemaParams.java
@@ -21,13 +21,14 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
/**
* Parameters for {@link IWatchFaceControlService#GetUserStyleSchema}.
*
@@ -39,8 +40,7 @@
/** The {@link ComponentName} of the watchface family to create. */
@ParcelField(1)
- @NonNull
- ComponentName mWatchFaceName;
+ @NonNull ComponentName mWatchFaceName;
/** Used by VersionedParcelable. */
GetUserStyleSchemaParams() {}
@@ -49,8 +49,7 @@
mWatchFaceName = watchFaceName;
}
- @NonNull
- public ComponentName getWatchFaceName() {
+ public @NonNull ComponentName getWatchFaceName() {
return mWatchFaceName;
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/HeadlessWatchFaceInstanceParams.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/HeadlessWatchFaceInstanceParams.java
index 88103ae..9925ea9 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/HeadlessWatchFaceInstanceParams.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/HeadlessWatchFaceInstanceParams.java
@@ -21,8 +21,6 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
@@ -30,6 +28,9 @@
import androidx.versionedparcelable.VersionedParcelize;
import androidx.wear.watchface.data.DeviceConfig;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Parameters for {@link IWatchFaceControlService#createHeadlessWatchFaceInstance}.
*
@@ -41,13 +42,11 @@
/** The {@link ComponentName} of the watchface family to create. */
@ParcelField(1)
- @NonNull
- ComponentName mWatchFaceName;
+ @NonNull ComponentName mWatchFaceName;
/** The {@link DeviceConfig} for the host wearable. */
@ParcelField(2)
- @NonNull
- DeviceConfig mDeviceConfig;
+ @NonNull DeviceConfig mDeviceConfig;
/** The desired width for screenshots. */
@ParcelField(3)
@@ -93,13 +92,11 @@
mInstanceId = instanceId;
}
- @NonNull
- public ComponentName getWatchFaceName() {
+ public @NonNull ComponentName getWatchFaceName() {
return mWatchFaceName;
}
- @NonNull
- public DeviceConfig getDeviceConfig() {
+ public @NonNull DeviceConfig getDeviceConfig() {
return mDeviceConfig;
}
@@ -111,8 +108,7 @@
return mHeight;
}
- @Nullable
- public String getInstanceId() {
+ public @Nullable String getInstanceId() {
return mInstanceId;
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/IdTypeAndDefaultProviderPolicyWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/IdTypeAndDefaultProviderPolicyWireFormat.java
index a3db1ab..5df0bdb 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/IdTypeAndDefaultProviderPolicyWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/IdTypeAndDefaultProviderPolicyWireFormat.java
@@ -22,14 +22,15 @@
import android.os.Parcelable;
import android.support.wearable.complications.ComplicationData;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
@@ -46,8 +47,7 @@
int mId;
@ParcelField(2)
- @Nullable
- List<ComponentName> mDefaultProvidersToTry;
+ @Nullable List<ComponentName> mDefaultProvidersToTry;
@ParcelField(3)
int mFallbackSystemProvider;
@@ -78,8 +78,7 @@
* Along with {@link #getFallbackSystemProvider} this is the wire format for
* DefaultComplicationDataSourcePolicy.
*/
- @Nullable
- public List<ComponentName> getDefaultProvidersToTry() {
+ public @Nullable List<ComponentName> getDefaultProvidersToTry() {
return mDefaultProvidersToTry;
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/WallpaperInteractiveWatchFaceInstanceParams.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/WallpaperInteractiveWatchFaceInstanceParams.java
index f9ea844..3a66899 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/WallpaperInteractiveWatchFaceInstanceParams.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/WallpaperInteractiveWatchFaceInstanceParams.java
@@ -23,8 +23,6 @@
import android.os.Parcelable;
import android.util.Log;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
@@ -36,6 +34,9 @@
import androidx.wear.watchface.data.WatchUiState;
import androidx.wear.watchface.style.data.UserStyleWireFormat;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
@@ -52,38 +53,31 @@
/** The id for the new instance, must be unique. */
@ParcelField(1)
- @NonNull
- String mInstanceId;
+ @NonNull String mInstanceId;
/** The {@link DeviceConfig} for the host wearable. */
@ParcelField(2)
- @NonNull
- DeviceConfig mDeviceConfig;
+ @NonNull DeviceConfig mDeviceConfig;
/** The {@link WatchUiState} for the host wearable. */
@ParcelField(3)
- @NonNull
- WatchUiState mWatchUiState;
+ @NonNull WatchUiState mWatchUiState;
/** The initial {@link UserStyleWireFormat}. */
@ParcelField(4)
- @NonNull
- UserStyleWireFormat mUserStyle;
+ @NonNull UserStyleWireFormat mUserStyle;
/** The initial state of the complications if known, or null otherwise. */
@ParcelField(100)
- @Nullable
- List<IdAndComplicationDataWireFormat> mIdAndComplicationDataWireFormats;
+ @Nullable List<IdAndComplicationDataWireFormat> mIdAndComplicationDataWireFormats;
/** Reserved field */
@ParcelField(101)
- @Nullable
- String mAuxiliaryComponentClassName;
+ @Nullable String mAuxiliaryComponentClassName;
/** Reserved field */
@ParcelField(102)
- @Nullable
- String mAuxiliaryComponentPackageName;
+ @Nullable String mAuxiliaryComponentPackageName;
/** Used by VersionedParcelable. */
WallpaperInteractiveWatchFaceInstanceParams() {}
@@ -105,23 +99,19 @@
mAuxiliaryComponentPackageName = auxiliaryComponentPackageName;
}
- @NonNull
- public String getInstanceId() {
+ public @NonNull String getInstanceId() {
return mInstanceId;
}
- @NonNull
- public DeviceConfig getDeviceConfig() {
+ public @NonNull DeviceConfig getDeviceConfig() {
return mDeviceConfig;
}
- @NonNull
- public WatchUiState getWatchUiState() {
+ public @NonNull WatchUiState getWatchUiState() {
return mWatchUiState;
}
- @NonNull
- public UserStyleWireFormat getUserStyle() {
+ public @NonNull UserStyleWireFormat getUserStyle() {
// TODO (b/284971375): This check really shouldn't be necessary.
if (mUserStyle == null) {
Log.e(TAG, "WallpaperInteractiveWatchFaceInstanceParams with null mUserStyle",
@@ -135,8 +125,7 @@
mUserStyle = userStyle;
}
- @Nullable
- public List<IdAndComplicationDataWireFormat> getIdAndComplicationDataWireFormats() {
+ public @Nullable List<IdAndComplicationDataWireFormat> getIdAndComplicationDataWireFormats() {
return mIdAndComplicationDataWireFormats;
}
@@ -145,13 +134,11 @@
mIdAndComplicationDataWireFormats = idAndComplicationDataWireFormats;
}
- @Nullable
- public String getAuxiliaryComponentClassName() {
+ public @Nullable String getAuxiliaryComponentClassName() {
return mAuxiliaryComponentClassName;
}
- @Nullable
- public String getAuxiliaryComponentPackageName() {
+ public @Nullable String getAuxiliaryComponentPackageName() {
return mAuxiliaryComponentPackageName;
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/WatchFaceRenderParams.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/WatchFaceRenderParams.java
index 22bf3d9..2a59b32 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/WatchFaceRenderParams.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/control/data/WatchFaceRenderParams.java
@@ -20,8 +20,6 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
@@ -31,6 +29,9 @@
import androidx.wear.watchface.data.RenderParametersWireFormat;
import androidx.wear.watchface.style.data.UserStyleWireFormat;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
@@ -43,8 +44,7 @@
public class WatchFaceRenderParams implements VersionedParcelable, Parcelable {
/** The {@link RenderParametersWireFormat} to render with. */
@ParcelField(1)
- @NonNull
- RenderParametersWireFormat mRenderParametersWireFormats;
+ @NonNull RenderParametersWireFormat mRenderParametersWireFormats;
/** The UTC time in milliseconds since the epoch to render with. */
@ParcelField(3)
@@ -55,15 +55,13 @@
* instead.
*/
@ParcelField(5)
- @Nullable
- UserStyleWireFormat mUserStyle;
+ @Nullable UserStyleWireFormat mUserStyle;
/**
* The complications to render with. If null then the current complication data is used instead.
*/
@ParcelField(100)
- @Nullable
- List<IdAndComplicationDataWireFormat> mIdAndComplicationDatumWireFormats;
+ @Nullable List<IdAndComplicationDataWireFormat> mIdAndComplicationDatumWireFormats;
/** Used by VersionedParcelable. */
WatchFaceRenderParams() {}
@@ -79,8 +77,7 @@
mIdAndComplicationDatumWireFormats = idAndComplicationDatumWireFormats;
}
- @NonNull
- public RenderParametersWireFormat getRenderParametersWireFormat() {
+ public @NonNull RenderParametersWireFormat getRenderParametersWireFormat() {
return mRenderParametersWireFormats;
}
@@ -89,13 +86,11 @@
return mCalendarTimeMillis;
}
- @Nullable
- public UserStyleWireFormat getUserStyle() {
+ public @Nullable UserStyleWireFormat getUserStyle() {
return mUserStyle;
}
- @Nullable
- public List<IdAndComplicationDataWireFormat> getIdAndComplicationDatumWireFormats() {
+ public @Nullable List<IdAndComplicationDataWireFormat> getIdAndComplicationDatumWireFormats() {
return mIdAndComplicationDatumWireFormats;
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/BoundingArcWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/BoundingArcWireFormat.java
index b26c1ed..79601b2 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/BoundingArcWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/BoundingArcWireFormat.java
@@ -20,14 +20,15 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
import androidx.wear.watchface.complications.data.ComplicationExperimental;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/** Wire format for BoundingArc. */
// TODO(b/230364881): Mark as @RestrictTo when BoundingArc is no longer experimental.
@VersionedParcelize
@@ -78,8 +79,7 @@
return 0;
}
- @NonNull
- public static final Parcelable.Creator<BoundingArcWireFormat> CREATOR =
+ public static final Parcelable.@NonNull Creator<BoundingArcWireFormat> CREATOR =
new Parcelable.Creator<BoundingArcWireFormat>() {
@SuppressWarnings("deprecation")
@Override
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/ComplicationSlotMetadataWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/ComplicationSlotMetadataWireFormat.java
index b725946..30fb15f 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/ComplicationSlotMetadataWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/ComplicationSlotMetadataWireFormat.java
@@ -24,8 +24,6 @@
import android.os.Parcelable;
import android.support.wearable.complications.ComplicationData;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
@@ -33,6 +31,9 @@
import androidx.versionedparcelable.VersionedParcelize;
import androidx.wear.watchface.complications.data.ComplicationExperimental;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@@ -44,24 +45,20 @@
int mId;
@ParcelField(2)
- @NonNull
- int[] mComplicationBoundsType = new int[0];
+ int @NonNull [] mComplicationBoundsType = new int[0];
@ParcelField(3)
- @NonNull
- RectF[] mComplicationBounds = new RectF[0];
+ RectF @NonNull [] mComplicationBounds = new RectF[0];
@ParcelField(4)
int mBoundsType;
@ParcelField(5)
- @NonNull
@ComplicationData.ComplicationType
- int[] mSupportedTypes = new int[0];
+ int @NonNull [] mSupportedTypes = new int[0];
@ParcelField(6)
- @Nullable
- List<ComponentName> mDefaultDataSourcesToTry;
+ @Nullable List<ComponentName> mDefaultDataSourcesToTry;
@ParcelField(7)
int mFallbackSystemDataSource;
@@ -77,8 +74,7 @@
boolean mFixedComplicationDataSource;
@ParcelField(11)
- @NonNull
- Bundle mComplicationConfigExtras;
+ @NonNull Bundle mComplicationConfigExtras;
// Not supported in library v1.0.
@ParcelField(12)
@@ -92,14 +88,12 @@
// Only valid for edge complications. Not supported in library v1.0.
@ParcelField(14)
- @Nullable
- BoundingArcWireFormat mBoundingArc;
+ @Nullable BoundingArcWireFormat mBoundingArc;
// This needs to be a list because VersionedParcelable appears not to be backwards compatible
// when introducing new arrays.
@ParcelField(value = 15, defaultValue = "null")
- @Nullable
- List<RectF> mComplicationMargins;
+ @Nullable List<RectF> mComplicationMargins;
/** Used by VersionedParcelable. */
ComplicationSlotMetadataWireFormat() {}
@@ -107,11 +101,11 @@
@ComplicationExperimental
public ComplicationSlotMetadataWireFormat(
int id,
- @NonNull int[] complicationBoundsType,
- @NonNull RectF[] complicationBounds,
+ int @NonNull [] complicationBoundsType,
+ RectF @NonNull [] complicationBounds,
@NonNull List<RectF> complicationMargins,
int boundsType,
- @NonNull @ComplicationData.ComplicationType int[] supportedTypes,
+ @ComplicationData.ComplicationType int @NonNull [] supportedTypes,
@Nullable List<ComponentName> defaultDataSourcesToTry,
int fallbackSystemDataSource,
@ComplicationData.ComplicationType int defaultDataSourceType,
@@ -141,10 +135,10 @@
// TODO(b/230364881): Deprecate when BoundingArc is no longer experimental.
public ComplicationSlotMetadataWireFormat(
int id,
- @NonNull int[] complicationBoundsType,
- @NonNull RectF[] complicationBounds,
+ int @NonNull [] complicationBoundsType,
+ RectF @NonNull [] complicationBounds,
int boundsType,
- @NonNull @ComplicationData.ComplicationType int[] supportedTypes,
+ @ComplicationData.ComplicationType int @NonNull [] supportedTypes,
@Nullable List<ComponentName> defaultDataSourcesToTry,
int fallbackSystemDataSource,
@ComplicationData.ComplicationType int defaultDataSourceType,
@@ -175,10 +169,10 @@
@Deprecated
public ComplicationSlotMetadataWireFormat(
int id,
- @NonNull int[] complicationBoundsType,
- @NonNull RectF[] complicationBounds,
+ int @NonNull [] complicationBoundsType,
+ RectF @NonNull [] complicationBounds,
int boundsType,
- @NonNull @ComplicationData.ComplicationType int[] supportedTypes,
+ @ComplicationData.ComplicationType int @NonNull [] supportedTypes,
@Nullable List<ComponentName> defaultDataSourcesToTry,
int fallbackSystemDataSource,
@ComplicationData.ComplicationType int defaultDataSourceType,
@@ -202,18 +196,15 @@
return mId;
}
- @NonNull
- public int[] getComplicationBoundsType() {
+ public int @NonNull [] getComplicationBoundsType() {
return mComplicationBoundsType;
}
- @NonNull
- public RectF[] getComplicationBounds() {
+ public RectF @NonNull [] getComplicationBounds() {
return mComplicationBounds;
}
- @Nullable
- public List<RectF> getComplicationMargins() {
+ public @Nullable List<RectF> getComplicationMargins() {
return mComplicationMargins;
}
@@ -221,9 +212,8 @@
return mBoundsType;
}
- @NonNull
@ComplicationData.ComplicationType
- public int[] getSupportedTypes() {
+ public int @NonNull [] getSupportedTypes() {
return mSupportedTypes;
}
@@ -231,8 +221,7 @@
* Along with {@link #getFallbackSystemDataSource} this is the wire format for
* DefaultComplicationDataSourcePolicy.
*/
- @Nullable
- public List<ComponentName> getDefaultDataSourcesToTry() {
+ public @Nullable List<ComponentName> getDefaultDataSourcesToTry() {
return mDefaultDataSourcesToTry;
}
@@ -287,14 +276,12 @@
return mFixedComplicationDataSource;
}
- @NonNull
- public Bundle getComplicationConfigExtras() {
+ public @NonNull Bundle getComplicationConfigExtras() {
return mComplicationConfigExtras;
}
- @Nullable
@ComplicationExperimental
- public BoundingArcWireFormat getBoundingArc() {
+ public @Nullable BoundingArcWireFormat getBoundingArc() {
return mBoundingArc;
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/ComplicationStateWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/ComplicationStateWireFormat.java
index 670ab54..4ed55668 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/ComplicationStateWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/ComplicationStateWireFormat.java
@@ -24,8 +24,6 @@
import android.os.Parcelable;
import android.support.wearable.complications.ComplicationData;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
@@ -33,6 +31,9 @@
import androidx.versionedparcelable.VersionedParcelize;
import androidx.wear.watchface.complications.data.ComplicationExperimental;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
@@ -44,20 +45,17 @@
@SuppressLint("BanParcelableUsage") // TODO(b/169214666): Remove Parcelable
public final class ComplicationStateWireFormat implements VersionedParcelable, Parcelable {
@ParcelField(1)
- @NonNull
- Rect mBounds;
+ @NonNull Rect mBounds;
@ParcelField(2)
int mBoundsType;
@ParcelField(3)
- @NonNull
@ComplicationData.ComplicationType
- int[] mSupportedTypes;
+ int @NonNull [] mSupportedTypes;
@ParcelField(4)
- @Nullable
- List<ComponentName> mDefaultDataSourcesToTry;
+ @Nullable List<ComponentName> mDefaultDataSourcesToTry;
@ParcelField(5)
int mFallbackSystemProvider;
@@ -80,8 +78,7 @@
boolean mFixedComplicationProvider;
@ParcelField(11)
- @NonNull
- Bundle mComplicationConfigExtras;
+ @NonNull Bundle mComplicationConfigExtras;
// Not supported in library v1.0.
@ParcelField(12)
@@ -103,12 +100,10 @@
// Only valid for edge complications. Not supported in library v1.0.
@ParcelField(16)
- @Nullable
- BoundingArcWireFormat mBoundingArc;
+ @Nullable BoundingArcWireFormat mBoundingArc;
@ParcelField(value = 17, defaultValue = "null")
- @Nullable
- Rect mBoundsWithMargins;
+ @Nullable Rect mBoundsWithMargins;
// NB 0 is not a valid resource id.
private static final int NULL_NAME_RESOURCE_ID = 0;
@@ -121,7 +116,7 @@
@NonNull Rect bounds,
@NonNull Rect boundsWithMargins,
int boundsType,
- @NonNull @ComplicationData.ComplicationType int[] supportedTypes,
+ @ComplicationData.ComplicationType int @NonNull [] supportedTypes,
@Nullable List<ComponentName> defaultDataSourcesToTry,
int fallbackSystemProvider,
@ComplicationData.ComplicationType int defaultDataSourceType,
@@ -161,7 +156,7 @@
public ComplicationStateWireFormat(
@NonNull Rect bounds,
int boundsType,
- @NonNull @ComplicationData.ComplicationType int[] supportedTypes,
+ @ComplicationData.ComplicationType int @NonNull [] supportedTypes,
@Nullable List<ComponentName> defaultDataSourcesToTry,
int fallbackSystemProvider,
@ComplicationData.ComplicationType int defaultDataSourceType,
@@ -202,7 +197,7 @@
public ComplicationStateWireFormat(
@NonNull Rect bounds,
int boundsType,
- @NonNull @ComplicationData.ComplicationType int[] supportedTypes,
+ @ComplicationData.ComplicationType int @NonNull [] supportedTypes,
@Nullable List<ComponentName> defaultDataSourcesToTry,
int fallbackSystemProvider,
@ComplicationData.ComplicationType int defaultDataSourceType,
@@ -225,13 +220,11 @@
mComplicationConfigExtras = complicationConfigExtras;
}
- @NonNull
- public Rect getBounds() {
+ public @NonNull Rect getBounds() {
return mBounds;
}
- @Nullable
- public Rect getBoundsWithMargins() {
+ public @Nullable Rect getBoundsWithMargins() {
return mBoundsWithMargins;
}
@@ -239,9 +232,8 @@
return mBoundsType;
}
- @NonNull
@ComplicationData.ComplicationType
- public int[] getSupportedTypes() {
+ public int @NonNull [] getSupportedTypes() {
return mSupportedTypes;
}
@@ -252,8 +244,7 @@
* @deprecated Use {@link #getDefaultDataSourcesToTry} instead.
*/
@Deprecated
- @Nullable
- public List<ComponentName> getDefaultProvidersToTry() {
+ public @Nullable List<ComponentName> getDefaultProvidersToTry() {
return mDefaultDataSourcesToTry;
}
@@ -261,8 +252,7 @@
* Along with {@link #getFallbackSystemProvider} this is the wire format for
* DefaultComplicationDataSourcePolicy.
*/
- @Nullable
- public List<ComponentName> getDefaultDataSourcesToTry() {
+ public @Nullable List<ComponentName> getDefaultDataSourcesToTry() {
return mDefaultDataSourcesToTry;
}
@@ -334,26 +324,22 @@
return mCurrentType;
}
- @NonNull
- public Bundle getComplicationConfigExtras() {
+ public @NonNull Bundle getComplicationConfigExtras() {
return mComplicationConfigExtras;
}
- @Nullable
- public Integer getNameResourceId() {
+ public @Nullable Integer getNameResourceId() {
return mNameResourceId != NULL_NAME_RESOURCE_ID ? mNameResourceId : null;
}
- @Nullable
- public Integer getScreenReaderNameResourceId() {
+ public @Nullable Integer getScreenReaderNameResourceId() {
return mScreenReaderNameResourceId != NULL_NAME_RESOURCE_ID
? mScreenReaderNameResourceId
: null;
}
- @Nullable
@ComplicationExperimental
- public BoundingArcWireFormat getBoundingArc() {
+ public @Nullable BoundingArcWireFormat getBoundingArc() {
return mBoundingArc;
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/DeviceConfig.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/DeviceConfig.java
index d0102f24..7e08095 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/DeviceConfig.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/DeviceConfig.java
@@ -20,13 +20,14 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
/**
* Data sent over AIDL during watch face creation for device characteristics that cannot change
* dynamically.
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/IdAndComplicationDataWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/IdAndComplicationDataWireFormat.java
index e4a5499..c0a4171 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/IdAndComplicationDataWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/IdAndComplicationDataWireFormat.java
@@ -21,13 +21,14 @@
import android.os.Parcelable;
import android.support.wearable.complications.ComplicationData;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
import java.util.Objects;
/**
@@ -44,8 +45,7 @@
/** The {@link ComplicationData} to set for the complication. */
@ParcelField(2)
- @NonNull
- ComplicationData mComplicationData;
+ @NonNull ComplicationData mComplicationData;
/** Used by VersionedParcelable. */
IdAndComplicationDataWireFormat() {}
@@ -59,8 +59,7 @@
return mId;
}
- @NonNull
- public ComplicationData getComplicationData() {
+ public @NonNull ComplicationData getComplicationData() {
return mComplicationData;
}
@@ -103,9 +102,8 @@
return Objects.hash(mId, mComplicationData);
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
return "IdAndComplicationDataWireFormat{"
+ "mId="
+ mId
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/IdAndComplicationStateWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/IdAndComplicationStateWireFormat.java
index fa3539c..8351e5d 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/IdAndComplicationStateWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/IdAndComplicationStateWireFormat.java
@@ -20,13 +20,14 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
/**
* Wire format to encode a pair of id to {@link ComplicationStateWireFormat}.
*
@@ -41,8 +42,7 @@
/** The {@link ComplicationStateWireFormat} for the complication. */
@ParcelField(2)
- @NonNull
- ComplicationStateWireFormat mComplicationState;
+ @NonNull ComplicationStateWireFormat mComplicationState;
/** Used by VersionedParcelable. */
IdAndComplicationStateWireFormat() {}
@@ -57,8 +57,7 @@
return mId;
}
- @NonNull
- public ComplicationStateWireFormat getComplicationState() {
+ public @NonNull ComplicationStateWireFormat getComplicationState() {
return mComplicationState;
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/IdAndTapEventWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/IdAndTapEventWireFormat.java
index 07f3343..b778ae1 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/IdAndTapEventWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/IdAndTapEventWireFormat.java
@@ -20,7 +20,6 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
import androidx.annotation.Px;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
@@ -28,6 +27,8 @@
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
/**
* Pair of a ComplicationSlotID and a TapEvent, the wire format of Map<Int, TapEvent>
*
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/LayerParameterWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/LayerParameterWireFormat.java
index b5b1d3f..877bd5d 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/LayerParameterWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/LayerParameterWireFormat.java
@@ -20,13 +20,14 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
/**
* Wire format for Map<{@link androidx.wear.watchface.style.Layer}, {@link
* androidx.wear.watchface.LayerMode}>
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/RenderParametersWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/RenderParametersWireFormat.java
index 7e8a74d..a1b4a87 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/RenderParametersWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/RenderParametersWireFormat.java
@@ -21,14 +21,15 @@
import android.os.Parcelable;
import androidx.annotation.ColorInt;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
@@ -90,8 +91,7 @@
* #ELEMENT_TYPE_USER_STYLE}.
*/
@ParcelField(5)
- @Nullable
- String mElementUserStyleSettingId;
+ @Nullable String mElementUserStyleSettingId;
/**
* Specifies the tint for the highlighted element. Only used when {@link #mElementType} isn't
@@ -113,8 +113,7 @@
/** Optional set of ComplicationSlots to render as pressed. */
@ParcelField(9)
- @Nullable
- List<IdAndTapEventWireFormat> mIdAndTapEventWireFormats;
+ @Nullable List<IdAndTapEventWireFormat> mIdAndTapEventWireFormats;
RenderParametersWireFormat() {}
@@ -166,8 +165,7 @@
return mElementComplicationSlotId;
}
- @Nullable
- public String getElementUserStyleSettingId() {
+ public @Nullable String getElementUserStyleSettingId() {
return mElementUserStyleSettingId;
}
@@ -181,8 +179,7 @@
return mBackgroundTint;
}
- @Nullable
- public List<IdAndTapEventWireFormat> getIdAndTapEventWireFormat() {
+ public @Nullable List<IdAndTapEventWireFormat> getIdAndTapEventWireFormat() {
return mIdAndTapEventWireFormats;
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/WatchFaceColorsWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/WatchFaceColorsWireFormat.java
index 51a8292..ceba8f1 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/WatchFaceColorsWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/WatchFaceColorsWireFormat.java
@@ -20,13 +20,14 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/** Wire format for WatchFaceColorsWireFormat. */
// TODO(b/230364881): Mark as @RestrictTo when BoundingArc is no longer experimental.
@VersionedParcelize
@@ -76,8 +77,7 @@
return 0;
}
- @NonNull
- public static final Parcelable.Creator<WatchFaceColorsWireFormat> CREATOR =
+ public static final Parcelable.@NonNull Creator<WatchFaceColorsWireFormat> CREATOR =
new Parcelable.Creator<WatchFaceColorsWireFormat>() {
@SuppressWarnings("deprecation")
@Override
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/WatchFaceOverlayStyleWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/WatchFaceOverlayStyleWireFormat.java
index 50e7db0..62cd606 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/WatchFaceOverlayStyleWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/WatchFaceOverlayStyleWireFormat.java
@@ -21,14 +21,15 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Wire format for {@link androidx.wear.watchface.WatchFace.WatchFaceOverlayStyle}.
*
@@ -69,8 +70,7 @@
}
/** Returns the background color or `null`. */
- @Nullable
- public Color getBackgroundColor() {
+ public @Nullable Color getBackgroundColor() {
if (!mHasBackgroundColor) {
return null;
}
@@ -78,8 +78,7 @@
}
/** Returns the foreground color or `null`. */
- @Nullable
- public Color getForegroundColor() {
+ public @Nullable Color getForegroundColor() {
if (!mHasForegroundColor) {
return null;
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/WatchUiState.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/WatchUiState.java
index f6dc2f9..fe66fef 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/WatchUiState.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/data/WatchUiState.java
@@ -20,13 +20,14 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
/**
* Data sent over AIDL for {@link IWatchFaceCommand#setWatchUiState}.
*
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/editor/data/EditorStateWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/editor/data/EditorStateWireFormat.java
index d3ab8cb..aac2be1 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/editor/data/EditorStateWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/editor/data/EditorStateWireFormat.java
@@ -21,8 +21,6 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
@@ -31,6 +29,9 @@
import androidx.wear.watchface.data.IdAndComplicationDataWireFormat;
import androidx.wear.watchface.style.data.UserStyleWireFormat;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
@@ -42,23 +43,19 @@
@SuppressLint("BanParcelableUsage") // TODO(b/169214666): Remove Parcelable
public final class EditorStateWireFormat implements VersionedParcelable, Parcelable {
@ParcelField(1)
- @Nullable
- String mWatchFaceInstanceId;
+ @Nullable String mWatchFaceInstanceId;
@ParcelField(2)
- @NonNull
- UserStyleWireFormat mUserStyle;
+ @NonNull UserStyleWireFormat mUserStyle;
@ParcelField(3)
- @NonNull
- List<IdAndComplicationDataWireFormat> mPreviewComplicationData;
+ @NonNull List<IdAndComplicationDataWireFormat> mPreviewComplicationData;
@ParcelField(4)
boolean mCommitChanges;
@ParcelField(5)
- @Nullable
- Bundle mPreviewImageBundle;
+ @Nullable Bundle mPreviewImageBundle;
/** Used by VersionedParcelable. */
EditorStateWireFormat() {}
@@ -76,18 +73,15 @@
mPreviewImageBundle = previewImageBundle;
}
- @Nullable
- public String getWatchFaceInstanceId() {
+ public @Nullable String getWatchFaceInstanceId() {
return mWatchFaceInstanceId;
}
- @NonNull
- public UserStyleWireFormat getUserStyle() {
+ public @NonNull UserStyleWireFormat getUserStyle() {
return mUserStyle;
}
- @NonNull
- public List<IdAndComplicationDataWireFormat> getPreviewComplicationData() {
+ public @NonNull List<IdAndComplicationDataWireFormat> getPreviewComplicationData() {
return mPreviewComplicationData;
}
@@ -95,8 +89,7 @@
return mCommitChanges;
}
- @Nullable
- public Bundle getPreviewImageBundle() {
+ public @Nullable Bundle getPreviewImageBundle() {
return mPreviewImageBundle;
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/BooleanOptionWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/BooleanOptionWireFormat.java
index 173e863..0901c11 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/BooleanOptionWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/BooleanOptionWireFormat.java
@@ -16,10 +16,11 @@
package androidx.wear.watchface.style.data;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
/**
* Wire format for {@link androidx.wear.watchface.style.BooleanUserStyleSetting.BooleanOption}.
*
@@ -32,7 +33,7 @@
// WARNING: This class is held in a list and can't change due to flaws in VersionedParcelable.
- public BooleanOptionWireFormat(@NonNull byte[] id) {
+ public BooleanOptionWireFormat(byte @NonNull [] id) {
super(id);
}
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/BooleanUserStyleSettingWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/BooleanUserStyleSettingWireFormat.java
index fe25464..ad41478 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/BooleanUserStyleSettingWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/BooleanUserStyleSettingWireFormat.java
@@ -19,11 +19,12 @@
import android.graphics.drawable.Icon;
import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ColorOptionWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ColorOptionWireFormat.java
index 1556af4..eb6169e 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ColorOptionWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ColorOptionWireFormat.java
@@ -18,12 +18,13 @@
import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
@@ -35,27 +36,23 @@
public class ColorOptionWireFormat extends OptionWireFormat {
/** Localized human readable name for the setting, used in the style selection UI. */
@ParcelField(2)
- @NonNull
- public CharSequence mDisplayName = "";
+ public @NonNull CharSequence mDisplayName = "";
@ParcelField(3)
- @NonNull
- public CharSequence mScreenReaderName = "";
+ public @NonNull CharSequence mScreenReaderName = "";
@ParcelField(4)
- @NonNull
- public List<Integer> mColors;
+ public @NonNull List<Integer> mColors;
@ParcelField(5)
- @Nullable
- public Bundle mOnWatchFaceEditorBundle;
+ public @Nullable Bundle mOnWatchFaceEditorBundle;
// WARNING: This class is held in a list and can't change due to flaws in VersionedParcelable.
ColorOptionWireFormat() {}
public ColorOptionWireFormat(
- @NonNull byte[] id, @NonNull CharSequence displayName,
+ byte @NonNull [] id, @NonNull CharSequence displayName,
@NonNull CharSequence screenReaderName, @NonNull List<Integer> colors,
@Nullable Bundle onWatchFaceEditorBundle) {
super(id);
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ColorUserStyleSettingWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ColorUserStyleSettingWireFormat.java
index ec6d423..21f4c73 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ColorUserStyleSettingWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ColorUserStyleSettingWireFormat.java
@@ -19,11 +19,12 @@
import android.graphics.drawable.Icon;
import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ComplicationOverlayWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ComplicationOverlayWireFormat.java
index 220ddb2..5d47951 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ComplicationOverlayWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ComplicationOverlayWireFormat.java
@@ -21,14 +21,15 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Map;
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@@ -51,8 +52,7 @@
public int mEnabled;
@ParcelField(3)
- @Nullable
- public Map<Integer, RectF> mPerComplicationTypeBounds;
+ public @Nullable Map<Integer, RectF> mPerComplicationTypeBounds;
/** Ideally this would be Integer but VersionedParcelable doesn't support that. */
@ParcelField(4)
@@ -91,8 +91,7 @@
* Returns the optional override to the accessibilityTraversalIndex used for sorting
* ContentDescriptionLabels. See ComplicationOverlay for details.
*/
- @Nullable
- public Integer getAccessibilityTraversalIndex() {
+ public @Nullable Integer getAccessibilityTraversalIndex() {
if (mAccessibilityTraversalIndex == NULL_ACCESSIBILITY_TRAVERSAL_INDEX) {
return null;
} else {
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ComplicationsOptionWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ComplicationsOptionWireFormat.java
index c39692b..9aadbfb 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ComplicationsOptionWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ComplicationsOptionWireFormat.java
@@ -18,12 +18,13 @@
import android.graphics.drawable.Icon;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
@@ -35,12 +36,10 @@
@VersionedParcelize
public class ComplicationsOptionWireFormat extends OptionWireFormat {
@ParcelField(2)
- @NonNull
- public CharSequence mDisplayName;
+ public @NonNull CharSequence mDisplayName;
@ParcelField(3)
- @Nullable
- public Icon mIcon;
+ public @Nullable Icon mIcon;
// WARNING: This class is held in a list and can't change due to flaws in VersionedParcelable.
@@ -49,29 +48,25 @@
* {@link ComplicationOverlayWireFormat} is ever extended.
*/
@ParcelField(100)
- @NonNull
- public ComplicationOverlayWireFormat[] mComplicationOverlays =
+ public ComplicationOverlayWireFormat @NonNull [] mComplicationOverlays =
new ComplicationOverlayWireFormat[0];
@ParcelField(value = 101, defaultValue = "null")
- @Nullable
- public List<PerComplicationTypeMargins> mComplicationOverlaysMargins;
+ public @Nullable List<PerComplicationTypeMargins> mComplicationOverlaysMargins;
@ParcelField(value = 102, defaultValue = "null")
- @Nullable
- public List<Integer> mComplicationNameResourceIds;
+ public @Nullable List<Integer> mComplicationNameResourceIds;
@ParcelField(value = 103, defaultValue = "null")
- @Nullable
- public List<Integer> mComplicationScreenReaderNameResourceIds;
+ public @Nullable List<Integer> mComplicationScreenReaderNameResourceIds;
ComplicationsOptionWireFormat() {}
public ComplicationsOptionWireFormat(
- @NonNull byte[] id,
+ byte @NonNull [] id,
@NonNull CharSequence displayName,
@Nullable Icon icon,
- @NonNull ComplicationOverlayWireFormat[] complicationOverlays,
+ ComplicationOverlayWireFormat @NonNull [] complicationOverlays,
@Nullable List<PerComplicationTypeMargins> complicationOverlaysMargins,
@Nullable List<Integer> complicationNameResourceIds,
@Nullable List<Integer> complicationScreenReaderNameResourceIds) {
@@ -89,10 +84,10 @@
*/
@Deprecated
public ComplicationsOptionWireFormat(
- @NonNull byte[] id,
+ byte @NonNull [] id,
@NonNull CharSequence displayName,
@Nullable Icon icon,
- @NonNull ComplicationOverlayWireFormat[] complicationOverlays) {
+ ComplicationOverlayWireFormat @NonNull [] complicationOverlays) {
super(id);
mDisplayName = displayName;
mIcon = icon;
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ComplicationsUserStyleSettingWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ComplicationsUserStyleSettingWireFormat.java
index bcb4202..1c15da8 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ComplicationsUserStyleSettingWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ComplicationsUserStyleSettingWireFormat.java
@@ -19,12 +19,13 @@
import android.graphics.drawable.Icon;
import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
@@ -35,9 +36,8 @@
@VersionedParcelize
public class ComplicationsUserStyleSettingWireFormat extends UserStyleSettingWireFormat {
- @Nullable
@ParcelField(104)
- public List<CharSequence> mPerOptionScreenReaderNames;
+ public @Nullable List<CharSequence> mPerOptionScreenReaderNames;
ComplicationsUserStyleSettingWireFormat() {}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/CustomValueOption2WireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/CustomValueOption2WireFormat.java
index 2ba009f..442bb47 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/CustomValueOption2WireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/CustomValueOption2WireFormat.java
@@ -16,10 +16,11 @@
package androidx.wear.watchface.style.data;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
/**
* Wire format for {@link androidx.wear.watchface.style.CustomValueStyleSetting.CustomValueOption2}.
*
@@ -31,7 +32,7 @@
// WARNING: This class is held in a list and can't change due to flaws in VersionedParcelable.
- public CustomValueOption2WireFormat(@NonNull byte[] id) {
+ public CustomValueOption2WireFormat(byte @NonNull [] id) {
super(id);
}
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/CustomValueOptionWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/CustomValueOptionWireFormat.java
index 72fc7c3..8e788b4 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/CustomValueOptionWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/CustomValueOptionWireFormat.java
@@ -16,10 +16,11 @@
package androidx.wear.watchface.style.data;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
/**
* Wire format for {@link androidx.wear.watchface.style.CustomValueStyleSetting.CustomValueOption}.
*
@@ -31,7 +32,7 @@
// WARNING: This class is held in a list and can't change due to flaws in VersionedParcelable.
- public CustomValueOptionWireFormat(@NonNull byte[] id) {
+ public CustomValueOptionWireFormat(byte @NonNull [] id) {
super(id);
}
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/CustomValueUserStyleSetting2WireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/CustomValueUserStyleSetting2WireFormat.java
index 5d8dc54..1877234 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/CustomValueUserStyleSetting2WireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/CustomValueUserStyleSetting2WireFormat.java
@@ -19,11 +19,12 @@
import android.graphics.drawable.Icon;
import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/CustomValueUserStyleSettingWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/CustomValueUserStyleSettingWireFormat.java
index f79fb14..0e7d862 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/CustomValueUserStyleSettingWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/CustomValueUserStyleSettingWireFormat.java
@@ -19,11 +19,12 @@
import android.graphics.drawable.Icon;
import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/DoubleRangeOptionWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/DoubleRangeOptionWireFormat.java
index 8424f45..9cc3297 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/DoubleRangeOptionWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/DoubleRangeOptionWireFormat.java
@@ -16,10 +16,11 @@
package androidx.wear.watchface.style.data;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
/**
* Wire format for {@link
* androidx.wear.watchface.style.DoubleRangeUserStyleSetting.DoubleRangeOption}.
@@ -32,7 +33,7 @@
// WARNING: This class is held in a list and can't change due to flaws in VersionedParcelable.
- public DoubleRangeOptionWireFormat(@NonNull byte[] id) {
+ public DoubleRangeOptionWireFormat(byte @NonNull [] id) {
super(id);
}
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/DoubleRangeUserStyleSettingWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/DoubleRangeUserStyleSettingWireFormat.java
index 98acd28..1091e88 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/DoubleRangeUserStyleSettingWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/DoubleRangeUserStyleSettingWireFormat.java
@@ -19,11 +19,12 @@
import android.graphics.drawable.Icon;
import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ListOptionWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ListOptionWireFormat.java
index f6d6172..3be3f58 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ListOptionWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ListOptionWireFormat.java
@@ -18,12 +18,13 @@
import android.graphics.drawable.Icon;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Wire format for {@link androidx.wear.watchface.style.ListUserStyleSetting.ListOption}.
*
@@ -33,20 +34,18 @@
public class ListOptionWireFormat extends OptionWireFormat {
/** Localized human readable name for the setting, used in the style selection UI. */
@ParcelField(2)
- @NonNull
- public CharSequence mDisplayName = "";
+ public @NonNull CharSequence mDisplayName = "";
/** Icon for use in the style selection UI. */
@ParcelField(3)
- @Nullable
- public Icon mIcon = null;
+ public @Nullable Icon mIcon = null;
// WARNING: This class is held in a list and can't change due to flaws in VersionedParcelable.
ListOptionWireFormat() {}
public ListOptionWireFormat(
- @NonNull byte[] id, @NonNull CharSequence displayName, @Nullable Icon icon) {
+ byte @NonNull [] id, @NonNull CharSequence displayName, @Nullable Icon icon) {
super(id);
this.mDisplayName = displayName;
this.mIcon = icon;
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ListUserStyleSettingWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ListUserStyleSettingWireFormat.java
index cae38b0..270ced9 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ListUserStyleSettingWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/ListUserStyleSettingWireFormat.java
@@ -19,12 +19,13 @@
import android.graphics.drawable.Icon;
import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
@@ -35,9 +36,8 @@
@VersionedParcelize
public class ListUserStyleSettingWireFormat extends UserStyleSettingWireFormat {
- @Nullable
@ParcelField(104)
- public List<CharSequence> mPerOptionScreenReaderNames;
+ public @Nullable List<CharSequence> mPerOptionScreenReaderNames;
ListUserStyleSettingWireFormat() {}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/LongRangeOptionWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/LongRangeOptionWireFormat.java
index df2e69f..93ba024 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/LongRangeOptionWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/LongRangeOptionWireFormat.java
@@ -16,10 +16,11 @@
package androidx.wear.watchface.style.data;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
/**
* Wire format for {@link androidx.wear.watchface.style.LongRangeUserStyleSetting.LongRangeOption}.
*
@@ -31,7 +32,7 @@
// WARNING: This class is held in a list and can't change due to flaws in VersionedParcelable.
- public LongRangeOptionWireFormat(@NonNull byte[] id) {
+ public LongRangeOptionWireFormat(byte @NonNull [] id) {
super(id);
}
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/LongRangeUserStyleSettingWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/LongRangeUserStyleSettingWireFormat.java
index 4f490fe..9ba9361 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/LongRangeUserStyleSettingWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/LongRangeUserStyleSettingWireFormat.java
@@ -19,11 +19,12 @@
import android.graphics.drawable.Icon;
import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/OptionWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/OptionWireFormat.java
index c6b184e..0392955 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/OptionWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/OptionWireFormat.java
@@ -20,13 +20,14 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
/**
* Wire format for {@link androidx.wear.watchface.style.UserStyleSetting.Option}.
*
@@ -37,14 +38,13 @@
public class OptionWireFormat implements VersionedParcelable, Parcelable {
/** Identifier for the option, must be unique within the UserStyleCategory. */
@ParcelField(1)
- @NonNull
- public byte[] mId = new byte[0];
+ public byte @NonNull [] mId = new byte[0];
// WARNING: This class is held in a list and can't change due to flaws in VersionedParcelable.
OptionWireFormat() {}
- public OptionWireFormat(@NonNull byte[] id) {
+ public OptionWireFormat(byte @NonNull [] id) {
mId = id;
}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/PerComplicationTypeMargins.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/PerComplicationTypeMargins.java
index 1b96c3d..0e9164c 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/PerComplicationTypeMargins.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/PerComplicationTypeMargins.java
@@ -18,20 +18,20 @@
import android.graphics.RectF;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
import java.util.Map;
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@VersionedParcelize
public class PerComplicationTypeMargins implements VersionedParcelable {
@ParcelField(1)
- @NonNull
- public Map<Integer, RectF> mPerComplicationTypeMargins;
+ public @NonNull Map<Integer, RectF> mPerComplicationTypeMargins;
PerComplicationTypeMargins() {}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleFlavorWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleFlavorWireFormat.java
index d446f2a..374cb8d 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleFlavorWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleFlavorWireFormat.java
@@ -20,7 +20,6 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
@@ -28,6 +27,8 @@
import androidx.versionedparcelable.VersionedParcelize;
import androidx.wear.watchface.complications.data.DefaultComplicationDataSourcePolicyWireFormat;
+import org.jspecify.annotations.NonNull;
+
import java.util.HashMap;
import java.util.Map;
@@ -37,18 +38,15 @@
public class UserStyleFlavorWireFormat implements VersionedParcelable, Parcelable {
/** User style identifier. */
@ParcelField(1)
- @NonNull
- public String mId = "";
+ public @NonNull String mId = "";
/** User style definition of the flavor. */
@ParcelField(2)
- @NonNull
- public UserStyleWireFormat mStyle = new UserStyleWireFormat();
+ public @NonNull UserStyleWireFormat mStyle = new UserStyleWireFormat();
/** Map of ComplicationSlot id to complication's default for the flavor. */
@ParcelField(3)
- @NonNull
- public Map<Integer, DefaultComplicationDataSourcePolicyWireFormat> mComplications =
+ public @NonNull Map<Integer, DefaultComplicationDataSourcePolicyWireFormat> mComplications =
new HashMap<>();
UserStyleFlavorWireFormat() {}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleFlavorsWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleFlavorsWireFormat.java
index a4670c6..a8d50e5 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleFlavorsWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleFlavorsWireFormat.java
@@ -20,13 +20,14 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
import java.util.ArrayList;
import java.util.List;
@@ -35,8 +36,7 @@
@SuppressLint("BanParcelableUsage") // TODO(b/169214666): Remove Parcelable
public class UserStyleFlavorsWireFormat implements VersionedParcelable, Parcelable {
@ParcelField(1)
- @NonNull
- public List<UserStyleFlavorWireFormat> mFlavors = new ArrayList<>();
+ public @NonNull List<UserStyleFlavorWireFormat> mFlavors = new ArrayList<>();
UserStyleFlavorsWireFormat() {}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleSchemaWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleSchemaWireFormat.java
index c7f8389..36c79d3 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleSchemaWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleSchemaWireFormat.java
@@ -20,13 +20,14 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
import java.util.ArrayList;
import java.util.List;
@@ -36,8 +37,8 @@
public class UserStyleSchemaWireFormat implements VersionedParcelable, Parcelable {
/** List of user style categories comprising the style schema. */
@ParcelField(1)
- @NonNull
- public List<UserStyleSettingWireFormat> mSchema = new ArrayList<UserStyleSettingWireFormat>();
+ public @NonNull List<UserStyleSettingWireFormat> mSchema =
+ new ArrayList<UserStyleSettingWireFormat>();
UserStyleSchemaWireFormat() {}
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleSettingWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleSettingWireFormat.java
index dd44eed..8a77ed8 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleSettingWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleSettingWireFormat.java
@@ -22,14 +22,15 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.List;
@@ -43,23 +44,19 @@
public class UserStyleSettingWireFormat implements VersionedParcelable, Parcelable {
/** Identifier for the element, must be unique. */
@ParcelField(1)
- @NonNull
- public String mId = "";
+ public @NonNull String mId = "";
/** Localized human readable name for the element, used in the userStyle selection UI. */
@ParcelField(2)
- @NonNull
- public CharSequence mDisplayName = "";
+ public @NonNull CharSequence mDisplayName = "";
/** Localized description string displayed under the displayName. */
@ParcelField(3)
- @NonNull
- public CharSequence mDescription = "";
+ public @NonNull CharSequence mDescription = "";
/** Icon for use in the style selection UI. */
@ParcelField(4)
- @Nullable
- public Icon mIcon = null;
+ public @Nullable Icon mIcon = null;
/** The default option index, used if nothing has been selected within the options list. */
@ParcelField(5)
@@ -67,8 +64,7 @@
/** Used by the style configuration UI. Describes which rendering layers this style affects. */
@ParcelField(6)
- @NonNull
- public List<Integer> mAffectsLayers;
+ public @NonNull List<Integer> mAffectsLayers;
/**
* List of options for this UserStyleCategory. Depending on the type of UserStyleCategory this
@@ -80,29 +76,25 @@
* (including elements of this list) will get corrupted.
*/
@ParcelField(100)
- @NonNull
- public List<OptionWireFormat> mOptions = new ArrayList<>();
+ public @NonNull List<OptionWireFormat> mOptions = new ArrayList<>();
/**
* Flattened list of child settings for each option. Note this ID must always be a list of
* Integers.
*/
- @Nullable
@ParcelField(101)
- public List<Integer> mOptionChildIndices = null;
+ public @Nullable List<Integer> mOptionChildIndices = null;
/** Contains OnWatchFaceData. */
- @Nullable
@ParcelField(102)
- public Bundle mOnWatchFaceEditorBundle = null;
+ public @Nullable Bundle mOnWatchFaceEditorBundle = null;
/**
* Per option OnWatchFaceData. Ideally this would be in OptionWireFormat, but
* VersionedParcellable doesn't support us adding that in a backwards compatible way.
*/
- @Nullable
@ParcelField(103)
- public List<Bundle> mPerOptionOnWatchFaceEditorBundles = new ArrayList<>();
+ public @Nullable List<Bundle> mPerOptionOnWatchFaceEditorBundles = new ArrayList<>();
// Field 104 is reserved.
diff --git a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleWireFormat.java b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleWireFormat.java
index e9f9225..cd89188 100644
--- a/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleWireFormat.java
+++ b/wear/watchface/watchface-data/src/main/java/androidx/wear/watchface/style/data/UserStyleWireFormat.java
@@ -20,13 +20,14 @@
import android.os.Parcel;
import android.os.Parcelable;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.versionedparcelable.ParcelField;
import androidx.versionedparcelable.ParcelUtils;
import androidx.versionedparcelable.VersionedParcelable;
import androidx.versionedparcelable.VersionedParcelize;
+import org.jspecify.annotations.NonNull;
+
import java.util.HashMap;
import java.util.Map;
@@ -36,8 +37,7 @@
public class UserStyleWireFormat implements VersionedParcelable, Parcelable {
/** Map from user style setting id to user style option id. */
@ParcelField(1)
- @NonNull
- public Map<String, byte[]> mUserStyle = new HashMap<>();
+ public @NonNull Map<String, byte[]> mUserStyle = new HashMap<>();
UserStyleWireFormat() {}
diff --git a/wear/watchface/watchface-guava/build.gradle b/wear/watchface/watchface-guava/build.gradle
index 28b9236..4328bbb 100644
--- a/wear/watchface/watchface-guava/build.gradle
+++ b/wear/watchface/watchface-guava/build.gradle
@@ -31,6 +31,7 @@
}
dependencies {
+ api(libs.jspecify)
api(project(":wear:watchface:watchface"))
api(libs.guavaAndroid)
diff --git a/wear/watchface/watchface-guava/src/test/java/androidx/wear/watchface/GlesRenderer.java b/wear/watchface/watchface-guava/src/test/java/androidx/wear/watchface/GlesRenderer.java
index c29bd9e..8120dcb 100644
--- a/wear/watchface/watchface-guava/src/test/java/androidx/wear/watchface/GlesRenderer.java
+++ b/wear/watchface/watchface-guava/src/test/java/androidx/wear/watchface/GlesRenderer.java
@@ -18,9 +18,10 @@
import android.view.SurfaceHolder;
-import androidx.annotation.NonNull;
import androidx.wear.watchface.style.CurrentUserStyleRepository;
+import org.jspecify.annotations.NonNull;
+
import java.time.ZonedDateTime;
// This class tests that a Java class extending ListenableGlesRenderer can successfully be compiled.
diff --git a/wear/watchface/watchface-samples-minimal-complications/build.gradle b/wear/watchface/watchface-samples-minimal-complications/build.gradle
index 8e82388..1ea310b 100644
--- a/wear/watchface/watchface-samples-minimal-complications/build.gradle
+++ b/wear/watchface/watchface-samples-minimal-complications/build.gradle
@@ -20,6 +20,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.activity:activity:1.3.1")
api(project(":wear:watchface:watchface"))
api(project(":wear:watchface:watchface-client-guava"))
diff --git a/wear/watchface/watchface-samples-minimal-complications/src/main/java/androidx/wear/watchface/samples/minimal/complications/ConfigActivity.java b/wear/watchface/watchface-samples-minimal-complications/src/main/java/androidx/wear/watchface/samples/minimal/complications/ConfigActivity.java
index 18132ad..612c3e73 100644
--- a/wear/watchface/watchface-samples-minimal-complications/src/main/java/androidx/wear/watchface/samples/minimal/complications/ConfigActivity.java
+++ b/wear/watchface/watchface-samples-minimal-complications/src/main/java/androidx/wear/watchface/samples/minimal/complications/ConfigActivity.java
@@ -24,7 +24,6 @@
import android.widget.TextView;
import androidx.activity.ComponentActivity;
-import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.FlowLiveDataConversions;
import androidx.wear.watchface.complications.ComplicationDataSourceInfo;
@@ -34,6 +33,8 @@
import com.google.common.util.concurrent.ListenableFuture;
+import org.jspecify.annotations.Nullable;
+
import java.util.concurrent.ExecutionException;
/** Configuration activity for the watch face. */
@@ -45,7 +46,7 @@
private ImageView mComplicationPreview;
private ComplicationDrawable mComplicationPreviewDrawable;
- @Nullable private ListenableEditorSession mEditorSession;
+ private @Nullable ListenableEditorSession mEditorSession;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
diff --git a/wear/watchface/watchface-samples-minimal-complications/src/main/java/androidx/wear/watchface/samples/minimal/complications/WatchFaceRenderer.java b/wear/watchface/watchface-samples-minimal-complications/src/main/java/androidx/wear/watchface/samples/minimal/complications/WatchFaceRenderer.java
index 68c796c..ca33a33 100644
--- a/wear/watchface/watchface-samples-minimal-complications/src/main/java/androidx/wear/watchface/samples/minimal/complications/WatchFaceRenderer.java
+++ b/wear/watchface/watchface-samples-minimal-complications/src/main/java/androidx/wear/watchface/samples/minimal/complications/WatchFaceRenderer.java
@@ -31,7 +31,6 @@
import android.graphics.Rect;
import android.view.SurfaceHolder;
-import androidx.annotation.NonNull;
import androidx.annotation.Px;
import androidx.wear.watchface.CanvasType;
import androidx.wear.watchface.ComplicationSlot;
@@ -42,6 +41,8 @@
import androidx.wear.watchface.WatchState;
import androidx.wear.watchface.style.CurrentUserStyleRepository;
+import org.jspecify.annotations.NonNull;
+
import java.time.ZonedDateTime;
import java.util.concurrent.TimeUnit;
diff --git a/wear/watchface/watchface-samples-minimal-complications/src/main/java/androidx/wear/watchface/samples/minimal/complications/WatchFaceService.java b/wear/watchface/watchface-samples-minimal-complications/src/main/java/androidx/wear/watchface/samples/minimal/complications/WatchFaceService.java
index 0d72556..03df083 100644
--- a/wear/watchface/watchface-samples-minimal-complications/src/main/java/androidx/wear/watchface/samples/minimal/complications/WatchFaceService.java
+++ b/wear/watchface/watchface-samples-minimal-complications/src/main/java/androidx/wear/watchface/samples/minimal/complications/WatchFaceService.java
@@ -22,7 +22,6 @@
import android.graphics.RectF;
import android.view.SurfaceHolder;
-import androidx.annotation.NonNull;
import androidx.wear.watchface.CanvasComplicationFactory;
import androidx.wear.watchface.ComplicationSlotInflationFactory;
import androidx.wear.watchface.ComplicationSlotsManager;
@@ -40,6 +39,8 @@
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import org.jspecify.annotations.NonNull;
+
/** The service hosting the watch face. */
public class WatchFaceService extends ListenableWatchFaceService {
public static final RectF COMPLICATION_BOUNDS = new RectF(.3f, 0.7f, .7f, .9f);
@@ -49,9 +50,8 @@
return resources.getInteger(R.integer.complication_slot_id);
}
- @NonNull
@Override
- protected ListenableFuture<WatchFace> createWatchFaceFuture(
+ protected @NonNull ListenableFuture<WatchFace> createWatchFaceFuture(
@NonNull SurfaceHolder surfaceHolder,
@NonNull WatchState watchState,
@NonNull ComplicationSlotsManager complicationSlotsManager,
@@ -71,15 +71,13 @@
new Intent(this, ComplicationRationalActivity.class)));
}
- @NonNull
@Override
- public ComplicationSlotInflationFactory getComplicationSlotInflationFactory(
+ public @NonNull ComplicationSlotInflationFactory getComplicationSlotInflationFactory(
@NonNull CurrentUserStyleRepository currentUserStyleRepository) {
final Context context = this;
return new ComplicationSlotInflationFactory() {
- @NonNull
@Override
- public CanvasComplicationFactory getCanvasComplicationFactory(int slotId) {
+ public @NonNull CanvasComplicationFactory getCanvasComplicationFactory(int slotId) {
return (watchState, invalidateCallback) ->
new CanvasComplicationDrawable(
new ComplicationDrawable(context), watchState, invalidateCallback);
diff --git a/wear/watchface/watchface-samples-minimal-instances/build.gradle b/wear/watchface/watchface-samples-minimal-instances/build.gradle
index 83345b2..ccbc592 100644
--- a/wear/watchface/watchface-samples-minimal-instances/build.gradle
+++ b/wear/watchface/watchface-samples-minimal-instances/build.gradle
@@ -21,6 +21,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.activity:activity:1.3.1")
api(project(":wear:watchface:watchface"))
api(project(":wear:watchface:watchface-editor"))
diff --git a/wear/watchface/watchface-samples-minimal-instances/src/main/java/androidx/wear/watchface/samples/minimal/instances/ConfigActivity.java b/wear/watchface/watchface-samples-minimal-instances/src/main/java/androidx/wear/watchface/samples/minimal/instances/ConfigActivity.java
index 5c017bd..4968628 100644
--- a/wear/watchface/watchface-samples-minimal-instances/src/main/java/androidx/wear/watchface/samples/minimal/instances/ConfigActivity.java
+++ b/wear/watchface/watchface-samples-minimal-instances/src/main/java/androidx/wear/watchface/samples/minimal/instances/ConfigActivity.java
@@ -24,7 +24,6 @@
import android.widget.TextView;
import androidx.activity.ComponentActivity;
-import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.wear.watchface.editor.ListenableEditorSession;
import androidx.wear.watchface.style.MutableUserStyle;
@@ -33,6 +32,8 @@
import com.google.common.util.concurrent.ListenableFuture;
+import org.jspecify.annotations.Nullable;
+
import java.util.Objects;
import java.util.concurrent.ExecutionException;
@@ -45,7 +46,7 @@
private TextView mStyleValue;
private final UserStyleSetting.Id mTimeStyleId = new UserStyleSetting.Id("TimeStyle");
- @Nullable private ListenableEditorSession mEditorSession;
+ private @Nullable ListenableEditorSession mEditorSession;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
diff --git a/wear/watchface/watchface-samples-minimal-instances/src/main/java/androidx/wear/watchface/samples/minimal/instances/WatchFaceRenderer.java b/wear/watchface/watchface-samples-minimal-instances/src/main/java/androidx/wear/watchface/samples/minimal/instances/WatchFaceRenderer.java
index 801e194..84f3f27 100644
--- a/wear/watchface/watchface-samples-minimal-instances/src/main/java/androidx/wear/watchface/samples/minimal/instances/WatchFaceRenderer.java
+++ b/wear/watchface/watchface-samples-minimal-instances/src/main/java/androidx/wear/watchface/samples/minimal/instances/WatchFaceRenderer.java
@@ -26,7 +26,6 @@
import android.graphics.RectF;
import android.view.SurfaceHolder;
-import androidx.annotation.NonNull;
import androidx.annotation.Px;
import androidx.annotation.UiThread;
import androidx.lifecycle.FlowLiveDataConversions;
@@ -44,6 +43,8 @@
import kotlin.Unit;
+import org.jspecify.annotations.NonNull;
+
import java.time.ZonedDateTime;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
@@ -89,9 +90,8 @@
}
@UiThread
- @NonNull
@Override
- public ListenableFuture<Unit> initFuture() {
+ public @NonNull ListenableFuture<Unit> initFuture() {
// observeForever has to be called from the UI thread but the WatchFaceRenderer is called
// from a background thread.
FlowLiveDataConversions.asLiveData(mCurrentUserStyleRepository.getUserStyle())
diff --git a/wear/watchface/watchface-samples-minimal-instances/src/main/java/androidx/wear/watchface/samples/minimal/instances/WatchFaceService.java b/wear/watchface/watchface-samples-minimal-instances/src/main/java/androidx/wear/watchface/samples/minimal/instances/WatchFaceService.java
index d06480a..de79469 100644
--- a/wear/watchface/watchface-samples-minimal-instances/src/main/java/androidx/wear/watchface/samples/minimal/instances/WatchFaceService.java
+++ b/wear/watchface/watchface-samples-minimal-instances/src/main/java/androidx/wear/watchface/samples/minimal/instances/WatchFaceService.java
@@ -18,7 +18,6 @@
import android.view.SurfaceHolder;
-import androidx.annotation.NonNull;
import androidx.wear.watchface.ComplicationSlotsManager;
import androidx.wear.watchface.ListenableWatchFaceService;
import androidx.wear.watchface.Renderer;
@@ -30,12 +29,13 @@
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import org.jspecify.annotations.NonNull;
+
/** The service that defines the watch face. */
public class WatchFaceService extends ListenableWatchFaceService {
- @NonNull
@Override
- protected ListenableFuture<WatchFace> createWatchFaceFuture(
+ protected @NonNull ListenableFuture<WatchFace> createWatchFaceFuture(
@NonNull SurfaceHolder surfaceHolder,
@NonNull WatchState watchState,
@NonNull ComplicationSlotsManager complicationSlotsManager,
diff --git a/wear/watchface/watchface-samples-minimal-style/build.gradle b/wear/watchface/watchface-samples-minimal-style/build.gradle
index e03b619..1bce071 100644
--- a/wear/watchface/watchface-samples-minimal-style/build.gradle
+++ b/wear/watchface/watchface-samples-minimal-style/build.gradle
@@ -20,6 +20,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.activity:activity:1.3.1")
api(project(":wear:watchface:watchface"))
api(project(":wear:watchface:watchface-editor"))
diff --git a/wear/watchface/watchface-samples-minimal-style/src/main/java/androidx/wear/watchface/samples/minimal/style/ConfigActivity.java b/wear/watchface/watchface-samples-minimal-style/src/main/java/androidx/wear/watchface/samples/minimal/style/ConfigActivity.java
index bc7d75b2..4731e7e 100644
--- a/wear/watchface/watchface-samples-minimal-style/src/main/java/androidx/wear/watchface/samples/minimal/style/ConfigActivity.java
+++ b/wear/watchface/watchface-samples-minimal-style/src/main/java/androidx/wear/watchface/samples/minimal/style/ConfigActivity.java
@@ -24,7 +24,6 @@
import android.widget.TextView;
import androidx.activity.ComponentActivity;
-import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.wear.watchface.editor.ListenableEditorSession;
import androidx.wear.watchface.style.MutableUserStyle;
@@ -32,6 +31,8 @@
import com.google.common.util.concurrent.ListenableFuture;
+import org.jspecify.annotations.Nullable;
+
import java.util.concurrent.ExecutionException;
/** Configuration activity for the watch face. */
@@ -42,7 +43,7 @@
private TextView mStyleValue;
private final UserStyleSetting.Id mTimeStyleId = new UserStyleSetting.Id("TimeStyle");
- @Nullable private ListenableEditorSession mEditorSession;
+ private @Nullable ListenableEditorSession mEditorSession;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
diff --git a/wear/watchface/watchface-samples-minimal-style/src/main/java/androidx/wear/watchface/samples/minimal/style/WatchFaceRenderer.java b/wear/watchface/watchface-samples-minimal-style/src/main/java/androidx/wear/watchface/samples/minimal/style/WatchFaceRenderer.java
index 7bddee6..23d3cbc 100644
--- a/wear/watchface/watchface-samples-minimal-style/src/main/java/androidx/wear/watchface/samples/minimal/style/WatchFaceRenderer.java
+++ b/wear/watchface/watchface-samples-minimal-style/src/main/java/androidx/wear/watchface/samples/minimal/style/WatchFaceRenderer.java
@@ -24,7 +24,6 @@
import android.graphics.Rect;
import android.view.SurfaceHolder;
-import androidx.annotation.NonNull;
import androidx.annotation.Px;
import androidx.annotation.UiThread;
import androidx.lifecycle.FlowLiveDataConversions;
@@ -42,6 +41,8 @@
import kotlin.Unit;
+import org.jspecify.annotations.NonNull;
+
import java.time.ZonedDateTime;
import java.util.concurrent.TimeUnit;
@@ -83,9 +84,8 @@
}
@UiThread
- @NonNull
@Override
- public ListenableFuture<Unit> initFuture() {
+ public @NonNull ListenableFuture<Unit> initFuture() {
// observeForever has to be called from the UI thread but the WatchFaceRenderer is called
// from a background thread.
FlowLiveDataConversions.asLiveData(mCurrentUserStyleRepository.getUserStyle())
diff --git a/wear/watchface/watchface-samples-minimal-style/src/main/java/androidx/wear/watchface/samples/minimal/style/WatchFaceService.java b/wear/watchface/watchface-samples-minimal-style/src/main/java/androidx/wear/watchface/samples/minimal/style/WatchFaceService.java
index 8756c93..a6fe881 100644
--- a/wear/watchface/watchface-samples-minimal-style/src/main/java/androidx/wear/watchface/samples/minimal/style/WatchFaceService.java
+++ b/wear/watchface/watchface-samples-minimal-style/src/main/java/androidx/wear/watchface/samples/minimal/style/WatchFaceService.java
@@ -18,7 +18,6 @@
import android.view.SurfaceHolder;
-import androidx.annotation.NonNull;
import androidx.wear.watchface.ComplicationSlotsManager;
import androidx.wear.watchface.ListenableWatchFaceService;
import androidx.wear.watchface.Renderer;
@@ -30,12 +29,13 @@
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import org.jspecify.annotations.NonNull;
+
/** The service that defines the watch face. */
public class WatchFaceService extends ListenableWatchFaceService {
- @NonNull
@Override
- protected ListenableFuture<WatchFace> createWatchFaceFuture(
+ protected @NonNull ListenableFuture<WatchFace> createWatchFaceFuture(
@NonNull SurfaceHolder surfaceHolder,
@NonNull WatchState watchState,
@NonNull ComplicationSlotsManager complicationSlotsManager,
diff --git a/wear/watchface/watchface/build.gradle b/wear/watchface/watchface/build.gradle
index 2204343..2a4b5ee 100644
--- a/wear/watchface/watchface/build.gradle
+++ b/wear/watchface/watchface/build.gradle
@@ -32,6 +32,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.annotation:annotation:1.8.1")
api("androidx.activity:activity:1.7.0")
api(project(":wear:watchface:watchface-complications-data"))
diff --git a/wear/watchface/watchface/samples/minimal/src/main/java/androidx/wear/watchface/samples/minimal/WatchFaceRenderer.java b/wear/watchface/watchface/samples/minimal/src/main/java/androidx/wear/watchface/samples/minimal/WatchFaceRenderer.java
index 0579c17..1859fe0 100644
--- a/wear/watchface/watchface/samples/minimal/src/main/java/androidx/wear/watchface/samples/minimal/WatchFaceRenderer.java
+++ b/wear/watchface/watchface/samples/minimal/src/main/java/androidx/wear/watchface/samples/minimal/WatchFaceRenderer.java
@@ -23,12 +23,13 @@
import android.graphics.Rect;
import android.view.SurfaceHolder;
-import androidx.annotation.NonNull;
import androidx.wear.watchface.CanvasType;
import androidx.wear.watchface.Renderer;
import androidx.wear.watchface.WatchState;
import androidx.wear.watchface.style.CurrentUserStyleRepository;
+import org.jspecify.annotations.NonNull;
+
import java.time.ZonedDateTime;
import java.util.concurrent.TimeUnit;
diff --git a/wear/watchface/watchface/samples/minimal/src/main/java/androidx/wear/watchface/samples/minimal/WatchFaceService.java b/wear/watchface/watchface/samples/minimal/src/main/java/androidx/wear/watchface/samples/minimal/WatchFaceService.java
index 41c1cef..c8e5578 100644
--- a/wear/watchface/watchface/samples/minimal/src/main/java/androidx/wear/watchface/samples/minimal/WatchFaceService.java
+++ b/wear/watchface/watchface/samples/minimal/src/main/java/androidx/wear/watchface/samples/minimal/WatchFaceService.java
@@ -18,7 +18,6 @@
import android.view.SurfaceHolder;
-import androidx.annotation.NonNull;
import androidx.wear.watchface.ComplicationSlotsManager;
import androidx.wear.watchface.ListenableWatchFaceService;
import androidx.wear.watchface.Renderer;
@@ -30,6 +29,8 @@
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import org.jspecify.annotations.NonNull;
+
/** The service that defines the watch face. */
public class WatchFaceService extends ListenableWatchFaceService {
diff --git a/wear/watchface/watchface/src/main/java/androidx/wear/watchface/CanvasComplicationFactory.java b/wear/watchface/watchface/src/main/java/androidx/wear/watchface/CanvasComplicationFactory.java
index ac5d1a0..66aa598 100644
--- a/wear/watchface/watchface/src/main/java/androidx/wear/watchface/CanvasComplicationFactory.java
+++ b/wear/watchface/watchface/src/main/java/androidx/wear/watchface/CanvasComplicationFactory.java
@@ -16,9 +16,10 @@
package androidx.wear.watchface;
-import androidx.annotation.NonNull;
import androidx.annotation.WorkerThread;
+import org.jspecify.annotations.NonNull;
+
/**
* Factory for creating a CanvasComplication. This decouples construction of Complications and their
* CanvasComplication renderers.
@@ -39,10 +40,9 @@
* loaded.
* @return The constructed CanvasComplication.
*/
- @NonNull
@WorkerThread
@SuppressWarnings("ExecutorRegistration") // This is UI thread only.
- CanvasComplication create(
+ @NonNull CanvasComplication create(
@NonNull WatchState watchState,
- @NonNull CanvasComplication.InvalidateCallback invalidateCallback);
+ CanvasComplication.@NonNull InvalidateCallback invalidateCallback);
}
diff --git a/wear/watchface/watchface/src/main/java/androidx/wear/watchface/ComplicationDataSourceChooserIntent.java b/wear/watchface/watchface/src/main/java/androidx/wear/watchface/ComplicationDataSourceChooserIntent.java
index 57a55e2..3b1d765 100644
--- a/wear/watchface/watchface/src/main/java/androidx/wear/watchface/ComplicationDataSourceChooserIntent.java
+++ b/wear/watchface/watchface/src/main/java/androidx/wear/watchface/ComplicationDataSourceChooserIntent.java
@@ -24,9 +24,10 @@
import android.support.wearable.complications.ComplicationData;
import android.support.wearable.complications.ComplicationProviderInfo;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
/**
* Utilities to allow watch faces to launch the complication data source chooser.
*
@@ -152,11 +153,10 @@
* chosen will be whichever was specified first.
* @see ComplicationHelperActivity
*/
- @NonNull
- public static Intent createComplicationDataSourceChooserIntent(
+ public static @NonNull Intent createComplicationDataSourceChooserIntent(
@NonNull ComponentName watchFace,
int watchFaceComplicationId,
- @NonNull @ComplicationData.ComplicationType int... supportedTypes) {
+ @ComplicationData.ComplicationType int @NonNull ... supportedTypes) {
Intent intent = new Intent(ACTION_CHOOSE_DATA_SOURCE);
intent.putExtra(EXTRA_WATCH_FACE_COMPONENT_NAME, watchFace);
intent.putExtra(EXTRA_COMPLICATION_ID, watchFaceComplicationId);
@@ -193,7 +193,7 @@
@NonNull Context context,
@NonNull ComponentName watchFace,
int watchFaceComplicationId,
- @NonNull @ComplicationData.ComplicationType int... supportedTypes) {
+ @ComplicationData.ComplicationType int @NonNull ... supportedTypes) {
Intent intent =
createComplicationDataSourceChooserIntent(
watchFace, watchFaceComplicationId, supportedTypes);
diff --git a/wear/watchface/watchface/src/main/java/androidx/wear/watchface/ComplicationHelperActivity.java b/wear/watchface/watchface/src/main/java/androidx/wear/watchface/ComplicationHelperActivity.java
index f5c3b71..8c2c588 100644
--- a/wear/watchface/watchface/src/main/java/androidx/wear/watchface/ComplicationHelperActivity.java
+++ b/wear/watchface/watchface/src/main/java/androidx/wear/watchface/ComplicationHelperActivity.java
@@ -27,14 +27,15 @@
import android.support.wearable.complications.ComplicationProviderInfo;
import androidx.activity.ComponentActivity;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.core.app.ActivityCompat;
import androidx.wear.watchface.complications.ComplicationDataSourceUpdateRequesterConstants;
import androidx.wear.watchface.complications.data.ComplicationType;
import androidx.wear.watchface.style.UserStyleData;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Collection;
import java.util.Objects;
@@ -113,7 +114,7 @@
@Nullable ComponentName mWatchFace;
int mWfComplicationId;
@Nullable Bundle mAdditionalExtras;
- @Nullable @ComplicationData.ComplicationType int[] mTypes;
+ @ComplicationData.ComplicationType int @Nullable [] mTypes;
Delegate mDelegate = new DelegateImpl(this);
/** Allows the logic to be tested. */
@@ -296,7 +297,7 @@
@Override
@SuppressWarnings("deprecation") //TODO: Use ActivityResultContract
public void onRequestPermissionsResult(
- int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ int requestCode, String @NonNull [] permissions, int @NonNull [] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (grantResults.length == 0) {
// Request was cancelled.
@@ -376,8 +377,7 @@
* @param complicationDenied Intent to launch the complication permission denied dialog.
* @param complicationRationale Intent to launch the complication permission rationale dialog.
*/
- @NonNull
- public static Intent createComplicationDataSourceChooserHelperIntent(
+ public static @NonNull Intent createComplicationDataSourceChooserHelperIntent(
@NonNull Context context,
@NonNull ComponentName watchFace,
int watchFaceComplicationId,
@@ -443,8 +443,7 @@
* @param complicationDenied Intent to launch the complication permission denied dialog.
* @param complicationRationale Intent to launch the complication permission rationale dialog.
*/
- @NonNull
- public static Intent createPermissionRequestHelperIntent(
+ public static @NonNull Intent createPermissionRequestHelperIntent(
@NonNull Context context,
@NonNull ComponentName watchFace,
@Nullable Intent complicationDenied,
diff --git a/wear/watchface/watchface/src/test/java/androidx/wear/watchface/JavaCompatTest.java b/wear/watchface/watchface/src/test/java/androidx/wear/watchface/JavaCompatTest.java
index 955a3f7..d2d8d9e 100644
--- a/wear/watchface/watchface/src/test/java/androidx/wear/watchface/JavaCompatTest.java
+++ b/wear/watchface/watchface/src/test/java/androidx/wear/watchface/JavaCompatTest.java
@@ -19,10 +19,11 @@
import android.graphics.Canvas;
import android.graphics.Rect;
-import androidx.annotation.NonNull;
import androidx.annotation.Px;
import androidx.wear.watchface.complications.data.ComplicationData;
+import org.jspecify.annotations.NonNull;
+
import java.time.ZonedDateTime;
/** Tests that Java interfaces implementing kotlin interfaces with defaults compile. */
@@ -60,9 +61,8 @@
@NonNull ZonedDateTime zonedDateTime,
int color) {}
- @NonNull
@Override
- public ComplicationData getData() {
+ public @NonNull ComplicationData getData() {
return null;
}
diff --git a/webkit/integration-tests/instrumentation/build.gradle b/webkit/integration-tests/instrumentation/build.gradle
index 34b6731..3ced188 100644
--- a/webkit/integration-tests/instrumentation/build.gradle
+++ b/webkit/integration-tests/instrumentation/build.gradle
@@ -36,6 +36,7 @@
}
dependencies {
+ api(libs.jspecify)
androidTestImplementation(project(":webkit:webkit"))
androidTestImplementation(libs.okhttpMockwebserver)
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/PollingCheck.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/PollingCheck.java
index 9cf05c9..02f73f3 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/PollingCheck.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/PollingCheck.java
@@ -18,8 +18,7 @@
import android.annotation.SuppressLint;
-import androidx.annotation.NonNull;
-
+import org.jspecify.annotations.NonNull;
import org.junit.Assert;
import java.util.concurrent.Callable;
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/PostMessageTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/PostMessageTest.java
index c881bda..8c10ea2 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/PostMessageTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/PostMessageTest.java
@@ -21,12 +21,12 @@
import android.os.HandlerThread;
import android.os.Looper;
-import androidx.annotation.NonNull;
import androidx.concurrent.futures.ResolvableFuture;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
import androidx.webkit.WebMessagePortCompat.WebMessageCallbackCompat;
+import org.jspecify.annotations.NonNull;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ProxyControllerTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ProxyControllerTest.java
index 8a5ff6d..b0c7f70 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ProxyControllerTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ProxyControllerTest.java
@@ -40,7 +40,6 @@
import okhttp3.mockwebserver.MockWebServer;
-
@MediumTest
@RunWith(AndroidJUnit4.class)
public class ProxyControllerTest {
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ServiceWorkerClientCompatTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ServiceWorkerClientCompatTest.java
index 292a28a..c1e4984 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ServiceWorkerClientCompatTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/ServiceWorkerClientCompatTest.java
@@ -24,11 +24,11 @@
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
@@ -114,9 +114,9 @@
public static class InterceptServiceWorkerClient extends ServiceWorkerClientCompat {
private final List<WebResourceRequest> mInterceptedRequests = new ArrayList<>();
- @Nullable
@Override
- public WebResourceResponse shouldInterceptRequest(@NonNull WebResourceRequest request) {
+ public @Nullable WebResourceResponse shouldInterceptRequest(
+ @NonNull WebResourceRequest request) {
// Records intercepted requests and only return content for SW_URL.
mInterceptedRequests.add(request);
try {
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebSettingsCompatDarkModeTestBase.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebSettingsCompatDarkModeTestBase.java
index 31c4b7d..b971cbf 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebSettingsCompatDarkModeTestBase.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebSettingsCompatDarkModeTestBase.java
@@ -25,11 +25,10 @@
import android.webkit.WebSettings;
import android.webkit.WebView;
-import androidx.annotation.NonNull;
-
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
+import org.jspecify.annotations.NonNull;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
@@ -94,13 +93,11 @@
}
}
- @NonNull
- public WebViewOnUiThread getWebViewOnUiThread() {
+ public @NonNull WebViewOnUiThread getWebViewOnUiThread() {
return mWebViewOnUiThread;
}
- @NonNull
- public WebSettings getSettingsOnUiThread() {
+ public @NonNull WebSettings getSettingsOnUiThread() {
return getWebViewOnUiThread().getSettings();
}
@@ -164,8 +161,7 @@
/**
* Returns a matcher to check if a color int is mostly green.
*/
- @NonNull
- public static Matcher<Integer> isGreen() {
+ public static @NonNull Matcher<Integer> isGreen() {
return new TypeSafeMatcher<Integer>() {
private int mPageColor;
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebSettingsCompatUserAgentMetadataTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebSettingsCompatUserAgentMetadataTest.java
index e71a3ed..0730565 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebSettingsCompatUserAgentMetadataTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebSettingsCompatUserAgentMetadataTest.java
@@ -20,7 +20,6 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-
import android.webkit.CookieManager;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewAssetLoaderTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewAssetLoaderTest.java
index 5aa1861..8839803 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewAssetLoaderTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewAssetLoaderTest.java
@@ -20,8 +20,6 @@
import android.net.Uri;
import android.webkit.WebResourceResponse;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
@@ -31,6 +29,8 @@
import androidx.webkit.WebViewAssetLoader.ResourcesPathHandler;
import androidx.webkit.internal.AssetHelper;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -147,8 +147,7 @@
AssetHelper mockAssetHelper = new AssetHelper(ApplicationProvider.getApplicationContext()) {
@Override
- @NonNull
- public InputStream openAsset(String path) throws IOException {
+ public @NonNull InputStream openAsset(String path) throws IOException {
if (path.equals("www/test.html")) {
return new ByteArrayInputStream(testHtmlContents.getBytes(ENCODING));
}
@@ -172,8 +171,7 @@
AssetHelper mockAssetHelper = new AssetHelper(ApplicationProvider.getApplicationContext()) {
@Override
- @NonNull
- public InputStream openResource(String path) throws IOException {
+ public @NonNull InputStream openResource(String path) throws IOException {
if (path.equals("raw/test.html")) {
return new ByteArrayInputStream(testHtmlContents.getBytes(ENCODING));
}
@@ -404,14 +402,12 @@
AssetHelper mockAssetHelper = new AssetHelper(ApplicationProvider.getApplicationContext()) {
@Override
- @NonNull
- public InputStream openAsset(String path) throws IOException {
+ public @NonNull InputStream openAsset(String path) throws IOException {
return new ByteArrayInputStream(testHtmlContents.getBytes(ENCODING));
}
@Override
- @NonNull
- public InputStream openResource(String path) throws IOException {
+ public @NonNull InputStream openResource(String path) throws IOException {
return new ByteArrayInputStream(testHtmlContents.getBytes(ENCODING));
}
};
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewClientCompatTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewClientCompatTest.java
index 227eb31..3f3b999 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewClientCompatTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewClientCompatTest.java
@@ -23,11 +23,11 @@
import android.webkit.WebView;
import android.webkit.WebViewClient;
-import androidx.annotation.NonNull;
import androidx.concurrent.futures.ResolvableFuture;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
+import org.jspecify.annotations.NonNull;
import org.junit.After;
import org.junit.Assert;
import org.junit.Assume;
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewCompatTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewCompatTest.java
index 5c86c57..ffdb08f 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewCompatTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewCompatTest.java
@@ -34,7 +34,6 @@
import android.webkit.WebView;
import android.webkit.WebViewClient;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.concurrent.futures.ResolvableFuture;
import androidx.test.core.app.ApplicationProvider;
@@ -42,6 +41,7 @@
import androidx.test.filters.MediumTest;
import androidx.test.filters.SdkSuppress;
+import org.jspecify.annotations.NonNull;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewDocumentStartJavaScriptTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewDocumentStartJavaScriptTest.java
index a8c9aee..1d1555f 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewDocumentStartJavaScriptTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewDocumentStartJavaScriptTest.java
@@ -19,10 +19,10 @@
import android.net.Uri;
import android.webkit.WebView;
-import androidx.annotation.NonNull;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
+import org.jspecify.annotations.NonNull;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewOnUiThread.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewOnUiThread.java
index ed2df16..4aa12b9 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewOnUiThread.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewOnUiThread.java
@@ -33,11 +33,12 @@
import android.webkit.WebViewClient;
import androidx.annotation.CallSuper;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.concurrent.futures.ResolvableFuture;
import androidx.test.core.app.ApplicationProvider;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.Executor;
@@ -118,8 +119,7 @@
volatile WebView mView;
}
- @NonNull
- public static WebView createWebView() {
+ public static @NonNull WebView createWebView() {
final Holder h = new Holder();
final Context ctx = ApplicationProvider.getApplicationContext();
WebkitUtils.onMainThreadSync(() -> {
@@ -233,20 +233,17 @@
webView, executor, webViewRenderProcessClient));
}
- @Nullable
- public WebViewRenderProcessClient getWebViewRenderProcessClient() {
+ public @Nullable WebViewRenderProcessClient getWebViewRenderProcessClient() {
return getWebViewRenderProcessClient(mWebView);
}
- @Nullable
- public static WebViewRenderProcessClient getWebViewRenderProcessClient(
+ public static @Nullable WebViewRenderProcessClient getWebViewRenderProcessClient(
final @NonNull WebView webView) {
return WebkitUtils.onMainThreadSync(
() -> WebViewCompat.getWebViewRenderProcessClient(webView));
}
- @NonNull
- public WebMessagePortCompat[] createWebMessageChannelCompat() {
+ public WebMessagePortCompat @NonNull [] createWebMessageChannelCompat() {
return WebkitUtils.onMainThreadSync(() -> WebViewCompat.createWebMessageChannel(mWebView));
}
@@ -258,7 +255,7 @@
public void addWebMessageListener(@NonNull String jsObjectName,
@NonNull Set<String> allowedOriginRules,
- final @NonNull WebViewCompat.WebMessageListener listener) {
+ final WebViewCompat.@NonNull WebMessageListener listener) {
WebkitUtils.onMainThreadSync(() -> WebViewCompat.addWebMessageListener(
mWebView, jsObjectName, allowedOriginRules, listener));
}
@@ -271,10 +268,9 @@
/**
* @deprecated unreleased API to be removed
*/
- @NonNull
@Deprecated
@SuppressWarnings("deprecation") // To be removed in 1.9.0
- public ScriptHandler addDocumentStartJavaScript(
+ public @NonNull ScriptHandler addDocumentStartJavaScript(
@NonNull String script, @NonNull Set<String> allowedOriginRules) {
return WebkitUtils.onMainThreadSync(() -> WebViewCompat.addDocumentStartJavaScript(
mWebView, script, allowedOriginRules));
@@ -290,7 +286,7 @@
* Test fails if the load timeout elapses.
* @param url The URL to load.
*/
- public void loadUrlAndWaitForCompletion(@NonNull final String url) {
+ public void loadUrlAndWaitForCompletion(final @NonNull String url) {
callAndWait(() -> mWebView.loadUrl(url));
}
@@ -306,8 +302,8 @@
* @param mimeType The mimeType to pass to loadData.
* @param encoding The encoding to pass to loadData.
*/
- public void loadDataAndWaitForCompletion(@NonNull final String data,
- @Nullable final String mimeType, @Nullable final String encoding) {
+ public void loadDataAndWaitForCompletion(final @NonNull String data,
+ final @Nullable String mimeType, final @Nullable String encoding) {
callAndWait(() -> mWebView.loadData(data, mimeType, encoding));
}
@@ -337,23 +333,20 @@
}
}
- @Nullable
- public String getTitle() {
+ public @Nullable String getTitle() {
return WebkitUtils.onMainThreadSync(() -> mWebView.getTitle());
}
- @NonNull
- public WebSettings getSettings() {
+ public @NonNull WebSettings getSettings() {
return WebkitUtils.onMainThreadSync(() -> mWebView.getSettings());
}
- @Nullable
- public String getUrl() {
+ public @Nullable String getUrl() {
return WebkitUtils.onMainThreadSync(() -> mWebView.getUrl());
}
public void postVisualStateCallbackCompat(final long requestId,
- final @NonNull WebViewCompat.VisualStateCallback callback) {
+ final WebViewCompat.@NonNull VisualStateCallback callback) {
WebkitUtils.onMainThreadSync(() -> WebViewCompat.postVisualStateCallback(
mWebView, requestId, callback));
}
@@ -361,8 +354,7 @@
/**
* Execute javascript synchronously, returning the result.
*/
- @Nullable
- public String evaluateJavascriptSync(final @NonNull String script) {
+ public @Nullable String evaluateJavascriptSync(final @NonNull String script) {
final ResolvableFuture<String> future = ResolvableFuture.create();
evaluateJavascript(script, future::set);
return WebkitUtils.waitForFuture(future);
@@ -373,28 +365,23 @@
WebkitUtils.onMainThread(() -> mWebView.evaluateJavascript(script, result));
}
- @NonNull
- public WebViewClient getWebViewClient() {
+ public @NonNull WebViewClient getWebViewClient() {
return getWebViewClient(mWebView);
}
- @NonNull
- public static WebViewClient getWebViewClient(final @NonNull WebView webView) {
+ public static @NonNull WebViewClient getWebViewClient(final @NonNull WebView webView) {
return WebkitUtils.onMainThreadSync(() -> WebViewCompat.getWebViewClient(webView));
}
- @Nullable
- public WebChromeClient getWebChromeClient() {
+ public @Nullable WebChromeClient getWebChromeClient() {
return getWebChromeClient(mWebView);
}
- @Nullable
- public static WebChromeClient getWebChromeClient(final @NonNull WebView webView) {
+ public static @Nullable WebChromeClient getWebChromeClient(final @NonNull WebView webView) {
return WebkitUtils.onMainThreadSync(() -> WebViewCompat.getWebChromeClient(webView));
}
- @NonNull
- public WebView getWebViewOnCurrentThread() {
+ public @NonNull WebView getWebViewOnCurrentThread() {
return mWebView;
}
@@ -425,8 +412,7 @@
* This synchronises so that the bitmap contents reflects the current DOM state, rather than
* potentially capturing a previously generated frame.
*/
- @NonNull
- public Bitmap captureBitmap() {
+ public @NonNull Bitmap captureBitmap() {
WebSettingsCompat.setOffscreenPreRaster(getSettings(), true);
waitForDOMReadyToRender();
return WebkitUtils.onMainThreadSync(() -> {
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewRenderProcessClientTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewRenderProcessClientTest.java
index 3e0c15f..68cb17b 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewRenderProcessClientTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewRenderProcessClientTest.java
@@ -20,12 +20,12 @@
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.concurrent.futures.ResolvableFuture;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewTestActivity.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewTestActivity.java
index 0cd87a3..a1be63e 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewTestActivity.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewTestActivity.java
@@ -21,14 +21,13 @@
import android.view.ViewGroup;
import android.webkit.WebView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
public class WebViewTestActivity extends Activity {
private WebView mWebView;
- @NonNull
- public WebView getWebView() {
+ public @NonNull WebView getWebView() {
return mWebView;
}
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewVersion.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewVersion.java
index 254764a..7315225 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewVersion.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewVersion.java
@@ -19,10 +19,11 @@
import android.content.Context;
import android.content.pm.PackageInfo;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.core.app.ApplicationProvider;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -49,8 +50,7 @@
}
}
- @Nullable
- static WebViewVersion getInstalledWebViewVersionFromPackage() {
+ static @Nullable WebViewVersion getInstalledWebViewVersionFromPackage() {
Context context = ApplicationProvider.getApplicationContext();
// Before M42, we used the major version number, followed by other text wrapped in
// parentheses.
@@ -92,9 +92,8 @@
return 0;
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
return this.mComponents[0] + "." + this.mComponents[1] + "."
+ this.mComponents[2] + "." + this.mComponents[3];
}
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewWebMessageCompatTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewWebMessageCompatTest.java
index 3104db2..78986b7 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewWebMessageCompatTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewWebMessageCompatTest.java
@@ -20,11 +20,11 @@
import android.os.Handler;
import android.os.Looper;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewWebMessageListenerTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewWebMessageListenerTest.java
index 37f689b..46f99d2 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewWebMessageListenerTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebViewWebMessageListenerTest.java
@@ -19,10 +19,10 @@
import android.net.Uri;
import android.webkit.WebView;
-import androidx.annotation.NonNull;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.MediumTest;
+import org.jspecify.annotations.NonNull;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebkitUtils.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebkitUtils.java
index 182f10e..b3e8506 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebkitUtils.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/WebkitUtils.java
@@ -19,11 +19,11 @@
import android.os.Handler;
import android.os.Looper;
-import androidx.annotation.NonNull;
import androidx.concurrent.futures.ResolvableFuture;
import com.google.common.util.concurrent.ListenableFuture;
+import org.jspecify.annotations.NonNull;
import org.junit.Assume;
import java.io.File;
@@ -65,8 +65,8 @@
* @param callable the {@link Callable} to execute.
* @return a {@link ListenableFuture} representing the result of {@code callable}.
*/
- @NonNull
- public static <T> ListenableFuture<T> onMainThread(final @NonNull Callable<T> callable) {
+ public static <T> @NonNull ListenableFuture<T> onMainThread(
+ final @NonNull Callable<T> callable) {
return onMainThreadDelayed(0, callable);
}
@@ -86,8 +86,7 @@
* @param callable the {@link Callable} to execute.
* @return a {@link ListenableFuture} representing the result of {@code callable}.
*/
- @NonNull
- public static <T> ListenableFuture<T> onMainThreadDelayed(
+ public static <T> @NonNull ListenableFuture<T> onMainThreadDelayed(
long delayMs, final @NonNull Callable<T> callable) {
final ResolvableFuture<T> future = ResolvableFuture.create();
sMainHandler.postDelayed(() -> {
diff --git a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/internal/WebViewFeatureInternalTest.java b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/internal/WebViewFeatureInternalTest.java
index a406145..31c72aa 100644
--- a/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/internal/WebViewFeatureInternalTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTest/java/androidx/webkit/internal/WebViewFeatureInternalTest.java
@@ -19,10 +19,10 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import androidx.annotation.NonNull;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
+import org.jspecify.annotations.NonNull;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -48,8 +48,7 @@
}
@Override
- @NonNull
- public String getPublicFeatureName() {
+ public @NonNull String getPublicFeatureName() {
return mPublicFeatureValue;
}
}
diff --git a/webkit/integration-tests/instrumentation/src/androidTestTargetSdk32/java/androidx/webkit/WebSettingsCompatForceDarkTest.java b/webkit/integration-tests/instrumentation/src/androidTestTargetSdk32/java/androidx/webkit/WebSettingsCompatForceDarkTest.java
index 426bcd0..68b554d 100644
--- a/webkit/integration-tests/instrumentation/src/androidTestTargetSdk32/java/androidx/webkit/WebSettingsCompatForceDarkTest.java
+++ b/webkit/integration-tests/instrumentation/src/androidTestTargetSdk32/java/androidx/webkit/WebSettingsCompatForceDarkTest.java
@@ -29,7 +29,6 @@
import org.junit.Test;
import org.junit.runner.RunWith;
-
/**
* Instrumentation tests for pre-33 dark mode behavior.
*/
diff --git a/webkit/integration-tests/testapp/build.gradle b/webkit/integration-tests/testapp/build.gradle
index 382dcd7..5071e58 100644
--- a/webkit/integration-tests/testapp/build.gradle
+++ b/webkit/integration-tests/testapp/build.gradle
@@ -30,6 +30,7 @@
}
dependencies {
+ api(libs.jspecify)
implementation("androidx.appcompat:appcompat:1.1.0")
implementation("androidx.core:core:1.1.0")
implementation("androidx.annotation:annotation:1.8.1")
diff --git a/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/WebkitTestHelpers.java b/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/WebkitTestHelpers.java
index 1d64198..e01fabb 100644
--- a/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/WebkitTestHelpers.java
+++ b/webkit/integration-tests/testapp/src/androidTest/java/com/example/androidx/webkit/WebkitTestHelpers.java
@@ -34,12 +34,12 @@
import android.content.Context;
import androidx.annotation.IdRes;
-import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import androidx.test.espresso.web.webdriver.Locator;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.NonNull;
import org.junit.Assume;
/**
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AllowlistActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AllowlistActivity.java
index 350bcdc..dd8ae2d 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AllowlistActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AllowlistActivity.java
@@ -20,7 +20,6 @@
import android.os.Bundle;
import android.webkit.WebView;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SwitchCompat;
import androidx.webkit.WebSettingsCompat;
@@ -28,6 +27,8 @@
import androidx.webkit.WebViewCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.Nullable;
+
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderAjaxActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderAjaxActivity.java
index 6acd859..7a69c55 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderAjaxActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderAjaxActivity.java
@@ -26,8 +26,6 @@
import android.webkit.WebViewClient;
import android.widget.Button;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AppCompatActivity;
import androidx.test.espresso.idling.net.UriIdlingResource;
@@ -35,6 +33,9 @@
import androidx.webkit.WebViewAssetLoader.AssetsPathHandler;
import androidx.webkit.WebViewAssetLoader.ResourcesPathHandler;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link Activity} to show a more useful use case: performing ajax calls to load files from
* local app assets and resources in a safer way using WebViewAssetLoader.
@@ -84,8 +85,7 @@
// IdlingResource that indicates that WebView has finished loading all WebResourceRequests
// by waiting until there are no requests made for 5000ms.
- @NonNull
- private final UriIdlingResource mUriIdlingResource =
+ private final @NonNull UriIdlingResource mUriIdlingResource =
new UriIdlingResource("AssetLoaderWebViewUriIdlingResource", MAX_IDLE_TIME_MS);
@SuppressLint("SetJavaScriptEnabled")
@@ -153,8 +153,7 @@
* all requested URIs.
*/
@VisibleForTesting
- @NonNull
- public UriIdlingResource getUriIdlingResource() {
+ public @NonNull UriIdlingResource getUriIdlingResource() {
return mUriIdlingResource;
}
}
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderInternalStorageActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderInternalStorageActivity.java
index bc683d9b..3187ada 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderInternalStorageActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderInternalStorageActivity.java
@@ -28,12 +28,13 @@
import android.webkit.WebView;
import android.webkit.WebViewClient;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebViewAssetLoader;
import androidx.webkit.WebViewAssetLoader.InternalStoragePathHandler;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -47,9 +48,9 @@
private static final String DEMO_HTML_CONTENT =
"<h3 id=\"data_success_msg\">Successfully loaded html from app files dir!</h3>";
- @NonNull private File mPublicDir;
- @NonNull private File mDemoFile;
- @NonNull private WebView mWebView;
+ private @NonNull File mPublicDir;
+ private @NonNull File mDemoFile;
+ private @NonNull WebView mWebView;
private static class MyWebViewClient extends WebViewClient {
private final WebViewAssetLoader mAssetLoader;
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderListActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderListActivity.java
index e07539e..7cde95c 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderListActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderListActivity.java
@@ -22,9 +22,10 @@
import android.os.Bundle;
import android.widget.ListView;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link Activity} for exercising various WebView functionality. This Activity is a {@link
* ListView} which starts other Activities, each of which may similarly be a ListView, or may
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderSimpleActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderSimpleActivity.java
index 594acdb..4071389 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderSimpleActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AssetLoaderSimpleActivity.java
@@ -24,11 +24,12 @@
import android.webkit.WebView;
import android.webkit.WebViewClient;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebViewAssetLoader;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link Activity} to show case a very simple use case of using
* {@link androidx.webkit.WebViewAssetLoader}.
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AsyncStartUpActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AsyncStartUpActivity.java
index 31dcf51..ea07c92 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AsyncStartUpActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/AsyncStartUpActivity.java
@@ -23,12 +23,13 @@
import android.widget.LinearLayout;
import android.widget.TextView;
-import androidx.annotation.Nullable;
import androidx.annotation.OptIn;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebViewCompat;
import androidx.webkit.WebViewStartUpConfig;
+import org.jspecify.annotations.Nullable;
+
import java.util.concurrent.Executors;
/**
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/CookieManagerActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/CookieManagerActivity.java
index dc503b0..9913e4d 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/CookieManagerActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/CookieManagerActivity.java
@@ -22,11 +22,12 @@
import android.webkit.WebViewClient;
import android.widget.TextView;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.CookieManagerCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/CustomInterstitialActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/CustomInterstitialActivity.java
index 070268c..082c5a1 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/CustomInterstitialActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/CustomInterstitialActivity.java
@@ -23,13 +23,14 @@
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.SafeBrowsingResponseCompat;
import androidx.webkit.WebViewClientCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link Activity} which shows a custom interstitial if {@link WebView} encounters malicious
* resources. This class contains the logic for responding to user interaction with custom
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/DataDirectorySuffixActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/DataDirectorySuffixActivity.java
index d8610f2..ac29adf 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/DataDirectorySuffixActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/DataDirectorySuffixActivity.java
@@ -22,11 +22,11 @@
import android.webkit.WebViewClient;
import android.widget.TextView;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.ProcessGlobalConfig;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.Nullable;
/**
* An {@link Activity} which makes use of
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/DirectoryBasePathsActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/DirectoryBasePathsActivity.java
index ce6f4f4..ea400b7 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/DirectoryBasePathsActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/DirectoryBasePathsActivity.java
@@ -23,12 +23,13 @@
import android.webkit.WebViewClient;
import android.widget.TextView;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.webkit.ProcessGlobalConfig;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.Nullable;
+
import java.io.File;
/**
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/DocumentStartJavaScriptActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/DocumentStartJavaScriptActivity.java
index 4238793..8b05214 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/DocumentStartJavaScriptActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/DocumentStartJavaScriptActivity.java
@@ -28,8 +28,6 @@
import android.webkit.WebViewClient;
import android.widget.Button;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.JavaScriptReplyProxy;
import androidx.webkit.WebMessageCompat;
@@ -37,6 +35,9 @@
import androidx.webkit.WebViewCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Collections;
import java.util.HashSet;
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ErrorLoggingWebViewClient.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ErrorLoggingWebViewClient.java
index 4ab8da4..94f8542 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ErrorLoggingWebViewClient.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ErrorLoggingWebViewClient.java
@@ -20,11 +20,12 @@
import android.webkit.WebView;
import android.widget.TextView;
-import androidx.annotation.NonNull;
import androidx.webkit.WebResourceErrorCompat;
import androidx.webkit.WebViewClientCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.NonNull;
+
import java.util.Locale;
/**
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ForceDarkActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ForceDarkActivity.java
index 5331d1f..278e2e7 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ForceDarkActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ForceDarkActivity.java
@@ -24,11 +24,12 @@
import android.webkit.WebView;
import android.webkit.WebViewClient;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebSettingsCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link Activity} to exercise Force Dark functionality.
* It shows WebViews side by side with different dark mode settings.
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ForceDarkStrategyActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ForceDarkStrategyActivity.java
index e6d53d4..9692e04 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ForceDarkStrategyActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ForceDarkStrategyActivity.java
@@ -25,11 +25,12 @@
import android.widget.Spinner;
import android.widget.Switch;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebSettingsCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link Activity} to exercise Force Dark Strategy functionality.
* It loads two web-pages in WebViews, one of which supports dark-theme while another does not
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/FullPageInterstitialActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/FullPageInterstitialActivity.java
index aa4caf5..4108d56 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/FullPageInterstitialActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/FullPageInterstitialActivity.java
@@ -22,11 +22,12 @@
import android.webkit.WebView;
import android.webkit.WebViewClient;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebSettingsCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link android.app.Activity} to demonstrate full page interstitials. WebView displays a
* red or grey error page with considerable description when it's "full" sized (takes up almost
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/FullscreenActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/FullscreenActivity.java
index 837ab2f..d97be25 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/FullscreenActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/FullscreenActivity.java
@@ -27,9 +27,10 @@
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
+import org.jspecify.annotations.Nullable;
+
/**
* An Activity to demonstrate how to properly display fullscreen web content with WebView.
*/
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/GetVariationsHeaderActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/GetVariationsHeaderActivity.java
index 7d21392..076faa6 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/GetVariationsHeaderActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/GetVariationsHeaderActivity.java
@@ -21,13 +21,14 @@
import android.webkit.WebViewClient;
import android.widget.TextView;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebViewCompat;
import androidx.webkit.WebViewFeature;
import com.google.common.collect.ImmutableMap;
+import org.jspecify.annotations.Nullable;
+
/** An {@link android.app.Activity} to demonstrate the getVariationsHeader() API. */
public class GetVariationsHeaderActivity extends AppCompatActivity {
@Override
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/GiantInterstitialActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/GiantInterstitialActivity.java
index 894f92f..ea97076 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/GiantInterstitialActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/GiantInterstitialActivity.java
@@ -21,11 +21,12 @@
import android.webkit.WebView;
import android.widget.LinearLayout;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebSettingsCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link android.app.Activity} to demonstrate Quiet Giant interstitials. Similar to {@link
* SmallInterstitialActivity}, WebView displays a grey error page with very little text when it
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/HttpServer.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/HttpServer.java
index f47fa96..cc91e2a 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/HttpServer.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/HttpServer.java
@@ -18,8 +18,8 @@
import static java.nio.charset.StandardCharsets.UTF_8;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -58,8 +58,7 @@
/**
* Called to initialize a new RequestHandler
*/
- @NonNull
- RequestHandler create(@NonNull Socket socket);
+ @NonNull RequestHandler create(@NonNull Socket socket);
}
private static final int TIMEOUT_MILLIS = 5000;
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ImageDragActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ImageDragActivity.java
index 1569ff6..2e8a2c0 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ImageDragActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ImageDragActivity.java
@@ -20,9 +20,10 @@
import android.webkit.WebView;
import android.webkit.WebViewClient;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
+import org.jspecify.annotations.Nullable;
+
/**
* An Activity to demonstrate example for dragging image out to other apps.
* You can use google logo to test.
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/InvisibleActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/InvisibleActivity.java
index 298a039..f942f23 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/InvisibleActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/InvisibleActivity.java
@@ -22,11 +22,12 @@
import android.webkit.WebView;
import android.widget.TextView;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebSettingsCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link android.app.Activity} to demonstrate Safe Browsing behavior with a {@link WebView}
* instance which is attached to the view hierarchy, but marked as {@link
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/JsJavaInteractionActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/JsJavaInteractionActivity.java
index e7841a5..f0d00d6c 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/JsJavaInteractionActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/JsJavaInteractionActivity.java
@@ -21,9 +21,10 @@
import android.content.Intent;
import android.os.Bundle;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link Activity} to exercise Js Java interaction related functionality.
*/
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MainActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MainActivity.java
index 23d4f17..0ea7265 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MainActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MainActivity.java
@@ -22,9 +22,10 @@
import android.os.Bundle;
import android.widget.ListView;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link Activity} for exercising various WebView functionality. This Activity is a {@link
* ListView} which starts other Activities, each of which may similarly be a ListView, or may
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MediumInterstitialActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MediumInterstitialActivity.java
index 934f3a3..240292b 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MediumInterstitialActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MediumInterstitialActivity.java
@@ -22,13 +22,14 @@
import android.webkit.WebViewClient;
import android.widget.LinearLayout;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebSettingsCompat;
import androidx.webkit.WebViewFeature;
import com.google.common.collect.ImmutableMap;
+import org.jspecify.annotations.Nullable;
+
import java.util.Map;
/**
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MenuListView.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MenuListView.java
index 78114cd..63bc4bd 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MenuListView.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MenuListView.java
@@ -22,8 +22,8 @@
import android.widget.ArrayAdapter;
import android.widget.ListView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* A {@link ListView} which serves as a menu of elements firing {@link Intent}s to other Activities.
@@ -57,8 +57,7 @@
}
@Override
- @NonNull
- public String toString() {
+ public @NonNull String toString() {
return mName;
}
@@ -77,7 +76,7 @@
/**
* Sets the menu items for this {@link MenuListView}.
*/
- public void setItems(@NonNull MenuItem[] items) {
+ public void setItems(MenuItem @NonNull [] items) {
final Context context = getContext();
ArrayAdapter<MenuItem> featureArrayAdapter =
new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, items);
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MultiProcessEnabledActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MultiProcessEnabledActivity.java
index a37014c..08c5bac 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MultiProcessEnabledActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MultiProcessEnabledActivity.java
@@ -18,11 +18,12 @@
import android.os.Bundle;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebViewCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link android.app.Activity} to demonstrate IsMultiProcessEnabled query.
*/
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MultiProfileTestActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MultiProfileTestActivity.java
index fda0a09..ff9d6ce 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MultiProfileTestActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MultiProfileTestActivity.java
@@ -22,13 +22,14 @@
import android.webkit.WebViewClient;
import android.widget.Toast;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.Profile;
import androidx.webkit.ProfileStore;
import androidx.webkit.WebViewCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link android.app.Activity} to demonstrate using Multi-Profile feature.
*
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MuteAudioActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MuteAudioActivity.java
index 880c2c2..5489fe3 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MuteAudioActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/MuteAudioActivity.java
@@ -22,7 +22,6 @@
import android.webkit.WebView;
import android.widget.Toast;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebViewCompat;
import androidx.webkit.WebViewFeature;
@@ -30,12 +29,13 @@
import com.google.common.base.Charsets;
import com.google.common.io.ByteStreams;
+import org.jspecify.annotations.Nullable;
+
import java.io.IOException;
import java.io.InputStream;
public class MuteAudioActivity extends AppCompatActivity {
- @Nullable
- private WebView mWebView;
+ private @Nullable WebView mWebView;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/PerWebViewEnableActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/PerWebViewEnableActivity.java
index 1ffe8b6..661ae0f 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/PerWebViewEnableActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/PerWebViewEnableActivity.java
@@ -19,11 +19,12 @@
import android.os.Bundle;
import android.webkit.WebView;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebSettingsCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link android.app.Activity} to demonstrate functionality to selectively enable/disable Safe
* Browsing for a subset of the application's {@link WebView}s. This shows three WebViews, to show
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/PopupInterstitialActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/PopupInterstitialActivity.java
index b56fe59..5f4753b 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/PopupInterstitialActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/PopupInterstitialActivity.java
@@ -25,11 +25,12 @@
import android.widget.CheckBox;
import android.widget.TextView;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.text.HtmlCompat;
import androidx.webkit.WebViewCompat;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link Activity} to demonstrate one way to implement a custom Safe Browsing interstitial. This
* should not be launched by itself (thus, it's not exported), but should be launched in response to
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ProcessGlobalConfigActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ProcessGlobalConfigActivity.java
index e35f253..6cb5e12 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ProcessGlobalConfigActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ProcessGlobalConfigActivity.java
@@ -21,9 +21,10 @@
import android.content.Intent;
import android.os.Bundle;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link Activity} which lists features that make use of
* {@link androidx.webkit.ProcessGlobalConfig} to set up process global configuration prior to
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ProxyOverrideActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ProxyOverrideActivity.java
index ae283e3..8eb0f4a 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ProxyOverrideActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/ProxyOverrideActivity.java
@@ -24,13 +24,14 @@
import android.widget.CheckBox;
import android.widget.TextView;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.ProxyConfig;
import androidx.webkit.ProxyController;
import androidx.webkit.WebViewClientCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link Activity} to exercise Proxy Override functionality.
*/
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/RendererTerminationActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/RendererTerminationActivity.java
index 4abcc8a..89b876e 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/RendererTerminationActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/RendererTerminationActivity.java
@@ -32,8 +32,6 @@
import android.widget.FrameLayout;
import android.widget.TextView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.DialogFragment;
@@ -42,6 +40,9 @@
import androidx.webkit.WebViewRenderProcess;
import androidx.webkit.WebViewRenderProcessClient;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/** An activity demonstrating the behaviour of renderer APIs. */
public class RendererTerminationActivity extends AppCompatActivity {
private TextView mStatus;
@@ -85,16 +86,14 @@
/** A renderer terminated {@link DialogFragment}. */
public static class RendererTerminatedDialogFragment extends DialogFragment {
/** Creates a new RendererTerminatedDialogFragment instance. */
- @NonNull
- public static RendererTerminatedDialogFragment newInstance() {
+ public static @NonNull RendererTerminatedDialogFragment newInstance() {
RendererTerminatedDialogFragment dialog = new RendererTerminatedDialogFragment();
dialog.setCancelable(false);
return dialog;
}
@Override
- @NonNull
- public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
+ public @NonNull Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
View v = LayoutInflater.from(getActivity())
.inflate(R.layout.fragment_renderer_terminated, null);
final Dialog dialog = new AlertDialog.Builder(getActivity())
@@ -111,16 +110,14 @@
/** A renderer unresponsive {@link DialogFragment}. */
public static class RendererUnresponsiveDialogFragment extends DialogFragment {
/** Creates a new RendererUnresponsiveDialogFragment instance. */
- @NonNull
- public static RendererUnresponsiveDialogFragment newInstance() {
+ public static @NonNull RendererUnresponsiveDialogFragment newInstance() {
RendererUnresponsiveDialogFragment dialog = new RendererUnresponsiveDialogFragment();
dialog.setCancelable(false);
return dialog;
}
@Override
- @NonNull
- public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
+ public @NonNull Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
View v = LayoutInflater.from(getActivity())
.inflate(R.layout.fragment_renderer_unresponsive, null);
final Dialog dialog = new AlertDialog.Builder(getActivity())
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/RequestedWithHeaderActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/RequestedWithHeaderActivity.java
index a956d90..d50dd79 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/RequestedWithHeaderActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/RequestedWithHeaderActivity.java
@@ -22,12 +22,13 @@
import android.webkit.WebView;
import android.widget.RadioGroup;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebSettingsCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Collections;
import java.util.Set;
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/RestrictedContentActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/RestrictedContentActivity.java
index 1c1009a..f4bddc6 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/RestrictedContentActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/RestrictedContentActivity.java
@@ -21,9 +21,10 @@
import android.content.Intent;
import android.os.Bundle;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link Activity} to exercise Restricted Content blocking functionality.
*/
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/SafeBrowsingActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/SafeBrowsingActivity.java
index 35534ca..b039a16 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/SafeBrowsingActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/SafeBrowsingActivity.java
@@ -21,9 +21,10 @@
import android.content.Intent;
import android.os.Bundle;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link Activity} to exercise Safe Browsing functionality.
*/
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/SmallInterstitialActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/SmallInterstitialActivity.java
index d99b9cb..5018d16 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/SmallInterstitialActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/SmallInterstitialActivity.java
@@ -20,11 +20,12 @@
import android.os.Bundle;
import android.webkit.WebView;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebSettingsCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link android.app.Activity} to demonstrate small ("Quiet") interstitials.
* <p>
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/TinyInterstitialActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/TinyInterstitialActivity.java
index ce55ca1..32cdf05 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/TinyInterstitialActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/TinyInterstitialActivity.java
@@ -19,9 +19,10 @@
import android.os.Bundle;
import android.webkit.WebView;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link android.app.Activity} to demonstrate tiny interstitials.
* <p>
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/TracingControllerActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/TracingControllerActivity.java
index 41521e9..e8c6c4d 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/TracingControllerActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/TracingControllerActivity.java
@@ -29,7 +29,6 @@
import android.widget.EditText;
import android.widget.TextView;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.TracingConfig;
import androidx.webkit.TracingController;
@@ -37,6 +36,7 @@
import org.json.JSONException;
import org.json.JSONObject;
+import org.jspecify.annotations.Nullable;
import java.io.BufferedReader;
import java.io.File;
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/UnattachedActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/UnattachedActivity.java
index e72cd23..accde1e 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/UnattachedActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/UnattachedActivity.java
@@ -20,11 +20,12 @@
import android.webkit.WebView;
import android.widget.TextView;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebSettingsCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.Nullable;
+
/**
* An {@link android.app.Activity} to demonstrate Safe Browsing behavior with a {@link WebView}
* instance which is detached from the view hierarchy. This behaves identically to {@link
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/UserAgentMetadataActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/UserAgentMetadataActivity.java
index 1cb19f1..b3d9407 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/UserAgentMetadataActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/UserAgentMetadataActivity.java
@@ -28,14 +28,15 @@
import android.webkit.WebViewClient;
import android.widget.RadioGroup;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.UserAgentMetadata;
import androidx.webkit.WebSettingsCompat;
import androidx.webkit.WebViewAssetLoader;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Collections;
/**
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageCompatActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageCompatActivity.java
index 8c66216..a0264cd 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageCompatActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageCompatActivity.java
@@ -30,8 +30,6 @@
import android.widget.Spinner;
import android.widget.TextView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.WebMessageCompat;
import androidx.webkit.WebMessagePortCompat;
@@ -41,6 +39,9 @@
import com.google.common.base.Charsets;
import com.google.common.io.ByteStreams;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageListenerActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageListenerActivity.java
index c604d9e..969c70a 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageListenerActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageListenerActivity.java
@@ -36,8 +36,6 @@
import android.widget.TextView;
import android.widget.Toast;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.JavaScriptReplyProxy;
import androidx.webkit.WebMessageCompat;
@@ -46,6 +44,9 @@
import androidx.webkit.WebViewCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Arrays;
import java.util.HashSet;
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageListenerMaliciousWebsiteActivity.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageListenerMaliciousWebsiteActivity.java
index b72ca5b..5b5c9c0 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageListenerMaliciousWebsiteActivity.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebMessageListenerMaliciousWebsiteActivity.java
@@ -28,8 +28,6 @@
import android.webkit.WebViewClient;
import android.widget.Toast;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.webkit.JavaScriptReplyProxy;
import androidx.webkit.WebMessageCompat;
@@ -37,6 +35,9 @@
import androidx.webkit.WebViewCompat;
import androidx.webkit.WebViewFeature;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
diff --git a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebkitHelpers.java b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebkitHelpers.java
index 0a86ae3..e74f2b5 100644
--- a/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebkitHelpers.java
+++ b/webkit/integration-tests/testapp/src/main/java/com/example/androidx/webkit/WebkitHelpers.java
@@ -20,10 +20,11 @@
import android.content.pm.PackageInfo;
import android.widget.TextView;
-import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import androidx.webkit.WebViewCompat;
+import org.jspecify.annotations.NonNull;
+
/**
* Static utility methods for the Webkit demo app.
*/
@@ -55,8 +56,7 @@
* @param messageResourceId the resource ID of the message to show.
* @return the {@link TextView} holding the error message.
*/
- @NonNull
- public static TextView showMessageInActivity(@NonNull Activity activity,
+ public static @NonNull TextView showMessageInActivity(@NonNull Activity activity,
@StringRes int messageResourceId) {
TextView errorMessage = new TextView(activity);
errorMessage.setText(messageResourceId);
diff --git a/webkit/webkit/build.gradle b/webkit/webkit/build.gradle
index c52a8a4..7457fc4 100644
--- a/webkit/webkit/build.gradle
+++ b/webkit/webkit/build.gradle
@@ -30,6 +30,7 @@
}
dependencies {
+ api(libs.jspecify)
api("androidx.annotation:annotation:1.8.1")
api("androidx.core:core:1.1.0")
api("androidx.annotation:annotation-experimental:1.4.1")
diff --git a/webkit/webkit/src/main/java/androidx/webkit/CookieManagerCompat.java b/webkit/webkit/src/main/java/androidx/webkit/CookieManagerCompat.java
index 8b77d9a..f6e315a 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/CookieManagerCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/CookieManagerCompat.java
@@ -19,13 +19,14 @@
import android.webkit.CookieManager;
import androidx.annotation.AnyThread;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresFeature;
import androidx.webkit.internal.ApiFeature;
import androidx.webkit.internal.CookieManagerAdapter;
import androidx.webkit.internal.WebViewFeatureInternal;
import androidx.webkit.internal.WebViewGlueCommunicator;
+import org.jspecify.annotations.NonNull;
+
import java.util.List;
/**
diff --git a/webkit/webkit/src/main/java/androidx/webkit/DropDataContentProvider.java b/webkit/webkit/src/main/java/androidx/webkit/DropDataContentProvider.java
index 50bf858..e9c943e 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/DropDataContentProvider.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/DropDataContentProvider.java
@@ -23,11 +23,11 @@
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.webkit.internal.WebViewGlueCommunicator;
import org.chromium.support_lib_boundary.DropDataContentProviderBoundaryInterface;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.io.FileNotFoundException;
@@ -56,48 +56,44 @@
return true;
}
- @Nullable
@Override
- public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode)
+ public @Nullable ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode)
throws FileNotFoundException {
return getDropImpl().openFile(this, uri);
}
- @Nullable
@Override
- public Cursor query(@NonNull Uri uri, @Nullable String[] projection,
- @Nullable String selection, @Nullable String[] selectionArgs,
+ public @Nullable Cursor query(@NonNull Uri uri, String @Nullable [] projection,
+ @Nullable String selection, String @Nullable [] selectionArgs,
@Nullable String sortOrder) {
return getDropImpl().query(uri, projection, selection, selectionArgs, sortOrder);
}
- @Nullable
@Override
- public String getType(@NonNull Uri uri) {
+ public @Nullable String getType(@NonNull Uri uri) {
return getDropImpl().getType(uri);
}
- @Nullable
@Override
- public Uri insert(@NonNull Uri uri, @Nullable ContentValues contentValues) {
+ public @Nullable Uri insert(@NonNull Uri uri, @Nullable ContentValues contentValues) {
throw new UnsupportedOperationException("Insert method is not supported.");
}
@Override
public int delete(@NonNull Uri uri, @Nullable String selection,
- @Nullable String[] selectionArgs) {
+ String @Nullable [] selectionArgs) {
throw new UnsupportedOperationException("delete method is not supported.");
}
@Override
public int update(@NonNull Uri uri, @Nullable ContentValues contentValues, @Nullable String s,
- @Nullable String[] strings) {
+ String @Nullable [] strings) {
throw new UnsupportedOperationException("update method is not supported.");
}
- @Nullable
@Override
- public Bundle call(@NonNull String method, @Nullable String arg, @Nullable Bundle extras) {
+ public @Nullable Bundle call(@NonNull String method, @Nullable String arg,
+ @Nullable Bundle extras) {
return getDropImpl().call(method, arg, extras);
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/JavaScriptReplyProxy.java b/webkit/webkit/src/main/java/androidx/webkit/JavaScriptReplyProxy.java
index deafaa7..3151d84 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/JavaScriptReplyProxy.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/JavaScriptReplyProxy.java
@@ -16,11 +16,12 @@
package androidx.webkit;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresFeature;
import androidx.annotation.RestrictTo;
import androidx.annotation.UiThread;
+import org.jspecify.annotations.NonNull;
+
/**
* This class represents the JavaScript object injected by {@link
* WebViewCompat#addWebMessageListener(android.webkit.WebView, String, java.util.Set,
@@ -59,7 +60,7 @@
*/
@RequiresFeature(name = WebViewFeature.WEB_MESSAGE_ARRAY_BUFFER,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- public abstract void postMessage(@NonNull byte[] arrayBuffer);
+ public abstract void postMessage(byte @NonNull [] arrayBuffer);
/**
* This class cannot be created by applications.
diff --git a/webkit/webkit/src/main/java/androidx/webkit/NoVarySearchData.java b/webkit/webkit/src/main/java/androidx/webkit/NoVarySearchData.java
index 43475d3..24a2050 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/NoVarySearchData.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/NoVarySearchData.java
@@ -16,7 +16,7 @@
package androidx.webkit;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
import java.util.ArrayList;
import java.util.List;
diff --git a/webkit/webkit/src/main/java/androidx/webkit/PrefetchException.java b/webkit/webkit/src/main/java/androidx/webkit/PrefetchException.java
index ae00f0e..9fd66cc 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/PrefetchException.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/PrefetchException.java
@@ -16,7 +16,7 @@
package androidx.webkit;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* Super class for all asynchronous exceptions produced by
diff --git a/webkit/webkit/src/main/java/androidx/webkit/PrefetchOperationCallback.java b/webkit/webkit/src/main/java/androidx/webkit/PrefetchOperationCallback.java
index 71eb028..eb5ddc3 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/PrefetchOperationCallback.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/PrefetchOperationCallback.java
@@ -16,7 +16,7 @@
package androidx.webkit;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.Nullable;
/**
* Callback interface for prefetch operations.
diff --git a/webkit/webkit/src/main/java/androidx/webkit/PrefetchParameters.java b/webkit/webkit/src/main/java/androidx/webkit/PrefetchParameters.java
index 8938a57..c21c30f 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/PrefetchParameters.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/PrefetchParameters.java
@@ -16,10 +16,11 @@
package androidx.webkit;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresFeature;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.HashMap;
import java.util.Map;
@@ -85,8 +86,7 @@
@RequiresFeature(name = WebViewFeature.PROFILE_URL_PREFETCH,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
@Profile.ExperimentalUrlPrefetch
- @NonNull
- public PrefetchParameters build() {
+ public @NonNull PrefetchParameters build() {
return new PrefetchParameters(mAdditionalHeaders, mExpectedNoVarySearchData,
mIsJavaScriptEnabled);
}
@@ -98,8 +98,7 @@
* Header keys must be RFC 2616-compliant.
*/
@Profile.ExperimentalUrlPrefetch
- @NonNull
- public Builder addAdditionalHeader(@NonNull String key, @NonNull String value) {
+ public @NonNull Builder addAdditionalHeader(@NonNull String key, @NonNull String value) {
mAdditionalHeaders.put(key, value);
return this;
}
@@ -112,8 +111,7 @@
* (i.e. start a network request).
*/
@Profile.ExperimentalUrlPrefetch
- @NonNull
- public Builder setExpectedNoVarySearchData(
+ public @NonNull Builder setExpectedNoVarySearchData(
@NonNull NoVarySearchData expectedNoVarySearchData) {
mExpectedNoVarySearchData = expectedNoVarySearchData;
return this;
@@ -125,8 +123,7 @@
* client hints header is sent with the prefetch request.
*/
@Profile.ExperimentalUrlPrefetch
- @NonNull
- public Builder setJavaScriptEnabled(boolean javaScriptEnabled) {
+ public @NonNull Builder setJavaScriptEnabled(boolean javaScriptEnabled) {
mIsJavaScriptEnabled = javaScriptEnabled;
return this;
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/ProcessGlobalConfig.java b/webkit/webkit/src/main/java/androidx/webkit/ProcessGlobalConfig.java
index 1dad219..6bb25fa 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/ProcessGlobalConfig.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/ProcessGlobalConfig.java
@@ -19,7 +19,6 @@
import android.content.Context;
import androidx.annotation.GuardedBy;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresFeature;
import androidx.annotation.RestrictTo;
import androidx.webkit.internal.ApiHelperForP;
@@ -27,6 +26,7 @@
import androidx.webkit.internal.WebViewFeatureInternal;
import org.chromium.support_lib_boundary.ProcessGlobalConfigConstants;
+import org.jspecify.annotations.NonNull;
import java.io.File;
import java.lang.reflect.Field;
@@ -113,8 +113,7 @@
@RequiresFeature(name = WebViewFeature.STARTUP_FEATURE_SET_DATA_DIRECTORY_SUFFIX,
enforcement =
"androidx.webkit.WebViewFeature#isConfigFeatureSupported(String, Context)")
- @NonNull
- public ProcessGlobalConfig setDataDirectorySuffix(@NonNull Context context,
+ public @NonNull ProcessGlobalConfig setDataDirectorySuffix(@NonNull Context context,
@NonNull String suffix) {
final StartupApiFeature.P feature =
WebViewFeatureInternal.STARTUP_FEATURE_SET_DATA_DIRECTORY_SUFFIX;
@@ -171,8 +170,7 @@
WebViewFeature.STARTUP_FEATURE_SET_DIRECTORY_BASE_PATHS,
enforcement =
"androidx.webkit.WebViewFeature#isConfigFeatureSupported(String, Context)")
- @NonNull
- public ProcessGlobalConfig setDirectoryBasePaths(@NonNull Context context,
+ public @NonNull ProcessGlobalConfig setDirectoryBasePaths(@NonNull Context context,
@NonNull File dataDirectoryBasePath, @NonNull File cacheDirectoryBasePath) {
final StartupApiFeature.NoFramework feature =
WebViewFeatureInternal.STARTUP_FEATURE_SET_DIRECTORY_BASE_PATH;
diff --git a/webkit/webkit/src/main/java/androidx/webkit/Profile.java b/webkit/webkit/src/main/java/androidx/webkit/Profile.java
index 391f3ed..58b944f 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/Profile.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/Profile.java
@@ -22,12 +22,13 @@
import android.webkit.WebStorage;
import androidx.annotation.AnyThread;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresFeature;
import androidx.annotation.RequiresOptIn;
import androidx.core.os.CancellationSignal;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -50,10 +51,9 @@
* ProfileStore create methods.
*/
@AnyThread
- @NonNull
@RequiresFeature(name = WebViewFeature.MULTI_PROFILE,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- String getName();
+ @NonNull String getName();
/**
* Returns the profile's cookie manager.
@@ -64,10 +64,9 @@
* {@link ProfileStore#deleteProfile(String)}}.
*/
@AnyThread
- @NonNull
@RequiresFeature(name = WebViewFeature.MULTI_PROFILE,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- CookieManager getCookieManager();
+ @NonNull CookieManager getCookieManager();
/**
* Returns the profile's web storage.
@@ -78,10 +77,9 @@
* {@link ProfileStore#deleteProfile(String)}}.
*/
@AnyThread
- @NonNull
@RequiresFeature(name = WebViewFeature.MULTI_PROFILE,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- WebStorage getWebStorage();
+ @NonNull WebStorage getWebStorage();
/**
* Returns the geolocation permissions of the profile.
@@ -92,10 +90,9 @@
* {@link ProfileStore#deleteProfile(String)}}.
*/
@AnyThread
- @NonNull
@RequiresFeature(name = WebViewFeature.MULTI_PROFILE,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- GeolocationPermissions getGeolocationPermissions();
+ @NonNull GeolocationPermissions getGeolocationPermissions();
/**
* Returns the service worker controller of the profile.
@@ -106,10 +103,9 @@
* {@link ProfileStore#deleteProfile(String)}}.
*/
@AnyThread
- @NonNull
@RequiresFeature(name = WebViewFeature.MULTI_PROFILE,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- ServiceWorkerController getServiceWorkerController();
+ @NonNull ServiceWorkerController getServiceWorkerController();
/**
* Denotes that the UrlPrefetch API surface is experimental.
diff --git a/webkit/webkit/src/main/java/androidx/webkit/ProfileStore.java b/webkit/webkit/src/main/java/androidx/webkit/ProfileStore.java
index 887e910..0318f1a 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/ProfileStore.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/ProfileStore.java
@@ -16,14 +16,15 @@
package androidx.webkit;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresFeature;
import androidx.annotation.UiThread;
import androidx.webkit.internal.ApiFeature;
import androidx.webkit.internal.ProfileStoreImpl;
import androidx.webkit.internal.WebViewFeatureInternal;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
@@ -49,10 +50,9 @@
*
* @return ProfileStore instance to use for managing profiles.
*/
- @NonNull
@RequiresFeature(name = WebViewFeature.MULTI_PROFILE,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- static ProfileStore getInstance() {
+ static @NonNull ProfileStore getInstance() {
ApiFeature.NoFramework feature = WebViewFeatureInternal.MULTI_PROFILE;
if (feature.isSupportedByWebView()) {
return ProfileStoreImpl.getInstance();
@@ -70,10 +70,9 @@
* @param name name of the profile to retrieve.
* @return instance of {@link Profile} matching this name.
*/
- @NonNull
@RequiresFeature(name = WebViewFeature.MULTI_PROFILE,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- Profile getOrCreateProfile(@NonNull String name);
+ @NonNull Profile getOrCreateProfile(@NonNull String name);
/**
* Returns a profile with the given name, if it exists.
@@ -84,10 +83,9 @@
* @param name the name of the profile to retrieve.
* @return instance of {@link Profile} matching this name, null otherwise if there's no match.
*/
- @Nullable
@RequiresFeature(name = WebViewFeature.MULTI_PROFILE,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- Profile getProfile(@NonNull String name);
+ @Nullable Profile getProfile(@NonNull String name);
/**
* Returns the names of all available profiles.
@@ -96,10 +94,9 @@
*
* @return profile names as a list.
*/
- @NonNull
@RequiresFeature(name = WebViewFeature.MULTI_PROFILE,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- List<String> getAllProfileNames();
+ @NonNull List<String> getAllProfileNames();
/**
* Deletes the profile data associated with the name.
diff --git a/webkit/webkit/src/main/java/androidx/webkit/ProxyConfig.java b/webkit/webkit/src/main/java/androidx/webkit/ProxyConfig.java
index f1772c6..5baf0df 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/ProxyConfig.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/ProxyConfig.java
@@ -16,11 +16,12 @@
package androidx.webkit;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresFeature;
import androidx.annotation.RestrictTo;
import androidx.annotation.StringDef;
+import org.jspecify.annotations.NonNull;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
@@ -90,8 +91,7 @@
*
* @return List of proxy rules
*/
- @NonNull
- public List<ProxyRule> getProxyRules() {
+ public @NonNull List<ProxyRule> getProxyRules() {
return Collections.unmodifiableList(mProxyRules);
}
@@ -102,8 +102,7 @@
*
* @return List of bypass rules
*/
- @NonNull
- public List<String> getBypassRules() {
+ public @NonNull List<String> getBypassRules() {
return Collections.unmodifiableList(mBypassRules);
}
@@ -147,8 +146,7 @@
*
* @return Scheme filter
*/
- @NonNull
- public String getSchemeFilter() {
+ public @NonNull String getSchemeFilter() {
return mSchemeFilter;
}
@@ -157,8 +155,7 @@
*
* @return Proxy URL
*/
- @NonNull
- public String getUrl() {
+ public @NonNull String getUrl() {
return mUrl;
}
}
@@ -199,8 +196,7 @@
*
* @return The ProxyConfig object represented by this Builder
*/
- @NonNull
- public ProxyConfig build() {
+ public @NonNull ProxyConfig build() {
return new ProxyConfig(proxyRules(), bypassRules(), reverseBypass());
}
@@ -233,8 +229,7 @@
* @param proxyUrl Proxy URL
* @return This Builder object
*/
- @NonNull
- public Builder addProxyRule(@NonNull String proxyUrl) {
+ public @NonNull Builder addProxyRule(@NonNull String proxyUrl) {
mProxyRules.add(new ProxyRule(proxyUrl));
return this;
}
@@ -249,9 +244,8 @@
* @param schemeFilter Scheme filter
* @return This Builder object
*/
- @NonNull
- public Builder addProxyRule(@NonNull String proxyUrl,
- @NonNull @ProxyScheme String schemeFilter) {
+ public @NonNull Builder addProxyRule(@NonNull String proxyUrl,
+ @ProxyScheme @NonNull String schemeFilter) {
mProxyRules.add(new ProxyRule(schemeFilter, proxyUrl));
return this;
}
@@ -266,8 +260,7 @@
* @param bypassRule Rule to be added to the exclusion list
* @return This Builder object
*/
- @NonNull
- public Builder addBypassRule(@NonNull String bypassRule) {
+ public @NonNull Builder addBypassRule(@NonNull String bypassRule) {
mBypassRules.add(bypassRule);
return this;
}
@@ -279,8 +272,7 @@
* @param schemeFilter Scheme filter
* @return This Builder object
*/
- @NonNull
- public Builder addDirect(@NonNull @ProxyScheme String schemeFilter) {
+ public @NonNull Builder addDirect(@ProxyScheme @NonNull String schemeFilter) {
mProxyRules.add(new ProxyRule(schemeFilter, DIRECT));
return this;
}
@@ -290,8 +282,7 @@
*
* @return This Builder object
*/
- @NonNull
- public Builder addDirect() {
+ public @NonNull Builder addDirect() {
return addDirect(MATCH_ALL_SCHEMES);
}
@@ -304,8 +295,7 @@
*
* @return This Builder object
*/
- @NonNull
- public Builder bypassSimpleHostnames() {
+ public @NonNull Builder bypassSimpleHostnames() {
return addBypassRule(BYPASS_RULE_SIMPLE_NAMES);
}
@@ -326,8 +316,7 @@
*
* @return This Builder object
*/
- @NonNull
- public Builder removeImplicitRules() {
+ public @NonNull Builder removeImplicitRules() {
return addBypassRule(BYPASS_RULE_REMOVE_IMPLICIT);
}
@@ -350,19 +339,16 @@
*/
@RequiresFeature(name = WebViewFeature.PROXY_OVERRIDE_REVERSE_BYPASS,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- @NonNull
- public Builder setReverseBypassEnabled(boolean reverseBypass) {
+ public @NonNull Builder setReverseBypassEnabled(boolean reverseBypass) {
mReverseBypass = reverseBypass;
return this;
}
- @NonNull
- private List<ProxyRule> proxyRules() {
+ private @NonNull List<ProxyRule> proxyRules() {
return mProxyRules;
}
- @NonNull
- private List<String> bypassRules() {
+ private @NonNull List<String> bypassRules() {
return mBypassRules;
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/ProxyController.java b/webkit/webkit/src/main/java/androidx/webkit/ProxyController.java
index 9d05f53..e499d0a 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/ProxyController.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/ProxyController.java
@@ -17,11 +17,12 @@
package androidx.webkit;
import androidx.annotation.AnyThread;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresFeature;
import androidx.annotation.RestrictTo;
import androidx.webkit.internal.ProxyControllerImpl;
+import org.jspecify.annotations.NonNull;
+
import java.util.concurrent.Executor;
/**
@@ -66,8 +67,7 @@
*/
@RequiresFeature(name = WebViewFeature.PROXY_OVERRIDE,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- @NonNull
- public static ProxyController getInstance() {
+ public static @NonNull ProxyController getInstance() {
if (!WebViewFeature.isFeatureSupported(WebViewFeature.PROXY_OVERRIDE)) {
throw new UnsupportedOperationException("Proxy override not supported");
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerClientCompat.java b/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerClientCompat.java
index 485cb49..879c0cc 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerClientCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerClientCompat.java
@@ -19,10 +19,11 @@
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Base class for clients to capture Service Worker related callbacks,
* see {@link ServiceWorkerControllerCompat} for usage example.
diff --git a/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerControllerCompat.java b/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerControllerCompat.java
index c4d9226..613aa9a 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerControllerCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerControllerCompat.java
@@ -17,12 +17,13 @@
package androidx.webkit;
import androidx.annotation.AnyThread;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresFeature;
import androidx.annotation.RestrictTo;
import androidx.webkit.internal.ServiceWorkerControllerImpl;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Manages Service Workers used by WebView.
*
@@ -59,10 +60,9 @@
*
* @return the default ServiceWorkerController instance
*/
- @NonNull
@RequiresFeature(name = WebViewFeature.SERVICE_WORKER_BASIC_USAGE,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- public static ServiceWorkerControllerCompat getInstance() {
+ public static @NonNull ServiceWorkerControllerCompat getInstance() {
return LAZY_HOLDER.INSTANCE;
}
@@ -77,8 +77,7 @@
* @return the current {@link ServiceWorkerWebSettingsCompat}
*
*/
- @NonNull
- public abstract ServiceWorkerWebSettingsCompat getServiceWorkerWebSettings();
+ public abstract @NonNull ServiceWorkerWebSettingsCompat getServiceWorkerWebSettings();
/**
*
diff --git a/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerWebSettingsCompat.java b/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerWebSettingsCompat.java
index 6713573..4815f50 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerWebSettingsCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/ServiceWorkerWebSettingsCompat.java
@@ -21,10 +21,11 @@
import androidx.annotation.AnyThread;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresFeature;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Set;
@@ -194,8 +195,7 @@
*/
@RequiresFeature(name = WebViewFeature.REQUESTED_WITH_HEADER_ALLOW_LIST,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- @NonNull
- public abstract Set<String> getRequestedWithHeaderOriginAllowList();
+ public abstract @NonNull Set<String> getRequestedWithHeaderOriginAllowList();
/**
* Set an allow-list of origins to receive the {@code X-Requested-With} HTTP header from
diff --git a/webkit/webkit/src/main/java/androidx/webkit/TracingConfig.java b/webkit/webkit/src/main/java/androidx/webkit/TracingConfig.java
index 78bc157..cba45e2 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/TracingConfig.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/TracingConfig.java
@@ -17,9 +17,10 @@
package androidx.webkit;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
@@ -145,8 +146,7 @@
*
* @return Empty list if no custom category patterns are specified.
*/
- @NonNull
- public List<String> getCustomIncludedCategories() {
+ public @NonNull List<String> getCustomIncludedCategories() {
return mCustomIncludedCategories;
}
@@ -210,8 +210,7 @@
*
* @return The {@link TracingConfig} with the current settings.
*/
- @NonNull
- public TracingConfig build() {
+ public @NonNull TracingConfig build() {
return new TracingConfig(mPredefinedCategories, mCustomIncludedCategories,
mTracingMode);
}
@@ -232,8 +231,8 @@
* @param predefinedCategories A list or bitmask of predefined category sets.
* @return The builder to facilitate chaining.
*/
- @NonNull
- public Builder addCategories(@NonNull @PredefinedCategories int... predefinedCategories) {
+ public @NonNull Builder addCategories(
+ @PredefinedCategories int @NonNull ... predefinedCategories) {
for (int categorySet : predefinedCategories) {
mPredefinedCategories |= categorySet;
}
@@ -252,8 +251,7 @@
* e.g. "blink*" or full category name e.g. "renderer.scheduler".
* @return The builder to facilitate chaining.
*/
- @NonNull
- public Builder addCategories(@NonNull String... categories) {
+ public @NonNull Builder addCategories(String @NonNull ... categories) {
mCustomIncludedCategories.addAll(Arrays.asList(categories));
return this;
}
@@ -266,8 +264,7 @@
* @param categories A list of category patterns.
* @return The builder to facilitate chaining.
*/
- @NonNull
- public Builder addCategories(@NonNull Collection<String> categories) {
+ public @NonNull Builder addCategories(@NonNull Collection<String> categories) {
mCustomIncludedCategories.addAll(categories);
return this;
}
@@ -282,8 +279,7 @@
* {@link TracingConfig#RECORD_CONTINUOUSLY}.
* @return The builder to facilitate chaining.
*/
- @NonNull
- public Builder setTracingMode(@TracingMode int tracingMode) {
+ public @NonNull Builder setTracingMode(@TracingMode int tracingMode) {
mTracingMode = tracingMode;
return this;
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/TracingController.java b/webkit/webkit/src/main/java/androidx/webkit/TracingController.java
index 6a46162..f9e49a6 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/TracingController.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/TracingController.java
@@ -19,12 +19,13 @@
import android.content.Context;
import androidx.annotation.AnyThread;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresFeature;
import androidx.annotation.RestrictTo;
import androidx.webkit.internal.TracingControllerImpl;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.OutputStream;
import java.util.concurrent.Executor;
@@ -64,10 +65,9 @@
* returns {@code true} for {@link WebViewFeature#TRACING_CONTROLLER_BASIC_USAGE}.
*
*/
- @NonNull
@RequiresFeature(name = WebViewFeature.TRACING_CONTROLLER_BASIC_USAGE,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- public static TracingController getInstance() {
+ public static @NonNull TracingController getInstance() {
return LAZY_HOLDER.INSTANCE;
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/URLUtilCompat.java b/webkit/webkit/src/main/java/androidx/webkit/URLUtilCompat.java
index a00ef4b..38c92ae 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/URLUtilCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/URLUtilCompat.java
@@ -19,8 +19,8 @@
import android.net.Uri;
import android.webkit.MimeTypeMap;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
@@ -77,9 +77,8 @@
* @see android.webkit.URLUtil#guessFileName(String, String, String)
* @see #getFilenameFromContentDisposition(String)
*/
- @NonNull
- public static String guessFileName(@NonNull String url, @Nullable String contentDisposition,
- @Nullable String mimeType) {
+ public static @NonNull String guessFileName(@NonNull String url,
+ @Nullable String contentDisposition, @Nullable String mimeType) {
String filename = getFilenameSuggestion(url, contentDisposition);
// Split filename between base and extension
// Add an extension if filename does not have one
@@ -104,8 +103,7 @@
* ensure that the filename contains no path separators by replacing them with the {@code "_"}
* character.
*/
- @NonNull
- private static String getFilenameSuggestion(@NonNull String url,
+ private static @NonNull String getFilenameSuggestion(@NonNull String url,
@Nullable String contentDisposition) {
// First attempt to parse the Content-Disposition header if available
if (contentDisposition != null) {
@@ -132,8 +130,7 @@
* Replace all instances of {@code "/"} with {@code "_"} to avoid filenames that navigate the
* path.
*/
- @NonNull
- private static String replacePathSeparators(@NonNull String raw) {
+ private static @NonNull String replacePathSeparators(@NonNull String raw) {
return raw.replaceAll("/", "_");
}
@@ -157,8 +154,7 @@
* @param mimeType Reported mimetype
* @return A file extension, including the {@code .}
*/
- @NonNull
- private static String suggestExtensionFromMimeType(@Nullable String mimeType) {
+ private static @NonNull String suggestExtensionFromMimeType(@Nullable String mimeType) {
if (mimeType == null) {
return ".bin";
}
@@ -212,8 +208,8 @@
* @return The filename suggested by the header or {@code null} if no filename could be
* parsed from the header value.
*/
- @Nullable
- public static String getFilenameFromContentDisposition(@NonNull String contentDisposition) {
+ public static @Nullable String getFilenameFromContentDisposition(
+ @NonNull String contentDisposition) {
String[] parts = contentDisposition.trim().split(";", 2);
if (parts.length < 2) {
// Need at least 2 parts, the `disposition-type` and at least one `disposition-parm`.
@@ -300,8 +296,7 @@
* Replace all instances of {@code "+"} with the percent-encoded equivalent for the given
* {@code encoding}.
*/
- @NonNull
- private static String encodePlusCharacters(@NonNull String valueChars,
+ private static @NonNull String encodePlusCharacters(@NonNull String valueChars,
@NonNull String encoding) {
Charset charset = Charset.forName(encoding);
StringBuilder sb = new StringBuilder();
diff --git a/webkit/webkit/src/main/java/androidx/webkit/UserAgentMetadata.java b/webkit/webkit/src/main/java/androidx/webkit/UserAgentMetadata.java
index b9ee81e..7265beb 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/UserAgentMetadata.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/UserAgentMetadata.java
@@ -16,10 +16,11 @@
package androidx.webkit;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -76,8 +77,7 @@
* @see Builder#setBrandVersionList
*
*/
- @NonNull
- public List<BrandVersion> getBrandVersionList() {
+ public @NonNull List<BrandVersion> getBrandVersionList() {
return mBrandVersionList;
}
@@ -87,8 +87,7 @@
* @see Builder#setFullVersion
*
*/
- @Nullable
- public String getFullVersion() {
+ public @Nullable String getFullVersion() {
return mFullVersion;
}
@@ -98,8 +97,7 @@
* @see Builder#setPlatform
*
*/
- @Nullable
- public String getPlatform() {
+ public @Nullable String getPlatform() {
return mPlatform;
}
@@ -110,8 +108,7 @@
*
* @return Platform version string.
*/
- @Nullable
- public String getPlatformVersion() {
+ public @Nullable String getPlatformVersion() {
return mPlatformVersion;
}
@@ -121,8 +118,7 @@
* @see Builder#setArchitecture
*
*/
- @Nullable
- public String getArchitecture() {
+ public @Nullable String getArchitecture() {
return mArchitecture;
}
@@ -132,8 +128,7 @@
* @see Builder#setModel
*
*/
- @Nullable
- public String getModel() {
+ public @Nullable String getModel() {
return mModel;
}
@@ -221,8 +216,7 @@
* Returns the brand of user-agent brand version tuple.
*
*/
- @NonNull
- public String getBrand() {
+ public @NonNull String getBrand() {
return mBrand;
}
@@ -230,8 +224,7 @@
* Returns the major version of user-agent brand version tuple.
*
*/
- @NonNull
- public String getMajorVersion() {
+ public @NonNull String getMajorVersion() {
return mMajorVersion;
}
@@ -239,14 +232,12 @@
* Returns the full version of user-agent brand version tuple.
*
*/
- @NonNull
- public String getFullVersion() {
+ public @NonNull String getFullVersion() {
return mFullVersion;
}
- @NonNull
@Override
- public String toString() {
+ public @NonNull String toString() {
return mBrand + "," + mMajorVersion + "," + mFullVersion;
}
@@ -308,8 +299,7 @@
* @throws IllegalStateException If any of the value in brand, majorVersion and
* fullVersion is null or blank.
*/
- @NonNull
- public BrandVersion build() {
+ public @NonNull BrandVersion build() {
if (mBrand == null || mBrand.trim().isEmpty()
|| mMajorVersion == null || mMajorVersion.trim().isEmpty()
|| mFullVersion == null || mFullVersion.trim().isEmpty()) {
@@ -326,8 +316,7 @@
* {@code sec-ch-ua} and {@code sec-ch-ua-full-version-list}.
*
*/
- @NonNull
- public BrandVersion.Builder setBrand(@NonNull String brand) {
+ public BrandVersion.@NonNull Builder setBrand(@NonNull String brand) {
if (brand.trim().isEmpty()) {
throw new IllegalArgumentException("Brand should not be blank.");
}
@@ -342,8 +331,7 @@
* {@code sec-ch-ua}.
*
*/
- @NonNull
- public BrandVersion.Builder setMajorVersion(@NonNull String majorVersion) {
+ public BrandVersion.@NonNull Builder setMajorVersion(@NonNull String majorVersion) {
if (majorVersion.trim().isEmpty()) {
throw new IllegalArgumentException("MajorVersion should not be blank.");
}
@@ -358,8 +346,7 @@
* {@code sec-ch-ua-full-version-list}.
*
*/
- @NonNull
- public BrandVersion.Builder setFullVersion(@NonNull String fullVersion) {
+ public BrandVersion.@NonNull Builder setFullVersion(@NonNull String fullVersion) {
if (fullVersion.trim().isEmpty()) {
throw new IllegalArgumentException("FullVersion should not be blank.");
}
@@ -431,8 +418,7 @@
*
* @return The UserAgentMetadata object represented by this Builder
*/
- @NonNull
- public UserAgentMetadata build() {
+ public @NonNull UserAgentMetadata build() {
return new UserAgentMetadata(mBrandVersionList, mFullVersion, mPlatform,
mPlatformVersion, mArchitecture, mModel, mMobile, mBitness, mWow64);
}
@@ -447,8 +433,7 @@
* hints {@code sec-cu-ua} and {@code sec-ch-ua-full-version-list}.
*
*/
- @NonNull
- public Builder setBrandVersionList(@NonNull List<BrandVersion> brandVersions) {
+ public @NonNull Builder setBrandVersionList(@NonNull List<BrandVersion> brandVersions) {
mBrandVersionList = brandVersions;
return this;
}
@@ -465,8 +450,7 @@
* {@code sec-ch-ua-full-version}.
*
*/
- @NonNull
- public Builder setFullVersion(@Nullable String fullVersion) {
+ public @NonNull Builder setFullVersion(@Nullable String fullVersion) {
if (fullVersion == null) {
mFullVersion = null;
return this;
@@ -486,8 +470,7 @@
* {@code sec-ch-ua-platform}.
*
*/
- @NonNull
- public Builder setPlatform(@Nullable String platform) {
+ public @NonNull Builder setPlatform(@Nullable String platform) {
if (platform == null) {
mPlatform = null;
return this;
@@ -507,8 +490,7 @@
* hint {@code sec-ch-ua-platform-version}.
*
*/
- @NonNull
- public Builder setPlatformVersion(@Nullable String platformVersion) {
+ public @NonNull Builder setPlatformVersion(@Nullable String platformVersion) {
mPlatformVersion = platformVersion;
return this;
}
@@ -521,8 +503,7 @@
* {@code sec-ch-ua-arch}.
*
*/
- @NonNull
- public Builder setArchitecture(@Nullable String architecture) {
+ public @NonNull Builder setArchitecture(@Nullable String architecture) {
mArchitecture = architecture;
return this;
}
@@ -535,8 +516,7 @@
* {@code sec-ch-ua-model}.
*
*/
- @NonNull
- public Builder setModel(@Nullable String model) {
+ public @NonNull Builder setModel(@Nullable String model) {
mModel = model;
return this;
}
@@ -548,8 +528,7 @@
* {@code sec-ch-ua-mobile}.
*
*/
- @NonNull
- public Builder setMobile(boolean mobile) {
+ public @NonNull Builder setMobile(boolean mobile) {
mMobile = mobile;
return this;
}
@@ -563,8 +542,7 @@
* {@code sec-ch-ua-bitness}.
*
*/
- @NonNull
- public Builder setBitness(int bitness) {
+ public @NonNull Builder setBitness(int bitness) {
mBitness = bitness;
return this;
}
@@ -576,8 +554,7 @@
* {@code sec-ch-ua-wow64}.
*
*/
- @NonNull
- public Builder setWow64(boolean wow64) {
+ public @NonNull Builder setWow64(boolean wow64) {
mWow64 = wow64;
return this;
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebMessageCompat.java b/webkit/webkit/src/main/java/androidx/webkit/WebMessageCompat.java
index aee9e29..939d8d1 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebMessageCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebMessageCompat.java
@@ -17,11 +17,12 @@
package androidx.webkit;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresFeature;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Objects;
@@ -42,9 +43,9 @@
* Indicates the payload of WebMessageCompat is JavaScript ArrayBuffer.
*/
public static final int TYPE_ARRAY_BUFFER = 1;
- private final @Nullable WebMessagePortCompat[] mPorts;
+ private final WebMessagePortCompat @Nullable [] mPorts;
private final @Nullable String mString;
- private final @Nullable byte[] mArrayBuffer;
+ private final byte @Nullable [] mArrayBuffer;
private final @Type int mType;
/**
@@ -62,7 +63,7 @@
* @param data the string data of the message.
* @param ports the ports that are sent with the message.
*/
- public WebMessageCompat(@Nullable String data, @Nullable WebMessagePortCompat[] ports) {
+ public WebMessageCompat(@Nullable String data, WebMessagePortCompat @Nullable [] ports) {
mString = data;
mArrayBuffer = null;
mPorts = ports;
@@ -76,7 +77,7 @@
*/
@RequiresFeature(name = WebViewFeature.WEB_MESSAGE_ARRAY_BUFFER,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- public WebMessageCompat(@NonNull byte[] arrayBuffer) {
+ public WebMessageCompat(byte @NonNull [] arrayBuffer) {
this(arrayBuffer, null);
}
@@ -88,8 +89,8 @@
*/
@RequiresFeature(name = WebViewFeature.WEB_MESSAGE_ARRAY_BUFFER,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- public WebMessageCompat(@NonNull byte[] arrayBuffer,
- @Nullable WebMessagePortCompat[] ports) {
+ public WebMessageCompat(byte @NonNull [] arrayBuffer,
+ WebMessagePortCompat @Nullable [] ports) {
Objects.requireNonNull(arrayBuffer);
mArrayBuffer = arrayBuffer;
mString = null;
@@ -120,7 +121,7 @@
*
* @return ArrayBuffer payload data.
*/
- public @NonNull byte[] getArrayBuffer() {
+ public byte @NonNull [] getArrayBuffer() {
checkType(TYPE_ARRAY_BUFFER);
// Required for null check. ArrayBuffer is always non-null when mType == TYPE_ARRAY_BUFFER.
Objects.requireNonNull(mArrayBuffer);
@@ -149,8 +150,7 @@
* Returns the ports that are sent with the message, or {@code null} if no port
* is sent.
*/
- @Nullable
- public WebMessagePortCompat[] getPorts() {
+ public WebMessagePortCompat @Nullable [] getPorts() {
return mPorts;
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebMessagePortCompat.java b/webkit/webkit/src/main/java/androidx/webkit/WebMessagePortCompat.java
index f1fb7f9..999de57 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebMessagePortCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebMessagePortCompat.java
@@ -20,12 +20,13 @@
import android.webkit.WebMessagePort;
import androidx.annotation.AnyThread;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RequiresFeature;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.lang.reflect.InvocationHandler;
/**
@@ -166,16 +167,14 @@
*/
@RequiresApi(23)
@RestrictTo(RestrictTo.Scope.LIBRARY)
- @NonNull
- public abstract WebMessagePort getFrameworkPort();
+ public abstract @NonNull WebMessagePort getFrameworkPort();
/**
* Internal getter returning the private {@link java.lang.reflect.InvocationHandler}
* implementing this class. This is only available on devices where the support library glue in
* the WebView APK supports {@link WebMessagePortCompat}.
*/
- @NonNull
@RestrictTo(RestrictTo.Scope.LIBRARY)
- public abstract InvocationHandler getInvocationHandler();
+ public abstract @NonNull InvocationHandler getInvocationHandler();
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebResourceErrorCompat.java b/webkit/webkit/src/main/java/androidx/webkit/WebResourceErrorCompat.java
index f96138c..d0d71ab 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebResourceErrorCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebResourceErrorCompat.java
@@ -20,10 +20,11 @@
import android.webkit.WebViewClient;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresFeature;
import androidx.annotation.RestrictTo;
+import org.jspecify.annotations.NonNull;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -79,10 +80,9 @@
*
* @return The description of the error
*/
- @NonNull
@RequiresFeature(name = WebViewFeature.WEB_RESOURCE_ERROR_GET_DESCRIPTION,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- public abstract CharSequence getDescription();
+ public abstract @NonNull CharSequence getDescription();
/**
* This class cannot be created by applications.
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebResourceRequestCompat.java b/webkit/webkit/src/main/java/androidx/webkit/WebResourceRequestCompat.java
index e2f97fa..bbecc97 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebResourceRequestCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebResourceRequestCompat.java
@@ -18,7 +18,6 @@
import android.webkit.WebResourceRequest;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresFeature;
import androidx.webkit.internal.ApiFeature;
import androidx.webkit.internal.ApiHelperForN;
@@ -26,6 +25,8 @@
import androidx.webkit.internal.WebViewFeatureInternal;
import androidx.webkit.internal.WebViewGlueCommunicator;
+import org.jspecify.annotations.NonNull;
+
/**
* Compatibility version of {@link WebResourceRequest}.
*/
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebSettingsCompat.java b/webkit/webkit/src/main/java/androidx/webkit/WebSettingsCompat.java
index 495bace..9a4c7e2 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebSettingsCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebSettingsCompat.java
@@ -20,7 +20,6 @@
import android.webkit.WebView;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresFeature;
import androidx.annotation.RequiresOptIn;
import androidx.annotation.RestrictTo;
@@ -34,6 +33,7 @@
import androidx.webkit.internal.WebViewGlueCommunicator;
import org.chromium.support_lib_boundary.WebSettingsBoundaryInterface;
+import org.jspecify.annotations.NonNull;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -658,8 +658,8 @@
*/
@RequiresFeature(name = WebViewFeature.REQUESTED_WITH_HEADER_ALLOW_LIST,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- @NonNull
- public static Set<String> getRequestedWithHeaderOriginAllowList(@NonNull WebSettings settings) {
+ public static @NonNull Set<String> getRequestedWithHeaderOriginAllowList(
+ @NonNull WebSettings settings) {
final ApiFeature.NoFramework feature =
WebViewFeatureInternal.REQUESTED_WITH_HEADER_ALLOW_LIST;
if (feature.isSupportedByWebView()) {
@@ -758,8 +758,7 @@
*/
@RequiresFeature(name = WebViewFeature.USER_AGENT_METADATA,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- @NonNull
- public static UserAgentMetadata getUserAgentMetadata(@NonNull WebSettings settings) {
+ public static @NonNull UserAgentMetadata getUserAgentMetadata(@NonNull WebSettings settings) {
final ApiFeature.NoFramework feature =
WebViewFeatureInternal.USER_AGENT_METADATA;
if (feature.isSupportedByWebView()) {
@@ -900,8 +899,7 @@
*/
@RequiresFeature(name = WebViewFeature.WEBVIEW_MEDIA_INTEGRITY_API_STATUS,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- @NonNull
- public static WebViewMediaIntegrityApiStatusConfig getWebViewMediaIntegrityApiStatus(
+ public static @NonNull WebViewMediaIntegrityApiStatusConfig getWebViewMediaIntegrityApiStatus(
@NonNull WebSettings settings) {
final ApiFeature.NoFramework feature =
WebViewFeatureInternal.WEBVIEW_MEDIA_INTEGRITY_API_STATUS;
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebViewAssetLoader.java b/webkit/webkit/src/main/java/androidx/webkit/WebViewAssetLoader.java
index 3a8a7fa..a2ca6af 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebViewAssetLoader.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebViewAssetLoader.java
@@ -22,13 +22,14 @@
import android.util.Log;
import android.webkit.WebResourceResponse;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.annotation.WorkerThread;
import androidx.core.util.Pair;
import androidx.webkit.internal.AssetHelper;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -140,8 +141,7 @@
* handle this path.
*/
@WorkerThread
- @Nullable
- WebResourceResponse handle(@NonNull String path);
+ @Nullable WebResourceResponse handle(@NonNull String path);
}
/**
@@ -182,8 +182,7 @@
*/
@Override
@WorkerThread
- @Nullable
- public WebResourceResponse handle(@NonNull String path) {
+ public @Nullable WebResourceResponse handle(@NonNull String path) {
try {
InputStream is = mAssetHelper.openAsset(path);
String mimeType = AssetHelper.guessMimeType(path);
@@ -233,8 +232,7 @@
*/
@Override
@WorkerThread
- @Nullable
- public WebResourceResponse handle(@NonNull String path) {
+ public @Nullable WebResourceResponse handle(@NonNull String path) {
try {
InputStream is = mAssetHelper.openResource(path);
String mimeType = AssetHelper.guessMimeType(path);
@@ -278,7 +276,7 @@
private static final String[] FORBIDDEN_DATA_DIRS =
new String[] {"app_webview/", "databases/", "lib/", "shared_prefs/", "code_cache/"};
- @NonNull private final File mDirectory;
+ private final @NonNull File mDirectory;
/**
* Creates PathHandler for app's internal storage.
@@ -358,8 +356,7 @@
*/
@Override
@WorkerThread
- @NonNull
- public WebResourceResponse handle(@NonNull String path) {
+ public @NonNull WebResourceResponse handle(@NonNull String path) {
try {
File file = AssetHelper.getCanonicalFileIfChild(mDirectory, path);
if (file != null) {
@@ -400,9 +397,9 @@
static final String HTTPS_SCHEME = "https";
final boolean mHttpEnabled;
- @NonNull final String mAuthority;
- @NonNull final String mPath;
- @NonNull final PathHandler mHandler;
+ final @NonNull String mAuthority;
+ final @NonNull String mPath;
+ final @NonNull PathHandler mHandler;
/**
* @param authority the authority to match (For instance {@code "example.com"})
@@ -410,8 +407,8 @@
* @param httpEnabled enable hosting under the HTTP scheme, HTTPS is always enabled.
* @param handler the {@link PathHandler} the handler class for this URI.
*/
- PathMatcher(@NonNull final String authority, @NonNull final String path,
- boolean httpEnabled, @NonNull final PathHandler handler) {
+ PathMatcher(final @NonNull String authority, final @NonNull String path,
+ boolean httpEnabled, final @NonNull PathHandler handler) {
if (path.isEmpty() || path.charAt(0) != '/') {
throw new IllegalArgumentException("Path should start with a slash '/'.");
}
@@ -439,8 +436,7 @@
* @return {@code PathHandler} if a match happens, {@code null} otherwise.
*/
@WorkerThread
- @Nullable
- public PathHandler match(@NonNull Uri uri) {
+ public @Nullable PathHandler match(@NonNull Uri uri) {
// Only match HTTP_SCHEME if caller enabled HTTP matches.
if (uri.getScheme().equals(HTTP_SCHEME) && !mHttpEnabled) {
return null;
@@ -465,8 +461,7 @@
* @return the suffix path.
*/
@WorkerThread
- @NonNull
- public String getSuffixPath(@NonNull String path) {
+ public @NonNull String getSuffixPath(@NonNull String path) {
return path.replaceFirst(mPath, "");
}
}
@@ -479,7 +474,7 @@
private String mDomain = DEFAULT_DOMAIN;
// This is stored as a List<Pair> to preserve the order in which PathHandlers are added and
// permit multiple PathHandlers for the same path.
- @NonNull private final List<Pair<String, PathHandler>> mHandlerList = new ArrayList<>();
+ private final @NonNull List<Pair<String, PathHandler>> mHandlerList = new ArrayList<>();
/**
* Set the domain under which app assets can be accessed.
@@ -488,8 +483,7 @@
* @param domain the domain on which app assets should be hosted.
* @return {@link Builder} object.
*/
- @NonNull
- public Builder setDomain(@NonNull String domain) {
+ public @NonNull Builder setDomain(@NonNull String domain) {
mDomain = domain;
return this;
}
@@ -500,8 +494,7 @@
*
* @return {@link Builder} object.
*/
- @NonNull
- public Builder setHttpAllowed(boolean httpAllowed) {
+ public @NonNull Builder setHttpAllowed(boolean httpAllowed) {
mHttpAllowed = httpAllowed;
return this;
}
@@ -521,8 +514,7 @@
* @return {@link Builder} object.
* @throws IllegalArgumentException if the path is invalid.
*/
- @NonNull
- public Builder addPathHandler(@NonNull String path, @NonNull PathHandler handler) {
+ public @NonNull Builder addPathHandler(@NonNull String path, @NonNull PathHandler handler) {
mHandlerList.add(Pair.create(path, handler));
return this;
}
@@ -532,8 +524,7 @@
*
* @return immutable {@link WebViewAssetLoader} object.
*/
- @NonNull
- public WebViewAssetLoader build() {
+ public @NonNull WebViewAssetLoader build() {
List<PathMatcher> pathMatcherList = new ArrayList<>();
for (Pair<String, PathHandler> pair : mHandlerList) {
String path = pair.first;
@@ -560,8 +551,7 @@
* {@code null} otherwise.
*/
@WorkerThread
- @Nullable
- public WebResourceResponse shouldInterceptRequest(@NonNull Uri url) {
+ public @Nullable WebResourceResponse shouldInterceptRequest(@NonNull Uri url) {
for (PathMatcher matcher : mMatchers) {
PathHandler handler = matcher.match(url);
// The requested URL doesn't match the URL where this handler has been registered.
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebViewClientCompat.java b/webkit/webkit/src/main/java/androidx/webkit/WebViewClientCompat.java
index 8a452e2..6b53149 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebViewClientCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebViewClientCompat.java
@@ -26,7 +26,6 @@
import android.webkit.WebViewClient;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.annotation.UiThread;
@@ -36,6 +35,7 @@
import org.chromium.support_lib_boundary.WebViewClientBoundaryInterface;
import org.chromium.support_lib_boundary.util.Features;
+import org.jspecify.annotations.NonNull;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -72,8 +72,7 @@
*/
@Override
@RestrictTo(RestrictTo.Scope.LIBRARY)
- @NonNull
- public final String[] getSupportedFeatures() {
+ public final String @NonNull [] getSupportedFeatures() {
return sSupportedFeatures;
}
@@ -292,7 +291,7 @@
@SuppressWarnings("MissingOverride")
@RestrictTo(RestrictTo.Scope.LIBRARY)
public boolean onWebAuthnIntent(@NonNull WebView view, @NonNull PendingIntent intent,
- @NonNull /* WebAuthnCallbackBoundaryInterface */ InvocationHandler callback) {
+ /* WebAuthnCallbackBoundaryInterface */ @NonNull InvocationHandler callback) {
// TODO(crbug.com/1284805): Implement the actual logic.
return false;
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebViewCompat.java b/webkit/webkit/src/main/java/androidx/webkit/WebViewCompat.java
index 4aa62e9..48b11a2 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebViewCompat.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebViewCompat.java
@@ -31,8 +31,6 @@
import android.webkit.WebViewClient;
import androidx.annotation.AnyThread;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresFeature;
import androidx.annotation.RequiresOptIn;
import androidx.annotation.RestrictTo;
@@ -53,6 +51,8 @@
import androidx.webkit.internal.WebViewRenderProcessImpl;
import org.chromium.support_lib_boundary.WebViewProviderBoundaryInterface;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -177,7 +177,7 @@
@RequiresFeature(name = WebViewFeature.VISUAL_STATE_CALLBACK,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
public static void postVisualStateCallback(@NonNull WebView webview, long requestId,
- @NonNull final VisualStateCallback callback) {
+ final @NonNull VisualStateCallback callback) {
ApiFeature.M feature = WebViewFeatureInternal.VISUAL_STATE_CALLBACK;
if (feature.isSupportedByFramework()) {
ApiHelperForM.postVisualStateCallback(webview, requestId, callback);
@@ -333,10 +333,9 @@
* @return the url pointing to a privacy policy document which can be displayed to users.
*/
@AnyThread
- @NonNull
@RequiresFeature(name = WebViewFeature.SAFE_BROWSING_PRIVACY_POLICY_URL,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- public static Uri getSafeBrowsingPrivacyPolicyUrl() {
+ public static @NonNull Uri getSafeBrowsingPrivacyPolicyUrl() {
ApiFeature.O_MR1 feature =
WebViewFeatureInternal.SAFE_BROWSING_PRIVACY_POLICY_URL;
if (feature.isSupportedByFramework()) {
@@ -362,8 +361,7 @@
// Note that this API is not protected by a {@link androidx.webkit.WebViewFeature} since
// this feature is not dependent on the WebView APK.
@AnyThread
- @Nullable
- public static PackageInfo getCurrentWebViewPackage(@NonNull Context context) {
+ public static @Nullable PackageInfo getCurrentWebViewPackage(@NonNull Context context) {
PackageInfo info = getCurrentLoadedWebViewPackage();
if (info != null) return info;
@@ -378,9 +376,8 @@
* @return the loaded WebView package, or null if no WebView is created.
*/
@AnyThread
- @Nullable
@RestrictTo(RestrictTo.Scope.LIBRARY)
- public static PackageInfo getCurrentLoadedWebViewPackage() {
+ public static @Nullable PackageInfo getCurrentLoadedWebViewPackage() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return ApiHelperForO.getCurrentWebViewPackage();
} else { // L-N
@@ -462,7 +459,7 @@
@UiThread
@RequiresFeature(name = WebViewFeature.CREATE_WEB_MESSAGE_CHANNEL,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- public static @NonNull WebMessagePortCompat[] createWebMessageChannel(
+ public static WebMessagePortCompat @NonNull [] createWebMessageChannel(
@NonNull WebView webview) {
final ApiFeature.M feature = WebViewFeatureInternal.CREATE_WEB_MESSAGE_CHANNEL;
if (feature.isSupportedByFramework()) {
@@ -958,7 +955,7 @@
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
public static void setWebViewRenderProcessClient(
@NonNull WebView webview,
- @NonNull /* @CallbackExecutor */ Executor executor,
+ /* @CallbackExecutor */ @NonNull Executor executor,
@NonNull WebViewRenderProcessClient webViewRenderProcessClient) {
final ApiFeature.Q feature =
WebViewFeatureInternal.WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE;
@@ -1138,11 +1135,10 @@
* @throws IllegalStateException if the WebView has been destroyed.
*/
@UiThread
- @NonNull
@RequiresFeature(
name = WebViewFeature.MULTI_PROFILE,
enforcement = "androidx.webkit.WebViewFeature#isFeatureSupported")
- public static Profile getProfile(@NonNull WebView webView) {
+ public static @NonNull Profile getProfile(@NonNull WebView webView) {
final ApiFeature.NoFramework feature = WebViewFeatureInternal.MULTI_PROFILE;
if (feature.isSupportedByWebView()) {
return getProvider(webView).getProfile();
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebViewFeature.java b/webkit/webkit/src/main/java/androidx/webkit/WebViewFeature.java
index 430a548..33fd8a8 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebViewFeature.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebViewFeature.java
@@ -27,11 +27,12 @@
import android.webkit.WebSettings;
import android.webkit.WebView;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.StringDef;
import androidx.webkit.internal.WebViewFeatureInternal;
+import org.jspecify.annotations.NonNull;
+
import java.io.File;
import java.io.OutputStream;
import java.lang.annotation.ElementType;
@@ -653,7 +654,7 @@
* @param feature the feature to be checked
* @return whether the feature is supported given the current platform SDK and WebView version
*/
- public static boolean isFeatureSupported(@NonNull @WebViewSupportFeature String feature) {
+ public static boolean isFeatureSupported(@WebViewSupportFeature @NonNull String feature) {
return WebViewFeatureInternal.isSupported(feature);
}
@@ -676,7 +677,7 @@
* @return whether the feature is supported given the current platform SDK and WebView version
*/
public static boolean isStartupFeatureSupported(@NonNull Context context,
- @NonNull @WebViewStartupFeature String startupFeature) {
+ @WebViewStartupFeature @NonNull String startupFeature) {
return WebViewFeatureInternal.isStartupFeatureSupported(startupFeature, context);
}
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebViewMediaIntegrityApiStatusConfig.java b/webkit/webkit/src/main/java/androidx/webkit/WebViewMediaIntegrityApiStatusConfig.java
index 110e7bd..d24c85c 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebViewMediaIntegrityApiStatusConfig.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebViewMediaIntegrityApiStatusConfig.java
@@ -19,11 +19,11 @@
import android.webkit.WebView;
import androidx.annotation.IntDef;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresFeature;
import androidx.annotation.RestrictTo;
import org.chromium.support_lib_boundary.WebSettingsBoundaryInterface;
+import org.jspecify.annotations.NonNull;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -123,8 +123,7 @@
* will be chosen.
*/
- @NonNull
- public Builder addOverrideRule(@NonNull String originPattern,
+ public @NonNull Builder addOverrideRule(@NonNull String originPattern,
@WebViewMediaIntegrityApiStatus int permission) {
mOverrideRules.put(originPattern, permission);
return this;
@@ -140,8 +139,7 @@
* This is only meant for internal use within the library.
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
- @NonNull
- public Builder setOverrideRules(@NonNull Map<String,
+ public @NonNull Builder setOverrideRules(@NonNull Map<String,
@WebViewMediaIntegrityApiStatus Integer> overrideRules) {
mOverrideRules = overrideRules;
return this;
@@ -150,8 +148,7 @@
/**
* Build the config.
*/
- @NonNull
- public WebViewMediaIntegrityApiStatusConfig build() {
+ public @NonNull WebViewMediaIntegrityApiStatusConfig build() {
return new WebViewMediaIntegrityApiStatusConfig(this);
}
}
@@ -168,8 +165,7 @@
* <p> This is a map from origin patterns to their desired WebView Media Integrity API statuses.
*
*/
- @NonNull
- public Map<String, @WebViewMediaIntegrityApiStatus Integer> getOverrideRules() {
+ public @NonNull Map<String, @WebViewMediaIntegrityApiStatus Integer> getOverrideRules() {
return mOverrideRules;
}
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebViewRenderProcessClient.java b/webkit/webkit/src/main/java/androidx/webkit/WebViewRenderProcessClient.java
index 0c8d80d..45766ce 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebViewRenderProcessClient.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebViewRenderProcessClient.java
@@ -18,8 +18,8 @@
import android.webkit.WebView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* Used to receive callbacks on {@link WebView} renderer events.
diff --git a/webkit/webkit/src/main/java/androidx/webkit/WebViewStartUpConfig.java b/webkit/webkit/src/main/java/androidx/webkit/WebViewStartUpConfig.java
index bd8409a..779f91d 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/WebViewStartUpConfig.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/WebViewStartUpConfig.java
@@ -16,7 +16,7 @@
package androidx.webkit;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
import java.util.concurrent.Executor;
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/ApiFeature.java b/webkit/webkit/src/main/java/androidx/webkit/internal/ApiFeature.java
index d467ac5..0428186 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/ApiFeature.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/ApiFeature.java
@@ -18,10 +18,10 @@
import android.os.Build;
-import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
+import org.jspecify.annotations.NonNull;
import java.util.Arrays;
import java.util.Collections;
@@ -58,9 +58,8 @@
sValues.add(this);
}
- @NonNull
@Override
- public String getPublicFeatureName() {
+ public @NonNull String getPublicFeatureName() {
return mPublicFeatureValue;
}
@@ -90,15 +89,13 @@
/**
* Get all instantiated values of this class as if it was an enum.
*/
- @NonNull
- public static Set<ApiFeature> values() {
+ public static @NonNull Set<ApiFeature> values() {
return Collections.unmodifiableSet(sValues);
}
- @NonNull
@VisibleForTesting
- public static Set<String> getWebViewApkFeaturesForTesting() {
+ public static @NonNull Set<String> getWebViewApkFeaturesForTesting() {
return LAZY_HOLDER.WEBVIEW_APK_FEATURES;
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForM.java b/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForM.java
index d2caca4..7eb5960 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForM.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForM.java
@@ -25,13 +25,14 @@
import android.webkit.WebSettings;
import android.webkit.WebView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.webkit.WebMessageCompat;
import androidx.webkit.WebMessagePortCompat;
import androidx.webkit.WebViewCompat;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Utility class to use new APIs that were added in M (API level 23).
* These need to exist in a separate class so that Android framework can successfully verify
@@ -62,7 +63,7 @@
* @see WebMessagePort#setWebMessageCallback(WebMessagePort.WebMessageCallback)
*/
public static void setWebMessageCallback(@NonNull WebMessagePort frameworksImpl,
- @NonNull WebMessagePortCompat.WebMessageCallbackCompat callback) {
+ WebMessagePortCompat.@NonNull WebMessageCallbackCompat callback) {
frameworksImpl.setWebMessageCallback(new WebMessagePort.WebMessageCallback() {
@Override
public void onMessage(WebMessagePort port, WebMessage message) {
@@ -78,7 +79,7 @@
* Wraps the passed callback in the framework callback type to isolate new types in this class.
*/
public static void setWebMessageCallback(@NonNull WebMessagePort frameworksImpl,
- @NonNull WebMessagePortCompat.WebMessageCallbackCompat callback,
+ WebMessagePortCompat.@NonNull WebMessageCallbackCompat callback,
@Nullable Handler handler) {
frameworksImpl.setWebMessageCallback(new WebMessagePort.WebMessageCallback() {
@Override
@@ -92,8 +93,7 @@
/**
* @see WebMessage#WebMessage(String, WebMessagePort[])} WebMessage
*/
- @NonNull
- public static WebMessage createWebMessage(@NonNull WebMessageCompat message) {
+ public static @NonNull WebMessage createWebMessage(@NonNull WebMessageCompat message) {
return new WebMessage(message.getData(),
WebMessagePortImpl.compatToPorts(message.getPorts()));
}
@@ -101,8 +101,7 @@
/**
* @see WebMessageCompat#WebMessageCompat(String, WebMessagePortCompat[])
*/
- @NonNull
- public static WebMessageCompat createWebMessageCompat(@NonNull WebMessage webMessage) {
+ public static @NonNull WebMessageCompat createWebMessageCompat(@NonNull WebMessage webMessage) {
return new WebMessageCompat(webMessage.getData(),
WebMessagePortImpl.portsToCompat(webMessage.getPorts()));
}
@@ -118,8 +117,7 @@
/**
* @see WebResourceError#getDescription()
*/
- @NonNull
- public static CharSequence getDescription(@NonNull WebResourceError webResourceError) {
+ public static @NonNull CharSequence getDescription(@NonNull WebResourceError webResourceError) {
return webResourceError.getDescription();
}
@@ -142,7 +140,7 @@
* @see WebView#postVisualStateCallback(long, WebView.VisualStateCallback)
*/
public static void postVisualStateCallback(@NonNull WebView webView, long requestId,
- final @NonNull WebViewCompat.VisualStateCallback callback) {
+ final WebViewCompat.@NonNull VisualStateCallback callback) {
webView.postVisualStateCallback(requestId, new WebView.VisualStateCallback() {
@Override
public void onComplete(long l) {
@@ -162,8 +160,7 @@
/**
* @see WebView#createWebMessageChannel()
*/
- @NonNull
- public static WebMessagePort[] createWebMessageChannel(@NonNull WebView webView) {
+ public static WebMessagePort @NonNull [] createWebMessageChannel(@NonNull WebView webView) {
return webView.createWebMessageChannel();
}
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForN.java b/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForN.java
index a8c61b2..eadeefd 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForN.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForN.java
@@ -24,11 +24,12 @@
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.webkit.ServiceWorkerClientCompat;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.File;
/**
@@ -44,24 +45,21 @@
/**
* @see Context#getDataDir()
*/
- @NonNull
- public static File getDataDir(@NonNull Context context) {
+ public static @NonNull File getDataDir(@NonNull Context context) {
return context.getDataDir();
}
/**
* @see ServiceWorkerController#getInstance()
*/
- @NonNull
- public static ServiceWorkerController getServiceWorkerControllerInstance() {
+ public static @NonNull ServiceWorkerController getServiceWorkerControllerInstance() {
return ServiceWorkerController.getInstance();
}
/**
* @see ServiceWorkerController#getServiceWorkerWebSettings()
*/
- @NonNull
- public static ServiceWorkerWebSettings getServiceWorkerWebSettings(
+ public static @NonNull ServiceWorkerWebSettings getServiceWorkerWebSettings(
@NonNull ServiceWorkerController serviceWorkerController) {
return serviceWorkerController.getServiceWorkerWebSettings();
}
@@ -69,8 +67,7 @@
/**
* @see ServiceWorkerController#getServiceWorkerWebSettings()
*/
- @NonNull
- public static ServiceWorkerWebSettingsImpl getServiceWorkerWebSettingsImpl(
+ public static @NonNull ServiceWorkerWebSettingsImpl getServiceWorkerWebSettingsImpl(
@NonNull ServiceWorkerController serviceWorkerController) {
return new ServiceWorkerWebSettingsImpl(
getServiceWorkerWebSettings(serviceWorkerController));
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForO.java b/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForO.java
index 5c0ce09..a8123a9 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForO.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForO.java
@@ -23,10 +23,11 @@
import android.webkit.WebView;
import android.webkit.WebViewClient;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Utility class to use new APIs that were added in O (API level 26).
* These need to exist in a separate class so that Android framework can successfully verify
@@ -54,24 +55,21 @@
/**
* @see WebView#getWebViewClient()
*/
- @Nullable
- public static WebViewClient getWebViewClient(@NonNull WebView webView) {
+ public static @Nullable WebViewClient getWebViewClient(@NonNull WebView webView) {
return webView.getWebViewClient();
}
/**
* @see WebView#getWebChromeClient()
*/
- @Nullable
- public static WebChromeClient getWebChromeClient(@NonNull WebView webView) {
+ public static @Nullable WebChromeClient getWebChromeClient(@NonNull WebView webView) {
return webView.getWebChromeClient();
}
/**
* @see WebView#getCurrentWebViewPackage()
*/
- @NonNull
- public static PackageInfo getCurrentWebViewPackage() {
+ public static @NonNull PackageInfo getCurrentWebViewPackage() {
return WebView.getCurrentWebViewPackage();
}
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForOMR1.java b/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForOMR1.java
index 85ab81a..0015cbe 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForOMR1.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForOMR1.java
@@ -23,10 +23,11 @@
import android.webkit.ValueCallback;
import android.webkit.WebView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.List;
/**
@@ -82,8 +83,7 @@
/**
* @see WebView#getSafeBrowsingPrivacyPolicyUrl()
*/
- @NonNull
- public static Uri getSafeBrowsingPrivacyPolicyUrl() {
+ public static @NonNull Uri getSafeBrowsingPrivacyPolicyUrl() {
return WebView.getSafeBrowsingPrivacyPolicyUrl();
}
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForP.java b/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForP.java
index b9d7643..0b9015f 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForP.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForP.java
@@ -21,11 +21,12 @@
import android.webkit.TracingController;
import android.webkit.WebView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.webkit.TracingConfig;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.io.OutputStream;
import java.util.concurrent.Executor;
@@ -42,8 +43,7 @@
/**
* @see TracingController#getInstance()
*/
- @NonNull
- public static TracingController getTracingControllerInstance() {
+ public static @NonNull TracingController getTracingControllerInstance() {
return TracingController.getInstance();
}
@@ -81,16 +81,14 @@
/**
* @see WebView#getWebViewClassLoader()
*/
- @NonNull
- public static ClassLoader getWebViewClassLoader() {
+ public static @NonNull ClassLoader getWebViewClassLoader() {
return WebView.getWebViewClassLoader();
}
/**
* @see WebView#getWebViewLooper()
*/
- @NonNull
- public static Looper getWebViewLooper(@NonNull WebView webView) {
+ public static @NonNull Looper getWebViewLooper(@NonNull WebView webView) {
return webView.getWebViewLooper();
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForQ.java b/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForQ.java
index 5917b04..87c05b3 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForQ.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/ApiHelperForQ.java
@@ -21,11 +21,12 @@
import android.webkit.WebView;
import android.webkit.WebViewRenderProcess;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.webkit.WebViewRenderProcessClient;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.concurrent.Executor;
/**
@@ -59,8 +60,7 @@
/**
* @see WebView#getWebViewRenderProcess()
*/
- @Nullable
- public static WebViewRenderProcess getWebViewRenderProcess(@NonNull WebView webView) {
+ public static @Nullable WebViewRenderProcess getWebViewRenderProcess(@NonNull WebView webView) {
return webView.getWebViewRenderProcess();
}
@@ -96,8 +96,7 @@
/**
* @see WebView#getWebViewRenderProcessClient()
*/
- @Nullable
- public static android.webkit.WebViewRenderProcessClient getWebViewRenderProcessClient(
+ public static android.webkit.@Nullable WebViewRenderProcessClient getWebViewRenderProcessClient(
@NonNull WebView webView) {
return webView.getWebViewRenderProcessClient();
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/AssetHelper.java b/webkit/webkit/src/main/java/androidx/webkit/internal/AssetHelper.java
index 8f582559..0eb90b4 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/AssetHelper.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/AssetHelper.java
@@ -22,8 +22,8 @@
import android.os.Build;
import android.util.TypedValue;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.io.File;
import java.io.FileInputStream;
@@ -44,20 +44,18 @@
*/
public static final String DEFAULT_MIME_TYPE = "text/plain";
- @NonNull private final Context mContext;
+ private final @NonNull Context mContext;
public AssetHelper(@NonNull Context context) {
this.mContext = context;
}
- @NonNull
- private static InputStream handleSvgzStream(@NonNull String path,
+ private static @NonNull InputStream handleSvgzStream(@NonNull String path,
@NonNull InputStream stream) throws IOException {
return path.endsWith(".svgz") ? new GZIPInputStream(stream) : stream;
}
- @NonNull
- private static String removeLeadingSlash(@NonNull String path) {
+ private static @NonNull String removeLeadingSlash(@NonNull String path) {
if (path.length() > 1 && path.charAt(0) == '/') {
path = path.substring(1);
}
@@ -81,8 +79,7 @@
* @param path Path of the form "resource_type/resource_name.ext".
* @return An {@link InputStream} to the Android resource.
*/
- @NonNull
- public InputStream openResource(@NonNull String path)
+ public @NonNull InputStream openResource(@NonNull String path)
throws Resources.NotFoundException, IOException {
path = removeLeadingSlash(path);
// The path must be of the form "resource_type/resource_name.ext".
@@ -114,8 +111,7 @@
* @param path Path to the asset file to load.
* @return An {@link InputStream} to the Android asset.
*/
- @NonNull
- public InputStream openAsset(@NonNull String path) throws IOException {
+ public @NonNull InputStream openAsset(@NonNull String path) throws IOException {
path = removeLeadingSlash(path);
AssetManager assets = mContext.getAssets();
return handleSvgzStream(path, assets.open(path, AssetManager.ACCESS_STREAMING));
@@ -127,8 +123,7 @@
* @param file The file to be opened.
* @return An {@code InputStream} for the requested file.
*/
- @NonNull
- public static InputStream openFile(@NonNull File file) throws FileNotFoundException,
+ public static @NonNull InputStream openFile(@NonNull File file) throws FileNotFoundException,
IOException {
FileInputStream fis = new FileInputStream(file);
return handleSvgzStream(file.getPath(), fis);
@@ -145,9 +140,8 @@
* @return {@link File} for the given child path or {@code null} if the given path doesn't
* resolve to be a child of the given parent.
*/
- @Nullable
- public static File getCanonicalFileIfChild(@NonNull File parent, @NonNull String child)
- throws IOException {
+ public static @Nullable File getCanonicalFileIfChild(@NonNull File parent,
+ @NonNull String child) throws IOException {
String parentCanonicalPath = getCanonicalDirPath(parent);
String childCanonicalPath = new File(parent, child).getCanonicalPath();
if (childCanonicalPath.startsWith(parentCanonicalPath)) {
@@ -165,8 +159,7 @@
* E.g: the directory {@code "/some/path/to"} is not a parent of "/some/path/to_file". However,
* it will pass the {@code parentPath.startsWith(childPath)} check.
*/
- @NonNull
- public static String getCanonicalDirPath(@NonNull File file) throws IOException {
+ public static @NonNull String getCanonicalDirPath(@NonNull File file) throws IOException {
String canonicalPath = file.getCanonicalPath();
if (!canonicalPath.endsWith("/")) canonicalPath += "/";
return canonicalPath;
@@ -178,8 +171,7 @@
* @param context the {@link Context} used to get the data dir.
* @return data dir {@link File} for that app.
*/
- @NonNull
- public static File getDataDir(@NonNull Context context) {
+ public static @NonNull File getDataDir(@NonNull Context context) {
// Context#getDataDir is only available in APIs >= 24.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return ApiHelperForN.getDataDir(context);
@@ -196,8 +188,7 @@
* @param filePath path of the file to guess its MIME type.
* @return MIME type guessed from file extension or {@link AssetHelper#DEFAULT_MIME_TYPE}.
*/
- @NonNull
- public static String guessMimeType(@NonNull String filePath) {
+ public static @NonNull String guessMimeType(@NonNull String filePath) {
String mimeType = MimeUtil.getMimeFromFileName(filePath);
return mimeType == null ? DEFAULT_MIME_TYPE : mimeType;
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/ConditionallySupportedFeature.java b/webkit/webkit/src/main/java/androidx/webkit/internal/ConditionallySupportedFeature.java
index a2a6ded9..bf24ff9 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/ConditionallySupportedFeature.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/ConditionallySupportedFeature.java
@@ -16,7 +16,7 @@
package androidx.webkit.internal;
-import androidx.annotation.NonNull;
+import org.jspecify.annotations.NonNull;
/**
* An interface to represent a feature which may or may not be supported. This should generally be
@@ -26,8 +26,7 @@
/**
* Get the name of the public feature this matches.
*/
- @NonNull
- String getPublicFeatureName();
+ @NonNull String getPublicFeatureName();
/**
* Return whether this feature is supported.
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/CookieManagerAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/CookieManagerAdapter.java
index 98fe199..a9cb1d2 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/CookieManagerAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/CookieManagerAdapter.java
@@ -16,9 +16,8 @@
package androidx.webkit.internal;
-import androidx.annotation.NonNull;
-
import org.chromium.support_lib_boundary.WebViewCookieManagerBoundaryInterface;
+import org.jspecify.annotations.NonNull;
import java.util.List;
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/FrameworkServiceWorkerClient.java b/webkit/webkit/src/main/java/androidx/webkit/internal/FrameworkServiceWorkerClient.java
index 1629d00..13c9d33 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/FrameworkServiceWorkerClient.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/FrameworkServiceWorkerClient.java
@@ -21,11 +21,12 @@
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.webkit.ServiceWorkerClientCompat;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* A shim class that implements {@link ServiceWorkerClient} by delegating to a
* {@link ServiceWorkerClientCompat}.
@@ -40,8 +41,8 @@
}
@Override
- @Nullable
- public WebResourceResponse shouldInterceptRequest(@NonNull WebResourceRequest request) {
+ public @Nullable WebResourceResponse shouldInterceptRequest(
+ @NonNull WebResourceRequest request) {
return mImpl.shouldInterceptRequest(request);
}
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/IncompatibleApkWebViewProviderFactory.java b/webkit/webkit/src/main/java/androidx/webkit/internal/IncompatibleApkWebViewProviderFactory.java
index 62285cf..9c73e72 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/IncompatibleApkWebViewProviderFactory.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/IncompatibleApkWebViewProviderFactory.java
@@ -18,8 +18,6 @@
import android.webkit.WebView;
-import androidx.annotation.NonNull;
-
import org.chromium.support_lib_boundary.DropDataContentProviderBoundaryInterface;
import org.chromium.support_lib_boundary.ProfileStoreBoundaryInterface;
import org.chromium.support_lib_boundary.ProxyControllerBoundaryInterface;
@@ -28,6 +26,7 @@
import org.chromium.support_lib_boundary.TracingControllerBoundaryInterface;
import org.chromium.support_lib_boundary.WebViewProviderBoundaryInterface;
import org.chromium.support_lib_boundary.WebkitToCompatConverterBoundaryInterface;
+import org.jspecify.annotations.NonNull;
/**
* This is a stub class used when the WebView Support Library is invoked on a device incompatible
@@ -42,56 +41,47 @@
+ "method is being called too early, or is being called on start-up rather than lazily";
@Override
- @NonNull
- public WebViewProviderBoundaryInterface createWebView(@NonNull WebView webview) {
+ public @NonNull WebViewProviderBoundaryInterface createWebView(@NonNull WebView webview) {
throw new UnsupportedOperationException(UNSUPPORTED_EXCEPTION_EXPLANATION);
}
@Override
- @NonNull
- public WebkitToCompatConverterBoundaryInterface getWebkitToCompatConverter() {
+ public @NonNull WebkitToCompatConverterBoundaryInterface getWebkitToCompatConverter() {
throw new UnsupportedOperationException(UNSUPPORTED_EXCEPTION_EXPLANATION);
}
@Override
- @NonNull
- public StaticsBoundaryInterface getStatics() {
+ public @NonNull StaticsBoundaryInterface getStatics() {
throw new UnsupportedOperationException(UNSUPPORTED_EXCEPTION_EXPLANATION);
}
@Override
- @NonNull
- public String[] getWebViewFeatures() {
+ public String @NonNull [] getWebViewFeatures() {
return EMPTY_STRING_ARRAY;
}
@Override
- @NonNull
- public ServiceWorkerControllerBoundaryInterface getServiceWorkerController() {
+ public @NonNull ServiceWorkerControllerBoundaryInterface getServiceWorkerController() {
throw new UnsupportedOperationException(UNSUPPORTED_EXCEPTION_EXPLANATION);
}
@Override
- @NonNull
- public TracingControllerBoundaryInterface getTracingController() {
+ public @NonNull TracingControllerBoundaryInterface getTracingController() {
throw new UnsupportedOperationException(UNSUPPORTED_EXCEPTION_EXPLANATION);
}
@Override
- @NonNull
- public ProxyControllerBoundaryInterface getProxyController() {
+ public @NonNull ProxyControllerBoundaryInterface getProxyController() {
throw new UnsupportedOperationException(UNSUPPORTED_EXCEPTION_EXPLANATION);
}
- @NonNull
@Override
- public DropDataContentProviderBoundaryInterface getDropDataProvider() {
+ public @NonNull DropDataContentProviderBoundaryInterface getDropDataProvider() {
throw new UnsupportedOperationException(UNSUPPORTED_EXCEPTION_EXPLANATION);
}
- @NonNull
@Override
- public ProfileStoreBoundaryInterface getProfileStore() {
+ public @NonNull ProfileStoreBoundaryInterface getProfileStore() {
throw new UnsupportedOperationException(UNSUPPORTED_EXCEPTION_EXPLANATION);
}
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/JavaScriptReplyProxyImpl.java b/webkit/webkit/src/main/java/androidx/webkit/internal/JavaScriptReplyProxyImpl.java
index e3793f4..5089cc8 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/JavaScriptReplyProxyImpl.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/JavaScriptReplyProxyImpl.java
@@ -16,11 +16,11 @@
package androidx.webkit.internal;
-import androidx.annotation.NonNull;
import androidx.webkit.JavaScriptReplyProxy;
import org.chromium.support_lib_boundary.JsReplyProxyBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
+import org.jspecify.annotations.NonNull;
import java.lang.reflect.InvocationHandler;
import java.util.Objects;
@@ -38,9 +38,8 @@
/**
* Get a support library JavaScriptReplyProxy object that is 1:1 with the AndroidX side object.
*/
- @NonNull
- public static JavaScriptReplyProxyImpl forInvocationHandler(
- @NonNull /* JsReplyProxy */ InvocationHandler invocationHandler) {
+ public static @NonNull JavaScriptReplyProxyImpl forInvocationHandler(
+ /* JsReplyProxy */ @NonNull InvocationHandler invocationHandler) {
final JsReplyProxyBoundaryInterface boundaryInterface =
BoundaryInterfaceReflectionUtil.castToSuppLibClass(
JsReplyProxyBoundaryInterface.class, invocationHandler);
@@ -49,7 +48,7 @@
}
@Override
- public void postMessage(@NonNull final String message) {
+ public void postMessage(final @NonNull String message) {
final ApiFeature.NoFramework feature = WebViewFeatureInternal.WEB_MESSAGE_LISTENER;
if (feature.isSupportedByWebView()) {
mBoundaryInterface.postMessage(message);
@@ -59,7 +58,7 @@
}
@Override
- public void postMessage(@NonNull byte[] arrayBuffer) {
+ public void postMessage(byte @NonNull [] arrayBuffer) {
// WebView cannot handle null ArrayBuffer as WebMessage.
Objects.requireNonNull(arrayBuffer, "ArrayBuffer must be non-null");
final ApiFeature.NoFramework feature = WebViewFeatureInternal.WEB_MESSAGE_ARRAY_BUFFER;
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/NoVarySearchDataAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/NoVarySearchDataAdapter.java
index 33cf99a..284be7b 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/NoVarySearchDataAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/NoVarySearchDataAdapter.java
@@ -16,10 +16,10 @@
package androidx.webkit.internal;
-import androidx.annotation.NonNull;
import androidx.webkit.NoVarySearchData;
import org.chromium.support_lib_boundary.NoVarySearchDataBoundaryInterface;
+import org.jspecify.annotations.NonNull;
import java.util.List;
@@ -40,15 +40,13 @@
return mImpl.ignoreDifferencesInParameters;
}
- @NonNull
@Override
- public List<String> getIgnoredQueryParameters() {
+ public @NonNull List<String> getIgnoredQueryParameters() {
return mImpl.ignoredQueryParameters;
}
- @NonNull
@Override
- public List<String> getConsideredQueryParameters() {
+ public @NonNull List<String> getConsideredQueryParameters() {
return mImpl.consideredQueryParameters;
}
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/PrefetchParametersAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/PrefetchParametersAdapter.java
index 21169dc..ec1528b 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/PrefetchParametersAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/PrefetchParametersAdapter.java
@@ -16,36 +16,30 @@
package androidx.webkit.internal;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.webkit.NoVarySearchData;
import androidx.webkit.PrefetchParameters;
-import org.chromium.support_lib_boundary.PrefetchParamsBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.lang.reflect.InvocationHandler;
import java.util.HashMap;
import java.util.Map;
-public class PrefetchParametersAdapter implements
- PrefetchParamsBoundaryInterface {
+public class PrefetchParametersAdapter {
private final PrefetchParameters mPrefetchParameters;
public PrefetchParametersAdapter(@Nullable PrefetchParameters impl) {
mPrefetchParameters = impl;
}
- @NonNull
- @Override
- public Map<String, String> getAdditionalHeaders() {
+ public @NonNull Map<String, String> getAdditionalHeaders() {
if (mPrefetchParameters == null) return new HashMap<>();
return mPrefetchParameters.getAdditionalHeaders();
}
- @Nullable
- @Override
- public InvocationHandler getNoVarySearchData() {
+ public @Nullable InvocationHandler getNoVarySearchData() {
if (mPrefetchParameters == null) return null;
NoVarySearchData noVarySearchData = mPrefetchParameters.getExpectedNoVarySearchData();
if (noVarySearchData == null) return null;
@@ -53,7 +47,6 @@
new NoVarySearchDataAdapter(noVarySearchData));
}
- @Override
public boolean isJavaScriptEnabled() {
if (mPrefetchParameters == null) return false;
return mPrefetchParameters.isJavaScriptEnabled();
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/ProfileImpl.java b/webkit/webkit/src/main/java/androidx/webkit/internal/ProfileImpl.java
index 6a9ba11..a762e5d 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/ProfileImpl.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/ProfileImpl.java
@@ -16,26 +16,20 @@
package androidx.webkit.internal;
-import android.util.Log;
import android.webkit.CookieManager;
import android.webkit.GeolocationPermissions;
import android.webkit.ServiceWorkerController;
import android.webkit.WebStorage;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.core.os.CancellationSignal;
-import androidx.webkit.PrefetchException;
import androidx.webkit.PrefetchOperationCallback;
import androidx.webkit.PrefetchParameters;
import androidx.webkit.Profile;
-import org.chromium.support_lib_boundary.PrefetchOperationResultBoundaryInterface;
-import org.chromium.support_lib_boundary.PrefetchStatusCodeBoundaryInterface;
import org.chromium.support_lib_boundary.ProfileBoundaryInterface;
-import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
-import java.lang.reflect.InvocationHandler;
/**
* Internal implementation of Profile.
@@ -54,8 +48,7 @@
}
@Override
- @NonNull
- public String getName() {
+ public @NonNull String getName() {
ApiFeature.NoFramework feature = WebViewFeatureInternal.MULTI_PROFILE;
if (feature.isSupportedByWebView()) {
return mProfileImpl.getName();
@@ -65,8 +58,7 @@
}
@Override
- @NonNull
- public CookieManager getCookieManager() throws IllegalStateException {
+ public @NonNull CookieManager getCookieManager() throws IllegalStateException {
ApiFeature.NoFramework feature = WebViewFeatureInternal.MULTI_PROFILE;
if (feature.isSupportedByWebView()) {
return mProfileImpl.getCookieManager();
@@ -76,8 +68,7 @@
}
@Override
- @NonNull
- public WebStorage getWebStorage() throws IllegalStateException {
+ public @NonNull WebStorage getWebStorage() throws IllegalStateException {
ApiFeature.NoFramework feature = WebViewFeatureInternal.MULTI_PROFILE;
if (feature.isSupportedByWebView()) {
return mProfileImpl.getWebStorage();
@@ -86,9 +77,9 @@
}
}
- @NonNull
@Override
- public GeolocationPermissions getGeolocationPermissions() throws IllegalStateException {
+ public @NonNull GeolocationPermissions getGeolocationPermissions()
+ throws IllegalStateException {
ApiFeature.NoFramework feature = WebViewFeatureInternal.MULTI_PROFILE;
if (feature.isSupportedByWebView()) {
return mProfileImpl.getGeoLocationPermissions();
@@ -97,9 +88,9 @@
}
}
- @NonNull
@Override
- public ServiceWorkerController getServiceWorkerController() throws IllegalStateException {
+ public @NonNull ServiceWorkerController getServiceWorkerController()
+ throws IllegalStateException {
ApiFeature.NoFramework feature = WebViewFeatureInternal.MULTI_PROFILE;
if (feature.isSupportedByWebView()) {
return mProfileImpl.getServiceWorkerController();
@@ -113,26 +104,6 @@
@Nullable CancellationSignal cancellationSignal,
@NonNull PrefetchOperationCallback<Void> operationCallback,
@Nullable PrefetchParameters params) {
- ApiFeature.NoFramework feature = WebViewFeatureInternal.PROFILE_URL_PREFETCH;
- if (feature.isSupportedByWebView()) {
- try {
- InvocationHandler paramsBoundaryInterface =
- BoundaryInterfaceReflectionUtil.createInvocationHandlerFor(
- new PrefetchParametersAdapter(params));
-
- mProfileImpl.prefetchUrl(url, paramsBoundaryInterface,
- value -> mapOperationResult(value, operationCallback));
-
- } catch (Exception e) {
- operationCallback.onError(e);
- }
- if (cancellationSignal != null) {
- cancellationSignal.setOnCancelListener(() -> mProfileImpl.cancelPrefetch(url,
- value -> mapOperationResult(value, operationCallback)));
- }
- } else {
- throw WebViewFeatureInternal.getUnsupportedOperationException();
- }
}
@Override
@@ -145,35 +116,6 @@
@Override
public void clearPrefetchAsync(@NonNull String url,
@NonNull PrefetchOperationCallback<Void> operationCallback) {
- ApiFeature.NoFramework feature = WebViewFeatureInternal.PROFILE_URL_PREFETCH;
- if (feature.isSupportedByWebView()) {
- try {
- mProfileImpl.clearPrefetch(url,
- value -> mapOperationResult(value, operationCallback));
- } catch (Exception e) {
- operationCallback.onError(e);
- }
- } else {
- throw WebViewFeatureInternal.getUnsupportedOperationException();
- }
- }
-
- private void mapOperationResult(InvocationHandler resultInvocation,
- PrefetchOperationCallback<Void> operationCallback) {
- PrefetchOperationResultBoundaryInterface result =
- BoundaryInterfaceReflectionUtil.castToSuppLibClass(
- PrefetchOperationResultBoundaryInterface.class, resultInvocation);
- assert result != null;
- switch (result.getStatusCode()) {
- case PrefetchStatusCodeBoundaryInterface.SUCCESS:
- operationCallback.onSuccess(null);
- break;
- case PrefetchStatusCodeBoundaryInterface.FAILURE:
- operationCallback.onError(new PrefetchException("An unexpected error occurred."));
- break;
- default:
- Log.e("Prefetch", "Unsupported status code received");
- }
}
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/ProfileStoreImpl.java b/webkit/webkit/src/main/java/androidx/webkit/internal/ProfileStoreImpl.java
index b237096..feb778c 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/ProfileStoreImpl.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/ProfileStoreImpl.java
@@ -16,14 +16,14 @@
package androidx.webkit.internal;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.webkit.Profile;
import androidx.webkit.ProfileStore;
import org.chromium.support_lib_boundary.ProfileBoundaryInterface;
import org.chromium.support_lib_boundary.ProfileStoreBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.lang.reflect.InvocationHandler;
import java.util.List;
@@ -49,8 +49,7 @@
*
* @return ProfileStore instance to use for managing profiles.
*/
- @NonNull
- public static ProfileStore getInstance() {
+ public static @NonNull ProfileStore getInstance() {
if (sInstance == null) {
sInstance = new ProfileStoreImpl(
WebViewGlueCommunicator.getFactory().getProfileStore());
@@ -59,8 +58,7 @@
}
@Override
- @NonNull
- public Profile getOrCreateProfile(@NonNull String name) {
+ public @NonNull Profile getOrCreateProfile(@NonNull String name) {
ApiFeature.NoFramework feature = WebViewFeatureInternal.MULTI_PROFILE;
if (feature.isSupportedByWebView()) {
return new ProfileImpl(BoundaryInterfaceReflectionUtil.castToSuppLibClass(
@@ -71,8 +69,7 @@
}
@Override
- @Nullable
- public Profile getProfile(@NonNull String name) {
+ public @Nullable Profile getProfile(@NonNull String name) {
ApiFeature.NoFramework feature = WebViewFeatureInternal.MULTI_PROFILE;
if (feature.isSupportedByWebView()) {
InvocationHandler profileBoundaryInterface = mProfileStoreImpl.getProfile(name);
@@ -88,8 +85,7 @@
}
@Override
- @NonNull
- public List<String> getAllProfileNames() {
+ public @NonNull List<String> getAllProfileNames() {
ApiFeature.NoFramework feature = WebViewFeatureInternal.MULTI_PROFILE;
if (feature.isSupportedByWebView()) {
return mProfileStoreImpl.getAllProfileNames();
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/ProxyControllerImpl.java b/webkit/webkit/src/main/java/androidx/webkit/internal/ProxyControllerImpl.java
index 3ec5036..6e7c63f 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/ProxyControllerImpl.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/ProxyControllerImpl.java
@@ -16,13 +16,13 @@
package androidx.webkit.internal;
-import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.webkit.ProxyConfig;
import androidx.webkit.ProxyConfig.ProxyRule;
import androidx.webkit.ProxyController;
import org.chromium.support_lib_boundary.ProxyControllerBoundaryInterface;
+import org.jspecify.annotations.NonNull;
import java.util.List;
import java.util.concurrent.Executor;
@@ -71,9 +71,9 @@
/**
* Converts a ProxyRule List into a String array.
*/
- @NonNull
@VisibleForTesting
- public static String[][] proxyRulesToStringArray(@NonNull List<ProxyRule> proxyRuleList) {
+ public static String @NonNull [][] proxyRulesToStringArray(
+ @NonNull List<ProxyRule> proxyRuleList) {
String[][] proxyRuleArray = new String[proxyRuleList.size()][2];
for (int i = 0; i < proxyRuleList.size(); i++) {
proxyRuleArray[i][0] = proxyRuleList.get(i).getSchemeFilter();
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/SafeBrowsingResponseImpl.java b/webkit/webkit/src/main/java/androidx/webkit/internal/SafeBrowsingResponseImpl.java
index 12c266a..9487bf4 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/SafeBrowsingResponseImpl.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/SafeBrowsingResponseImpl.java
@@ -18,12 +18,12 @@
import android.webkit.SafeBrowsingResponse;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.webkit.SafeBrowsingResponseCompat;
import org.chromium.support_lib_boundary.SafeBrowsingResponseBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
+import org.jspecify.annotations.NonNull;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/ScriptHandlerImpl.java b/webkit/webkit/src/main/java/androidx/webkit/internal/ScriptHandlerImpl.java
index 87e7eed..c9b2f47 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/ScriptHandlerImpl.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/ScriptHandlerImpl.java
@@ -16,11 +16,11 @@
package androidx.webkit.internal;
-import androidx.annotation.NonNull;
import androidx.webkit.ScriptHandler;
import org.chromium.support_lib_boundary.ScriptHandlerBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
+import org.jspecify.annotations.NonNull;
import java.lang.reflect.InvocationHandler;
@@ -48,7 +48,7 @@
* Create an AndroidX ScriptHandler from the given InvocationHandler.
*/
public static @NonNull ScriptHandlerImpl toScriptHandler(
- @NonNull /* ScriptHandler */ InvocationHandler invocationHandler) {
+ /* ScriptHandler */ @NonNull InvocationHandler invocationHandler) {
final ScriptHandlerBoundaryInterface boundaryInterface =
BoundaryInterfaceReflectionUtil.castToSuppLibClass(
ScriptHandlerBoundaryInterface.class, invocationHandler);
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/ServiceWorkerClientAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/ServiceWorkerClientAdapter.java
index 6bcb7957..c5a65ff 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/ServiceWorkerClientAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/ServiceWorkerClientAdapter.java
@@ -19,12 +19,12 @@
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.webkit.ServiceWorkerClientCompat;
import org.chromium.support_lib_boundary.ServiceWorkerClientBoundaryInterface;
import org.chromium.support_lib_boundary.util.Features;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* Adapter between {@link ServiceWorkerClientCompat} and
@@ -39,14 +39,13 @@
}
@Override
- @Nullable
- public WebResourceResponse shouldInterceptRequest(@NonNull WebResourceRequest request) {
+ public @Nullable WebResourceResponse shouldInterceptRequest(
+ @NonNull WebResourceRequest request) {
return mClient.shouldInterceptRequest(request);
}
@Override
- @NonNull
- public String[] getSupportedFeatures() {
+ public String @NonNull [] getSupportedFeatures() {
return new String[] { Features.SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST };
}
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/ServiceWorkerControllerImpl.java b/webkit/webkit/src/main/java/androidx/webkit/internal/ServiceWorkerControllerImpl.java
index 151714b..e07b570 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/ServiceWorkerControllerImpl.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/ServiceWorkerControllerImpl.java
@@ -18,8 +18,6 @@
import android.webkit.ServiceWorkerController;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.webkit.ServiceWorkerClientCompat;
import androidx.webkit.ServiceWorkerControllerCompat;
@@ -27,6 +25,8 @@
import org.chromium.support_lib_boundary.ServiceWorkerControllerBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
/**
* Implementation of {@link ServiceWorkerControllerCompat}.
@@ -71,9 +71,8 @@
return mBoundaryInterface;
}
- @NonNull
@Override
- public ServiceWorkerWebSettingsCompat getServiceWorkerWebSettings() {
+ public @NonNull ServiceWorkerWebSettingsCompat getServiceWorkerWebSettings() {
return mWebSettings;
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/ServiceWorkerWebSettingsImpl.java b/webkit/webkit/src/main/java/androidx/webkit/internal/ServiceWorkerWebSettingsImpl.java
index 6282b83..cd75402 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/ServiceWorkerWebSettingsImpl.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/ServiceWorkerWebSettingsImpl.java
@@ -18,12 +18,12 @@
import android.webkit.ServiceWorkerWebSettings;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.webkit.ServiceWorkerWebSettingsCompat;
import org.chromium.support_lib_boundary.ServiceWorkerWebSettingsBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
+import org.jspecify.annotations.NonNull;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
@@ -183,9 +183,8 @@
}
}
- @NonNull
@Override
- public Set<String> getRequestedWithHeaderOriginAllowList() {
+ public @NonNull Set<String> getRequestedWithHeaderOriginAllowList() {
final ApiFeature.NoFramework feature =
WebViewFeatureInternal.REQUESTED_WITH_HEADER_ALLOW_LIST;
if (feature.isSupportedByWebView()) {
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/StartupApiFeature.java b/webkit/webkit/src/main/java/androidx/webkit/internal/StartupApiFeature.java
index 85a81f5..e945ae9 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/StartupApiFeature.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/StartupApiFeature.java
@@ -24,11 +24,12 @@
import android.os.Build;
import android.os.Bundle;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.webkit.WebViewCompat;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -71,8 +72,7 @@
sValues.add(this);
}
- @NonNull
- public String getPublicFeatureName() {
+ public @NonNull String getPublicFeatureName() {
return mPublicFeatureValue;
}
@@ -112,8 +112,7 @@
/**
* Get all instantiated values of this class as if it was an enum.
*/
- @NonNull
- public static Set<StartupApiFeature> values() {
+ public static @NonNull Set<StartupApiFeature> values() {
return Collections.unmodifiableSet(sValues);
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/TracingControllerImpl.java b/webkit/webkit/src/main/java/androidx/webkit/internal/TracingControllerImpl.java
index 6355172..5dd4db3 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/TracingControllerImpl.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/TracingControllerImpl.java
@@ -16,13 +16,13 @@
package androidx.webkit.internal;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.webkit.TracingConfig;
import androidx.webkit.TracingController;
import org.chromium.support_lib_boundary.TracingControllerBoundaryInterface;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.io.OutputStream;
import java.util.concurrent.Executor;
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/UserAgentMetadataInternal.java b/webkit/webkit/src/main/java/androidx/webkit/internal/UserAgentMetadataInternal.java
index d238bc1..945286b 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/UserAgentMetadataInternal.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/UserAgentMetadataInternal.java
@@ -16,9 +16,10 @@
package androidx.webkit.internal;
-import androidx.annotation.NonNull;
import androidx.webkit.UserAgentMetadata;
+import org.jspecify.annotations.NonNull;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -99,8 +100,7 @@
*
* @return A hashmap contains user-agent metadata key name, and corresponding objects.
*/
- @NonNull
- static Map<String, Object> convertUserAgentMetadataToMap(
+ static @NonNull Map<String, Object> convertUserAgentMetadataToMap(
@NonNull UserAgentMetadata uaMetadata) {
Map<String, Object> item = new HashMap<>();
item.put(BRAND_VERSION_LIST, getBrandVersionArray(uaMetadata.getBrandVersionList()));
@@ -139,8 +139,7 @@
* objects.
* @return This UserAgentMetadata object
*/
- @NonNull
- static UserAgentMetadata getUserAgentMetadataFromMap(
+ static @NonNull UserAgentMetadata getUserAgentMetadataFromMap(
@NonNull Map<String, Object> uaMetadataMap) {
UserAgentMetadata.Builder builder = new UserAgentMetadata.Builder();
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/VisualStateCallbackAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/VisualStateCallbackAdapter.java
index 29529c5..dc6ceae 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/VisualStateCallbackAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/VisualStateCallbackAdapter.java
@@ -16,10 +16,10 @@
package androidx.webkit.internal;
-import androidx.annotation.NonNull;
import androidx.webkit.WebViewCompat;
import org.chromium.support_lib_boundary.VisualStateCallbackBoundaryInterface;
+import org.jspecify.annotations.NonNull;
/**
* Adapter between WebViewCompat.VisualStateCallback and VisualStateCallbackBoundaryInterface (the
@@ -29,7 +29,7 @@
private final WebViewCompat.VisualStateCallback mVisualStateCallback;
public VisualStateCallbackAdapter(
- @NonNull WebViewCompat.VisualStateCallback visualStateCallback) {
+ WebViewCompat.@NonNull VisualStateCallback visualStateCallback) {
mVisualStateCallback = visualStateCallback;
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageAdapter.java
index 050e123..97df9cc 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageAdapter.java
@@ -18,8 +18,6 @@
import static org.chromium.support_lib_boundary.WebMessagePayloadBoundaryInterface.WebMessagePayloadType;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.webkit.WebMessageCompat;
import androidx.webkit.WebMessagePortCompat;
@@ -27,6 +25,8 @@
import org.chromium.support_lib_boundary.WebMessagePayloadBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
import org.chromium.support_lib_boundary.util.Features;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.lang.reflect.InvocationHandler;
import java.util.Objects;
@@ -51,14 +51,12 @@
*/
@Deprecated
@Override
- @Nullable
- public String getData() {
+ public @Nullable String getData() {
return mWebMessageCompat.getData();
}
@Override
- @Nullable
- public InvocationHandler getMessagePayload() {
+ public @Nullable InvocationHandler getMessagePayload() {
final WebMessagePayloadAdapter adapter;
switch (mWebMessageCompat.getType()) {
case WebMessageCompat.TYPE_STRING:
@@ -76,8 +74,7 @@
}
@Override
- @Nullable
- public InvocationHandler[] getPorts() {
+ public InvocationHandler @Nullable [] getPorts() {
WebMessagePortCompat[] ports = mWebMessageCompat.getPorts();
if (ports == null) return null;
@@ -89,8 +86,7 @@
}
@Override
- @NonNull
- public String[] getSupportedFeatures() {
+ public String @NonNull [] getSupportedFeatures() {
// getData() and getPorts() are not covered by feature flags.
return sFeatures;
}
@@ -115,8 +111,7 @@
* Return null when the WebMessageCompat payload type is not supported by AndroidX now.
*/
@SuppressWarnings("deprecation")
- @Nullable
- public static WebMessageCompat webMessageCompatFromBoundaryInterface(
+ public static @Nullable WebMessageCompat webMessageCompatFromBoundaryInterface(
@NonNull WebMessageBoundaryInterface boundaryInterface) {
final WebMessagePortCompat[] ports = toWebMessagePortCompats(
boundaryInterface.getPorts());
@@ -139,8 +134,8 @@
return new WebMessageCompat(boundaryInterface.getData(), ports);
}
- @NonNull
- private static WebMessagePortCompat[] toWebMessagePortCompats(InvocationHandler[] ports) {
+ private static WebMessagePortCompat @NonNull [] toWebMessagePortCompats(
+ InvocationHandler[] ports) {
WebMessagePortCompat[] compatPorts = new WebMessagePortCompat[ports.length];
for (int n = 0; n < ports.length; n++) {
compatPorts[n] = new WebMessagePortImpl(ports[n]);
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageCallbackAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageCallbackAdapter.java
index cc490cb..290d224 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageCallbackAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageCallbackAdapter.java
@@ -16,7 +16,6 @@
package androidx.webkit.internal;
-import androidx.annotation.NonNull;
import androidx.webkit.WebMessageCompat;
import androidx.webkit.WebMessagePortCompat.WebMessageCallbackCompat;
@@ -24,6 +23,7 @@
import org.chromium.support_lib_boundary.WebMessageCallbackBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
import org.chromium.support_lib_boundary.util.Features;
+import org.jspecify.annotations.NonNull;
import java.lang.reflect.InvocationHandler;
@@ -51,8 +51,7 @@
// This method declares which APIs the support library side supports - so that the Chromium-side
// doesn't crash if we remove APIs from the support library side.
@Override
- @NonNull
- public String[] getSupportedFeatures() {
+ public String @NonNull [] getSupportedFeatures() {
return new String[] { Features.WEB_MESSAGE_CALLBACK_ON_MESSAGE };
}
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageListenerAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageListenerAdapter.java
index 701f316..0d2f0e8 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageListenerAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessageListenerAdapter.java
@@ -19,7 +19,6 @@
import android.net.Uri;
import android.webkit.WebView;
-import androidx.annotation.NonNull;
import androidx.webkit.JavaScriptReplyProxy;
import androidx.webkit.WebMessageCompat;
import androidx.webkit.WebViewCompat;
@@ -28,6 +27,7 @@
import org.chromium.support_lib_boundary.WebMessageListenerBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
import org.chromium.support_lib_boundary.util.Features;
+import org.jspecify.annotations.NonNull;
import java.lang.reflect.InvocationHandler;
@@ -38,14 +38,14 @@
public class WebMessageListenerAdapter implements WebMessageListenerBoundaryInterface {
private final WebViewCompat.WebMessageListener mWebMessageListener;
- public WebMessageListenerAdapter(@NonNull WebViewCompat.WebMessageListener webMessageListener) {
+ public WebMessageListenerAdapter(WebViewCompat.@NonNull WebMessageListener webMessageListener) {
mWebMessageListener = webMessageListener;
}
@Override
public void onPostMessage(@NonNull WebView view,
- @NonNull /* WebMessage */ InvocationHandler message, @NonNull Uri sourceOrigin,
- boolean isMainFrame, @NonNull /* JavaScriptReplyProxy */ InvocationHandler replyProxy) {
+ /* WebMessage */ @NonNull InvocationHandler message, @NonNull Uri sourceOrigin,
+ boolean isMainFrame, /* JavaScriptReplyProxy */ @NonNull InvocationHandler replyProxy) {
final WebMessageCompat webMessage = WebMessageAdapter.webMessageCompatFromBoundaryInterface(
BoundaryInterfaceReflectionUtil.castToSuppLibClass(
WebMessageBoundaryInterface.class, message));
@@ -62,7 +62,7 @@
* doesn't crash if we remove APIs from the support library side.
*/
@Override
- public @NonNull String[] getSupportedFeatures() {
+ public String @NonNull [] getSupportedFeatures() {
return new String[] {Features.WEB_MESSAGE_LISTENER, Features.WEB_MESSAGE_ARRAY_BUFFER};
}
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessagePayloadAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessagePayloadAdapter.java
index 532683f..9965d3f 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessagePayloadAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessagePayloadAdapter.java
@@ -16,11 +16,11 @@
package androidx.webkit.internal;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.webkit.WebMessageCompat;
import org.chromium.support_lib_boundary.WebMessagePayloadBoundaryInterface;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.util.Objects;
@@ -31,23 +31,22 @@
public class WebMessagePayloadAdapter implements WebMessagePayloadBoundaryInterface {
private final @WebMessagePayloadType int mType;
private final @Nullable String mString;
- private final @Nullable byte[] mArrayBuffer;
+ private final byte @Nullable [] mArrayBuffer;
- public WebMessagePayloadAdapter(@Nullable final String data) {
+ public WebMessagePayloadAdapter(final @Nullable String data) {
mType = WebMessageCompat.TYPE_STRING;
mString = data;
mArrayBuffer = null;
}
- public WebMessagePayloadAdapter(@NonNull final byte[] arrayBuffer) {
+ public WebMessagePayloadAdapter(final byte @NonNull [] arrayBuffer) {
mType = WebMessageCompat.TYPE_ARRAY_BUFFER;
mString = null;
mArrayBuffer = arrayBuffer;
}
@Override
- @NonNull
- public String[] getSupportedFeatures() {
+ public String @NonNull [] getSupportedFeatures() {
// getType, getAsString and getAsArrayBuffer are covered by
// WEB_MESSAGE_ARRAY_BUFFER.
return new String[0];
@@ -58,16 +57,14 @@
return mType;
}
- @Nullable
@Override
- public String getAsString() {
+ public @Nullable String getAsString() {
checkType(WebMessagePayloadType.TYPE_STRING);
return mString;
}
- @NonNull
@Override
- public byte[] getAsArrayBuffer() {
+ public byte @NonNull [] getAsArrayBuffer() {
checkType(WebMessagePayloadType.TYPE_ARRAY_BUFFER);
return Objects.requireNonNull(mArrayBuffer);
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessagePortImpl.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessagePortImpl.java
index c74e9aa..0840ef7 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessagePortImpl.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebMessagePortImpl.java
@@ -20,14 +20,14 @@
import android.webkit.WebMessage;
import android.webkit.WebMessagePort;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.webkit.WebMessageCompat;
import androidx.webkit.WebMessagePortCompat;
import org.chromium.support_lib_boundary.WebMessagePortBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
@@ -98,7 +98,7 @@
}
@Override
- public void setWebMessageCallback(@NonNull final WebMessageCallbackCompat callback) {
+ public void setWebMessageCallback(final @NonNull WebMessageCallbackCompat callback) {
final ApiFeature.M feature = WebViewFeatureInternal.WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK;
if (feature.isSupportedByWebView()) {
// We prefer use WebView impl, since the impl in framework does not support
@@ -115,7 +115,7 @@
@Override
public void setWebMessageCallback(@Nullable Handler handler,
- @NonNull final WebMessageCallbackCompat callback) {
+ final @NonNull WebMessageCallbackCompat callback) {
final ApiFeature.M feature = WebViewFeatureInternal.CREATE_WEB_MESSAGE_CHANNEL;
if (feature.isSupportedByWebView()) {
// We prefer use WebView impl, since the impl in framework does not support
@@ -130,16 +130,14 @@
}
}
- @NonNull
@RequiresApi(23)
@Override
- public WebMessagePort getFrameworkPort() {
+ public @NonNull WebMessagePort getFrameworkPort() {
return getFrameworksImpl();
}
- @NonNull
@Override
- public InvocationHandler getInvocationHandler() {
+ public @NonNull InvocationHandler getInvocationHandler() {
return Proxy.getInvocationHandler(getBoundaryInterface());
}
@@ -147,8 +145,8 @@
* Convert an array of {@link WebMessagePort} objects into an array containing objects of the
* corresponding support library class {@link WebMessagePortCompat}.
*/
- @Nullable
- public static WebMessagePortCompat[] portsToCompat(@Nullable WebMessagePort[] ports) {
+ public static WebMessagePortCompat @Nullable [] portsToCompat(
+ WebMessagePort @Nullable [] ports) {
if (ports == null) return null;
WebMessagePortCompat[] compatPorts = new WebMessagePortCompat[ports.length];
for (int n = 0; n < ports.length; n++) {
@@ -162,8 +160,8 @@
* the corresponding framework class {@link WebMessagePort}.
*/
@RequiresApi(23)
- @Nullable
- public static WebMessagePort[] compatToPorts(@Nullable WebMessagePortCompat[] compatPorts) {
+ public static WebMessagePort @Nullable [] compatToPorts(
+ WebMessagePortCompat @Nullable [] compatPorts) {
if (compatPorts == null) return null;
WebMessagePort[] ports = new WebMessagePort[compatPorts.length];
for (int n = 0; n < ports.length; n++) {
@@ -176,8 +174,7 @@
* Convert a {@link WebMessageCompat} into the corresponding framework class {@link WebMessage}.
*/
@RequiresApi(23)
- @NonNull
- public static WebMessage compatToFrameworkMessage(@NonNull WebMessageCompat message) {
+ public static @NonNull WebMessage compatToFrameworkMessage(@NonNull WebMessageCompat message) {
return ApiHelperForM.createWebMessage(message);
}
@@ -186,8 +183,7 @@
* {@link WebMessageCompat}.
*/
@RequiresApi(23)
- @NonNull
- public static WebMessageCompat frameworkMessageToCompat(@NonNull WebMessage message) {
+ public static @NonNull WebMessageCompat frameworkMessageToCompat(@NonNull WebMessage message) {
return ApiHelperForM.createWebMessageCompat(message);
}
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebResourceErrorImpl.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebResourceErrorImpl.java
index 312e461..d313453 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebResourceErrorImpl.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebResourceErrorImpl.java
@@ -18,12 +18,12 @@
import android.webkit.WebResourceError;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.webkit.WebResourceErrorCompat;
import org.chromium.support_lib_boundary.WebResourceErrorBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
+import org.jspecify.annotations.NonNull;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
@@ -87,9 +87,8 @@
}
}
- @NonNull
@Override
- public CharSequence getDescription() {
+ public @NonNull CharSequence getDescription() {
final ApiFeature.M feature = WebViewFeatureInternal.WEB_RESOURCE_ERROR_GET_DESCRIPTION;
if (feature.isSupportedByFramework()) {
return ApiHelperForM.getDescription(getFrameworksImpl());
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebResourceRequestAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebResourceRequestAdapter.java
index 5fbd02e..22deddc 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebResourceRequestAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebResourceRequestAdapter.java
@@ -18,9 +18,8 @@
import android.webkit.WebResourceRequest;
-import androidx.annotation.NonNull;
-
import org.chromium.support_lib_boundary.WebResourceRequestBoundaryInterface;
+import org.jspecify.annotations.NonNull;
/**
* Adapter between {@link androidx.webkit.WebResourceRequestCompat} and
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebSettingsAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebSettingsAdapter.java
index 1b5ac1e..9351f2d 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebSettingsAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebSettingsAdapter.java
@@ -18,12 +18,11 @@
import android.webkit.WebSettings;
-import androidx.annotation.NonNull;
import androidx.webkit.UserAgentMetadata;
import androidx.webkit.WebViewMediaIntegrityApiStatusConfig;
-
import org.chromium.support_lib_boundary.WebSettingsBoundaryInterface;
+import org.jspecify.annotations.NonNull;
import java.util.Set;
@@ -143,8 +142,7 @@
* Adapter method for
* {@link androidx.webkit.WebSettingsCompat#getRequestedWithHeaderOriginAllowList(WebSettings)}.
*/
- @NonNull
- public Set<String> getRequestedWithHeaderOriginAllowList() {
+ public @NonNull Set<String> getRequestedWithHeaderOriginAllowList() {
return mBoundaryInterface.getRequestedWithHeaderOriginAllowList();
}
@@ -161,8 +159,7 @@
* Adapter method for
* {@link androidx.webkit.WebSettingsCompat#getUserAgentMetadata(WebSettings)}.
*/
- @NonNull
- public UserAgentMetadata getUserAgentMetadata() {
+ public @NonNull UserAgentMetadata getUserAgentMetadata() {
return UserAgentMetadataInternal.getUserAgentMetadataFromMap(
mBoundaryInterface.getUserAgentMetadataMap());
}
@@ -207,8 +204,7 @@
* Adapter method for
* {@link androidx.webkit.WebSettingsCompat#getWebViewMediaIntegrityApiStatus(WebSettings)}
*/
- @NonNull
- public WebViewMediaIntegrityApiStatusConfig getWebViewMediaIntegrityApiStatus() {
+ public @NonNull WebViewMediaIntegrityApiStatusConfig getWebViewMediaIntegrityApiStatus() {
return new WebViewMediaIntegrityApiStatusConfig
.Builder(mBoundaryInterface.getWebViewMediaIntegrityApiDefaultStatus())
.setOverrideRules(mBoundaryInterface.getWebViewMediaIntegrityApiOverrideRules())
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewFeatureInternal.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewFeatureInternal.java
index de1cb09..6ac11d9 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewFeatureInternal.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewFeatureInternal.java
@@ -27,7 +27,6 @@
import android.webkit.WebSettings;
import android.webkit.WebView;
-import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.webkit.PrefetchParameters;
@@ -48,6 +47,7 @@
import androidx.webkit.WebViewFeature;
import org.chromium.support_lib_boundary.util.Features;
+import org.jspecify.annotations.NonNull;
import java.io.File;
import java.io.OutputStream;
@@ -668,7 +668,7 @@
* Return whether a public feature is supported by any internal features defined in this class.
*/
public static boolean isSupported(
- @NonNull @WebViewFeature.WebViewSupportFeature String publicFeatureValue) {
+ @WebViewFeature.WebViewSupportFeature @NonNull String publicFeatureValue) {
return isSupported(publicFeatureValue, ApiFeature.values());
}
@@ -677,7 +677,7 @@
* this class.
*/
public static boolean isStartupFeatureSupported(
- @NonNull @WebViewFeature.WebViewStartupFeature String publicFeatureValue,
+ @WebViewFeature.WebViewStartupFeature @NonNull String publicFeatureValue,
@NonNull Context context) {
return isStartupFeatureSupported(publicFeatureValue, StartupApiFeature.values(), context);
}
@@ -691,7 +691,7 @@
*/
@VisibleForTesting
public static <T extends ConditionallySupportedFeature> boolean isSupported(
- @NonNull @WebViewFeature.WebViewSupportFeature String publicFeatureValue,
+ @WebViewFeature.WebViewSupportFeature @NonNull String publicFeatureValue,
@NonNull Collection<T> internalFeatures) {
Set<ConditionallySupportedFeature> matchingFeatures = new HashSet<>();
for (ConditionallySupportedFeature feature : internalFeatures) {
@@ -717,7 +717,7 @@
*/
@VisibleForTesting
public static boolean isStartupFeatureSupported(
- @NonNull @WebViewFeature.WebViewStartupFeature String publicFeatureValue,
+ @WebViewFeature.WebViewStartupFeature @NonNull String publicFeatureValue,
@NonNull Collection<StartupApiFeature> internalFeatures, @NonNull Context context) {
Set<StartupApiFeature> matchingFeatures = new HashSet<>();
for (StartupApiFeature feature : internalFeatures) {
@@ -738,8 +738,7 @@
* Utility method for throwing an exception explaining that the feature the app trying to use
* isn't supported.
*/
- @NonNull
- public static UnsupportedOperationException getUnsupportedOperationException() {
+ public static @NonNull UnsupportedOperationException getUnsupportedOperationException() {
return new UnsupportedOperationException("This method is not supported by the current "
+ "version of the framework and the current WebView APK");
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewGlueCommunicator.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewGlueCommunicator.java
index bb08259..6c9a2b0 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewGlueCommunicator.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewGlueCommunicator.java
@@ -19,10 +19,9 @@
import android.os.Build;
import android.webkit.WebView;
-import androidx.annotation.NonNull;
-
import org.chromium.support_lib_boundary.WebViewProviderFactoryBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
+import org.jspecify.annotations.NonNull;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
@@ -40,13 +39,11 @@
/**
* Fetch the one global support library WebViewProviderFactory from the WebView glue layer.
*/
- @NonNull
- public static WebViewProviderFactory getFactory() {
+ public static @NonNull WebViewProviderFactory getFactory() {
return LAZY_FACTORY_HOLDER.INSTANCE;
}
- @NonNull
- public static WebkitToCompatConverter getCompatConverter() {
+ public static @NonNull WebkitToCompatConverter getCompatConverter() {
return LAZY_COMPAT_CONVERTER_HOLDER.INSTANCE;
}
@@ -70,8 +67,7 @@
}
@SuppressWarnings("WeakerAccess") /* synthetic access */
- @NonNull
- static WebViewProviderFactory createGlueProviderFactory() {
+ static @NonNull WebViewProviderFactory createGlueProviderFactory() {
InvocationHandler invocationHandler;
try {
invocationHandler = fetchGlueProviderFactoryImpl();
@@ -92,8 +88,7 @@
/**
* Load the WebView code from the WebView APK and return the classloader containing that code.
*/
- @NonNull
- public static ClassLoader getWebViewClassLoader() {
+ public static @NonNull ClassLoader getWebViewClassLoader() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
return ApiHelperForP.getWebViewClassLoader();
} else {
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderAdapter.java
index 74666b1..f1b08cd 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderAdapter.java
@@ -22,8 +22,6 @@
import android.webkit.WebView;
import android.webkit.WebViewClient;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.webkit.Profile;
import androidx.webkit.WebMessageCompat;
import androidx.webkit.WebMessagePortCompat;
@@ -34,6 +32,8 @@
import org.chromium.support_lib_boundary.ProfileBoundaryInterface;
import org.chromium.support_lib_boundary.WebViewProviderBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.lang.reflect.InvocationHandler;
import java.util.concurrent.Executor;
@@ -55,7 +55,7 @@
* Adapter method WebViewCompat.insertVisualStateCallback().
*/
public void insertVisualStateCallback(
- long requestId, @NonNull WebViewCompat.VisualStateCallback callback) {
+ long requestId, WebViewCompat.@NonNull VisualStateCallback callback) {
mImpl.insertVisualStateCallback(requestId,
BoundaryInterfaceReflectionUtil.createInvocationHandlerFor(
new VisualStateCallbackAdapter(callback)));
@@ -64,8 +64,7 @@
/**
* Adapter method for {@link WebViewCompat#createWebMessageChannel(WebView)}.
*/
- @NonNull
- public WebMessagePortCompat[] createWebMessageChannel() {
+ public WebMessagePortCompat @NonNull [] createWebMessageChannel() {
InvocationHandler[] invocationHandlers = mImpl.createWebMessageChannel();
WebMessagePortCompat[] messagePorts = new WebMessagePortCompat[invocationHandlers.length];
for (int n = 0; n < invocationHandlers.length; n++) {
@@ -88,8 +87,8 @@
* String, java.util.List, androidx.webkit.WebViewCompat.WebMessageListener)}.
*/
public void addWebMessageListener(@NonNull String jsObjectName,
- @NonNull String[] allowedOriginRules,
- @NonNull WebViewCompat.WebMessageListener listener) {
+ String @NonNull [] allowedOriginRules,
+ WebViewCompat.@NonNull WebMessageListener listener) {
mImpl.addWebMessageListener(jsObjectName, allowedOriginRules,
BoundaryInterfaceReflectionUtil.createInvocationHandlerFor(
new WebMessageListenerAdapter(listener)));
@@ -100,7 +99,7 @@
* String, Set)}
*/
public @NonNull ScriptHandlerImpl addDocumentStartJavaScript(
- @NonNull String script, @NonNull String[] allowedOriginRules) {
+ @NonNull String script, String @NonNull [] allowedOriginRules) {
return ScriptHandlerImpl.toScriptHandler(
mImpl.addDocumentStartJavaScript(script, allowedOriginRules));
}
@@ -115,32 +114,28 @@
/**
* Adapter method for {@link WebViewCompat#getWebViewClient()}.
*/
- @NonNull
- public WebViewClient getWebViewClient() {
+ public @NonNull WebViewClient getWebViewClient() {
return mImpl.getWebViewClient();
}
/**
* Adapter method for {@link WebViewCompat#getWebChromeClient()}.
*/
- @Nullable
- public WebChromeClient getWebChromeClient() {
+ public @Nullable WebChromeClient getWebChromeClient() {
return mImpl.getWebChromeClient();
}
/**
* Adapter method for {@link WebViewCompat#getWebViewRenderer()}.
*/
- @Nullable
- public WebViewRenderProcess getWebViewRenderProcess() {
+ public @Nullable WebViewRenderProcess getWebViewRenderProcess() {
return WebViewRenderProcessImpl.forInvocationHandler(mImpl.getWebViewRenderer());
}
/**
* Adapter method for {@link WebViewCompat#getWebViewRendererClient()}.
*/
- @Nullable
- public WebViewRenderProcessClient getWebViewRenderProcessClient() {
+ public @Nullable WebViewRenderProcessClient getWebViewRenderProcessClient() {
InvocationHandler handler = mImpl.getWebViewRendererClient();
if (handler == null) return null;
return ((WebViewRenderProcessClientAdapter)
@@ -173,8 +168,7 @@
/**
* Adapter method for {@link WebViewCompat#getProfile(WebView)}.
*/
- @NonNull
- public Profile getProfile() {
+ public @NonNull Profile getProfile() {
ProfileBoundaryInterface profile = BoundaryInterfaceReflectionUtil.castToSuppLibClass(
ProfileBoundaryInterface.class, mImpl.getProfile());
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderFactory.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderFactory.java
index a8ff33f..1404525 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderFactory.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderFactory.java
@@ -19,8 +19,6 @@
import android.webkit.TracingController;
import android.webkit.WebView;
-import androidx.annotation.NonNull;
-
import org.chromium.support_lib_boundary.DropDataContentProviderBoundaryInterface;
import org.chromium.support_lib_boundary.ProfileStoreBoundaryInterface;
import org.chromium.support_lib_boundary.ProxyControllerBoundaryInterface;
@@ -29,6 +27,7 @@
import org.chromium.support_lib_boundary.TracingControllerBoundaryInterface;
import org.chromium.support_lib_boundary.WebViewProviderBoundaryInterface;
import org.chromium.support_lib_boundary.WebkitToCompatConverterBoundaryInterface;
+import org.jspecify.annotations.NonNull;
/**
* Interface representing {@link android.webkit.WebViewFactoryProvider}.
@@ -42,58 +41,49 @@
/**
* Create a support library version of {@link android.webkit.WebViewProvider}.
*/
- @NonNull
- WebViewProviderBoundaryInterface createWebView(@NonNull WebView webview);
+ @NonNull WebViewProviderBoundaryInterface createWebView(@NonNull WebView webview);
/**
* Create the boundary interface for {@link WebkitToCompatConverter}
* which converts android.webkit classes into their corresponding support library classes.
*/
- @NonNull
- WebkitToCompatConverterBoundaryInterface getWebkitToCompatConverter();
+ @NonNull WebkitToCompatConverterBoundaryInterface getWebkitToCompatConverter();
/**
* Fetch the boundary interface representing
* {@link android.webkit.WebViewFactoryProvider#Statics}.
*/
- @NonNull
- StaticsBoundaryInterface getStatics();
+ @NonNull StaticsBoundaryInterface getStatics();
/**
* Fetch the features supported by the current WebView APK.
*/
- @NonNull
- String[] getWebViewFeatures();
+ String @NonNull [] getWebViewFeatures();
/**
* Fetch the boundary interface representing {@link android.webkit.ServiceWorkerController}.
*/
- @NonNull
- ServiceWorkerControllerBoundaryInterface getServiceWorkerController();
+ @NonNull ServiceWorkerControllerBoundaryInterface getServiceWorkerController();
/**
* Fetch the boundary interface representing {@link TracingController}.
*/
- @NonNull
- TracingControllerBoundaryInterface getTracingController();
+ @NonNull TracingControllerBoundaryInterface getTracingController();
/**
* Fetch the boundary interface representing {@link android.webkit.ProxyController}.
*/
- @NonNull
- ProxyControllerBoundaryInterface getProxyController();
+ @NonNull ProxyControllerBoundaryInterface getProxyController();
/**
* Fetch the boundary interface representing image drag drop implementation.
*/
- @NonNull
- DropDataContentProviderBoundaryInterface getDropDataProvider();
+ @NonNull DropDataContentProviderBoundaryInterface getDropDataProvider();
/**
* Fetch the boundary interface representing profile store for Multi-Profile.
*/
- @NonNull
- ProfileStoreBoundaryInterface getProfileStore();
+ @NonNull ProfileStoreBoundaryInterface getProfileStore();
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderFactoryAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderFactoryAdapter.java
index 0c62bf1..6d9a1e7 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderFactoryAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewProviderFactoryAdapter.java
@@ -18,8 +18,6 @@
import android.webkit.WebView;
-import androidx.annotation.NonNull;
-
import org.chromium.support_lib_boundary.DropDataContentProviderBoundaryInterface;
import org.chromium.support_lib_boundary.ProfileStoreBoundaryInterface;
import org.chromium.support_lib_boundary.ProxyControllerBoundaryInterface;
@@ -30,6 +28,7 @@
import org.chromium.support_lib_boundary.WebViewProviderFactoryBoundaryInterface;
import org.chromium.support_lib_boundary.WebkitToCompatConverterBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
+import org.jspecify.annotations.NonNull;
/**
* Adapter for WebViewProviderFactoryBoundaryInterface providing static WebView functionality
@@ -48,9 +47,8 @@
* {@link android.webkit.WebViewProvider} - the class used to implement
* {@link androidx.webkit.WebViewCompat}.
*/
- @NonNull
@Override
- public WebViewProviderBoundaryInterface createWebView(@NonNull WebView webview) {
+ public @NonNull WebViewProviderBoundaryInterface createWebView(@NonNull WebView webview) {
return BoundaryInterfaceReflectionUtil.castToSuppLibClass(
WebViewProviderBoundaryInterface.class, mImpl.createWebView(webview));
}
@@ -60,9 +58,8 @@
* {@link androidx.webkit.internal.WebkitToCompatConverter}, which converts android.webkit
* classes into their corresponding support library classes.
*/
- @NonNull
@Override
- public WebkitToCompatConverterBoundaryInterface getWebkitToCompatConverter() {
+ public @NonNull WebkitToCompatConverterBoundaryInterface getWebkitToCompatConverter() {
return BoundaryInterfaceReflectionUtil.castToSuppLibClass(
WebkitToCompatConverterBoundaryInterface.class, mImpl.getWebkitToCompatConverter());
}
@@ -71,9 +68,8 @@
* Adapter method for fetching the support library class representing
* {@link android.webkit.WebViewFactoryProvider#Statics}.
*/
- @NonNull
@Override
- public StaticsBoundaryInterface getStatics() {
+ public @NonNull StaticsBoundaryInterface getStatics() {
return BoundaryInterfaceReflectionUtil.castToSuppLibClass(
StaticsBoundaryInterface.class, mImpl.getStatics());
}
@@ -81,9 +77,8 @@
/**
* Adapter method for fetching the features supported by the current WebView APK.
*/
- @NonNull
@Override
- public String[] getWebViewFeatures() {
+ public String @NonNull [] getWebViewFeatures() {
return mImpl.getSupportedFeatures();
}
@@ -92,8 +87,7 @@
* {@link android.webkit.ServiceWorkerController}.
*/
@Override
- @NonNull
- public ServiceWorkerControllerBoundaryInterface getServiceWorkerController() {
+ public @NonNull ServiceWorkerControllerBoundaryInterface getServiceWorkerController() {
return BoundaryInterfaceReflectionUtil.castToSuppLibClass(
ServiceWorkerControllerBoundaryInterface.class, mImpl.getServiceWorkerController());
}
@@ -102,9 +96,8 @@
* Adapter method for fetching the support library class representing
* {@link android.webkit.TracingController}.
*/
- @NonNull
@Override
- public TracingControllerBoundaryInterface getTracingController() {
+ public @NonNull TracingControllerBoundaryInterface getTracingController() {
return BoundaryInterfaceReflectionUtil.castToSuppLibClass(
TracingControllerBoundaryInterface.class, mImpl.getTracingController());
}
@@ -113,9 +106,8 @@
* Adapter method for fetching the support library class representing
* {@link android.webkit.ProxyController}.
*/
- @NonNull
@Override
- public ProxyControllerBoundaryInterface getProxyController() {
+ public @NonNull ProxyControllerBoundaryInterface getProxyController() {
return BoundaryInterfaceReflectionUtil.castToSuppLibClass(
ProxyControllerBoundaryInterface.class, mImpl.getProxyController());
}
@@ -124,16 +116,14 @@
* Adapter method for fetching the support library class representing Drag drop
* Image implementation.
*/
- @NonNull
@Override
- public DropDataContentProviderBoundaryInterface getDropDataProvider() {
+ public @NonNull DropDataContentProviderBoundaryInterface getDropDataProvider() {
return BoundaryInterfaceReflectionUtil.castToSuppLibClass(
DropDataContentProviderBoundaryInterface.class, mImpl.getDropDataProvider());
}
- @NonNull
@Override
- public ProfileStoreBoundaryInterface getProfileStore() {
+ public @NonNull ProfileStoreBoundaryInterface getProfileStore() {
return BoundaryInterfaceReflectionUtil.castToSuppLibClass(
ProfileStoreBoundaryInterface.class, mImpl.getProfileStore());
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessClientAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessClientAdapter.java
index 556f527..9ecf6e3 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessClientAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessClientAdapter.java
@@ -19,13 +19,13 @@
import android.annotation.SuppressLint;
import android.webkit.WebView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.webkit.WebViewRenderProcess;
import androidx.webkit.WebViewRenderProcessClient;
import org.chromium.support_lib_boundary.WebViewRendererClientBoundaryInterface;
import org.chromium.support_lib_boundary.util.Features;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import java.lang.reflect.InvocationHandler;
import java.util.concurrent.Executor;
@@ -51,8 +51,7 @@
mWebViewRenderProcessClient = webViewRenderProcessClient;
}
- @Nullable
- public WebViewRenderProcessClient getWebViewRenderProcessClient() {
+ public @Nullable WebViewRenderProcessClient getWebViewRenderProcessClient() {
return mWebViewRenderProcessClient;
}
@@ -61,8 +60,7 @@
* subset of the Features declared in WebViewFeature.
*/
@Override
- @NonNull
- public final String[] getSupportedFeatures() {
+ public final String @NonNull [] getSupportedFeatures() {
return sSupportedFeatures;
}
@@ -72,8 +70,8 @@
*/
@Override
public final void onRendererUnresponsive(
- @NonNull final WebView view,
- @NonNull /* WebViewRenderer */ final InvocationHandler renderer) {
+ final @NonNull WebView view,
+ /* WebViewRenderer */ final @NonNull InvocationHandler renderer) {
final WebViewRenderProcess rendererObject =
WebViewRenderProcessImpl.forInvocationHandler(renderer);
final WebViewRenderProcessClient client = mWebViewRenderProcessClient;
@@ -90,8 +88,8 @@
*/
@Override
public final void onRendererResponsive(
- @NonNull final WebView view,
- @NonNull /* WebViewRenderer */ InvocationHandler renderer) {
+ final @NonNull WebView view,
+ /* WebViewRenderer */ @NonNull InvocationHandler renderer) {
final WebViewRenderProcess rendererObject =
WebViewRenderProcessImpl.forInvocationHandler(renderer);
final WebViewRenderProcessClient client = mWebViewRenderProcessClient;
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessClientFrameworkAdapter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessClientFrameworkAdapter.java
index d0e5b1c..1386dff 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessClientFrameworkAdapter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessClientFrameworkAdapter.java
@@ -18,11 +18,12 @@
import android.webkit.WebView;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.webkit.WebViewRenderProcessClient;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
+
/**
* Adapter class to pass a {@link android.webkit.WebViewRenderProcessClient} over to chromium.
*/
@@ -37,20 +38,19 @@
@Override
public void onRenderProcessUnresponsive(@NonNull WebView view,
- @Nullable final android.webkit.WebViewRenderProcess renderer) {
+ final android.webkit.@Nullable WebViewRenderProcess renderer) {
mWebViewRenderProcessClient.onRenderProcessUnresponsive(view,
WebViewRenderProcessImpl.forFrameworkObject(renderer));
}
@Override
public void onRenderProcessResponsive(@NonNull WebView view,
- @Nullable final android.webkit.WebViewRenderProcess renderer) {
+ final android.webkit.@Nullable WebViewRenderProcess renderer) {
mWebViewRenderProcessClient.onRenderProcessResponsive(view,
WebViewRenderProcessImpl.forFrameworkObject(renderer));
}
- @Nullable
- public WebViewRenderProcessClient getFrameworkRenderProcessClient() {
+ public @Nullable WebViewRenderProcessClient getFrameworkRenderProcessClient() {
return mWebViewRenderProcessClient;
}
}
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessImpl.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessImpl.java
index c6ebe8f..c8a6f2b 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessImpl.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebViewRenderProcessImpl.java
@@ -16,11 +16,11 @@
package androidx.webkit.internal;
-import androidx.annotation.NonNull;
import androidx.webkit.WebViewRenderProcess;
import org.chromium.support_lib_boundary.WebViewRendererBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
+import org.jspecify.annotations.NonNull;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationHandler;
@@ -42,7 +42,7 @@
}
public WebViewRenderProcessImpl(
- @NonNull android.webkit.WebViewRenderProcess frameworkRenderer) {
+ android.webkit.@NonNull WebViewRenderProcess frameworkRenderer) {
mFrameworkObject = new WeakReference<>(frameworkRenderer);
}
@@ -67,7 +67,7 @@
* Get a support library WebViewRenderProcess object that is 1:1 with the framework object.
*/
public static @NonNull WebViewRenderProcessImpl forFrameworkObject(
- @NonNull android.webkit.WebViewRenderProcess frameworkRenderer) {
+ android.webkit.@NonNull WebViewRenderProcess frameworkRenderer) {
WebViewRenderProcessImpl renderer = sFrameworkMap.get(frameworkRenderer);
if (renderer != null) {
return renderer;
diff --git a/webkit/webkit/src/main/java/androidx/webkit/internal/WebkitToCompatConverter.java b/webkit/webkit/src/main/java/androidx/webkit/internal/WebkitToCompatConverter.java
index 2d7327d4..eec25de 100644
--- a/webkit/webkit/src/main/java/androidx/webkit/internal/WebkitToCompatConverter.java
+++ b/webkit/webkit/src/main/java/androidx/webkit/internal/WebkitToCompatConverter.java
@@ -24,7 +24,6 @@
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
-import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.webkit.SafeBrowsingResponseCompat;
import androidx.webkit.WebResourceErrorCompat;
@@ -35,6 +34,7 @@
import org.chromium.support_lib_boundary.WebViewCookieManagerBoundaryInterface;
import org.chromium.support_lib_boundary.WebkitToCompatConverterBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
+import org.jspecify.annotations.NonNull;
import java.lang.reflect.InvocationHandler;
@@ -54,8 +54,7 @@
* objects affect the other object. That WebSettingsAdapter can be used to implement
* {@link androidx.webkit.WebSettingsCompat}.
*/
- @NonNull
- public WebSettingsAdapter convertSettings(@NonNull WebSettings webSettings) {
+ public @NonNull WebSettingsAdapter convertSettings(@NonNull WebSettings webSettings) {
return new WebSettingsAdapter(BoundaryInterfaceReflectionUtil.castToSuppLibClass(
WebSettingsBoundaryInterface.class, mImpl.convertSettings(webSettings)));
}
@@ -64,8 +63,7 @@
* Return a {@link WebResourceRequestAdapter} linked to the given {@link WebResourceRequest} so
* that calls on either of those objects affect the other object.
*/
- @NonNull
- public WebResourceRequestAdapter convertWebResourceRequest(
+ public @NonNull WebResourceRequestAdapter convertWebResourceRequest(
@NonNull WebResourceRequest request) {
return new WebResourceRequestAdapter(BoundaryInterfaceReflectionUtil.castToSuppLibClass(
WebResourceRequestBoundaryInterface.class,
@@ -77,8 +75,7 @@
* {@link ServiceWorkerWebSettings} such that calls on either of those objects affect the other
* object.
*/
- @NonNull
- public InvocationHandler convertServiceWorkerSettings(
+ public @NonNull InvocationHandler convertServiceWorkerSettings(
@NonNull ServiceWorkerWebSettings settings) {
return mImpl.convertServiceWorkerSettings(settings);
}
@@ -89,9 +86,8 @@
* {@link ServiceWorkerWebSettings}.
*/
@RequiresApi(24)
- @NonNull
- public ServiceWorkerWebSettings convertServiceWorkerSettings(
- @NonNull /* SupportLibServiceWorkerSettings */ InvocationHandler
+ public @NonNull ServiceWorkerWebSettings convertServiceWorkerSettings(
+ /* SupportLibServiceWorkerSettings */ @NonNull InvocationHandler
serviceWorkerSettings) {
return (ServiceWorkerWebSettings) mImpl.convertServiceWorkerSettings(serviceWorkerSettings);
}
@@ -101,8 +97,8 @@
* {@link WebResourceError}such that calls on either of those objects affect the other
* object.
*/
- @NonNull
- public InvocationHandler convertWebResourceError(@NonNull WebResourceError webResourceError) {
+ public @NonNull InvocationHandler convertWebResourceError(
+ @NonNull WebResourceError webResourceError) {
return mImpl.convertWebResourceError(webResourceError);
}
@@ -112,9 +108,8 @@
* a {@link WebResourceError}.
*/
@RequiresApi(23)
- @NonNull
- public WebResourceError convertWebResourceError(
- @NonNull /* SupportLibWebResourceError */ InvocationHandler webResourceError) {
+ public @NonNull WebResourceError convertWebResourceError(
+ /* SupportLibWebResourceError */ @NonNull InvocationHandler webResourceError) {
return (WebResourceError) mImpl.convertWebResourceError(webResourceError);
}
@@ -123,8 +118,7 @@
* {@link SafeBrowsingResponse} such that calls on either of those objects affect the other
* object.
*/
- @NonNull
- public InvocationHandler convertSafeBrowsingResponse(
+ public @NonNull InvocationHandler convertSafeBrowsingResponse(
@NonNull SafeBrowsingResponse safeBrowsingResponse) {
return mImpl.convertSafeBrowsingResponse(safeBrowsingResponse);
}
@@ -135,9 +129,8 @@
* into a {@link SafeBrowsingResponse}.
*/
@RequiresApi(27)
- @NonNull
- public SafeBrowsingResponse convertSafeBrowsingResponse(
- @NonNull /* SupportLibSafeBrowsingResponse */ InvocationHandler safeBrowsingResponse) {
+ public @NonNull SafeBrowsingResponse convertSafeBrowsingResponse(
+ /* SupportLibSafeBrowsingResponse */ @NonNull InvocationHandler safeBrowsingResponse) {
return (SafeBrowsingResponse) mImpl.convertSafeBrowsingResponse(safeBrowsingResponse);
}
@@ -146,8 +139,8 @@
* {@link WebResourceError} such that calls on either of those objects affect the other
* object.
*/
- @NonNull
- public InvocationHandler convertWebMessagePort(@NonNull WebMessagePort webMessagePort) {
+ public @NonNull InvocationHandler convertWebMessagePort(
+ @NonNull WebMessagePort webMessagePort) {
return mImpl.convertWebMessagePort(webMessagePort);
}
@@ -157,9 +150,8 @@
* a {@link WebResourceError}.
*/
@RequiresApi(23)
- @NonNull
- public WebMessagePort convertWebMessagePort(
- @NonNull /* SupportLibWebMessagePort */ InvocationHandler webMessagePort) {
+ public @NonNull WebMessagePort convertWebMessagePort(
+ /* SupportLibWebMessagePort */ @NonNull InvocationHandler webMessagePort) {
return (WebMessagePort) mImpl.convertWebMessagePort(webMessagePort);
}
@@ -168,8 +160,8 @@
* objects affect the other object. That CookieManagerAdapter can be used to implement
* {@link androidx.webkit.CookieManagerCompat}.
*/
- @NonNull
- public CookieManagerAdapter convertCookieManager(@NonNull CookieManager cookieManager) {
+ public @NonNull CookieManagerAdapter convertCookieManager(
+ @NonNull CookieManager cookieManager) {
return new CookieManagerAdapter(BoundaryInterfaceReflectionUtil.castToSuppLibClass(
WebViewCookieManagerBoundaryInterface.class,
mImpl.convertCookieManager(cookieManager)));