Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove reference to internal class #393

Merged
merged 5 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ VisUI is licensed under Apache2 license meaning that you can use it for free in

[![Maven Central](https://img.shields.io/maven-central/v/com.kotcrab.vis/vis-ui.svg)](https://search.maven.org/artifact/com.kotcrab.vis/vis-ui)

Please refer to [libGDX documentation](https://libgdx.com/wiki/articles/dependency-management-with-gradle) if you don't know how to mange dependencies with Gradle. Alternatively JAR can be downloaded from [Maven repository](http://search.maven.org/#search|gav|1|g%3A%22com.kotcrab.vis%22%20AND%20a%3A%22vis-ui%22). If you are creating new project, you can use gdx-setup to automatically add VisUI for you. (press 'Show Third Party Extension' button)
Please refer to [libGDX documentation](https://libgdx.com/wiki/articles/dependency-management-with-gradle) if you don't know how to manage dependencies with Gradle. Alternatively JAR can be downloaded from [Maven repository](http://search.maven.org/#search|gav|1|g%3A%22com.kotcrab.vis%22%20AND%20a%3A%22vis-ui%22). If you are creating new project, you can use gdx-setup to automatically add VisUI for you. (press 'Show Third Party Extension' button)

#### Manual Gradle setup:

Expand Down
29 changes: 18 additions & 11 deletions ui/src/main/java/com/kotcrab/vis/ui/widget/file/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.kotcrab.vis.ui.widget.file;

import com.apple.eio.FileManager;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.Array;
Expand All @@ -25,6 +24,7 @@

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.text.DecimalFormat;
import java.util.Comparator;

Expand Down Expand Up @@ -164,19 +164,26 @@ public static void showDirInExplorer (FileHandle dir) throws IOException {
dirToShow = dir.parent().file();
}

if (OsUtils.isMac()) {
FileManager.revealInFinder(dirToShow);
} else {
try {
// Using reflection to avoid importing AWT desktop which would trigger Android Lint errors
// This is desktop only, rarely called, performance drop is negligible
// Basically 'Desktop.getDesktop().open(dirToShow);'
Class desktopClass = Class.forName("java.awt.Desktop");
Object desktop = desktopClass.getMethod("getDesktop").invoke(null);
try {
// Using reflection to avoid importing AWT desktop which would trigger Android Lint errors
// This is desktop only, rarely called, performance drop is negligible
// Basically 'Desktop.getDesktop().open(dirToShow);'
Class desktopClass = Class.forName("java.awt.Desktop");
Object desktop = desktopClass.getMethod("getDesktop").invoke(null);
// browseFileDirectory was introduced in JDK 9
desktopClass.getMethod("browseFileDirectory", File.class).invoke(desktop, dirToShow);
} catch (NoSuchMethodException | InvocationTargetException e) {
// browseFileDirectory throws UnsupportedOperationException on some platforms, which is then
// wrapped in InvocationTargetException because it's accessed via reflection.
// throw again all other exceptions we didn't expect
if (e instanceof InvocationTargetException && !(e.getCause() instanceof UnsupportedOperationException)) {
throw e;
}
desktopClass.getMethod("open", File.class).invoke(desktop, dirToShow);
} catch (Exception e) {
Gdx.app.log("VisUI", "Can't open file " + dirToShow.getPath(), e);
}
} catch (Exception e) {
Gdx.app.log("VisUI", "Can't open file " + dirToShow.getPath(), e);
}
}
}
Loading