diff --git a/xwords4/android/XWords4/res/layout/board.xml b/xwords4/android/XWords4/res/layout/board.xml
index 1317c2c5e..a5207e78c 100644
--- a/xwords4/android/XWords4/res/layout/board.xml
+++ b/xwords4/android/XWords4/res/layout/board.xml
@@ -21,7 +21,8 @@
android:longClickable="true"
android:drawSelectorOnTop="false"/>
-
@@ -37,18 +38,19 @@
-
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
index 900bbf2f1..d8d581370 100644
--- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java
@@ -66,6 +66,7 @@ public class BoardActivity extends Activity implements UtilCtxt {
private TimerRunnable[] m_timers;
private String m_path;
private int m_currentOrient;
+ private Toolbar m_toolbar;
private String m_dlgBytes = null;
private EditText m_passwdEdit = null;
@@ -346,6 +347,11 @@ public class BoardActivity extends Activity implements UtilCtxt {
public void onConfigurationChanged( Configuration newConfig )
{
m_currentOrient = newConfig.orientation;
+ if ( null != m_toolbar ) {
+ boolean landscape =
+ m_currentOrient == Configuration.ORIENTATION_LANDSCAPE;
+ m_toolbar.orientChanged( landscape );
+ }
super.onConfigurationChanged( newConfig );
}
@@ -694,6 +700,15 @@ public class BoardActivity extends Activity implements UtilCtxt {
m_jniThread.handle( JNICmd.CMD_START );
setTitle( GameUtils.gameName( this, m_path ) );
+ m_toolbar =
+ new Toolbar( m_jniThread,
+ findViewById( R.id.toolbar_horizontal ),
+ findViewById( R.id.toolbar_vertical ) );
+
+ boolean isLandscape =
+ getResources().getConfiguration().orientation
+ == Configuration.ORIENTATION_LANDSCAPE;
+ m_toolbar.orientChanged( isLandscape );
}
}
} // loadGame
diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Toolbar.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Toolbar.java
new file mode 100644
index 000000000..a68ee510b
--- /dev/null
+++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Toolbar.java
@@ -0,0 +1,67 @@
+/* -*- compile-command: "cd ../../../../../; ant install"; -*- */
+/*
+ * Copyright 2009-2010 by Eric House (xwords@eehouse.org). All
+ * rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+package org.eehouse.android.xw4;
+
+import android.view.View;
+
+import org.eehouse.android.xw4.jni.*;
+
+public class Toolbar {
+
+ private View m_horLayout;
+ private View m_vertLayout;
+ private JNIThread m_jniThread;
+
+ private enum ORIENTATION { ORIENT_UNKNOWN,
+ ORIENT_PORTRAIT,
+ ORIENT_LANDSCAPE,
+ };
+ private ORIENTATION m_curOrient = ORIENTATION.ORIENT_UNKNOWN;
+
+ public Toolbar( JNIThread jniThread, View horLayout,
+ View vertLayout )
+ {
+ m_jniThread = jniThread;
+ m_horLayout = horLayout;
+ m_vertLayout = vertLayout;
+ }
+
+ 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 {
+ if ( landscape ) {
+ m_curOrient = ORIENTATION.ORIENT_LANDSCAPE;
+ m_horLayout.setVisibility( View.GONE );
+ m_vertLayout.setVisibility( View.VISIBLE );
+ } else {
+ m_curOrient = ORIENTATION.ORIENT_PORTRAIT;
+ m_horLayout.setVisibility( View.VISIBLE );
+ m_vertLayout.setVisibility( View.GONE );
+ }
+ }
+ }
+
+}