Skip to content

Commit

Permalink
Merge remote-tracking branch 'github_origin/ThreeThreeOne' into githu…
Browse files Browse the repository at this point in the history
…b_sandbox_threethreeone
  • Loading branch information
spiridon-alexandru committed Jun 27, 2013
2 parents b7c4744 + d3de3b7 commit 6214451
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ public void postWidgetItemClickedEvent(int widgetHandle, int position)
*/
public void postWidgetTabChangedEvent(int tabScreen, int newTabIndex)
{
// Save the current tab screen.
sMoSyncThread.setCurrentScreen(tabScreen);

postWidgetEvent(
IX_WIDGET.MAW_EVENT_TAB_CHANGED,
tabScreen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,22 @@ public void onCreate(Bundle savedInstanceState)
// Options Menu is enabled for devices prior to Honeycomb.
// ActionBar is disabled by default starting with Honeycomb, and can be
// enabled using maActionBarSetEnabled(true)
if ( Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB )
{
// Action bar will not be supported on pre-Honeycomb devices
requestWindowFeature(Window.FEATURE_NO_TITLE);
NativeUI.mActionBarEnabled = false;
}
else
{
requestWindowFeature(Window.FEATURE_ACTION_BAR);
NativeUI.mActionBarEnabled = true;
getActionBar().hide();
}

// This part will be needed when adding the Action-bar but please reevaluate all
// Action-bar related code and do proper testing.
//
// if ( Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB )
// {
// // Action bar will not be supported on pre-Honeycomb devices
// requestWindowFeature(Window.FEATURE_NO_TITLE);
// NativeUI.mActionBarEnabled = false;
// }
// else
// {
// requestWindowFeature(Window.FEATURE_ACTION_BAR);
// NativeUI.mActionBarEnabled = true;
// getActionBar().hide();
// }

// Create the view.
mMoSyncView = createMoSyncView();
Expand Down Expand Up @@ -393,8 +397,8 @@ public static int getScreenOrientation()
}
break;
case Configuration.ORIENTATION_LANDSCAPE:
if(mScreenRotation == android.view.Surface.ROTATION_0 ||
mScreenRotation == android.view.Surface.ROTATION_90)
if(mScreenRotation == Surface.ROTATION_0 ||
mScreenRotation == Surface.ROTATION_90)
{
screenOrientation = MA_SCREEN_ORIENTATION_LANDSCAPE_LEFT;
}
Expand Down Expand Up @@ -527,31 +531,20 @@ public boolean onCreateOptionsMenu(Menu menu) {
for (int i=0; i < items.size(); i++)
{
MenuItem item = menu.add ( 0, items.get(i).getId(), 0, items.get(i).getTitle() );
if (NativeUI.mActionBarEnabled)
item.setShowAsAction(items.get(i).getShowActionFlag());
if ( items.get(i).hasIconFromResources() )
// if (NativeUI.mActionBarEnabled)
// item.setShowAsAction(items.get(i).getShowActionFlag());
if ( items.get(i).hasPredefinedIcon() )
{
item.setIcon( items.get(i).getIconResId() );
item.setIcon( items.get(i).getPredefinedIconID() );
}
else
else if ( items.get(i).hasCustomIcon() )
{
item.setIcon( items.get(i).getIcon() );
item.setIcon( items.get(i).getCustomIcon() );
}
}
// return true;
}
else
Log.e("@@MoSync"," onCreateOptionsMenu screen is NULL");
//
// return super.onCreateOptionsMenu(menu);

// MenuItem item1 = menu.add(0, 1, 0, "btn");
// item1.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
// item1.setIcon(17301555);
//
// MenuItem item2 = menu.add(1,0,0,"t");
// item2.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
// item2.setIcon(17301583);

return super.onCreateOptionsMenu(menu);
}
Expand All @@ -565,16 +558,6 @@ public boolean onPrepareOptionsMenu(Menu menu)
{
Log.e("@@MoSync", "MoSync onPrepareOptionsMenu");

// MenuItem item1 = menu.add(0, 1, 0, "btn");
// item1.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
// item1.setIcon(17301555);
//
// MenuItem item2 = menu.add(1,0,0,"t");
// item2.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
// item2.setIcon(17301583);

// return super.onPrepareOptionsMenu(menu);

// // Remove all the items from the menu.
menu.clear();

Expand All @@ -591,27 +574,25 @@ public boolean onPrepareOptionsMenu(Menu menu)
{
MenuItem item = menu.add ( 0, items.get(i).getId(), 0, items.get(i).getTitle() );
// When enabled, use ActionBar items.
if (NativeUI.mActionBarEnabled)
{
item.setShowAsAction(items.get(i).getShowActionFlag());
}
// if (NativeUI.mActionBarEnabled)
// {
// item.setShowAsAction(items.get(i).getShowActionFlag());
// }

if ( items.get(i).hasIconFromResources() )
if ( items.get(i).hasPredefinedIcon() )
{
item.setIcon( items.get(i).getIconResId() );
item.setIcon( items.get(i).getPredefinedIconID() );
}
else if ( items.get(i).hasIconPredefined() )
else if ( items.get(i).hasCustomIcon() )
{
item.setIcon( items.get(i).getIcon() );
item.setIcon( items.get(i).getCustomIcon() );
}
}
// return true;
}
else
Log.e("@@MoSync"," onPrepareOptionsMenu screen is NULL");

return super.onPrepareOptionsMenu(menu);
// return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ else if ( m_currentScreen instanceof TabScreenWidget )
else if(m_currentScreen instanceof ScreenWidget )
return (ScreenWidget) m_currentScreen;

return null;//(ScreenWidget) m_currentScreen;
return null;
}

/**
Expand Down Expand Up @@ -763,7 +763,10 @@ public int maWidgetScreenAddOptionsMenuItem(
// Create a menu item with no icon if iconHandle is left null.
if ( TextUtils.isEmpty(iconHandle) )
{
return screen.addOptionsMenuItem(title, null);
int index = screen.addOptionsMenuItem(title, null);
mMoSyncThread.invalidateOptionsMenu(m_activity);
// When adding a new menu item the id is returned.
return index;
}

// Parse iconHandle to get the iconPredefinedId, or iconId.
Expand All @@ -786,12 +789,10 @@ public int maWidgetScreenAddOptionsMenuItem(
.parseInt(IX_WIDGET.MAW_OPTIONS_MENU_ICON_CONSTANT_ADD)
&& iconID <= Integer
.parseInt(IX_WIDGET.MAW_OPTIONS_MENU_ICON_CONSTANT_ZOOM))
//return screen.addMenuItem(title, iconID);
{
int index = screen.addOptionsMenuItem(title, iconID);

mMoSyncThread.invalidateOptionsMenu(m_activity);
//m_activity.onCreateOptionsMenu( screen.getMenu() );
// When adding a new menu item the id is returned.
return index;
}
else
Expand All @@ -809,8 +810,10 @@ public int maWidgetScreenAddOptionsMenuItem(
Bitmap icon = NativeUI.getBitmap( iconID );
if( icon != null )
{
int index = screen.addOptionsMenuItem(title, new BitmapDrawable(icon));
mMoSyncThread.invalidateOptionsMenu(m_activity);
// When adding a new menu item the id is returned.
return screen.addOptionsMenuItem(title, new BitmapDrawable(icon));
return index;
}
}
Log.e("@@MoSync","maWidgetScreenAddOptionsMenuItem: Invalid icon handle: " + iconHandle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.mosync.nativeui.ui.factories;

import android.app.Activity;
import android.util.Log;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;
Expand All @@ -27,6 +28,7 @@
import android.widget.TabWidget;

import com.mosync.internal.android.EventQueue;
import com.mosync.internal.android.MoSyncThread;
import com.mosync.nativeui.ui.widgets.TabScreenWidget;
import com.mosync.nativeui.ui.widgets.Widget;

Expand Down Expand Up @@ -137,6 +139,15 @@ public TabChangeListener(int tabScreenHandle)
@Override
public void onTabChanged(String tabTag)
{
MoSyncThread mosyncThread = MoSyncThread.getInstance();

// Save the current tab screen.
mosyncThread.setCurrentScreen(m_tabScreenHandle);

// Recreate options menu
Log.e("@@MoSync", "TabChangeListener onTabChanged invalidate options menu");
mosyncThread.invalidateOptionsMenu(mosyncThread.getActivity());

// Assumes that the tag of the tab is the same as it's handle.
EventQueue.getDefault( ).postWidgetTabChangedEvent(
m_tabScreenHandle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,14 @@ public class OptionsMenuItem
private String m_title = "";

/**
* Icon of this menu item.
* Custom icon of this menu item.
*/
private Drawable m_icon = null;
private Drawable m_customIcon = null;

/**
* If true, the icon is taken from resources.
* If false it is a user defined icon.
* The id of the predefined icon for this menu item.
*/
private Boolean m_iconResource = false;

/**
* The icon resource id.
*/
private int m_iconResID = -1;
private int m_predefinedIconID = -1;

/**
* The item id.
Expand All @@ -66,28 +60,32 @@ public class OptionsMenuItem
/**
* Constructor
*
* @param handle handle Integer handle corresponding to this instance.
* @param view A screen wrapped by this widget.
* @param handle Integer handle corresponding to this instance.
* @param title The text that will be displayed on the menu item.
* @param icon The icon that will be displayed on the menu item.
*/
public OptionsMenuItem(int handle, String title, Drawable icon ){
m_itemId = handle;
m_title = title;
m_icon = icon;
if ( icon != null )
{
m_customIcon = icon;
}
}

/**
* Constructor.
*
* @param handle handle Integer handle corresponding to this instance.
* @param iconRes The resource id of the icon. One of the
* @param handle Integer handle corresponding to this instance.
* @param title The text that will be displayed on the menu item.
* @param predefinedIconId The resource id of the predefined icon
* that will be displayed on this menu item. One of the
* MAW_OPTIONS_MENU_ICON_CONSTANT_ constants.
* @param view A screen wrapped by this widget.
*/
public OptionsMenuItem(int handle, String title, int iconRes){
public OptionsMenuItem(int handle, String title, int predefinedIconId){
m_itemId = handle;
m_title = title;
m_iconResource = true;
m_iconResID = iconRes;
m_predefinedIconID = predefinedIconId;
}

public void setShowAsAction(int flag)
Expand All @@ -100,14 +98,14 @@ public int getShowActionFlag()
return m_displayFlag;
}

public Boolean hasIconFromResources()
public Boolean hasCustomIcon()
{
return m_iconResource;
return (m_customIcon != null ? true : false);
}

public Boolean hasIconPredefined()
public Boolean hasPredefinedIcon()
{
return (m_iconResID != -1 ? true : false );
return (m_predefinedIconID != -1 ? true : false );
}

public String getTitle()
Expand All @@ -120,13 +118,13 @@ public int getId()
return m_itemId;
}

public Drawable getIcon()
public Drawable getCustomIcon()
{
return m_icon;
return m_customIcon;
}

public int getIconResId()
public int getPredefinedIconID()
{
return m_iconResID;
return m_predefinedIconID;
}
}

0 comments on commit 6214451

Please sign in to comment.