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

feat(android): add separate lock mode for left and right drawers #11271

Merged
merged 5 commits into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
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