Skip to content

180717_addingChangesFromCn1Repository #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 113 commits into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
0f73e4c
Fixed infinite loop regression in replaceInFile() that was introduced…
shannah May 19, 2017
795f57d
Fixed issue with floating hint becoming unresponsive.
shannah May 19, 2017
14c9281
Removed some debugging code from previous commit.
shannah May 19, 2017
f8f1533
Fixed glitch in SplitPane that caused you to have to press expand or …
shannah May 21, 2017
25544c8
Fixed exception in unit test code and refined deprecation comment wit…
shai-almog May 23, 2017
23f6564
Fixed #2029 Theme designer Border Tab shows wrong border type
shai-almog May 23, 2017
7b41fd5
Fixed #1846 ResourceEditor: Preserve Aspect Ratio button doesn't adju…
shai-almog May 23, 2017
97244af
Fixed #1913 Exporting test reports as JUnit XML reports enabled for a…
shai-almog May 23, 2017
8a64457
Fixed #2077 JSONParser will now parse boolean values correctly
shai-almog May 23, 2017
626a5de
Fixed compilation isssue
shai-almog May 23, 2017
7724f2c
Fixed issue with SplitPane expand/collapse buttons not working after …
shannah May 23, 2017
8c0aeba
Implemented #1906 add CN1 support for clearing a text field on iOS an…
shai-almog May 24, 2017
046f178
Fixed potential race condition in run on ui and block
shai-almog May 24, 2017
60da1ba
Fixed #1734 we now have a new global context class that isn't display…
shai-almog May 25, 2017
e193168
Fixed NPE on iOS date picker when date set to null. https://groups.g…
shannah May 25, 2017
eb2265a
Added commented-out template for injecting a tracer method to help de…
shannah May 25, 2017
6f9693b
Fixed NPE in IOS port edit string. https://github.com/codenameone/Cod…
shannah May 25, 2017
e226b07
Removed some confusing logging
shai-almog May 25, 2017
e233557
Fixed back button behaviour so that the hideBackButtonBool is true on…
shannah May 25, 2017
738cd10
Merge branch 'master' of https://github.com/codenameone/CodenameOne
shannah May 25, 2017
e5cd4a5
Added support for desktop ports to check if a control key (shift, alt…
shannah May 26, 2017
42a539d
Fixed issue with facebook permissions. A change in the permissions i…
shannah May 26, 2017
24b49f9
Merge branch 'tmp_guibuilder'
shannah May 26, 2017
f9f443d
Fixed potential rounding error in L10NManager, added additional Stora…
shai-almog May 28, 2017
b3b4145
Merge branch 'master' of https://github.com/codenameone/CodenameOne
shannah May 29, 2017
0169d51
Fixed so that IOS doesn't fall back to handling/sending cookies itsel…
shannah May 29, 2017
1110aad
Added support for text area and icon size into the clearable text field
shai-almog May 31, 2017
e45a791
Deprecated SideMenuBar in favor of Toolbar
shai-almog May 31, 2017
d3e94c8
Fixed memory leak in browser component in simulator. This also cause…
shannah Jun 1, 2017
1c85b45
Fixed some issues with retaining proper positioning when changing ref…
shannah Jun 2, 2017
8657ecb
Rest API
chen-fishbein Jun 3, 2017
86e415b
Merge branch 'master' of https://github.com/codenameone/CodenameOne
chen-fishbein Jun 3, 2017
b22c567
added missing author
chen-fishbein Jun 3, 2017
c5b7f10
Fixed NPE in Layeredlayout changeUnits
shannah Jun 5, 2017
79baac2
Merge branch 'master' of https://github.com/codenameone/CodenameOne
shannah Jun 5, 2017
710bc8a
Fixed issue with buttons incorrectly going into pressed state during …
shannah Jun 5, 2017
9ebcd6c
Replaced NSLog calls with CN1Log which is a macro that uses printf in…
shannah Jun 6, 2017
56a5551
Fixed issue with android Google connect that might cause infinite log…
shannah Jun 6, 2017
1f16988
Fix for issue in lead component behavior
shai-almog Jun 6, 2017
e16ea2b
added desktop resizeable skin
chen-fishbein Jun 6, 2017
21d107a
Merge branch 'master' of https://github.com/codenameone/CodenameOne
chen-fishbein Jun 6, 2017
4b197ab
Fixed potential array outofbounds exception in layeredlayout.
shannah Jun 7, 2017
869f9fd
Merged changes from github to Container
shannah Jun 7, 2017
d88dbf8
Merge branch 'master' of https://github.com/codenameone/CodenameOne
shannah Jun 7, 2017
03d350c
Fixed off validation occuring off EDT on size changed in simulator. …
shannah Jun 7, 2017
12deacf
Fixed issue with tabs consuming events that occur outside their bounds.
shannah Jun 7, 2017
2c95652
Added Component.visibleBoundsContains(x,y) method that checks if a po…
shannah Jun 7, 2017
d949eb3
Fixed typo in last commit
shannah Jun 7, 2017
480b2a1
New preferences support for properties
shai-almog Jun 9, 2017
3da0e20
Added support for layered layout to have a preferred size that is use…
shannah Jun 9, 2017
058b832
Fixed #2089 Simulator on Linux does not scroll to show the entire device
shai-almog Jun 12, 2017
d62c54b
JavaDoc deprections
shai-almog Jun 12, 2017
5312756
Removed image cache as it used the hashcode of a byte array as the ke…
shannah Jun 12, 2017
2382b6f
Merge branch 'master' of https://github.com/codenameone/CodenameOne
shannah Jun 14, 2017
26035a4
Fixed locale support in iOS L10Manager. https://github.com/codenameo…
shannah Jun 14, 2017
5ecc902
Fixed JavaSE port so that invokeHover setting isn't obliterated by th…
shannah Jun 16, 2017
4d72217
Fixed #2134 NPE on threadsafe database
shai-almog Jun 16, 2017
88a9a6b
desktop skin bug fix
chen-fishbein Jun 16, 2017
825d32d
Workaround for issue where a hidden poup still sends events.
shai-almog Jun 18, 2017
4461b69
Fixed desktop skin resize
shai-almog Jun 18, 2017
c656270
Updated version numbers
shai-almog Jun 18, 2017
030c739
Guarded against dividing by zero in layered layout.
shannah Jun 20, 2017
34fbb1e
Added Inset.getValueAsString(decimalPlaces) to format inset values mo…
shannah Jun 21, 2017
012fb9a
Revert "Added Inset.getValueAsString(decimalPlaces) to format inset v…
shai-almog Jun 22, 2017
689117e
Fix for #2136 exception on orientation change due to desktop skin fea…
shai-almog Jun 22, 2017
2a1e96f
Fix for issue #2139 pending review for inclusion. Regression in auto-…
shai-almog Jun 23, 2017
d282d09
Updated readme with more refined copy and up to date information
shai-almog Jun 27, 2017
86c3144
Update README.md
shai-almog Jun 27, 2017
4ea35c7
Update README.md
shai-almog Jun 27, 2017
d494a57
Create CONTRIBUTING.md
shai-almog Jun 27, 2017
870325c
Update README.md
shai-almog Jun 27, 2017
389beeb
Added package.html to the notifications package.
shannah Jun 27, 2017
ea74e0b
Fixed custom alert sound not working in android local notifications. …
shannah Jun 27, 2017
457b21f
Fixed bubble transition always happening in top left regardless of po…
shannah Jun 27, 2017
6a6a489
Fixed issue with clip stack not working for mutable images on javase …
shannah Jun 27, 2017
4d4ebdc
Fixed issue with text alignment in text fields on iOS. https://githu…
shannah Jun 27, 2017
65e94c2
Merge branch 'freeze_issue_2091'
shannah Jun 28, 2017
b4b370c
Merge branch 'freeze_issue_2092'
shannah Jun 28, 2017
cd8b3b4
Merge branch 'issue_2137'
shannah Jun 28, 2017
2fe094a
Re-added getValueAsString to layered layout with decimal formatting f…
shannah Jun 28, 2017
9dd4003
Added GET_ACCOUNTS permission check when logging into google as it is…
shannah Jun 28, 2017
93a8401
Fix for NPE when building kotlin code
shannah Jun 30, 2017
e4b96ed
Fixed get IP address API which returned 127.0.0.1 sometimes
shai-almog Jul 3, 2017
691914b
Merge remote-tracking branch 'refs/remotes/codenameone/master'
diamondobama Jul 4, 2017
e6d913a
Merge remote-tracking branch 'refs/remotes/codenameone/master'
diamondobama Jul 6, 2017
0d1e9f6
Fixed SQL error on "WHERE" Clause that uses "," instead of "AND" for …
diamondobama Jul 6, 2017
40cf43a
Merge pull request #2150 from diamondobama/master
shai-almog Jul 6, 2017
14b404a
Removed forced opacity from scale image label and added package doc f…
shai-almog Jul 6, 2017
dc262bb
Fixed compilation issues with svn migration
shai-almog Jul 7, 2017
16a843a
Updated JavaDoc
vprise Jul 8, 2017
58a571f
Merge pull request #2153 from vprise/patch-1
shai-almog Jul 8, 2017
9159ae6
Fix for #2155 the ip address detection code I committed previously wa…
shai-almog Jul 10, 2017
dd5bcfa
Fixed an issue in the last commit
shai-almog Jul 10, 2017
b54bea2
Added some getters to SplitPane to make it easier to get the current …
shannah Jul 10, 2017
809969a
Fixed some javadoc typos
shannah Jul 10, 2017
51e499a
Fixed NPE from GuiBuilder crash report.
shannah Jul 10, 2017
175ec44
Merge branch 'master' of https://github.com/codenameone/CodenameOne
shannah Jul 10, 2017
45468d3
Updated the Android & iOS themes to make them feel more "native". Add…
shai-almog Jul 11, 2017
2690251
Added error logging for Facebook connect
shai-almog Jul 11, 2017
beed296
Updated with information on the new Kotlin support
shai-almog Jul 11, 2017
0c5bbef
Fixed #2158 clarified JavaDocs related to the ends with 3 points feat…
shai-almog Jul 12, 2017
8353504
Update README.md
shai-almog Jul 13, 2017
fb82442
iOS Support for GoogleSignIn.
shannah Jul 13, 2017
41564af
Merge branch 'master' of https://github.com/codenameone/CodenameOne
shannah Jul 13, 2017
9c39beb
Fixed some issues in the project.pbxproj template so that xcodeproj d…
shannah Jul 13, 2017
3445dd3
Added define toggle whether cocoapods was used for facebook connect. …
shannah Jul 14, 2017
4f89026
Minor fixes to the build, updated holo light in the native android pr…
shai-almog Jul 15, 2017
fe68789
Experimental support for fractions in padding and margin units, new r…
shai-almog Jul 15, 2017
1c5b9f7
Multiple fixes to round border, added support for round rect into the…
shai-almog Jul 16, 2017
02fdb84
Added AutoCloseable to ParparVM JavaAPI.
shannah Jul 17, 2017
41c7617
Fixed NPE with peer components in simulator.
shannah Jul 17, 2017
f7784df
Added support for Android material design style ripple effect
shai-almog Jul 17, 2017
00e6cd1
Fixes to ripple drawing. Position wasn't calculated correctly and som…
shai-almog Jul 18, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Contributing

Thank you for your interest in Codename One! We have always been community driven and contibuting a pull request is the highest form of that.

## Discussion

Before you start working on something we would suggest talking to us in the [discussion forum](https://www.codenameone.com/discussion-forum.html) or asking a question on [stack overflow with the codenameone tag](http://stackoverflow.com/tags/codenameone). You can also contact us via the chat widget on the [main Codename One website](https://www.codenameone.com).

There are a lot of nuances and pitfalls when making a change or even with submitting an issue and it's worthwhile to ask first so the issue is clear.

Since Codename One is such a large project with so many different pieces contributing to each one of these pieces is a radically different process which is why discussion with the community is helpful.

## Filing Issues

Once we have a sense of what needs doing we suggest filing an issue so we can track the process. Filing an issue is a contibution in its own right. When you write clear concise issues with good test cases & screenshots we can assign them to a specific milestone and move the product forward more easily.

## Documenting

This is probably one of the most important things you can do as a contributor and probably one of the easiest things you can do. There are two big pieces of documentation you can edit right here on github!

The first is the [JavaDoc](https://www.codenameone.com/javadoc/) which you can edit directly in the source code, if there is an ommission or a mistake you can just press the edit button on the file and make the change directly even without an IDE. These pull requests are highly appreciaed and will help future generations of developers!

The [Codename One developer guide](https://www.codenameone.com/manual/) is genenrated from [the wiki pages of this project](https://github.com/codenameone/CodenameOne/wiki/) you can just [edit the wiki directly](https://www.codenameone.com/blog/wiki-parparvm-performance-actionevent-type.html) and your changes propogate into the developers guide. Don't forget to edit the authors section and add some credit!

The wiki uses the asciidoc format to generate HTML & PDF versions. There are plenty of guides on the internet to asciidoc but the syntax is pretty simple. Please try to maintin the convention for the guide as we automate many pieces in the guide generation and conversion.

## Working with the Source

We have a blog post that covers forking, running the simulator and submitting a pull request [here](http://www.codenameone.com/blog/how-to-use-the-codename-one-sources.html). While it's pretty exhaustive it doesn't cover more esoteric features like ParparVM or the iKVM fork. For those our only reference is the source.

## Ownership

By contributing code you are granting Codename One shared ownership of your work. You still own it but Codename One will have the right to relicense your work based on our needs & treat this work as if it was developed by a Codename One engineer. This is important as we might need to provide propriatery licenses for commercial companies and we might want to change the general project license in the future to attract more developers.
30 changes: 10 additions & 20 deletions CodenameOne/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${codenameone.dir}/CLDC11/src" excludes="*.java,${excludes}" includes="${includes}">
<fileset dir="../Ports/CLDC11/src" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
Expand Down Expand Up @@ -157,7 +157,7 @@
<copy file="dist/CodenameOne.jar" todir="build/tmp" />
<copy file="build/CodenameOneDist/CodenameOne/demos/CodenameOne_SRC.zip" todir="build/tmp" />
<copy file="../Ports/JavaSE/dist/JavaSE.jar" todir="build/tmp" />
<copy file="${codenameone.dir}/CLDC11/dist/CLDC11.jar" todir="build/tmp" />
<copy file="../Ports/CLDC11/dist/CLDC11.jar" todir="build/tmp" />
<zip basedir="build/tmp" compress="true" file="updatedLibs.zip" />
<deltree dir="build/tmp"/>
</target>
Expand Down Expand Up @@ -249,8 +249,8 @@

<ant inheritall="false" antfile="../Ports/JavaSE/build.xml" target="clean" />
<ant inheritall="false" antfile="../Ports/JavaSE/build.xml" target="jar" />
<ant inheritall="false" antfile="${codenameone.dir}/CLDC11/build.xml" target="clean" />
<ant inheritall="false" antfile="${codenameone.dir}/CLDC11/build.xml" target="jar" />
<ant inheritall="false" antfile="../Ports/CLDC11/build.xml" target="clean" />
<ant inheritall="false" antfile="../Ports/CLDC11/build.xml" target="jar" />
<ant inheritall="false" antfile="../Ports/JavaSEWithSVGSupport/build.xml" target="clean" />
<ant inheritall="false" antfile="../Ports/JavaSEWithSVGSupport/build.xml" target="jar" />

Expand Down Expand Up @@ -284,7 +284,7 @@
<copydir src="../../SwiftnotesCN1" dest="build/CodenameOneDist/CodenameOne/demos/Swiftnotes" />

<copy file="../Ports/JavaSE/dist/JavaSE.jar" todir="build/CodenameOneDist/CodenameOne/demos" />
<copy file="${codenameone.dir}/CLDC11/dist/CLDC11.jar" todir="build/CodenameOneDist/CodenameOne/demos" />
<copy file="../Ports/CLDC11/dist/CLDC11.jar" todir="build/CodenameOneDist/CodenameOne/demos" />

<delete dir="build/tempsource" />
<!-- this will get overriden the main value is keeping the package.html files -->
Expand All @@ -300,19 +300,10 @@

<copy file="dist/CodenameOne.jar" todir="build/CodenameOneDist/CodenameOne/demos" />
<copy file="../Ports/JavaSE/dist/JavaSE.jar" todir="../demos" />
<copy file="${codenameone.dir}/CLDC11/dist/CLDC11.jar" todir="../demos" />
<copy file="../Ports/CLDC11/dist/CLDC11.jar" todir="../demos" />
<copy file="dist/CodenameOne.jar" todir="../demos" />
<copy file="build/CodenameOneDist/CodenameOne/demos/CodenameOne_SRC.zip" todir="../demos" />

<copy file="${codenameone.dir}/CLDC11/dist/CLDC11.jar" todir="${codenameone.dir}/IdeaPlugin/depedencies" />
<copy file="build/CodenameOneDist/CodenameOne/demos/CodenameOne_SRC.zip" todir="${codenameone.dir}/IdeaPlugin/depedencies" />
<copy file="dist/CodenameOne.jar" todir="${codenameone.dir}/IdeaPlugin/depedencies" />
<copy file="${codenameone.dir}/BuildClient/dist/CodenameOneBuildClient.jar" tofile="${codenameone.dir}/IdeaPlugin/depedencies/CodeNameOneBuildClient.jar" />

<copy file="${codenameone.dir}/CLDC11/dist/CLDC11.jar" todir="${codenameone.dir}/IdeaPlugin/resources/dependencies" />
<copy file="build/CodenameOneDist/CodenameOne/demos/CodenameOne_SRC.zip" todir="${codenameone.dir}/IdeaPlugin/resources/dependencies" />
<copy file="dist/CodenameOne.jar" todir="${codenameone.dir}/IdeaPlugin/resources/dependencies" />
<copy file="${codenameone.dir}/BuildClient/dist/CodenameOneBuildClient.jar" tofile="${codenameone.dir}/IdeaPlugin/resources/dependencies/CodeNameOneBuildClient.jar" />

<delete>
<fileset dir="build/CodenameOneDist/CodenameOne/demos" includes="**/*.jar" />
Expand All @@ -323,7 +314,7 @@
<copy file="dist/CodenameOne.jar" todir="build/tmp" />
<copy file="build/CodenameOneDist/CodenameOne/demos/CodenameOne_SRC.zip" todir="build/tmp" />
<copy file="../Ports/JavaSE/dist/JavaSE.jar" todir="build/tmp" />
<copy file="${codenameone.dir}/CLDC11/dist/CLDC11.jar" todir="build/tmp" />
<copy file="../Ports/CLDC11/dist/CLDC11.jar" todir="build/tmp" />
<zip basedir="build/tmp" compress="true" file="repo/updatedLibs.zip" />
<deltree dir="build/tmp"/>

Expand Down Expand Up @@ -369,7 +360,6 @@
<ant inheritall="false" antfile="${codenameone.dir}/GUIBuilder/GUIBuilderSE/build.xml" target="pack" />
<ant inheritall="false" antfile="../CodenameOneDesigner/build.xml" target="release" />
<!-- zip basedir="../CodenameOneDesigner/dist" includes="designer.jar" file="../nightly_builds/CodenameOneDesigner_${tstamp}.zip" / -->
<copy file="../CodenameOneDesigner/dist/designer.jar" todir="${codenameone.dir}/IdeaPlugin/depedencies" />

<!-- prepare the NB Plugin -->
<property name="nbplugin" location="${codenameone.dir}/NBPlugin"/>
Expand All @@ -390,11 +380,11 @@
<copy file="../Ports/JavaSE/dist/JavaSE.jar" todir="${nbplugin}/CodenameOnePlugin/release/modules/ext" />
<copy file="../Ports/JavaSE/dist/JavaSE.jar" todir="${nbplugin}/CodenameOne_Template/" />

<copy file="${codenameone.dir}/CLDC11/dist/CLDC11.jar" todir="${nbplugin}/CodenameOne_Template/lib" />
<copy file="${codenameone.dir}/CLDC11/dist/CLDC11.jar" todir="${nbplugin}/LibraryProject/lib" />
<copy file="../Ports/CLDC11/dist/CLDC11.jar" todir="${nbplugin}/CodenameOne_Template/lib" />
<copy file="../Ports/CLDC11/dist/CLDC11.jar" todir="${nbplugin}/LibraryProject/lib" />

<!-- Libs for Demos -->
<copy file="${codenameone.dir}/CLDC11/dist/CLDC11.jar" todir="../CodenameOnePlugin/src" />
<copy file="../Ports/CLDC11/dist/CLDC11.jar" todir="../CodenameOnePlugin/src" />
<copy file="dist/CodenameOne.jar" todir="${codenameone.dir}/NBPlugin/CodenameOnePlugin/src"/>
<copy file="build/CodenameOneDist/CodenameOne/demos/CodenameOne_SRC.zip" todir="${codenameone.dir}/NBPlugin/CodenameOnePlugin/src"/>
<copy file="../Ports/JavaSE/dist/JavaSE.jar" todir="${codenameone.dir}/NBPlugin/CodenameOnePlugin/src" />
Expand Down
3 changes: 1 addition & 2 deletions CodenameOne/src/cn1-version-numbers
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
5ad4700144e6d2d647e4bfdbed729151640d4c7f
2376
3445dd3e0a4db4701e26d8401db66f4b092220eb
92 changes: 92 additions & 0 deletions CodenameOne/src/com/codename1/components/ClearableTextField.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright (c) 2012, Codename One and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Codename One designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Codename One through http://www.codenameone.com/ if you
* need additional information or have any questions.
*/

package com.codename1.components;

import com.codename1.ui.Button;
import com.codename1.ui.Component;
import com.codename1.ui.Container;
import com.codename1.ui.FontImage;
import com.codename1.ui.TextArea;
import com.codename1.ui.TextField;
import com.codename1.ui.events.ActionEvent;
import com.codename1.ui.events.ActionListener;
import com.codename1.ui.layouts.BorderLayout;
import com.codename1.ui.plaf.Border;
import com.codename1.ui.plaf.Style;

/**
* Wraps a text field so it will have an X to clear its content on the right hand side
*
* @author Shai Almog
*/
public class ClearableTextField extends Container {
private ClearableTextField() {
super(new BorderLayout());
}

/**
* Wraps the given text field with a UI that will allow us to clear it
* @param tf the text field
* @param iconSize size in millimeters for the clear icon, -1 for default size
* @return a Container that should be added to the UI instead of the actual text field
*/
public static ClearableTextField wrap(final TextArea tf, float iconSize) {
ClearableTextField cf = new ClearableTextField();
Button b = new Button("", tf.getUIID());
if(iconSize > 0) {
FontImage.setMaterialIcon(b, FontImage.MATERIAL_CLEAR, iconSize);
} else {
FontImage.setMaterialIcon(b, FontImage.MATERIAL_CLEAR);
}
removeCmpBackground(tf);
removeCmpBackground(b);
cf.setUIID(tf.getUIID());
cf.add(BorderLayout.CENTER, tf);
cf.add(BorderLayout.EAST, b);
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
tf.stopEditing();
tf.setText("");
tf.startEditingAsync();
}
});
return cf;
}

/**
* Wraps the given text field with a UI that will allow us to clear it
* @param tf the text field
* @return a Container that should be added to the UI instead of the actual text field
*/
public static ClearableTextField wrap(final TextArea tf) {
return wrap(tf, -1);
}

private static void removeCmpBackground(Component cmp) {
Style s = cmp.getAllStyles();
s.setBorder(Border.createEmpty());
s.setBackgroundType(Style.BACKGROUND_NONE);
s.setBgTransparency(0);
}
}
104 changes: 68 additions & 36 deletions CodenameOne/src/com/codename1/components/FloatingHint.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.codename1.ui.Button;
import com.codename1.ui.Component;
import com.codename1.ui.Container;
import com.codename1.ui.Display;
import com.codename1.ui.Label;
import com.codename1.ui.TextField;
import com.codename1.ui.events.ActionEvent;
Expand All @@ -49,16 +50,21 @@
* @author Shai Almog
*/
public class FloatingHint extends Container {
private final TextField 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) {
super(new LayeredLayout());
this.tf = tf;
Container content = new Container(new BorderLayout());
add(content);
final Button hintButton = new Button(tf.getHint());
final Label hintLabel = new Label(tf.getHint());
hintButton = new Button(tf.getHint());
hintLabel = new Label(tf.getHint());
tf.setHint("");
hintButton.setFocusable(false);
hintButton.setUIID("FloatingHint");
Expand Down Expand Up @@ -86,45 +92,71 @@ public void actionPerformed(ActionEvent evt) {
}
FocusListener fl = new FocusListener() {
public void focusGained(Component cmp) {
if(isInitialized()) {
if(!hintButton.isVisible()) {
hintButton.setVisible(true);
if(getComponentForm().grabAnimationLock()) {
morphAndWait(hintLabel, hintButton, 150);
getComponentForm().releaseAnimationLock();
}
hintLabel.setVisible(false);
tf.getComponentForm().revalidate();
tf.startEditingAsync();
} else {
tf.startEditingAsync();
}
} else {
boolean t = tf.getText() == null || tf.getText().length() == 0;
hintButton.setVisible(t);
hintLabel.setVisible(!t);
}
focusGainedImpl();
}

public void focusLost(Component cmp) {
if(isInitialized()) {
if(tf.getText().length() == 0) {
hintLabel.setVisible(true);
if(getComponentForm().grabAnimationLock()) {
morphAndWait(hintButton, hintLabel, 150);
getComponentForm().releaseAnimationLock();
}
hintButton.setVisible(false);
tf.getComponentForm().revalidate();
revalidate();
}
} else {
boolean t = tf.getText() == null || tf.getText().length() == 0;
hintButton.setVisible(!t);
hintLabel.setVisible(t);
}
focusLostImpl();
}
};
tf.addFocusListener(fl);
}

private void focusGainedImpl() {
if(isInitialized()) {
if(!hintButton.isVisible()) {
hintButton.setVisible(true);
if(getComponentForm().grabAnimationLock()) {
morphAndWait(hintLabel, hintButton, 150);
getComponentForm().releaseAnimationLock();
}
hintLabel.setVisible(false);
tf.getComponentForm().revalidate();
tf.setEditable(true);
tf.startEditingAsync();
} else {
tf.setEditable(true);
tf.startEditingAsync();
}
} else {
boolean t = tf.getText() == null || tf.getText().length() == 0;
hintButton.setVisible(t);
hintLabel.setVisible(!t);
revalidate();
}
}

private void focusLostImpl() {
if(isInitialized()) {
if(tf.getText().length() == 0) {
hintLabel.setVisible(true);
if(getComponentForm().grabAnimationLock()) {
morphAndWait(hintButton, hintLabel, 150);
getComponentForm().releaseAnimationLock();
}
hintButton.setVisible(false);
tf.getComponentForm().revalidate();
revalidate();
tf.setEditable(false);
}
} else {
boolean t = tf.getText() == null || tf.getText().length() == 0;
hintButton.setVisible(!t);
hintLabel.setVisible(t);
revalidate();
}
}

@Override
protected void initComponent() {
super.initComponent();
if (tf.hasFocus()) {
focusGainedImpl();
}

}




}
4 changes: 0 additions & 4 deletions CodenameOne/src/com/codename1/components/ScaleImageLabel.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public ScaleImageLabel() {
setUIID("Label");
setShowEvenIfBlank(true);
getAllStyles().setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FIT);
getAllStyles().setBgTransparency(255);
}

/**
Expand All @@ -62,7 +61,6 @@ public ScaleImageLabel(Image i) {
setUIID("Label");
setShowEvenIfBlank(true);
getAllStyles().setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FIT);
getAllStyles().setBgTransparency(255);
setIcon(i);
}

Expand Down Expand Up @@ -172,7 +170,6 @@ public void setUIID(String id) {
super.setUIID(id);
setIcon(icon);
getAllStyles().setBackgroundType(type);
getAllStyles().setBgTransparency(255);
}

@Override
Expand All @@ -182,7 +179,6 @@ protected void refreshTheme(String id, boolean merge) {
super.refreshTheme(id, merge);
setIcon(icon);
getAllStyles().setBackgroundType(type);
getAllStyles().setBgTransparency(255);
}

/**
Expand Down
Loading