Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
shai-almog committed Mar 7, 2018
2 parents 1ad1a3c + 0d49314 commit fffd7b4
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 20 deletions.
29 changes: 12 additions & 17 deletions CodenameOne/src/com/codename1/ui/AutoCompleteTextField.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ protected void updateFilterList() {
popup.setVisible(v);
popup.setEnabled(v);
f.repaint();
}
}
if(f != null) {
dontCalcSize = false;
f.revalidate();
Expand Down Expand Up @@ -217,23 +217,18 @@ private boolean filterImpl(String text) {
popup.getComponentAt(0).setScrollY(0);
popup.setVisible(v);
popup.setEnabled(v);
Form f = getComponentForm();
if(f != null) {
if(popup.getHeight() < f.getContentPane().getHeight()/2){
int popupHeight = calcPopuupHeight((List)popup.getComponentAt(0));
popup.setHeight(popupHeight);
dontCalcSize = false;
popup.forceRevalidate();
dontCalcSize = true;
f.repaint();
}
}
}
Form f = getComponentForm();

if(!v) {
if(f != null) {
f.repaint();
}
}
if (popup.getComponentCount() > 0) {
int popupHeight = calcPopuupHeight((List)popup.getComponentAt(0));
popup.setHeight(popupHeight);
dontCalcSize = false;
popup.forceRevalidate();
dontCalcSize = true;
}
if (f != null) {
f.repaint();
}
}
return res;
Expand Down
2 changes: 2 additions & 0 deletions CodenameOne/src/com/codename1/ui/SwipeableContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ public void actionPerformed(ActionEvent evt) {
if (topX > 0) {
if (topX > bottomLeftW / 2) {
open = false;
openedToRight = false;
openToRight();
} else {
open = true;
Expand All @@ -417,6 +418,7 @@ public void actionPerformed(ActionEvent evt) {
} else {
if (topX + topWrapper.getWidth() < bottomRightX + bottomRightW / 2) {
open = false;
openedToLeft = false;
openToLeft();
} else {
open = true;
Expand Down
18 changes: 16 additions & 2 deletions Ports/Android/src/com/codename1/impl/android/InPlaceEditView.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.FrameLayout;
import com.codename1.ui.Accessor;

import com.codename1.ui.Component;
import com.codename1.ui.Container;
Expand Down Expand Up @@ -1506,7 +1507,20 @@ public static void edit(final AndroidImplementation impl, final Component compon
if (mIsEditing) {

if (impl.isAsyncEditMode()) {
isEditedFieldSwitch = true;
// Using isEditedFieldSwitch was causing issues with cursors not showing up.
// https://github.com/codenameone/CodenameOne/issues/2353
// https://stackoverflow.com/questions/49004370/focus-behaviour-in-textarea-in-cn1
// Disabling this feature by default now, but can be re-enabled by setting
// Display.getInstance().setProperty("android.reuseTextEditorOnSwitch", "true");
// This editedFieldSwitch feature was added a while back to improve experience on older
// Android devices where the field switching was going too slow.
// https://github.com/codenameone/CodenameOne/issues/2012
// This issue was resolved in this commit (https://github.com/jaanushansen/CodenameOne/commit/f3e53a80704149e4d7cde276d01c1368bcdcfe2c)
// which was submitted as part of a pull request. This fix has been the source of several
// regressions, mostly related to properties not being propagated properly when a text field is changed
// However, this issue (with the cursor not showing up), doesn't appear to have a simple solution
// so, I'm disabling this feature for now.
isEditedFieldSwitch = "true".equals(Display.getInstance().getProperty("android.reuseTextEditorOnSwitch", "false"));
final String[] out = new String[1];
TextArea prevTextArea = null;
if(sInstance != null && sInstance.mLastEditText != null) {
Expand Down Expand Up @@ -1726,7 +1740,7 @@ private static boolean isScrollableParent(Component c){
float pixelSize = f == null ? Display.getInstance().convertToPixels(4) : f.getPixelSize();
while( p != null){

if(p.isScrollableY() && p.getAbsoluteY() + p.getScrollY() < Display.getInstance().getDisplayHeight() / 2 - pixelSize * 2){
if(Accessor.scrollableYFlag(p) && p.getAbsoluteY() + p.getScrollY() < Display.getInstance().getDisplayHeight() / 2 - pixelSize * 2){
return true;
}
p = p.getParent();
Expand Down
3 changes: 3 additions & 0 deletions Ports/Android/src/com/codename1/ui/Accessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ public class Accessor {
public static Object getNativeGraphics(Graphics g) {
return g.getGraphics();
}
public static boolean scrollableYFlag(Container c) {
return c.scrollableYFlag();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ public void run() {
// async editing viable. We start with half-way down the screen.
int keyboardClippingThresholdY = Display.getInstance().getDisplayWidth() / 2;
while(p != null) {
if(p.isScrollableY() && p.getAbsoluteY() < keyboardClippingThresholdY) {
if(Accessor.scrollableYFlag(p) && p.getAbsoluteY() < keyboardClippingThresholdY) {
break;
}
p = p.getParent();
Expand Down
4 changes: 4 additions & 0 deletions Ports/iOSPort/src/com/codename1/ui/Accessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ public static Object getNativeGraphics(Graphics g) {
public static boolean isPaintPeersBehindEnabled(Graphics g) {
return g.paintPeersBehind;
}

public static boolean scrollableYFlag(Container cnt) {
return cnt.scrollableYFlag();
}
}

0 comments on commit fffd7b4

Please sign in to comment.