remove layout and code allowing toolbar to be positioned in landscape

mode.
This commit is contained in:
Andy2 2011-03-12 04:15:57 -08:00
parent 257d7cf094
commit 58ff3189a0
3 changed files with 38 additions and 132 deletions

View file

@ -1,99 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:paddingTop="3dp"
android:layout_weight="1"
>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
>
<org.eehouse.android.xw4.BoardView
android:id="@+id/board_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:focusable="true"
android:clickable="true"
android:longClickable="true"
android:drawSelectorOnTop="false"/>
<org.eehouse.android.xw4.BoardView
android:id="@+id/board_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:focusable="true"
android:clickable="true"
android:longClickable="true"
android:drawSelectorOnTop="false"/>
<LinearLayout android:id="@+id/toolbar_horizontal"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<ImageButton android:id="@+id/prevhint_button_horizontal"
style="@style/toolbar_button"
android:src="@drawable/prev_hint"
/>
<ImageButton android:id="@+id/nexthint_button_horizontal"
style="@style/toolbar_button"
android:src="@drawable/next_hint"
/>
<ImageButton android:id="@+id/shuffle_button_horizontal"
style="@style/toolbar_button"
android:src="@drawable/shuffle"
/>
<ImageButton android:id="@+id/flip_button_horizontal"
style="@style/toolbar_button"
android:src="@drawable/flip"
/>
<ImageButton android:id="@+id/zoom_button_horizontal"
style="@style/toolbar_button"
android:src="@drawable/zoom"
/>
<ImageButton android:id="@+id/undo_button_horizontal"
style="@style/toolbar_button"
android:src="@drawable/undo"
/>
<ImageButton android:id="@+id/chat_button_horizontal"
style="@style/toolbar_button"
android:src="@drawable/stat_notify_chat"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout android:id="@+id/toolbar_vertical"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
<LinearLayout android:id="@+id/toolbar_horizontal"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<ImageButton android:id="@+id/prevhint_button_vertical"
<ImageButton android:id="@+id/prevhint_button_horizontal"
style="@style/toolbar_button"
android:src="@drawable/prev_hint"
/>
<ImageButton android:id="@+id/nexthint_button_vertical"
<ImageButton android:id="@+id/nexthint_button_horizontal"
style="@style/toolbar_button"
android:src="@drawable/next_hint"
/>
<ImageButton android:id="@+id/shuffle_button_vertical"
<ImageButton android:id="@+id/shuffle_button_horizontal"
style="@style/toolbar_button"
android:src="@drawable/shuffle"
/>
<ImageButton android:id="@+id/flip_button_vertical"
<ImageButton android:id="@+id/flip_button_horizontal"
style="@style/toolbar_button"
android:src="@drawable/flip"
/>
<ImageButton android:id="@+id/zoom_button_vertical"
<ImageButton android:id="@+id/zoom_button_horizontal"
style="@style/toolbar_button"
android:src="@drawable/zoom"
/>
<ImageButton android:id="@+id/undo_button_vertical"
<ImageButton android:id="@+id/undo_button_horizontal"
style="@style/toolbar_button"
android:src="@drawable/undo"
/>
<ImageButton android:id="@+id/chat_button_vertical"
<ImageButton android:id="@+id/chat_button_horizontal"
style="@style/toolbar_button"
android:src="@drawable/stat_notify_chat"
/>
</LinearLayout>
</LinearLayout>

View file

@ -1138,14 +1138,8 @@ public class BoardActivity extends XWActivity
if ( !CommonPrefs.getHideTitleBar( this ) ) {
setTitle( GameUtils.gameName( this, m_path ) );
}
m_toolbar =
new Toolbar( this, findViewById( R.id.toolbar_horizontal ),
findViewById( R.id.toolbar_vertical ) );
m_toolbar = new Toolbar( this );
boolean isLandscape =
getResources().getConfiguration().orientation
== Configuration.ORIENTATION_LANDSCAPE;
m_toolbar.orientChanged( isLandscape );
populateToolbar();
int flags = DBUtils.getMsgFlags( m_path );

View file

@ -27,19 +27,16 @@ import android.content.DialogInterface;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ImageButton;
//import android.view.LayoutInflater;
//import java.util.HashMap;
//import junit.framework.Assert;
import org.eehouse.android.xw4.jni.*;
public class Toolbar {
private static class TBButtonInfo {
public TBButtonInfo( int idHor, int idVert ) {
m_ids = new int[] { idHor, idVert };
public TBButtonInfo( int id/*, int idVert*/ ) {
m_id = id;
}
public int m_ids[];
public int m_id;
}
public static final int BUTTON_HINT_PREV = 0;
@ -52,31 +49,22 @@ public class Toolbar {
private static TBButtonInfo[] s_buttonInfo = {
// BUTTON_HINT_PREV
new TBButtonInfo(R.id.prevhint_button_horizontal,
R.id.prevhint_button_vertical),
new TBButtonInfo(R.id.prevhint_button_horizontal ),
// BUTTON_HINT_NEXT
new TBButtonInfo(R.id.nexthint_button_horizontal,
R.id.nexthint_button_vertical),
new TBButtonInfo(R.id.nexthint_button_horizontal ),
// BUTTON_FLIP
new TBButtonInfo(R.id.flip_button_horizontal,
R.id.flip_button_vertical),
new TBButtonInfo(R.id.flip_button_horizontal ),
// BUTTON_JUGGLE
new TBButtonInfo( R.id.shuffle_button_horizontal,
R.id.shuffle_button_vertical ),
new TBButtonInfo( R.id.shuffle_button_horizontal ),
// BUTTON_ZOOM
new TBButtonInfo( R.id.zoom_button_horizontal,
R.id.zoom_button_vertical ),
new TBButtonInfo( R.id.zoom_button_horizontal ),
// BUTTON_UNDO
new TBButtonInfo( R.id.undo_button_horizontal,
R.id.undo_button_vertical ),
new TBButtonInfo( R.id.undo_button_horizontal ),
// BUTTON_CHAT
new TBButtonInfo( R.id.chat_button_horizontal,
R.id.chat_button_vertical ),
new TBButtonInfo( R.id.chat_button_horizontal ),
};
private XWActivity m_activity;
private LinearLayout m_horLayout;
private LinearLayout m_vertLayout;
private enum ORIENTATION { ORIENT_UNKNOWN,
ORIENT_PORTRAIT,
@ -84,20 +72,16 @@ public class Toolbar {
};
private ORIENTATION m_curOrient = ORIENTATION.ORIENT_UNKNOWN;
public Toolbar( XWActivity activity, View horLayout, View vertLayout )
public Toolbar( XWActivity activity )
{
m_activity = activity;
m_horLayout = (LinearLayout)horLayout;
m_vertLayout = (LinearLayout)vertLayout;
}
public void setListener( int index, View.OnClickListener listener )
{
TBButtonInfo info = s_buttonInfo[index];
for ( int id : info.m_ids ) {
ImageButton button = (ImageButton)m_activity.findViewById( id );
button.setOnClickListener( listener );
}
ImageButton button = (ImageButton)m_activity.findViewById( info.m_id );
button.setOnClickListener( listener );
}
public void setListener( int index, final int msgID, final int prefsKey,
@ -111,39 +95,13 @@ public class Toolbar {
setListener( index, listener );
}
public void orientChanged( boolean landscape )
{
if ( landscape && m_curOrient == ORIENTATION.ORIENT_LANDSCAPE ) {
// do nothing
} else if ( !landscape && m_curOrient == ORIENTATION.ORIENT_PORTRAIT ) {
// do nothing
} else {
LinearLayout prevLayout, nextLayout;
if ( landscape ) {
m_curOrient = ORIENTATION.ORIENT_LANDSCAPE;
prevLayout = m_horLayout;
nextLayout = m_vertLayout;
} else {
m_curOrient = ORIENTATION.ORIENT_PORTRAIT;
prevLayout = m_vertLayout;
nextLayout = m_horLayout;
}
prevLayout.setVisibility( View.GONE );
nextLayout.setVisibility( View.VISIBLE );
}
}
public void update( int index, boolean enable )
{
TBButtonInfo info = s_buttonInfo[index];
int vis = enable ? View.VISIBLE : View.GONE;
ImageButton button;
for ( int id : info.m_ids ) {
button = (ImageButton)m_activity.findViewById( id );
button.setVisibility( vis );
}
ImageButton button = (ImageButton)m_activity.findViewById( info.m_id );
button.setVisibility( vis );
}
}