/*
* Calendula - An assistant for personal medication management.
* Copyright (C) 2016 CITIUS - USC
*
* Calendula 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 software. If not, see <http://www.gnu.org/licenses/>.
*/
package es.usc.citius.servando.calendula.util;
import android.content.Context;
import android.graphics.Typeface;
import com.mikepenz.iconics.typeface.IIcon;
import com.mikepenz.iconics.typeface.ITypeface;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
/**
* Created by mikepenz on 01.11.14.
*/
public class PresentationsTypeface implements ITypeface {
private static final String TTF_FILE = "presentation_icons.ttf";
private static Typeface typeface = null;
private static HashMap<String, Character> mChars;
@Override
public IIcon getIcon(String key) {
return Icon.valueOf(key);
}
@Override
public HashMap<String, Character> getCharacters() {
if (mChars == null) {
HashMap<String, Character> aChars = new HashMap<String, Character>();
for (Icon v : Icon.values()) {
aChars.put(v.name(), v.character);
}
mChars = aChars;
}
return mChars;
}
@Override
public String getMappingPrefix() {
return "faw";
}
@Override
public String getFontName() {
return "FontAwesome";
}
@Override
public String getVersion() {
return "4.4.0";
}
@Override
public int getIconCount() {
return mChars.size();
}
@Override
public Collection<String> getIcons() {
Collection<String> icons = new LinkedList<>();
for (Icon value : Icon.values()) {
icons.add(value.name());
}
return icons;
}
@Override
public String getAuthor() {
return "Ángel Piñeiro";
}
@Override
public String getUrl() {
return "";
}
@Override
public String getDescription() {
return "";
}
@Override
public String getLicense() {
return "";
}
@Override
public String getLicenseUrl() {
return "";
}
@Override
public Typeface getTypeface(Context context) {
if (typeface == null) {
try {
typeface = Typeface.createFromAsset(context.getAssets(), "fonts/" + TTF_FILE);
} catch (Exception e) {
return null;
}
}
return typeface;
}
public enum Icon implements IIcon {
ic_cream('\ue900'),
ic_drops('\ue901'),
ic_effervescent('\ue902'),
ic_inhaler('\ue903'),
ic_injection('\ue904'),
ic_capsule('\ue905'),
ic_pill('\ue906'),
ic_spray('\ue907'),
ic_syrup('\ue908'),
ic_patch('\ue909');
char character;
Icon(char character) {
this.character = character;
}
public String getFormattedName() {
return "{" + name() + "}";
}
public char getCharacter() {
return character;
}
public String getName() {
return name();
}
// remember the typeface so we can use it later
private static ITypeface typeface;
public ITypeface getTypeface() {
if (typeface == null) {
typeface = new PresentationsTypeface();
}
return typeface;
}
}
}