Put material color utilities in a separate Gradle module

This avoids polluting our main sourceset and makes it easier to substitute for a proper Gradle dependency in the future

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey 2022-08-10 16:54:57 +02:00 committed by Andy Scherzinger
parent 5b983d0ce4
commit 5636d4354b
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
28 changed files with 81 additions and 43 deletions

View File

@ -335,6 +335,7 @@ dependencies {
gplayImplementation "com.google.firebase:firebase-messaging:23.0.7"
// implementation 'androidx.activity:activity-ktx:1.4.0'
implementation project(':material-color-utilities')
}
task installGitHooks(type: Copy, group: "development") {

View File

@ -22,7 +22,7 @@
package com.nextcloud.talk.ui.theme
import androidx.annotation.ColorInt
import scheme.Scheme
import com.material_foundation.material_color_utilities.scheme.Scheme
interface ServerTheme {
@get:ColorInt

View File

@ -26,7 +26,7 @@ package com.nextcloud.talk.ui.theme
import com.nextcloud.talk.R
import com.nextcloud.talk.models.json.capabilities.ThemingCapability
import com.nextcloud.talk.utils.ui.ColorUtil
import scheme.Scheme
import com.material_foundation.material_color_utilities.scheme.Scheme
internal class ServerThemeImpl(themingCapability: ThemingCapability?, colorUtil: ColorUtil) :
ServerTheme {

View File

@ -76,7 +76,7 @@ import com.nextcloud.talk.utils.ui.PlatformThemeUtil.isDarkMode
import com.vanniktech.emoji.EmojiTextView
import com.yarolegovich.mp.MaterialPreferenceCategory
import com.yarolegovich.mp.MaterialSwitchPreference
import scheme.Scheme
import com.material_foundation.material_color_utilities.scheme.Scheme
import javax.inject.Inject
import kotlin.math.roundToInt

1
material-color-utilities/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build

View File

@ -0,0 +1,2 @@
Imported from https://github.com/material-foundation/material-color-utilities with license APACHE-2.0,to be substituted
with a Gradle dependency when they publish it.

View File

@ -0,0 +1,33 @@
/*
* Nextcloud Talk application
*
* @author Álvaro Brey
* Copyright (C) 2022 Álvaro Brey
* Copyright (C) 2022 Nextcloud GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
plugins {
id 'java-library'
}
java {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
dependencies {
implementation 'com.google.errorprone:error_prone_annotations:2.9.0'
}

View File

@ -16,12 +16,12 @@
// This file is automatically generated. Do not modify it.
package blend;
package com.material_foundation.material_color_utilities.blend;
import hct.Cam16;
import hct.Hct;
import utils.ColorUtils;
import utils.MathUtils;
import com.material_foundation.material_color_utilities.hct.Cam16;
import com.material_foundation.material_color_utilities.hct.Hct;
import com.material_foundation.material_color_utilities.utils.ColorUtils;
import com.material_foundation.material_color_utilities.utils.MathUtils;
/** Functions for blending in HCT and CAM16. */
public class Blend {

View File

@ -14,11 +14,11 @@
* limitations under the License.
*/
package hct;
package com.material_foundation.material_color_utilities.hct;
import static java.lang.Math.max;
import utils.ColorUtils;
import com.material_foundation.material_color_utilities.utils.ColorUtils;
/**
* CAM16, a color appearance model. Colors are not just defined by their hex code, but rather, a hex

View File

@ -14,9 +14,9 @@
* limitations under the License.
*/
package hct;
package com.material_foundation.material_color_utilities.hct;
import utils.ColorUtils;
import com.material_foundation.material_color_utilities.utils.ColorUtils;
/**
* A color system built using CAM16 hue and chroma, and L* from L*a*b*.

View File

@ -16,10 +16,10 @@
// This file is automatically generated. Do not modify it.
package hct;
package com.material_foundation.material_color_utilities.hct;
import utils.ColorUtils;
import utils.MathUtils;
import com.material_foundation.material_color_utilities.utils.ColorUtils;
import com.material_foundation.material_color_utilities.utils.MathUtils;
/** A class that solves the HCT equation. */
public class HctSolver {

View File

@ -14,10 +14,10 @@
* limitations under the License.
*/
package hct;
package com.material_foundation.material_color_utilities.hct;
import utils.ColorUtils;
import utils.MathUtils;
import com.material_foundation.material_color_utilities.utils.ColorUtils;
import com.material_foundation.material_color_utilities.utils.MathUtils;
/**
* In traditional color spaces, a color can be identified solely by the observer's measurement of

View File

@ -14,15 +14,15 @@
* limitations under the License.
*/
package palettes;
package com.material_foundation.material_color_utilities.palettes;
import static java.lang.Math.max;
import static java.lang.Math.min;
import hct.Hct;
import com.material_foundation.material_color_utilities.hct.Hct;
/**
* An intermediate concept between the key color for a UI theme, and a full color scheme. 5 sets of
* An intermediate concept between the key color for a UI theme, and a full color com.material_foundation.material_color_utilities.scheme. 5 sets of
* tones are generated, all except one use the same hue as the key color, and all vary in chroma.
*/
public final class CorePalette {

View File

@ -14,9 +14,9 @@
* limitations under the License.
*/
package palettes;
package com.material_foundation.material_color_utilities.palettes;
import hct.Hct;
import com.material_foundation.material_color_utilities.hct.Hct;
import java.util.HashMap;
import java.util.Map;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package quantize;
package com.material_foundation.material_color_utilities.quantize;
/** An interface to allow use of different color spaces by quantizers. */
public interface PointProvider {

View File

@ -14,9 +14,9 @@
* limitations under the License.
*/
package quantize;
package com.material_foundation.material_color_utilities.quantize;
import utils.ColorUtils;
import com.material_foundation.material_color_utilities.utils.ColorUtils;
/**
* Provides conversions needed for K-Means quantization. Converting input to points, and converting

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package quantize;
package com.material_foundation.material_color_utilities.quantize;
interface Quantizer {
public QuantizerResult quantize(int[] pixels, int maxColors);

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package quantize;
package com.material_foundation.material_color_utilities.quantize;
import java.util.Map;
import java.util.Set;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package quantize;
package com.material_foundation.material_color_utilities.quantize;
import java.util.HashMap;
import java.util.Map;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package quantize;
package com.material_foundation.material_color_utilities.quantize;
import java.util.Map;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package quantize;
package com.material_foundation.material_color_utilities.quantize;
import static java.lang.Math.min;

View File

@ -14,9 +14,9 @@
* limitations under the License.
*/
package quantize;
package com.material_foundation.material_color_utilities.quantize;
import utils.ColorUtils;
import com.material_foundation.material_color_utilities.utils.ColorUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

View File

@ -16,13 +16,13 @@
// This file is automatically generated. Do not modify it.
package scheme;
package com.material_foundation.material_color_utilities.scheme;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.CheckReturnValue;
import palettes.CorePalette;
import com.material_foundation.material_color_utilities.palettes.CorePalette;
/** Represents a Material color scheme, a mapping of color roles to colors. */
/** Represents a Material color com.material_foundation.material_color_utilities.scheme, a mapping of color roles to colors. */
@CheckReturnValue
public class Scheme {
private int primary;

View File

@ -14,11 +14,11 @@
* limitations under the License.
*/
package score;
package com.material_foundation.material_color_utilities.score;
import hct.Cam16;
import utils.ColorUtils;
import utils.MathUtils;
import com.material_foundation.material_color_utilities.hct.Cam16;
import com.material_foundation.material_color_utilities.utils.ColorUtils;
import com.material_foundation.material_color_utilities.utils.MathUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

View File

@ -16,7 +16,7 @@
// This file is automatically generated. Do not modify it.
package utils;
package com.material_foundation.material_color_utilities.utils;
/**
* Color science utilities.

View File

@ -16,7 +16,7 @@
// This file is automatically generated. Do not modify it.
package utils;
package com.material_foundation.material_color_utilities.utils;
/** Utility methods for mathematical operations. */
public class MathUtils {

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package utils;
package com.material_foundation.material_color_utilities.utils;
/** Utility methods for string representations of colors. */
final class StringUtils {

View File

@ -19,3 +19,4 @@
*/
include ':app'
include ':material-color-utilities'