Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@
TiC.PROPERTY_TRANSITION_NAME,
TiC.PROPERTY_HIDDEN_BEHAVIOR,
TiC.PROPERTY_ANCHOR_POINT,
TiC.PROPERTY_ACCESSIBILITY_DISABLE_LONG
TiC.PROPERTY_ACCESSIBILITY_DISABLE_LONG,
TiC.PROPERTY_CLIP_MODE
})
public abstract class TiViewProxy extends KrollProxy
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;

import ti.modules.titanium.ui.UIModule;

/**
* This class is for Titanium View implementations, that correspond with TiViewProxy.
* A TiUIView is responsible for creating and maintaining a native Android View instance.
Expand Down Expand Up @@ -974,6 +976,10 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
} else {
Log.w(TAG, "Setting the 'viewShadowColor' property requires Android P or later");
}
} else if (key.equals(TiC.PROPERTY_CLIP_MODE)) {
if (nativeView != null) {
setClipMode(TiConvert.toInt(newValue));
}
} else if (Log.isDebugModeEnabled()) {
Log.d(TAG, "Unhandled property key: " + key, Log.DEBUG_MODE);
}
Expand Down Expand Up @@ -1142,13 +1148,7 @@ public void processProperties(KrollDict d)
}

if (d.containsKey(TiC.PROPERTY_CLIP_MODE) && !nativeViewNull) {
if (nativeView != null
&& TiConvert.toInt(d, TiC.PROPERTY_CLIP_MODE) == -1
&& nativeView instanceof ViewGroup viewGroup
&& viewGroup.getParent() == null) {
viewGroup.setClipChildren(false);
viewGroup.setClipToPadding(false);
}
setClipMode(TiConvert.toInt(d, TiC.PROPERTY_CLIP_MODE));
}

if (!nativeViewNull && d.containsKeyAndNotNull(TiC.PROPERTY_TRANSITION_NAME)) {
Expand Down Expand Up @@ -1207,6 +1207,21 @@ private void applyCustomBackground(boolean reuseCurrentDrawable)
}
}

private void setClipMode(int clipMode)
{

if (nativeView instanceof ViewGroup viewGroup) {
if (clipMode == UIModule.CLIP_MODE_DISABLED) {
viewGroup.setClipChildren(false);
viewGroup.setClipToPadding(false);
} else {
viewGroup.setClipChildren(true);
viewGroup.setClipToPadding(true);
}
viewGroup.invalidate();
}
}

/**
* @param props View's property dictionary
* @return true if touch feedback can be applied.
Expand Down
Loading