Skip to content
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

[TIMOB-23974] Android: Add property to release space when hiding an object #8458

Merged
merged 3 commits into from
Oct 6, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions android/titanium/src/java/org/appcelerator/titanium/TiC.java
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,11 @@ public class TiC
*/
public static final String PROPERTY_FRAGMENT_ONLY = "fragmentOnly";

/**
* @module.api
*/
public static final String PROPERTY_FREE_SPACE = "freeSpace";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the property-name. What about a more "boolean-like" property, e.g. showSpaceWhenHidden or truncateSpace? Or even expose the used constant directly and introduce a hiddenBahavior property. That keeps it more flexible, allows more configuration and sounds more native. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! I'll go for hiddenBehaviour: Ti.UI.VIEW_GONE | Ti.UI.VIEW_INVISIBLE
Then it looks almost like the native View.GONE and View.INVISIBLE


/**
* @module.api
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"softKeyboardOnFocus", "transform", "elevation", "touchTestId",
"translationX", "translationY", "translationZ", "rotation", "rotationX", "rotationY", "scaleX", "scaleY",

TiC.PROPERTY_TOUCH_FEEDBACK, TiC.PROPERTY_TOUCH_FEEDBACK_COLOR, TiC.PROPERTY_TRANSITION_NAME
TiC.PROPERTY_TOUCH_FEEDBACK, TiC.PROPERTY_TOUCH_FEEDBACK_COLOR, TiC.PROPERTY_TRANSITION_NAME,
TiC.PROPERTY_FREE_SPACE
})
public abstract class TiViewProxy extends KrollProxy implements Handler.Callback
{
Expand Down Expand Up @@ -118,6 +119,7 @@ public TiViewProxy()
defaultValues.put(TiC.PROPERTY_BACKGROUND_REPEAT, false);
defaultValues.put(TiC.PROPERTY_VISIBLE, true);
defaultValues.put(TiC.PROPERTY_ENABLED, true);
defaultValues.put(TiC.PROPERTY_FREE_SPACE, false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public abstract class TiUIView

//to maintain sync visibility between borderview and view. Default is visible
private int visibility = View.VISIBLE;
private boolean freeSpace = false;

protected GestureDetector detector = null;

Expand Down Expand Up @@ -941,6 +942,8 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
if (getOuterView() != null) {
ViewCompat.setRotationY(getOuterView(), TiConvert.toFloat(newValue));
}
} else if (key.equals(TiC.PROPERTY_FREE_SPACE)) {
freeSpace = TiConvert.toBoolean(newValue);
} else if (Log.isDebugModeEnabled()) {
Log.d(TAG, "Unhandled property key: " + key, Log.DEBUG_MODE);
}
Expand Down Expand Up @@ -997,6 +1000,9 @@ public void processProperties(KrollDict d)
}
}

if (d.containsKey(TiC.PROPERTY_FREE_SPACE) && !nativeViewNull) {
freeSpace = TiConvert.toBoolean(d, TiC.PROPERTY_FREE_SPACE, false);
}
if (d.containsKey(TiC.PROPERTY_VISIBLE) && !nativeViewNull) {
Object visible = d.get(TiC.PROPERTY_VISIBLE);
if (visible != null) {
Expand Down Expand Up @@ -1229,6 +1235,9 @@ public void release()

private void setVisibility(int visibility)
{
if (freeSpace && visibility == View.INVISIBLE) {
visibility = View.GONE;
}
this.visibility = visibility;
if (borderView != null) {
borderView.setVisibility(this.visibility);
Expand Down
11 changes: 11 additions & 0 deletions apidoc/Titanium/UI/View.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,17 @@ properties:
type: Boolean
default: false
platforms: [android]

- name: freeSpace
summary: Releases the space when hiding an object
description: |
If setting `freeSpace` to true it will automatically release the space the view occupied.
For example: in a vertical layout the views below the object will move up when you hide
an object with `freeSpace:true`.
type: Boolean
default: false
platforms: [android]
since: 6.0.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6.0.0 is already in QE-testing, please set it to 6.1.0 and we'll try to review it in that timeframe. Thx!


- name: height
summary: View height, in platform-specific units.
Expand Down