mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-08 05:24:39 +01:00
fix long-tap menus in dual-pane mode
The DualpaneDelegate needed to handle (delegate) the necessary methods.
This commit is contained in:
parent
2105c43987
commit
cfbd06927a
3 changed files with 62 additions and 3 deletions
|
@ -89,9 +89,9 @@ public class DelegateBase implements DlgClickNotify,
|
|||
protected void onSaveInstanceState( Bundle outState ) {}
|
||||
public boolean onPrepareOptionsMenu( Menu menu ) { return false; }
|
||||
public boolean onOptionsItemSelected( MenuItem item ) { return false; }
|
||||
public void onCreateContextMenu( ContextMenu menu, View view,
|
||||
ContextMenuInfo menuInfo ) {}
|
||||
public boolean onContextItemSelected( MenuItem item ) { return false; }
|
||||
protected void onCreateContextMenu( ContextMenu menu, View view,
|
||||
ContextMenuInfo menuInfo ) {}
|
||||
protected boolean onContextItemSelected( MenuItem item ) { return false; }
|
||||
protected void onStop() {}
|
||||
protected void onDestroy() {}
|
||||
protected void onWindowFocusChanged( boolean hasFocus ) {}
|
||||
|
|
|
@ -24,6 +24,10 @@ import android.app.Activity;
|
|||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
public class DualpaneDelegate extends DelegateBase {
|
||||
private Activity m_activity;
|
||||
|
@ -75,4 +79,20 @@ public class DualpaneDelegate extends DelegateBase {
|
|||
MainActivity main = (MainActivity)m_activity;
|
||||
main.dispatchOnActivityResult( requestCode, resultCode, data );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreateContextMenu( ContextMenu menu, View view,
|
||||
ContextMenuInfo menuInfo )
|
||||
{
|
||||
MainActivity main = (MainActivity)m_activity;
|
||||
main.dispatchOnCreateContextMenu( menu, view, menuInfo );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onContextItemSelected( MenuItem item )
|
||||
{
|
||||
MainActivity main = (MainActivity)m_activity;
|
||||
return main.dispatchOnContextItemSelected( item );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,6 +34,9 @@ import android.support.v4.app.FragmentActivity;
|
|||
import android.support.v4.app.FragmentManager.BackStackEntry;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
|
@ -204,6 +207,28 @@ public class MainActivity extends XWActivity
|
|||
}
|
||||
}
|
||||
|
||||
protected void dispatchOnCreateContextMenu( ContextMenu menu, View view,
|
||||
ContextMenuInfo menuInfo )
|
||||
{
|
||||
XWFragment[] frags = getVisibleFragments();
|
||||
for ( XWFragment frag : frags ) {
|
||||
frag.getDelegate().onCreateContextMenu( menu, view, menuInfo );
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean dispatchOnContextItemSelected( MenuItem item )
|
||||
{
|
||||
boolean handled = false;
|
||||
XWFragment[] frags = getVisibleFragments();
|
||||
for ( XWFragment frag : frags ) {
|
||||
handled = frag.getDelegate().onContextItemSelected( item );
|
||||
if ( handled ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
protected Point getFragmentSize()
|
||||
{
|
||||
Rect rect = new Rect();
|
||||
|
@ -324,6 +349,20 @@ public class MainActivity extends XWActivity
|
|||
return frag;
|
||||
}
|
||||
|
||||
private XWFragment[] getVisibleFragments()
|
||||
{
|
||||
int childCount = m_root.getChildCount();
|
||||
int count = Math.min( m_maxPanes, childCount );
|
||||
XWFragment[] result = new XWFragment[count];
|
||||
for ( int ii = 0; ii < count; ++ii ) {
|
||||
View child = m_root.getChildAt( childCount - 1 - ii );
|
||||
result[ii] = (XWFragment)getSupportFragmentManager()
|
||||
.findFragmentById( child.getId() );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Walk all Fragment children and if they care notify of change.
|
||||
private void tellOrientationChanged()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue