summaryrefslogtreecommitdiffstats
path: root/mobile/android/base/java/org/mozilla/gecko/util/ColorUtil.java
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2019-04-23 15:32:23 -0400
committerMatt A. Tobin <email@mattatobin.com>2019-04-23 15:32:23 -0400
commitabe80cc31d5a40ebed743085011fbcda0c1a9a10 (patch)
treefb3762f06b84745b182af281abb107b95a9fcf01 /mobile/android/base/java/org/mozilla/gecko/util/ColorUtil.java
parent63295d0087eb58a6eb34cad324c4c53d1b220491 (diff)
downloadUXP-abe80cc31d5a40ebed743085011fbcda0c1a9a10.tar
UXP-abe80cc31d5a40ebed743085011fbcda0c1a9a10.tar.gz
UXP-abe80cc31d5a40ebed743085011fbcda0c1a9a10.tar.lz
UXP-abe80cc31d5a40ebed743085011fbcda0c1a9a10.tar.xz
UXP-abe80cc31d5a40ebed743085011fbcda0c1a9a10.zip
Issue #1053 - Drop support Android and remove Fennec - Part 1a: Remove mobile/android
Diffstat (limited to 'mobile/android/base/java/org/mozilla/gecko/util/ColorUtil.java')
-rw-r--r--mobile/android/base/java/org/mozilla/gecko/util/ColorUtil.java44
1 files changed, 0 insertions, 44 deletions
diff --git a/mobile/android/base/java/org/mozilla/gecko/util/ColorUtil.java b/mobile/android/base/java/org/mozilla/gecko/util/ColorUtil.java
deleted file mode 100644
index ec227d1ce..000000000
--- a/mobile/android/base/java/org/mozilla/gecko/util/ColorUtil.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-package org.mozilla.gecko.util;
-
-import android.graphics.Color;
-
-public class ColorUtil {
- public static int darken(final int color, final double fraction) {
- int red = Color.red(color);
- int green = Color.green(color);
- int blue = Color.blue(color);
- red = darkenColor(red, fraction);
- green = darkenColor(green, fraction);
- blue = darkenColor(blue, fraction);
- final int alpha = Color.alpha(color);
- return Color.argb(alpha, red, green, blue);
- }
-
- public static int getReadableTextColor(final int backgroundColor) {
- final int greyValue = grayscaleFromRGB(backgroundColor);
- // 186 chosen rather than the seemingly obvious 128 because of gamma.
- if (greyValue < 186) {
- return Color.WHITE;
- } else {
- return Color.BLACK;
- }
- }
-
- private static int darkenColor(final int color, final double fraction) {
- return (int) Math.max(color - (color * fraction), 0);
- }
-
- private static int grayscaleFromRGB(final int color) {
- final int red = Color.red(color);
- final int green = Color.green(color);
- final int blue = Color.blue(color);
- // Magic weighting taken from a stackoverflow post, supposedly related to how
- // humans perceive color.
- return (int) (0.299 * red + 0.587 * green + 0.114 * blue);
- }
-}