add preference controlling whether volume keys or a

ZoomButtonsController is used to support zooming.  Default is the more
discoverable ZoomButtonsController.
This commit is contained in:
eehouse 2010-04-15 03:34:03 +00:00
parent a9a4a99243
commit 95ddf7ddd4
5 changed files with 40 additions and 9 deletions

View file

@ -181,6 +181,7 @@
<string name="explain_robot">Explain robot moves</string>
<string name="skip_confirm_turn">Skip confirming turn</string>
<string name="hide_values">Hide values</string>
<string name="ringer_zoom">Volume keys zoom</string>
<string name="role_standalone">Standalone</string>
<string name="role_host">Host</string>
@ -280,6 +281,7 @@
<string name="key_explain_robot">key_explain_robot</string>
<string name="key_skip_confirm">key_skip_confirm</string>
<string name="key_hide_values">key_hide_values</string>
<string name="key_ringer_zoom">key_ringer_zoom</string>
<string name="key_player0">key_clr_player0</string>
<string name="key_player1">key_clr_player1</string>
<string name="key_player2">key_clr_player2</string>
@ -295,8 +297,5 @@
<string name="key_sms_port">key_sms_port</string>
<string name="key_dict_host">key_dict_host</string>
<string name="key_anti_alias">key_anti_alias</string>
<string name="key_subpixel">key_subpixel</string>
<string name="default_host">eehouse.org</string>
</resources>

View file

@ -29,6 +29,11 @@
android:title="@string/hide_values"
android:defaultValue="false"
/>
<CheckBoxPreference android:key="@string/key_ringer_zoom"
android:title="@string/ringer_zoom"
android:defaultValue="false"
/>
</PreferenceCategory>
<PreferenceScreen android:title="@string/prefs_colors"

View file

@ -72,6 +72,7 @@ public class BoardActivity extends Activity implements UtilCtxt {
private String[] m_texts;
private CommonPrefs m_cp;
private JNIUtils m_jniu;
private boolean m_volKeysZoom;
// call startActivityForResult synchronously
private Semaphore m_forResultWait = new Semaphore(0);
@ -226,7 +227,7 @@ public class BoardActivity extends Activity implements UtilCtxt {
m_cp = CommonPrefs.get();
m_jniu = JNIUtilsImpl.get();
m_volKeysZoom = CommonPrefs.getVolKeysZoom();
setContentView( R.layout.board );
m_handler = new Handler();
m_timers = new TimerRunnable[4]; // needs to be in sync with
@ -241,6 +242,7 @@ public class BoardActivity extends Activity implements UtilCtxt {
if ( m_path.charAt(0) == '/' ) {
m_path = m_path.substring( 1 );
}
} // onCreate
@Override
@ -295,6 +297,8 @@ public class BoardActivity extends Activity implements UtilCtxt {
m_view.prefsChanged();
m_jniThread.handle( JNIThread.JNICmd.CMD_PREFS_CHANGE );
}
m_volKeysZoom = CommonPrefs.getVolKeysZoom();
m_view.setUseZoomControl( !m_volKeysZoom );
// onContentChanged();
}
}
@ -317,10 +321,12 @@ public class BoardActivity extends Activity implements UtilCtxt {
} else {
switch( keyCode ) {
case KeyEvent.KEYCODE_VOLUME_DOWN:
handled = doZoom( -JNIThread.ZOOM_AMT );
break;
case KeyEvent.KEYCODE_VOLUME_UP:
handled = doZoom( JNIThread.ZOOM_AMT );
if ( m_volKeysZoom ) {
int zoomBy = KeyEvent.KEYCODE_VOLUME_DOWN == keyCode
? -JNIThread.ZOOM_AMT : JNIThread.ZOOM_AMT;
handled = doZoom( zoomBy );
}
break;
}
}

View file

@ -113,6 +113,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
private int[] m_playerColors;
private int[] m_otherColors;
private ZoomButtonsController m_zoomButtons;
private boolean m_useZoomControl;
public BoardView( Context context )
{
@ -140,11 +141,15 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
switch ( action ) {
case MotionEvent.ACTION_DOWN:
m_zoomButtons.setVisible( true );
if ( m_useZoomControl ) {
m_zoomButtons.setVisible( true );
}
m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_DOWN, xx, yy );
break;
case MotionEvent.ACTION_MOVE:
m_zoomButtons.setVisible( true );
if ( m_useZoomControl ) {
m_zoomButtons.setVisible( true );
}
m_jniThread.handle( JNIThread.JNICmd.CMD_PEN_MOVE, xx, yy );
break;
case MotionEvent.ACTION_UP:
@ -222,6 +227,14 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
m_zoomButtons.setZoomSpeed( 100 ); // milliseconds
}
protected void setUseZoomControl( boolean useZoomControl )
{
m_useZoomControl = useZoomControl;
if ( !m_useZoomControl ) {
m_zoomButtons.setVisible( false );
}
}
private boolean layoutBoardOnce()
{
final int width = getWidth();

View file

@ -155,4 +155,12 @@ public class CommonPrefs {
return sp.getString( key, "" );
}
public static boolean getVolKeysZoom()
{
SharedPreferences sp =
PreferenceManager.getDefaultSharedPreferences( s_context );
String key = s_context.getString( R.string.key_ringer_zoom );
return sp.getBoolean( key, false );
}
}