mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-07 05:24:46 +01:00
implement getting active rect when that pref is set
This commit is contained in:
parent
71d83e188e
commit
9e87a5ee92
2 changed files with 33 additions and 4 deletions
|
@ -20,7 +20,6 @@
|
|||
|
||||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.view.Display;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
|
@ -40,6 +39,7 @@ import android.os.Handler;
|
|||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import android.view.Display;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -2061,6 +2061,7 @@ public class BoardActivity extends XWActivity
|
|||
if ( GitVersion.THUMBNAIL_SUPPORTED ) {
|
||||
Bitmap thumb = null;
|
||||
if ( XWPrefs.getThumbEnabled( this ) ) {
|
||||
int nCols = m_gi.boardSize;
|
||||
int scale = XWPrefs.getThumbScale( this );
|
||||
Assert.assertTrue( 0 < scale );
|
||||
|
||||
|
@ -2068,7 +2069,22 @@ public class BoardActivity extends XWActivity
|
|||
int width = display.getWidth();
|
||||
int height = display.getHeight();
|
||||
int dim = Math.min( width, height ) / scale;
|
||||
int size = dim - (dim % 15);
|
||||
int size = dim - (dim % nCols);
|
||||
|
||||
// If user wants active rect, we try to make it as
|
||||
// large as possible while still not exceeding the
|
||||
// scale. Since we're only using a fraction of the
|
||||
// board, the board we draw before clipping may be
|
||||
// huge.
|
||||
int[] dims = new int[2];
|
||||
Rect activeRect =
|
||||
XWPrefs.getUseActiveRect( this ) ? new Rect() : null;
|
||||
if ( null != activeRect ) {
|
||||
dims = new int[2];
|
||||
XwJNI.board_getActiveRect( m_jniGamePtr, activeRect, dims );
|
||||
int numCells = Math.max( dims[0], dims[1] );
|
||||
size = size * nCols / numCells;
|
||||
}
|
||||
thumb = Bitmap.createBitmap( size, size, Bitmap.Config.ARGB_8888 );
|
||||
|
||||
Rect bounds = new Rect( 0, 0, size, size );
|
||||
|
@ -2077,8 +2093,16 @@ public class BoardActivity extends XWActivity
|
|||
|
||||
ThumbCanvas canvas = new ThumbCanvas( this, thumb );
|
||||
XwJNI.board_setDraw( m_jniGamePtr, canvas );
|
||||
XwJNI.board_invalAll( m_jniGamePtr );
|
||||
XwJNI.board_draw( m_jniGamePtr );
|
||||
XwJNI.board_invalAll( m_jniGamePtr );
|
||||
XwJNI.board_draw( m_jniGamePtr );
|
||||
|
||||
if ( null != activeRect ) {
|
||||
XwJNI.board_getActiveRect( m_jniGamePtr, activeRect, null );
|
||||
thumb = Bitmap.createBitmap( thumb, activeRect.left,
|
||||
activeRect.top,
|
||||
activeRect.width(),
|
||||
activeRect.height() );
|
||||
}
|
||||
}
|
||||
DBUtils.saveThumbnail( this, m_gameLock, thumb );
|
||||
}
|
||||
|
|
|
@ -333,6 +333,11 @@ public class XWPrefs {
|
|||
return !getPrefsBoolean( context, R.string.key_thumb_disabled, false );
|
||||
}
|
||||
|
||||
public static boolean getUseActiveRect( Context context )
|
||||
{
|
||||
return getPrefsBoolean( context, R.string.key_thumb_useactive, false );
|
||||
}
|
||||
|
||||
public static int getThumbScale( Context context )
|
||||
{
|
||||
String scale = getPrefsString( context, R.string.key_thumbsize );
|
||||
|
|
Loading…
Reference in a new issue