Skip to content

Commit

Permalink
[M3][Color] Internal Color changes.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 495968907
  • Loading branch information
Material Design Team authored and imhappi committed Dec 19, 2022
1 parent 93f8ffb commit e7e9747
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,25 @@

package com.google.android.material.color;

import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP;

import android.content.Context;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.core.os.BuildCompat;
import java.util.Map;

/**
* The interface class that hides the detailed implementation of color resources override at
* runtime. (e.g. with Resources Loader implementation pre-U.)
*
* @hide
*/
interface ColorResourcesOverride {
@RestrictTo(LIBRARY_GROUP)
public interface ColorResourcesOverride {
/**
* Overrides the color resources to the given context, returns {@code true} if new color values
* have been applied.
Expand All @@ -37,7 +44,8 @@ interface ColorResourcesOverride {
* color value.
*/
// TODO(b/255834202): Using SparseIntArray here to store the mapping to save memory.
boolean applyIfPossible(Context context, Map<Integer, Integer> colorResourceIdsToColorValues);
boolean applyIfPossible(
@NonNull Context context, @NonNull Map<Integer, Integer> colorResourceIdsToColorValues);

@Nullable
static ColorResourcesOverride getInstance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,24 @@

import com.google.android.material.R;

import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP;

import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import com.google.android.material.color.utilities.DynamicColor;
import com.google.android.material.color.utilities.DynamicScheme;
import com.google.android.material.color.utilities.MaterialDynamicColors;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/** Helper methods for communication with the Material Color Utilities library. */
final class MaterialColorUtilitiesHelper {
/**
* Helper methods for communication with the Material Color Utilities library.
*
* @hide
*/
@RestrictTo(LIBRARY_GROUP)
public final class MaterialColorUtilitiesHelper {

private MaterialColorUtilitiesHelper() {}

Expand Down Expand Up @@ -129,7 +137,7 @@ private MaterialColorUtilitiesHelper() {}
}

@NonNull
static Map<Integer, Integer> createColorResourcesIdsToColorValues(
public static Map<Integer, Integer> createColorResourcesIdsToColorValues(
@NonNull DynamicScheme colorScheme) {
HashMap<Integer, Integer> map = new HashMap<>();
for (Map.Entry<Integer, DynamicColor> entry : colorResourceIdToColorValue.entrySet()) {
Expand Down

0 comments on commit e7e9747

Please sign in to comment.