mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-01-10 01:29:45 +03:00
Merge branch 'dev' of github.com:GravitLauncher/Launcher into dev
This commit is contained in:
commit
c8017ff01d
3 changed files with 35 additions and 2 deletions
|
@ -131,6 +131,7 @@ var options = {
|
||||||
}
|
}
|
||||||
options.update();
|
options.update();
|
||||||
});
|
});
|
||||||
|
testMod.setFocusTraversable(false);
|
||||||
checkBoxList.add(testMod);
|
checkBoxList.add(testMod);
|
||||||
testMod.getStyleClass().add("modname");
|
testMod.getStyleClass().add("modname");
|
||||||
if(modDescription != "") {
|
if(modDescription != "") {
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import ru.gravit.launcher.hasher.HashedEntry;
|
import ru.gravit.launcher.hasher.HashedEntry;
|
||||||
import ru.gravit.launcher.hasher.HashedEntryAdapter;
|
import ru.gravit.launcher.hasher.HashedEntryAdapter;
|
||||||
|
import ru.gravit.utils.helper.CommonHelper;
|
||||||
|
|
||||||
public class GsonManager {
|
public class GsonManager {
|
||||||
public GsonBuilder gsonBuilder;
|
public GsonBuilder gsonBuilder;
|
||||||
|
@ -12,8 +13,8 @@ public class GsonManager {
|
||||||
public Gson configGson;
|
public Gson configGson;
|
||||||
|
|
||||||
public void initGson() {
|
public void initGson() {
|
||||||
gsonBuilder = new GsonBuilder();
|
gsonBuilder = CommonHelper.newBuilder();
|
||||||
configGsonBuilder = new GsonBuilder();
|
configGsonBuilder = CommonHelper.newBuilder();
|
||||||
configGsonBuilder.setPrettyPrinting();
|
configGsonBuilder.setPrettyPrinting();
|
||||||
registerAdapters(gsonBuilder);
|
registerAdapters(gsonBuilder);
|
||||||
registerAdapters(configGsonBuilder);
|
registerAdapters(configGsonBuilder);
|
||||||
|
|
|
@ -6,6 +6,18 @@
|
||||||
import javax.script.ScriptEngine;
|
import javax.script.ScriptEngine;
|
||||||
import javax.script.ScriptEngineFactory;
|
import javax.script.ScriptEngineFactory;
|
||||||
import javax.script.ScriptEngineManager;
|
import javax.script.ScriptEngineManager;
|
||||||
|
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.JsonDeserializationContext;
|
||||||
|
import com.google.gson.JsonDeserializer;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
|
import com.google.gson.JsonPrimitive;
|
||||||
|
import com.google.gson.JsonSerializationContext;
|
||||||
|
import com.google.gson.JsonSerializer;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.Base64;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -120,4 +132,23 @@ public static String[] parseCommand(CharSequence line) throws CommandException {
|
||||||
// Return result as array
|
// Return result as array
|
||||||
return result.toArray(new String[0]);
|
return result.toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@LauncherAPI
|
||||||
|
public static GsonBuilder newBuilder() {
|
||||||
|
return new GsonBuilder().registerTypeHierarchyAdapter(byte[].class,
|
||||||
|
ByteArrayToBase64TypeAdapter.INSTANCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ByteArrayToBase64TypeAdapter implements JsonSerializer<byte[]>, JsonDeserializer<byte[]> {
|
||||||
|
private static final ByteArrayToBase64TypeAdapter INSTANCE = new ByteArrayToBase64TypeAdapter();
|
||||||
|
private Base64.Decoder decoder = Base64.getUrlDecoder();
|
||||||
|
private Base64.Encoder encoder = Base64.getUrlEncoder();
|
||||||
|
public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||||
|
return decoder.decode(json.getAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonElement serialize(byte[] src, Type typeOfSrc, JsonSerializationContext context) {
|
||||||
|
return new JsonPrimitive(encoder.encodeToString(src));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue