use sdk 28 for real

requires dropping junit Assert and accessing an old Canvas method via reflection.
This commit is contained in:
Eric House 2019-10-17 21:53:59 +02:00
parent bf37ab0fc1
commit 06b6afe612
4 changed files with 34 additions and 4 deletions

View file

@ -36,7 +36,7 @@ android {
buildToolsVersion '27.0.3'
defaultConfig {
minSdkVersion 14
targetSdkVersion 28
targetSdkVersion 28 // must match ../build.gradle
versionCode VERSION_CODE_BASE
versionName VERSION_NAME
}

View file

@ -36,7 +36,7 @@ public class Assert {
if (! val) {
Log.e( TAG, "firing assert!" );
DbgUtils.printStack( TAG );
junit.framework.Assert.fail();
assert false;
}
}

View file

@ -30,7 +30,9 @@ import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Set;
@ -574,6 +576,34 @@ public class BoardCanvas extends Canvas implements DrawCtx {
}
}
private static Method sSaveMethod;
private void saveImpl( Rect rect )
{
if ( Build.VERSION.SDK_INT >= 21 ) {
saveLayer( new RectF(rect), null );
} else {
if ( null == sSaveMethod ) {
try {
Class<?> cls = Class.forName("android.graphics.Canvas");
sSaveMethod = cls.getDeclaredMethod( "save", new Class[] {int.class} );
} catch ( NoSuchMethodException | ClassNotFoundException ex ) {
Log.e( TAG, "%s", ex );
Assert.fail();
}
}
final int CLIP_SAVE_FLAG = 0x02;
try {
sSaveMethod.invoke( this, CLIP_SAVE_FLAG );
Log.d( TAG, "saveImpl() worked" );
} catch ( java.lang.reflect.InvocationTargetException
| IllegalAccessException ex ) {
Log.e( TAG, "%s", ex );
Assert.fail();
}
}
}
private boolean drawTileImpl( Rect rect, String text, int val,
int flags, boolean clearBack )
{
@ -583,7 +613,7 @@ public class BoardCanvas extends Canvas implements DrawCtx {
boolean notEmpty = (flags & CELL_ISEMPTY) == 0;
boolean isCursor = (flags & CELL_ISCURSOR) != 0;
save( Canvas.CLIP_SAVE_FLAG );
saveImpl( rect );
rect.top += 1;
clipRect( rect );

View file

@ -32,7 +32,7 @@ subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 26
compileSdkVersion 28 // must match app/build.gradle
}
}
}