-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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-17964] Android 5.0: Add support for Toolbar #9147
Changes from 5 commits
e7027e8
e85d4c2
3ce34d8
568b463
f47b07b
125d5d1
bd93828
9ccebb2
0b5f7b2
bdb1b50
310795a
4c7aa90
71fb43e
bde9fce
90abe32
0b0ac4b
05229b4
0254123
c69fea1
05f614c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package ti.modules.titanium.filesystem; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this should go in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That will create a circular dependency between 'titanium' and 'titanium-filesystem' modules. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the "ResourceHelper.java" file really needed? In all the places you call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's way better. I didn't realize I could use it. |
||
|
||
import org.appcelerator.kroll.KrollProxy; | ||
import org.appcelerator.titanium.view.TiDrawableReference; | ||
|
||
public class ResourceHelper { | ||
|
||
private ResourceHelper() { | ||
instance = new ResourceHelper(); | ||
} | ||
|
||
public static ResourceHelper getInstance() { | ||
return instance; | ||
} | ||
|
||
private static ResourceHelper instance; | ||
|
||
public static TiDrawableReference makeImageSource(KrollProxy proxy, Object object) | ||
{ | ||
if (object instanceof FileProxy) { | ||
return TiDrawableReference.fromFile(proxy.getActivity(), ((FileProxy) object).getBaseFile()); | ||
} else if (object instanceof String) { | ||
return TiDrawableReference.fromUrl(proxy, (String) object); | ||
} else { | ||
return TiDrawableReference.fromObject(proxy.getActivity(), object); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,212 @@ | ||
package ti.modules.titanium.ui; | ||
|
||
import android.app.Activity; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.View; | ||
import org.appcelerator.kroll.annotations.Kroll; | ||
import org.appcelerator.titanium.TiC; | ||
import org.appcelerator.titanium.proxy.TiToolbarProxy; | ||
import org.appcelerator.titanium.view.TiUIView; | ||
import ti.modules.titanium.ui.android.AndroidModule; | ||
import ti.modules.titanium.ui.widget.TiToolbar; | ||
|
||
@Kroll.proxy(creatableInModule=AndroidModule.class, propertyAccessors = { | ||
TiC.PROPERTY_BAR_COLOR, | ||
TiC.PROPERTY_EXTEND_BACKGROUND, | ||
TiC.PROPERTY_ITEMS, | ||
TiC.PROPERTY_TRANSLUCENT, | ||
}) | ||
public class ToolbarProxy extends TiToolbarProxy { | ||
|
||
private static final java.lang.String TAG = "Toolbar"; | ||
|
||
public View getToolbarInstance() { | ||
return getTiToolbarView().getNativeView(); | ||
} | ||
|
||
private TiToolbar getTiToolbarView() { | ||
return ((TiToolbar) getOrCreateView()); | ||
} | ||
|
||
@Override | ||
public TiUIView createView(Activity activity) { | ||
return new TiToolbar(this); | ||
} | ||
|
||
//region Android only methods | ||
@Kroll.method | ||
public void collapseActionView() { | ||
getTiToolbarView().collapseActionView(); | ||
} | ||
|
||
@Kroll.method | ||
public void dismissPopupMenus() { | ||
getTiToolbarView().dismissPopupMenus(); | ||
} | ||
|
||
@Kroll.method | ||
public int getContentInsetEnd() { | ||
//Gets the ending content inset for this toolbar. | ||
return ((Toolbar) getTiToolbarView().getNativeView()).getContentInsetEnd(); | ||
} | ||
|
||
@Kroll.method | ||
public int getContentInsetEndWithActions() { | ||
//Gets the end content inset to use when action buttons are present. | ||
return ((Toolbar) getTiToolbarView().getNativeView()).getContentInsetEndWithActions(); | ||
} | ||
|
||
@Kroll.method | ||
public int getContentInsetLeft() { | ||
//Gets the left content inset for this toolbar. | ||
return ((Toolbar) getTiToolbarView().getNativeView()).getContentInsetLeft(); | ||
} | ||
|
||
@Kroll.method | ||
public int getContentInsetRight() { | ||
//Gets the right content inset for this toolbar. | ||
return ((Toolbar) getTiToolbarView().getNativeView()).getContentInsetRight(); | ||
} | ||
|
||
@Kroll.method | ||
public int getContentInsetStart() { | ||
//Gets the starting content inset for this toolbar. | ||
return ((Toolbar) getTiToolbarView().getNativeView()).getContentInsetStart(); | ||
} | ||
|
||
@Kroll.method | ||
public int getContentInsetStartWithNavigation() { | ||
//Gets the start content inset to use when a navigation button is present. | ||
return ((Toolbar) getTiToolbarView().getNativeView()).getContentInsetStartWithNavigation(); | ||
} | ||
|
||
@Kroll.method | ||
public int getCurrentContentInsetEnd() { | ||
//Gets the content inset that will be used on the ending side of the bar in the current toolbar configuration. | ||
return ((Toolbar) getTiToolbarView().getNativeView()).getCurrentContentInsetEnd(); | ||
} | ||
|
||
@Kroll.method | ||
public int getCurrentContentInsetLeft() { | ||
//Gets the content inset that will be used on the left side of the bar in the current toolbar configuration. | ||
return ((Toolbar) getTiToolbarView().getNativeView()).getCurrentContentInsetLeft(); | ||
} | ||
|
||
@Kroll.method | ||
public int getCurrentContentInsetRight() { | ||
//Gets the content inset that will be used on the right side of the bar in the current toolbar configuration. | ||
return ((Toolbar) getTiToolbarView().getNativeView()).getCurrentContentInsetRight(); | ||
} | ||
|
||
@Kroll.method | ||
public int getCurrentContentInsetStart() { | ||
//Gets the content inset that will be used on the starting side of the bar in the current toolbar configuration. | ||
return ((Toolbar) getTiToolbarView().getNativeView()).getCurrentContentInsetStart(); | ||
} | ||
|
||
@Kroll.method | ||
public Object getLogo() { | ||
return getTiToolbarView().getLogo(); | ||
} | ||
|
||
@Kroll.method | ||
public Object getNavigationIcon() { | ||
return getTiToolbarView().getNavigationIcon(); | ||
} | ||
|
||
@Kroll.method | ||
public Object getOverflowIcon() { | ||
return getTiToolbarView().getOverflowMenuIcon(); | ||
} | ||
|
||
@Kroll.method | ||
public String getSubtitle() { | ||
return ((Toolbar) getTiToolbarView().getNativeView()).getSubtitle().toString(); | ||
} | ||
|
||
@Kroll.method | ||
public String getTitle() { | ||
return ((Toolbar) getTiToolbarView().getNativeView()).getTitle().toString(); | ||
} | ||
|
||
@Kroll.method | ||
public boolean hasExpandedActionView() { | ||
return ((Toolbar) getTiToolbarView().getNativeView()).hasExpandedActionView(); | ||
} | ||
|
||
@Kroll.method | ||
public void hideOverflowMenu() { | ||
getTiToolbarView().hideOverFlowMenu(); | ||
} | ||
|
||
@Kroll.method | ||
public boolean isOverflowMenuShowing() { | ||
return ((Toolbar) getTiToolbarView().getNativeView()).isOverflowMenuShowing(); | ||
} | ||
|
||
@Kroll.method | ||
public void setLogo(Object object) { | ||
getTiToolbarView().setLogo(object); | ||
} | ||
|
||
@Kroll.method | ||
public void setNavigationIcon(String value) { | ||
getTiToolbarView().setNavigationIcon(value); | ||
} | ||
|
||
@Kroll.method | ||
public void setOverflowIcon(String value) { | ||
getTiToolbarView().setOverflowMenuIcon(value); | ||
} | ||
|
||
@Kroll.method | ||
public void setSubtitle(String value) { | ||
getTiToolbarView().setSubtitle(value); | ||
} | ||
|
||
@Kroll.method | ||
public void setSubtitleTextColor(String value) { | ||
getTiToolbarView().setSubtitleTextColor(value); | ||
} | ||
|
||
@Kroll.method | ||
public void setTitle(String value) { | ||
getTiToolbarView().setTitle(value); | ||
} | ||
|
||
@Kroll.method | ||
public void setTitleTextColor(String value) { | ||
getTiToolbarView().setTitleTextColor(value); | ||
} | ||
|
||
//Sets the start content inset to use when action buttons are present. | ||
@Kroll.method | ||
public void setContentInsetEndWithActions(int value) { | ||
getTiToolbarView().setContentInsetEndWithActions(value); | ||
} | ||
|
||
//Sets the start content inset to use when a navigation button is present. | ||
@Kroll.method | ||
public void setContentInsetStartWithNavigation(int value) { | ||
getTiToolbarView().setContentInsetStartWithNavigation(value); | ||
} | ||
|
||
//Sets the content insets for this toolbar. | ||
@Kroll.method | ||
public void setContentInsetsAbsolute(int insetLeft, int insetRight) { | ||
getTiToolbarView().setContentInsetsAbsolute(insetLeft,insetRight); | ||
} | ||
|
||
//Sets the content insets for this toolbar relative to layout direction. | ||
@Kroll.method | ||
public void setContentInsetsRelative(int insetStart, int insetEnd) { | ||
getTiToolbarView().setContentInsetsRelative(insetStart,insetEnd); | ||
} | ||
|
||
@Kroll.method | ||
public void showOverflowMenu() { | ||
getTiToolbarView().showOverFlowMenu(); | ||
} | ||
//endregion | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to always space your arguments
(this, picture)