public static synchronized Engine getEngine() { if (engine == null) { engine = Engine.create(MyCertificate.getBytes()); } return engine; }
public final boolean newPackage() { final Activity context = this.activity; String fileName = makeUntitledFilename(); File file = new File(activity.getFilesDir(), fileName); try { ContentPackage newPackage = editor.getEngine().createPackage(file); newPart(file, newPackage, true); } catch (IOException e) { Toast.makeText(context, "Failed to create package", Toast.LENGTH_LONG).show(); } catch (IllegalArgumentException e) { Toast.makeText(context, "Package already opened", Toast.LENGTH_LONG).show(); } return true; }
public final boolean openPart(@NonNull String fileName, int indexOfPart) { try { File file = new File(activity.getFilesDir(), fileName); ContentPackage newPackage = editor.getEngine().openPackage(file); ContentPart newPart = newPackage.getPart(indexOfPart); setPart(file, newPackage, newPart); } catch (IOException e) { Toast.makeText(this.activity, "Failed to open part for file \"" + fileName + "\" with index " + indexOfPart, Toast.LENGTH_LONG).show(); } return true; }
Configuration conf = engine.getConfiguration(); String confDir = "zip://" + getPackageCodePath() + "!/assets/conf"; conf.setStringArray("configuration-manager.search-path", new String[]{confDir}); try contentPackage = engine.createPackage(file); contentPart = contentPackage.createPart("Text Document"); // Choose type of content (possible values are: "Text Document", "Text", "Diagram", "Math", and "Drawing")
public void setEditor(@NonNull Editor editor) { this.editor = editor; editor.addListener(this); editor.getRenderer().addListener(this); this.exportParams = editor.getEngine().createParameterSet(); this.exportParams.setBoolean("export.jiix.strokes", false); this.exportParams.setBoolean("export.jiix.bounding-box", false); this.exportParams.setBoolean("export.jiix.glyphs", false); this.exportParams.setBoolean("export.jiix.primitives", false); this.exportParams.setBoolean("export.jiix.chars", false); Configuration configuration = editor.getEngine().getConfiguration(); fadeOutWriteInDiagramDelay = configuration.getNumber("smart-guide.fade-out-delay.write-in-diagram", SMART_GUIDE_FADE_OUT_DELAY_WRITE_IN_DIAGRAM_DEFAULT).intValue(); fadeOutWriteDelay = configuration.getNumber("smart-guide.fade-out-delay.write", SMART_GUIDE_FADE_OUT_DELAY_WRITE_DEFAULT).intValue(); fadeOutOtherDelay = configuration.getNumber("smart-guide.fade-out-delay.other", SMART_GUIDE_FADE_OUT_DELAY_OTHER_DEFAULT).intValue(); removeHighlightDelay = configuration.getNumber("smart-guide.highlight-removal-delay", SMART_GUIDE_HIGHLIGHT_REMOVAL_DELAY_DEFAULT).intValue(); }
Configuration conf = engine.getConfiguration(); String confDir = "zip://" + getPackageCodePath() + "!/assets/conf"; conf.setStringArray("configuration-manager.search-path", new String[]{confDir});
renderer = engine.createRenderer(displayMetrics.xdpi, displayMetrics.ydpi, this); editor = engine.createEditor(renderer); editor.setFontMetricsProvider(new FontMetricsProvider(displayMetrics, typefaceMap));
final String[] partTypes = engine.getSupportedPartTypes(); final int[] selected = new int[]{0}; AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity).setCancelable(false);
public static synchronized Engine getEngine() { if (engine == null) { engine = Engine.create(MyCertificate.getBytes()); } return engine; }
@Override public void onClick(DialogInterface dialog, int which) { File newFile = files[selected[0]]; try { ContentPackage newPackage = editor.getEngine().openPackage(newFile); ContentPart newPart = newPackage.getPart(0); setPart(newFile, newPackage, newPart); } catch (IOException e) { Toast.makeText(context, "Failed to open package", Toast.LENGTH_LONG).show(); } } });