All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.upplication.cordova.config.IconConfig Maven / Gradle / Ivy

There is a newer version: 9.0.0
Show newest version
package com.upplication.cordova.config;

import com.upplication.cordova.Icon;
import com.upplication.cordova.Platform;
import com.upplication.cordova.util.ConfigProcessor;
import com.upplication.cordova.util.IConfigProcessor;
import org.w3c.dom.Element;

import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;

/**
 * icon
 * cordova.config().icon().add("src/img/icon.png");
 * cordova.config().icon().add(Icon.create().src("src/img").height(100).width(100).density("zsdad"));
 * platform icon
 * cordova.config().platform("android").icon().add("src/img/android/icon.png")
 * cordova.config().platform("android").icon().add(Icon.create().src("src/img").density("ldpi"));
 */
public class IconConfig {

    private Platform platform;
    private IConfigProcessor configProcessor;

    public IconConfig(IConfigProcessor configProcessor, Platform platform) {
        this.platform = platform;
        this.configProcessor = configProcessor;
    }

    public void add(String src) throws IOException {
        add(Icon.create().src(src));
    }

    public void add(Icon icon) throws IOException {
        configProcessor.addIcon(getPlatform(), icon.getSrc(), icon.getWidth(), icon.getHeight(), icon.getDensity());
    }

    public List getAll() throws IOException {
        return configProcessor.getIcons(getPlatform());
    }

    private String getPlatform() {
        if (platform != null) {
            return platform.name().toLowerCase();
        } else {
            return null;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy