SDL: mosaic TV borders, do not show dull grey, or Google will reject the app

This commit is contained in:
Sergii Pylypenko
2016-06-08 20:49:55 +03:00
parent ec408b555a
commit 90cc2821a6
5 changed files with 73 additions and 9 deletions

View File

@@ -39,6 +39,7 @@ import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.graphics.drawable.Drawable;
import android.graphics.Color;
import android.content.res.Configuration;
@@ -352,17 +353,80 @@ public class MainActivity extends Activity
setContentView(_videoLayout);
mGLView = new DemoGLSurfaceView(this);
SetLayerType.get().setLayerType(mGLView);
FrameLayout.LayoutParams margin = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
// Add TV screen borders, if needed
if( Globals.TvBorders )
margin.setMargins( getResources().getDimensionPixelOffset(R.dimen.screen_border_horizontal),
getResources().getDimensionPixelOffset(R.dimen.screen_border_vertical),
getResources().getDimensionPixelOffset(R.dimen.screen_border_horizontal),
getResources().getDimensionPixelOffset(R.dimen.screen_border_vertical));
_videoLayout.addView(mGLView, margin);
{
RelativeLayout view = new RelativeLayout(this);
RelativeLayout.LayoutParams layout;
/*
layout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
layout.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
layout.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
mGLView.setLayoutParams(layout);
view.addView(mGLView);
*/
layout = new RelativeLayout.LayoutParams(getResources().getDimensionPixelOffset(R.dimen.screen_border_horizontal), RelativeLayout.LayoutParams.MATCH_PARENT);
layout.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
layout.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
ImageView borderLeft = new ImageView(this);
borderLeft.setId(R.drawable.b1); // Any random ID
borderLeft.setImageResource(R.drawable.tv_border_left);
borderLeft.setScaleType(ImageView.ScaleType.FIT_XY);
view.addView(borderLeft, layout);
layout = new RelativeLayout.LayoutParams(getResources().getDimensionPixelOffset(R.dimen.screen_border_horizontal), RelativeLayout.LayoutParams.MATCH_PARENT);
layout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
layout.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
ImageView borderRight = new ImageView(this);
borderRight.setId(R.drawable.b2);
borderRight.setImageResource(R.drawable.tv_border_left);
borderRight.setScaleType(ImageView.ScaleType.FIT_XY);
borderRight.setScaleX(-1f);
view.addView(borderRight, layout);
layout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, getResources().getDimensionPixelOffset(R.dimen.screen_border_vertical));
layout.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
layout.addRule(RelativeLayout.RIGHT_OF, borderLeft.getId());
layout.addRule(RelativeLayout.LEFT_OF, borderRight.getId());
ImageView borderTop = new ImageView(this);
borderTop.setId(R.drawable.b3);
borderTop.setImageResource(R.drawable.tv_border_top);
borderTop.setScaleType(ImageView.ScaleType.FIT_XY);
view.addView(borderTop, layout);
layout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, getResources().getDimensionPixelOffset(R.dimen.screen_border_vertical));
layout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
layout.addRule(RelativeLayout.RIGHT_OF, borderLeft.getId());
layout.addRule(RelativeLayout.LEFT_OF, borderRight.getId());
ImageView borderBottom = new ImageView(this);
borderBottom.setId(R.drawable.b4);
borderBottom.setImageResource(R.drawable.tv_border_top);
borderBottom.setScaleType(ImageView.ScaleType.FIT_XY);
borderBottom.setScaleY(-1f);
view.addView(borderBottom, layout);
layout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
layout.addRule(RelativeLayout.RIGHT_OF, borderLeft.getId());
layout.addRule(RelativeLayout.LEFT_OF, borderRight.getId());
layout.addRule(RelativeLayout.BELOW, borderTop.getId());
layout.addRule(RelativeLayout.ABOVE, borderBottom.getId());
mGLView.setLayoutParams(layout);
view.addView(mGLView);
_videoLayout.addView(view, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
}
else
{
_videoLayout.addView(mGLView, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
}
mGLView.setFocusableInTouchMode(true);
mGLView.setFocusable(true);
mGLView.requestFocus();
if( _ad.getView() != null )
{
_videoLayout.addView(_ad.getView());

View File

@@ -7,10 +7,10 @@ AppName="SuperTux"
AppFullName=org.lethargik.supertux2
# Application version code (integer)
AppVersionCode=04010
AppVersionCode=04011
# Application user-visible version name (string)
AppVersionName="0.4.0.10"
AppVersionName="0.4.0.11"
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu

View File

@@ -76,7 +76,7 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInit) ( JNIEnv* env, jobject thiz, jstring
int i = 0;
char curdir[PATH_MAX] = "";
const jbyte *jstr;
const char * str = "sdl";
const char * str = "SDL_app";
static_env = env;
static_thiz = thiz;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 526 KiB

After

Width:  |  Height:  |  Size: 455 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 485 KiB

After

Width:  |  Height:  |  Size: 421 KiB