mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
Added better Emoticon handling.
git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@8103 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
@ -26,7 +26,6 @@ import javax.swing.ImageIcon;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.FilenameFilter;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
@ -92,9 +91,6 @@ public class EmoticonManager {
|
|||||||
// Copy over to allow for non-admins to extract.
|
// Copy over to allow for non-admins to extract.
|
||||||
copyFiles();
|
copyFiles();
|
||||||
|
|
||||||
|
|
||||||
expandNewPacks();
|
|
||||||
|
|
||||||
final LocalPreferences pref = SettingsManager.getLocalPreferences();
|
final LocalPreferences pref = SettingsManager.getLocalPreferences();
|
||||||
String emoticonPack = pref.getEmoticonPack();
|
String emoticonPack = pref.getEmoticonPack();
|
||||||
|
|
||||||
@ -119,10 +115,15 @@ public class EmoticonManager {
|
|||||||
try {
|
try {
|
||||||
// Copy over
|
// Copy over
|
||||||
File newFile = new File(newEmoticonDir, file.getName());
|
File newFile = new File(newEmoticonDir, file.getName());
|
||||||
String name = URLFileSystem.getName(newFile.toURL());
|
|
||||||
File directory = new File(newEmoticonDir, name);
|
// Check timestamps
|
||||||
if (!directory.exists()) {
|
long installerFile = file.lastModified();
|
||||||
|
long copiedFile = newFile.lastModified();
|
||||||
|
|
||||||
|
if (installerFile > copiedFile) {
|
||||||
|
// Copy over and expand :)
|
||||||
URLFileSystem.copy(file.toURL(), newFile);
|
URLFileSystem.copy(file.toURL(), newFile);
|
||||||
|
expandNewPack(newFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
@ -387,28 +388,7 @@ public class EmoticonManager {
|
|||||||
/**
|
/**
|
||||||
* Expands any zipped Emoticon Packs.
|
* Expands any zipped Emoticon Packs.
|
||||||
*/
|
*/
|
||||||
private void expandNewPacks() {
|
private void expandNewPack(File file) {
|
||||||
File[] jars = EMOTICON_DIRECTORY.listFiles(new FilenameFilter() {
|
|
||||||
public boolean accept(File dir, String name) {
|
|
||||||
boolean accept = false;
|
|
||||||
String smallName = name.toLowerCase();
|
|
||||||
if (smallName.endsWith(".zip")) {
|
|
||||||
accept = true;
|
|
||||||
}
|
|
||||||
return accept;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Do nothing if no jar or zip files were found
|
|
||||||
if (jars == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < jars.length; i++) {
|
|
||||||
if (jars[i].isFile()) {
|
|
||||||
File file = jars[i];
|
|
||||||
|
|
||||||
URL url = null;
|
URL url = null;
|
||||||
try {
|
try {
|
||||||
url = file.toURL();
|
url = file.toURL();
|
||||||
@ -418,18 +398,9 @@ public class EmoticonManager {
|
|||||||
}
|
}
|
||||||
String name = URLFileSystem.getName(url);
|
String name = URLFileSystem.getName(url);
|
||||||
File directory = new File(EMOTICON_DIRECTORY, name);
|
File directory = new File(EMOTICON_DIRECTORY, name);
|
||||||
if (directory.exists() && directory.isDirectory()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Unzip contents into directory
|
// Unzip contents into directory
|
||||||
unzipPack(file, directory.getParentFile());
|
unzipPack(file, directory.getParentFile());
|
||||||
|
|
||||||
// Delete the pack
|
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user