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-15910] Android: Implement Ti.UI.Android.DrawerLayout #9091

Merged
merged 9 commits into from
Aug 23, 2017
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
28 changes: 28 additions & 0 deletions android/modules/ui/res/layout/titanium_ui_drawer_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
android:id="@+id/drawer_layout_container"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout_toolbar"
android:visibility="gone"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="#222299"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:elevation="4dp"/>

<org.appcelerator.titanium.view.TiCompositeLayout
android:layout_below="@id/drawer_layout_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
3 changes: 3 additions & 0 deletions android/modules/ui/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Titanium UI Module</string>

<string name="drawer_layout_open">Open</string>
<string name="drawer_layout_close">Close</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2017 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
package ti.modules.titanium.ui.android;

import ti.modules.titanium.ui.widget.TiUIDrawerLayout;

import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.view.TiUIView;

import android.app.Activity;
import android.os.Message;
import android.support.v4.widget.DrawerLayout;

@Kroll.proxy(creatableInModule = AndroidModule.class)
public class DrawerLayoutProxy extends TiViewProxy
{
@Kroll.constant public static final int LOCK_MODE_LOCKED_CLOSED = DrawerLayout.LOCK_MODE_LOCKED_CLOSED;
@Kroll.constant public static final int LOCK_MODE_LOCKED_OPEN = DrawerLayout.LOCK_MODE_LOCKED_OPEN;
@Kroll.constant public static final int LOCK_MODE_UNLOCKED = DrawerLayout.LOCK_MODE_UNLOCKED;

private static final String TAG = "DrawerLayoutProxy";

private TiUIDrawerLayout drawer;

public DrawerLayoutProxy() {
super();
}

@Override
public TiUIView createView(Activity activity) {
drawer = new TiUIDrawerLayout(this);
drawer.getLayoutParams().autoFillsHeight = true;
drawer.getLayoutParams().autoFillsWidth = true;
return drawer;
}

@Kroll.method(runOnUiThread=true)
public void toggleLeft() {
drawer.toggleLeft();
}

@Kroll.method(runOnUiThread=true)
public void openLeft() {
drawer.openLeft();
}

@Kroll.method(runOnUiThread=true)
public void closeLeft() {
drawer.closeLeft();
}

@Kroll.method(runOnUiThread=true)
public void toggleRight() {
drawer.toggleRight();
}

@Kroll.method(runOnUiThread=true)
public void openRight() {
drawer.openRight();
}

@Kroll.method(runOnUiThread=true)
public void closeRight() {
drawer.closeRight();
}

@Kroll.method
@Kroll.getProperty
public boolean getIsLeftOpen() {
return drawer.isLeftOpen();
}

@Kroll.method
@Kroll.getProperty
public boolean getIsRightOpen() {
return drawer.isRightOpen();
}

@Kroll.method
@Kroll.getProperty
public boolean getIsLeftVisible() {
return drawer.isLeftVisible();
}

@Kroll.method
@Kroll.getProperty
public boolean getIsRightVisible() {
return drawer.isRightVisible();
}

@Kroll.method
@Kroll.setProperty
public void setLeftWidth(Object arg) {
setPropertyAndFire(TiC.PROPERTY_LEFT_WIDTH, arg);
}

@Kroll.method
@Kroll.setProperty
public void setLeftView(Object arg) {
setPropertyAndFire(TiC.PROPERTY_LEFT_VIEW, arg);
}

@Kroll.method
@Kroll.setProperty
public void setRightWidth(Object arg) {
setPropertyAndFire(TiC.PROPERTY_RIGHT_WIDTH, arg);
}

@Kroll.method
@Kroll.setProperty
public void setRightView(Object arg) {
setPropertyAndFire(TiC.PROPERTY_RIGHT_VIEW, arg);
}

@Kroll.method
@Kroll.setProperty
public void setCenterView(Object arg) {
setPropertyAndFire(TiC.PROPERTY_CENTER_VIEW, arg);
}

@Kroll.method
@Kroll.setProperty
public void setDrawerIndicatorEnabled(Object arg) {
setPropertyAndFire(TiC.PROPERTY_DRAWER_INDICATOR_ENABLED, arg);
}

@Kroll.method
@Kroll.setProperty
public void setDrawerLockMode(Object arg) {
setPropertyAndFire(TiC.PROPERTY_DRAWER_LOCK_MODE, arg);
}

@Kroll.method
public void interceptTouchEvent (TiViewProxy view, Boolean disallowIntercept){
view.getOrCreateView().getOuterView().getParent().requestDisallowInterceptTouchEvent(disallowIntercept);
}

@Kroll.method
@Kroll.setProperty
public void setToolbarEnabled(Object arg) {
setPropertyAndFire(TiC.PROPERTY_TOOLBAR_ENABLED, arg);
}
}