WIP Porting category color code from Nextcloud Maps js code
This commit is contained in:
@ -10,8 +10,8 @@
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"versionCode": 2,
|
||||
"versionName": "0.2",
|
||||
"versionCode": 3,
|
||||
"versionName": "0.3.1",
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
]
|
||||
|
@ -0,0 +1,22 @@
|
||||
package it.danieleverducci.nextcloudmaps.utils;
|
||||
|
||||
public class Color {
|
||||
|
||||
/**
|
||||
* Based on Nextcloud Maps's getLetterColor util
|
||||
* @see "https://github.com/nextcloud/maps/blob/master/src/utils.js"
|
||||
* @param catName category name
|
||||
*/
|
||||
public static generareCategoryColor(String catName) {
|
||||
// If category is default, return default color
|
||||
|
||||
// Else
|
||||
int letter1Index = letter1.toLowerCase().charCodeAt(0);
|
||||
int letter2Index = letter2.toLowerCase().charCodeAt(0);
|
||||
var letterCoef = ((letter1Index * letter2Index) % 100) / 100;
|
||||
var h = letterCoef * 360;
|
||||
var s = 75 + letterCoef * 10;
|
||||
var l = 50 + letterCoef * 10;
|
||||
return {h: Math.round(h), s: Math.round(s), l: Math.round(l)};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user