Skip to content

Commit

Permalink
Merge pull request #11 from codenameone/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
ThomasH99 authored Sep 13, 2017
2 parents 7982987 + 99d9dc9 commit 655ee66
Show file tree
Hide file tree
Showing 97 changed files with 8,572 additions and 1,831 deletions.
2 changes: 1 addition & 1 deletion CodenameOne/build_javadoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ rm -Rf dist/javadoc
rm -Rf build/tempJavaSources
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java -jar ~/dev/java/JavaDocSourceEmbed/target/JavaDocSourceEmbed-1.0-SNAPSHOT.jar src build/tempJavaSources

/usr/bin/find build/tempJavaSources ../../CodenameOne/CLDC11/src -name "*.java" | /usr/bin/grep -v /impl/ | /usr/bin/xargs /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/javadoc -protected -d dist/javadoc -windowtitle "Codename One API"
/usr/bin/find build/tempJavaSources ../Ports/CLDC11/src -name "*.java" | /usr/bin/grep -v /impl/ | /usr/bin/xargs /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/javadoc -protected -d dist/javadoc -windowtitle "Codename One API"
2 changes: 1 addition & 1 deletion CodenameOne/src/cn1-version-numbers
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4c9e7664ec38eaffd5493d601d76671ca93480af
7ff2ab7747628f6d0777b0bf0db2c282b2f76933
9 changes: 9 additions & 0 deletions CodenameOne/src/com/codename1/background/package.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<p>Background fetch is a mechanism whereby an application is granted permission by the operating system to update its data periodically. At times of the native platform's choosing, an app that supports background fetch will be started up (in the background), and its {@link com.codename1.background.BackgroundFetch#performBackgroundFetch(long, com.codename1.util.Callback) } method will be called.</p>
</body>
</html>
6 changes: 3 additions & 3 deletions CodenameOne/src/com/codename1/charts/models/XYSeries.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public synchronized double getY(int index) {
}

/**
* Add an String at (x,y) coordinates
* Add a String at (x,y) coordinates
*
* @param annotation String text
* @param x
Expand All @@ -264,7 +264,7 @@ public void addAnnotation(String annotation, double x, double y) {
}

/**
* Add an String at (x,y) coordinates
* Add a String at (x,y) coordinates
*
* @param annotation String text
* @param index the index to add the annotation to
Expand All @@ -280,7 +280,7 @@ public void addAnnotation(String annotation, int index, double x, double y) {
}

/**
* Remove an String at index
* Remove a String at index
*
* @param index
*/
Expand Down
2 changes: 1 addition & 1 deletion CodenameOne/src/com/codename1/charts/views/PieSegment.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


/**
* Holds An PieChart Segment
* Holds A PieChart Segment
*/
public class PieSegment {
private float mStartAngle;
Expand Down
64 changes: 58 additions & 6 deletions CodenameOne/src/com/codename1/components/Accordion.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.codename1.ui.layouts.BorderLayout;
import com.codename1.ui.layouts.BoxLayout;
import com.codename1.ui.plaf.UIManager;
import com.codename1.ui.util.EventDispatcher;

/**
* <p>The {@code Accordion} ui pattern is a vertically stacked list of items.
Expand Down Expand Up @@ -63,18 +64,17 @@
public class Accordion extends Container {

private Image closeIcon;

private Image openIcon;

private boolean autoClose = true;
private final EventDispatcher listeners = new EventDispatcher();

/**
* Empty Constructor
*/
public Accordion() {
super.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
closeIcon = FontImage.createMaterial(FontImage.MATERIAL_KEYBOARD_ARROW_RIGHT, UIManager.getInstance().getComponentStyle("Label"));
openIcon = FontImage.createMaterial(FontImage.MATERIAL_KEYBOARD_ARROW_DOWN, UIManager.getInstance().getComponentStyle("Label"));
closeIcon = FontImage.createMaterial(FontImage.MATERIAL_KEYBOARD_ARROW_RIGHT, UIManager.getInstance().getComponentStyle("AccordionArrow"));
openIcon = FontImage.createMaterial(FontImage.MATERIAL_KEYBOARD_ARROW_DOWN, UIManager.getInstance().getComponentStyle("AccordionArrow"));
setScrollableY(true);
}

Expand Down Expand Up @@ -129,7 +129,6 @@ public void addContent(Component header, Component body) {
add(new AccordionContent(header, body));
}


/**
* Returns the body component of the currently expanded accordion element or null if none is expanded
* @return a component
Expand All @@ -144,7 +143,6 @@ public Component getCurrentlyExpanded() {
return null;
}


/**
* Expands the accordion with the given "body"
* @param body the body component of the accordion to expand
Expand Down Expand Up @@ -194,6 +192,40 @@ public void setOpenIcon(Image openIcon) {
this.openIcon = openIcon;
}

/**
* Sets the closed icon using material image
* @param closeIcon the close icon (e.g. {@code FontImage.MATERIAL_KEYBOARD_ARROW_DOWN})
*/
public void setCloseIcon(char closeIcon) {
this.closeIcon = FontImage.createMaterial(closeIcon, UIManager.getInstance().getComponentStyle("AccordionArrow"));
}

/**
* Sets the open icon using material image
* @param openIcon the open icon (e.g. {@code FontImage.MATERIAL_KEYBOARD_ARROW_RIGHT})
*/
public void setOpenIcon(char openIcon) {
this.openIcon = FontImage.createMaterial(openIcon, UIManager.getInstance().getComponentStyle("AccordionArrow"));
}

/**
* Sets the closed icon using material image with a custom uiid
* @param closeIcon the close icon (e.g. {@code FontImage.MATERIAL_KEYBOARD_ARROW_DOWN})
* @param uiid to custom icon from res file
*/
public void setCloseIcon(char closeIcon, String uiid) {
this.closeIcon = FontImage.createMaterial(closeIcon, UIManager.getInstance().getComponentStyle(uiid));
}

/**
* Sets the open icon using material image with a custom uiid
* @param openIcon the open icon (e.g. {@code FontImage.MATERIAL_KEYBOARD_ARROW_RIGHT})
* @param uiid to custom icon from res file
*/
public void setOpenIcon(char openIcon, String uiid) {
this.openIcon = FontImage.createMaterial(openIcon, UIManager.getInstance().getComponentStyle(uiid));
}

/**
* Sets the auto close flag, if this flag is true clicking on an item to open
* an item will automatically close the previous opened item.
Expand Down Expand Up @@ -240,6 +272,7 @@ public void actionPerformed(ActionEvent evt) {
}
}
Accordion.this.animateLayout(250);
fireEvent(evt);
}
});
top.add(BorderLayout.EAST, arrow);
Expand All @@ -265,5 +298,24 @@ public void openClose(boolean close) {


}

/**
* To listen item click in accordion component
* @param ActionListener to implement the method
*/
public void addOnClickItemListener(ActionListener a) {
listeners.addListener(a);
}
/**
* To remove item click in accordion component
* @param ActionListener to implement the method
*/
public void removeOnClickItemListener(ActionListener a) {
listeners.removeListener(a);
}

private void fireEvent(ActionEvent ev) {
listeners.fireActionEvent(ev);
}

}
5 changes: 3 additions & 2 deletions CodenameOne/src/com/codename1/components/FloatingHint.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.codename1.ui.Container;
import com.codename1.ui.Display;
import com.codename1.ui.Label;
import com.codename1.ui.TextArea;
import com.codename1.ui.TextField;
import com.codename1.ui.events.ActionEvent;
import com.codename1.ui.events.ActionListener;
Expand All @@ -50,15 +51,15 @@
* @author Shai Almog
*/
public class FloatingHint extends Container {
private final TextField tf;
private final TextArea tf;
private final Button hintButton;
private final Label hintLabel;

/**
* Wraps a text field in a floating hint
* @param tf the text field
*/
public FloatingHint(final TextField tf) {
public FloatingHint(final TextArea tf) {
super(new LayeredLayout());
this.tf = tf;
Container content = new Container(new BorderLayout());
Expand Down
24 changes: 16 additions & 8 deletions CodenameOne/src/com/codename1/components/InteractionDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,21 +328,29 @@ public void dispose() {
* Removes the interaction dialog from view with an animation to the left
*/
public void disposeToTheLeft() {
Container p = getParent();
final Container p = getParent();
if(p != null) {
Form f = p.getComponentForm();
final Form f = p.getComponentForm();
if(f != null) {
setX(-getWidth());
if(animateShow) {
p.animateUnlayoutAndWait(400, 255);
p.animateUnlayout(400, 255, new Runnable() {
public void run() {
Container pp = getLayeredPane(f);
remove();
p.remove();
pp.removeAll();
pp.revalidate();
}
});
} else {
p.revalidate();
Container pp = getLayeredPane(f);
remove();
p.remove();
pp.removeAll();
pp.revalidate();
}
Container pp = getLayeredPane(f);
remove();
p.remove();
pp.removeAll();
pp.revalidate();
} else {
remove();
}
Expand Down
22 changes: 13 additions & 9 deletions CodenameOne/src/com/codename1/components/ToastBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public void show() {
/**
* Schedules this status message to be shown after a specified number of milliseconds,
* if it hasn't been cleared or shown first.
* <p>This is handy if you want to show an status for an operation that usually completes very quickly, but could
* <p>This is handy if you want to show a status for an operation that usually completes very quickly, but could
* potentially hang. In such a case you might decide not to display a status message at all unless the operation
* takes more than 500ms to complete.</p>
*
Expand Down Expand Up @@ -599,16 +599,20 @@ public void actionPerformed(ActionEvent evt) {
Dimension oldTextAreaSize = UIManager.getInstance().getLookAndFeel().getTextAreaSize(c.label, true);
Dimension newTexAreaSize = UIManager.getInstance().getLookAndFeel().getTextAreaSize(newLabel, true);

c.label.getParent().replaceAndWait(c.label, newLabel, CommonTransitions.createCover(CommonTransitions.SLIDE_VERTICAL, true, 300));
c.label = newLabel;

if (oldTextAreaSize.getHeight() != newTexAreaSize.getHeight()) {

c.label.setPreferredH(newTexAreaSize.getHeight());
c.getParent().animateHierarchyAndWait(300);
// this can happen in an edge case where animateHierarchyAndWait and replaceAndWait
// are stuck in blocking mode between them and the label just got discarded see:
// https://stackoverflow.com/questions/46172993/codename-one-toastbar-nullpointerexception
if(c.label.getParent() != null) {
c.label.getParent().replaceAndWait(c.label, newLabel, CommonTransitions.createCover(CommonTransitions.SLIDE_VERTICAL, true, 300));
c.label = newLabel;

if (oldTextAreaSize.getHeight() != newTexAreaSize.getHeight()) {

c.label.setPreferredH(newTexAreaSize.getHeight());
c.getParent().animateHierarchyAndWait(300);
}
}


} else {
if (s.getMessageUIID() != null) {
c.label.setUIID(s.getMessageUIID());
Expand Down
13 changes: 8 additions & 5 deletions CodenameOne/src/com/codename1/db/ThreadSafeDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,17 @@

import com.codename1.io.Log;
import com.codename1.util.EasyThread;
import com.codename1.util.RunnableWithResult;
import com.codename1.util.RunnableWithResultSync;
import com.codename1.util.SuccessCallback;
import java.io.IOException;

/**
* Wraps all database calls in a single thread so they are all proxied thru that thread
*
* @author Shai Almog
* @deprecated platform specific nuances prevented this approach from working out, we improved the native iOS support for thread safety instead
*/
public class ThreadSafeDatabase extends Database {
private Database underlying;
private final Database underlying;
private final EasyThread et;

/**
Expand Down Expand Up @@ -110,7 +109,7 @@ public Object run() {
public void commitTransaction() throws IOException {
invokeWithException(new RunnableWithIOException() {
public void run() throws IOException {
underlying.beginTransaction();
underlying.commitTransaction();
}
});
}
Expand All @@ -134,6 +133,7 @@ public void run() {
} catch(IOException err) {
Log.e(err);
}
et.kill();
}
});
}
Expand Down Expand Up @@ -221,10 +221,13 @@ public Object run() throws IOException {
}

private class CursorWrapper implements Cursor {
private Cursor underlyingCursor;
private final Cursor underlyingCursor;
public CursorWrapper(Cursor underlyingCursor) {
this.underlyingCursor = underlyingCursor;
}

protected void finalize() {
}

public boolean first() throws IOException {
return (Boolean)invokeWithException(new RunnableWithResponseOrIOException() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public interface VirtualKeyboardInterface {
* This can be used to indicate to the VirtualKeyboard what type of input
* to display.
*
* @param constraint one of TextArea.ANY, TextArea.EMAILADDR,
* @param inputType one of TextArea.ANY, TextArea.EMAILADDR,
* TextArea.NUMERIC, TextArea.PHONENUMBER, TextArea.URL, TextArea.DECIMAL
* it can be bitwised or'd with one of TextArea.PASSWORD,
* TextArea.UNEDITABLE, TextArea.SENSITIVE, TextArea.NON_PREDICTIVE,
Expand Down
2 changes: 1 addition & 1 deletion CodenameOne/src/com/codename1/io/rest/RequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public RequestBuilder acceptJson() {
* @return RequestBuilder instance
*/
public RequestBuilder basicAuth(String username, String password) {
header("Authorization", "Basic " + Base64.encode((username + ":" + password).getBytes()));
header("Authorization", "Basic " + Base64.encodeNoNewline((username + ":" + password).getBytes()));
return this;
}

Expand Down
4 changes: 2 additions & 2 deletions CodenameOne/src/com/codename1/javascript/JSObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public class JSObject {
* </pre></code>
* @param context The javascript context in which this object is being created.
*
* @param expr A javascript expression that resolves to an Javascript Object.
* @param expr A javascript expression that resolves to a Javascript Object.
*/
public JSObject(JavascriptContext context, String expr) {
this.context = context;
Expand Down Expand Up @@ -383,7 +383,7 @@ public boolean getBoolean(String key){
/**
* Wrapper around the get() method to return a JSObject.
* @param key The name of the property in the object to retrieve. Value of this property
* must be an Javascript object or function.
* must be a Javascript object or function.
* @return The property value as a JSObject.
*/
public JSObject getObject(String key){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ void addCallback(JSObject source, String method, JSFunction callback, boolean as
String id = JSObject.ID_KEY;
//String lookup = LOOKUP_TABLE;
String self = source.toJSPointer();
String isSimulator = Display.getInstance().isSimulator() ? "true":"false";
String js = self+"."+method+"=function(){"+
"var len=arguments.length;var url='https://www.codenameone.com/!cn1command/"+self+"."+method+"?'; "+
"for (var i=0; i<len; i++){"+
Expand All @@ -725,7 +726,7 @@ void addCallback(JSObject source, String method, JSFunction callback, boolean as
"url += encodeURIComponent(typeof(val))+'='+encodeURIComponent(strval);"+
"if (i < len-1){ url += '&';}"+
//"} var iframe=document.createElement('iframe');iframe.src=url;document.body.appendChild(iframe)"+
"} if (window.cn1application && window.cn1application.shouldNavigate) { window.cn1application.shouldNavigate(url) } else {window.location.href=url}"+
"} if (window.cn1application && window.cn1application.shouldNavigate) { window.cn1application.shouldNavigate(url) } else if ("+isSimulator+") {window._cn1ready = window._cn1ready || []; window._cn1ready.push(function(){window.cn1application.shouldNavigate(url)});} else {window.location.href=url}"+
//"} return 56;"+
//"console.log('About to try to load '+url); var el = document.createElement('iframe'); el.setAttribute('src', url); document.body.appendChild(el); el.parentNode.removeChild(el); console.log(el); el = null"+
"}";
Expand Down
2 changes: 1 addition & 1 deletion CodenameOne/src/com/codename1/l10n/Format.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public abstract class Format implements Cloneable {
public abstract String format(Object source) throws IllegalArgumentException;

/**
* Parse an string to an object.
* Parse a string to an object.
*
* @param source document to be parsed.
* @return parsed object.
Expand Down
Loading

0 comments on commit 655ee66

Please sign in to comment.