Skip to content

Commit

Permalink
feat(android): add separate lock mode for left and right drawers (#11271
Browse files Browse the repository at this point in the history
)

Fixes TIMOB-25556
  • Loading branch information
drauggres committed Nov 9, 2020
1 parent 77e5d44 commit e51c84b
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,48 @@ public void setDrawerLockMode(Object arg)
setPropertyAndFire(TiC.PROPERTY_DRAWER_LOCK_MODE, arg);
}

// clang-format off
@Kroll.method
@Kroll.getProperty
public int getLeftDrawerLockMode()
// clang-format on
{
if (hasProperty(TiC.PROPERTY_LEFT_DRAWER_LOCK_MODE)) {
return (Integer) getProperty(TiC.PROPERTY_LEFT_DRAWER_LOCK_MODE);
}
return LOCK_MODE_UNDEFINED;
}

// clang-format off
@Kroll.method
@Kroll.setProperty
public void setLeftDrawerLockMode(Object arg)
// clang-format on
{
setPropertyAndFire(TiC.PROPERTY_LEFT_DRAWER_LOCK_MODE, arg);
}

// clang-format off
@Kroll.method
@Kroll.getProperty
public int getRightDrawerLockMode()
// clang-format on
{
if (hasProperty(TiC.PROPERTY_RIGHT_DRAWER_LOCK_MODE)) {
return (Integer) getProperty(TiC.PROPERTY_RIGHT_DRAWER_LOCK_MODE);
}
return LOCK_MODE_UNDEFINED;
}

// clang-format off
@Kroll.method
@Kroll.setProperty
public void setRightDrawerLockMode(Object arg)
// clang-format on
{
setPropertyAndFire(TiC.PROPERTY_RIGHT_DRAWER_LOCK_MODE, arg);
}

@Kroll.method
public void interceptTouchEvent(TiViewProxy view, Boolean disallowIntercept)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,12 @@ public void processProperties(KrollDict d)
if (d.containsKey(TiC.PROPERTY_DRAWER_LOCK_MODE)) {
layout.setDrawerLockMode(TiConvert.toInt(d.get(TiC.PROPERTY_DRAWER_LOCK_MODE)));
}
if (d.containsKey(TiC.PROPERTY_LEFT_DRAWER_LOCK_MODE)) {
layout.setDrawerLockMode(TiConvert.toInt(d.get(TiC.PROPERTY_LEFT_DRAWER_LOCK_MODE)), Gravity.START);
}
if (d.containsKey(TiC.PROPERTY_RIGHT_DRAWER_LOCK_MODE)) {
layout.setDrawerLockMode(TiConvert.toInt(d.get(TiC.PROPERTY_RIGHT_DRAWER_LOCK_MODE)), Gravity.END);
}
// If theme has default ActionBar ignore `toolbarEnabled` and `toolbar` properties
if (!this.themeHasActionBar) {
if (d.containsKey(TiC.PROPERTY_TOOLBAR_ENABLED)) {
Expand Down Expand Up @@ -537,7 +543,10 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP

} else if (key.equals(TiC.PROPERTY_DRAWER_LOCK_MODE)) {
layout.setDrawerLockMode(TiConvert.toInt(newValue));

} else if (key.equals(TiC.PROPERTY_LEFT_DRAWER_LOCK_MODE)) {
layout.setDrawerLockMode(TiConvert.toInt(newValue), Gravity.START);
} else if (key.equals(TiC.PROPERTY_RIGHT_DRAWER_LOCK_MODE)) {
layout.setDrawerLockMode(TiConvert.toInt(newValue), Gravity.END);
} else if (key.equals(TiC.PROPERTY_DRAWER_INDICATOR_ENABLED)) {
if (drawerToggle != null) {
drawerToggle.setDrawerIndicatorEnabled((Boolean) newValue);
Expand Down Expand Up @@ -609,4 +618,4 @@ private View getNativeView(TiViewProxy viewProxy)
}
return nativeView;
}
}
}
10 changes: 10 additions & 0 deletions android/titanium/src/java/org/appcelerator/titanium/TiC.java
Original file line number Diff line number Diff line change
Expand Up @@ -2104,6 +2104,11 @@ public class TiC
*/
public static final String PROPERTY_LAYOUT_ID = "layoutId";

/**
* @module.api
*/
public static final String PROPERTY_LEFT_DRAWER_LOCK_MODE = "leftDrawerLockMode";

/**
* @module.api
*/
Expand Down Expand Up @@ -2783,6 +2788,11 @@ public class TiC
*/
public static final String PROPERTY_RIGHT_BUTTON = "rightButton";

/**
* @module.api
*/
public static final String PROPERTY_RIGHT_DRAWER_LOCK_MODE = "rightDrawerLockMode";

/**
* @module.api
*/
Expand Down
14 changes: 14 additions & 0 deletions apidoc/Titanium/UI/Android/DrawerLayout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ properties:
constants: Titanium.UI.Android.DrawerLayout.LOCK_MODE_*
default: <Titanium.UI.Android.DrawerLayout.LOCK_MODE_UNDEFINED>

- name: leftDrawerLockMode
summary: Get or set lock mode for the left drawer
type: Number
constants: Titanium.UI.Android.DrawerLayout.LOCK_MODE_*
default: <Titanium.UI.Android.DrawerLayout.LOCK_MODE_UNDEFINED>
since: "9.3.0"

- name: rightDrawerLockMode
summary: Get or set lock mode for the right drawer
type: Number
constants: Titanium.UI.Android.DrawerLayout.LOCK_MODE_*
default: <Titanium.UI.Android.DrawerLayout.LOCK_MODE_UNDEFINED>
since: "9.3.0"

- name: toolbarEnabled
summary: Determine whether to enable the toolbar.
description: |
Expand Down

0 comments on commit e51c84b

Please sign in to comment.