use of com.codename1.io.Log in project CodenameOne by codenameone.
the class DefaultCrashReporter method init.
/**
* Installs a crash reporter within the system
* @param promptUser indicates whether the user should be prompted on crash reporting
* @param frequency the frequency with which we send the log to the server in debug mode in minutes
* frequency must be at least 1. Any lower level automatically disables this feature
*/
public static void init(boolean promptUser, int frequency) {
if (Preferences.get("$CN1_crashBlocked", false) || Log.getReportingLevel() == Log.REPORTING_NONE) {
return;
}
if (Preferences.get("$CN1_pendingCrash", false)) {
// we must have crashed during a report, send it.
Log.sendLog();
Preferences.set("$CN1_pendingCrash", false);
}
if (Log.getReportingLevel() == Log.REPORTING_DEBUG && frequency > 0) {
java.util.Timer t = new java.util.Timer();
t.schedule(new TimerTask() {
public void run() {
if (!Display.getInstance().isEdt()) {
Display.getInstance().callSerially(this);
return;
}
Log.sendLog();
}
}, frequency * 60000, frequency * 60000);
}
DefaultCrashReporter d = new DefaultCrashReporter();
d.promptUser = promptUser && Preferences.get("$CN1_prompt", true);
Display.getInstance().setCrashReporter(d);
}
use of com.codename1.io.Log in project CodenameOne by codenameone.
the class TestUtils method ensureVisible.
/**
* Scrolls to show the component in case it is invisible currently
* @param c the component
*/
public static void ensureVisible(Component c) {
if (verbose) {
log("ensureVisible(" + c + ")");
}
Form f = Display.getInstance().getCurrent();
f.scrollComponentToVisible(c);
}
use of com.codename1.io.Log in project CodenameOne by codenameone.
the class TestUtils method setText.
/**
* Sets the text for the given component
* @param name the name of the component
* @param text the text to set
*/
public static void setText(String name, String text) {
if (verbose) {
log("setText(" + name + ", " + text + ")");
}
Component c = findByName(name);
if (c instanceof Label) {
((Label) c).setText(text);
return;
}
((TextArea) c).setText(text);
Display.getInstance().onEditingComplete(c, text);
}
use of com.codename1.io.Log in project CodenameOne by codenameone.
the class TestUtils method pointerRelease.
/**
* A component release on a given named component at x/y where x and y are <b>NOT pixels</b>
* but rather a number between 0 to 1 representing the percentage within the component where the
* event took place. E.g. For a 100x100 component a press within 10,5 would be 0.1f, 0.05f.
* @param x the offset within the component as a number between 0 and 1
* @param y the offset within the component as a number between 0 and 1
* @param path the path to the component
*/
public static void pointerRelease(float x, float y, int[] path) {
if (verbose) {
log("pointerRelease(" + x + ", " + y + ", " + toString(path) + ")");
}
Component c = getComponentByPath(path);
int actualX = c.getAbsoluteX() + (int) (x * c.getWidth());
int actualY = c.getAbsoluteY() + (int) (y * c.getHeight());
Display.getInstance().getCurrent().pointerReleased(actualX, actualY);
waitFor(10);
}
use of com.codename1.io.Log in project CodenameOne by codenameone.
the class TestUtils method pointerPress.
/**
* A component press on a given named component at x/y where x and y are <b>NOT pixels</b>
* but rather a number between 0 to 1 representing the percentage within the component where the
* event took place. E.g. For a 100x100 component a press within 10,5 would be 0.1f, 0.05f.
* @param x the offset within the component as a number between 0 and 1
* @param y the offset within the component as a number between 0 and 1
* @param path the path to the component
*/
public static void pointerPress(float x, float y, int[] path) {
if (verbose) {
log("pointerPress(" + x + ", " + y + ", " + toString(path) + ")");
}
Component c = getComponentByPath(path);
int actualX = c.getAbsoluteX() + (int) (x * c.getWidth());
int actualY = c.getAbsoluteY() + (int) (y * c.getHeight());
Display.getInstance().getCurrent().pointerPressed(actualX, actualY);
waitFor(10);
}
Aggregations