mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
IJPL-326 make beforeApplicationLoaded as suspend
GitOrigin-RevId: f574119a3a1cc377aa1dbe53b14624de75e3f148
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e419afb90a
commit
6bd52f2137
@@ -8,6 +8,6 @@
|
||||
]]></description>
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<fileType name="Image" extensions="webp"/>
|
||||
<ApplicationLoadListener implementation="com.android.tools.adtui.webp.WebpMetadata$WebpMetadataRegistrar"/>
|
||||
<ApplicationLoadListener implementation="com.android.tools.adtui.webp.WebpMetadataRegistrar"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
@@ -50,9 +50,9 @@ public final class WebpImageReaderSpi extends ImageReaderSpi {
|
||||
WebpImageReaderSpi() {
|
||||
vendorName = WebpMetadata.WEBP_VENDOR;
|
||||
version = WebpNativeLibHelper.getDecoderVersion();
|
||||
suffixes = WebpMetadata.WEBP_SUFFIXES;
|
||||
names = WebpMetadata.WEBP_FORMAT_NAMES;
|
||||
MIMETypes = WebpMetadata.WEBP_MIME_TYPES;
|
||||
suffixes = WebpMetadata.Companion.getWEBP_SUFFIXES();
|
||||
names = WebpMetadata.Companion.getWEBP_FORMAT_NAMES();
|
||||
MIMETypes = WebpMetadata.Companion.getWEBP_MIME_TYPES();
|
||||
pluginClassName = WebpReader.class.getName();
|
||||
inputTypes = new Class<?>[]{ImageInputStream.class};
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.android.tools.adtui.webp;
|
||||
|
||||
|
||||
import com.google.webp.libwebp;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -38,9 +37,9 @@ public final class WebpImageWriterSpi extends ImageWriterSpi {
|
||||
WebpImageWriterSpi() {
|
||||
vendorName = WebpMetadata.WEBP_VENDOR;
|
||||
version = WebpNativeLibHelper.getEncoderVersion();
|
||||
suffixes = WebpMetadata.WEBP_SUFFIXES;
|
||||
names = WebpMetadata.WEBP_FORMAT_NAMES;
|
||||
MIMETypes = WebpMetadata.WEBP_MIME_TYPES;
|
||||
suffixes = WebpMetadata.Companion.getWEBP_SUFFIXES();
|
||||
names = WebpMetadata.Companion.getWEBP_FORMAT_NAMES();
|
||||
MIMETypes = WebpMetadata.Companion.getWEBP_MIME_TYPES();
|
||||
pluginClassName = WebpWriter.class.getName();
|
||||
outputTypes = new Class<?>[]{ImageOutputStream.class};
|
||||
}
|
||||
|
||||
@@ -13,65 +13,57 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.tools.adtui.webp;
|
||||
package com.android.tools.adtui.webp
|
||||
|
||||
import com.intellij.ide.ApplicationLoadListener;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.w3c.dom.Node;
|
||||
import com.intellij.ide.ApplicationLoadListener
|
||||
import com.intellij.openapi.application.Application
|
||||
import org.w3c.dom.Node
|
||||
import java.nio.file.Path
|
||||
import javax.imageio.metadata.IIOMetadata
|
||||
import javax.imageio.metadata.IIOMetadataNode
|
||||
import javax.imageio.spi.IIORegistry
|
||||
import javax.imageio.spi.ImageReaderSpi
|
||||
import javax.imageio.spi.ImageWriterSpi
|
||||
|
||||
import javax.imageio.metadata.IIOMetadata;
|
||||
import javax.imageio.metadata.IIOMetadataNode;
|
||||
import javax.imageio.spi.IIORegistry;
|
||||
import javax.imageio.spi.ImageReaderSpi;
|
||||
import javax.imageio.spi.ImageWriterSpi;
|
||||
import java.nio.file.Path;
|
||||
class WebpMetadata : IIOMetadata() {
|
||||
companion object {
|
||||
const val WEBP_FORMAT_LOWER_CASE: String = "webp"
|
||||
private const val WEBP_FORMAT_UPPER_CASE: String = "WEBP"
|
||||
val WEBP_FORMAT_NAMES: Array<String> = arrayOf(WEBP_FORMAT_UPPER_CASE, WEBP_FORMAT_LOWER_CASE)
|
||||
private const val EXT_WEBP: String = WEBP_FORMAT_LOWER_CASE
|
||||
|
||||
public final class WebpMetadata extends IIOMetadata {
|
||||
public static final String WEBP_FORMAT_LOWER_CASE = "webp";
|
||||
public static final String WEBP_FORMAT_UPPER_CASE = "WEBP";
|
||||
public static final String[] WEBP_FORMAT_NAMES = new String[] {WEBP_FORMAT_UPPER_CASE, WEBP_FORMAT_LOWER_CASE};
|
||||
public static final String EXT_WEBP = WEBP_FORMAT_LOWER_CASE;
|
||||
public static final String[] WEBP_SUFFIXES = new String[] { EXT_WEBP};
|
||||
public static final String[] WEBP_MIME_TYPES = new String[] {"image/webp"};
|
||||
public static final String WEBP_VENDOR = "Google LLC";
|
||||
public static final float DEFAULT_ENCODING_QUALITY = 0.75f;
|
||||
public static final boolean DEFAULT_LOSSLESS = true;
|
||||
val WEBP_SUFFIXES: Array<String> = arrayOf(EXT_WEBP)
|
||||
val WEBP_MIME_TYPES: Array<String> = arrayOf("image/webp")
|
||||
|
||||
static final class WebpMetadataRegistrar implements ApplicationLoadListener {
|
||||
private WebpMetadataRegistrar() {
|
||||
}
|
||||
const val WEBP_VENDOR: String = "Google LLC"
|
||||
const val DEFAULT_ENCODING_QUALITY: Float = 0.75f
|
||||
const val DEFAULT_LOSSLESS: Boolean = true
|
||||
|
||||
@Override
|
||||
public void beforeApplicationLoaded(@NotNull Application application, @NotNull Path configPath) {
|
||||
ensureWebpRegistered();
|
||||
/**
|
||||
* Ensures that service providers are registered.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun ensureWebpRegistered() {
|
||||
val defaultInstance = IIORegistry.getDefaultInstance()
|
||||
defaultInstance.registerServiceProvider(WebpImageReaderSpi(), ImageReaderSpi::class.java)
|
||||
defaultInstance.registerServiceProvider(WebpImageWriterSpi(), ImageWriterSpi::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that service providers are registered.
|
||||
*/
|
||||
public static void ensureWebpRegistered() {
|
||||
IIORegistry defaultInstance = IIORegistry.getDefaultInstance();
|
||||
defaultInstance.registerServiceProvider(new WebpImageReaderSpi(), ImageReaderSpi.class);
|
||||
defaultInstance.registerServiceProvider(new WebpImageWriterSpi(), ImageWriterSpi.class);
|
||||
override fun isReadOnly(): Boolean = false
|
||||
|
||||
override fun getAsTree(formatName: String): Node = IIOMetadataNode(nativeMetadataFormatName)
|
||||
|
||||
override fun mergeTree(formatName: String, root: Node) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node getAsTree(String formatName) {
|
||||
return new IIOMetadataNode(nativeMetadataFormatName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mergeTree(String formatName, Node root) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
override fun reset() {
|
||||
}
|
||||
}
|
||||
|
||||
private class WebpMetadataRegistrar : ApplicationLoadListener {
|
||||
override suspend fun beforeApplicationLoaded(application: Application, configPath: Path) {
|
||||
WebpMetadata.ensureWebpRegistered()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user