diff --git a/ChangeAppSettings.sh b/ChangeAppSettings.sh
index 6609767d5..b9e62ce93 100755
--- a/ChangeAppSettings.sh
+++ b/ChangeAppSettings.sh
@@ -564,6 +564,48 @@ if [ -n "$ReadmeText1" ] ; then
fi
fi
+if [ -z "$AUTO" -o -z "$AdmobPublisherId" ]; then
+echo
+echo -n "Your AdMob Publisher ID, (n) if you don't want advertisements ($AdmobPublisherId): "
+read var
+if [ -n "$var" ] ; then
+ AdmobPublisherId="$var"
+ CHANGED=1
+fi
+fi
+
+if [ "$AdmobPublisherId" '!=' "n" ]; then
+if [ -z "$AUTO" -o -z "$AdmobTestDeviceId" ]; then
+echo
+echo -n "Your AdMob test device ID, to receive a test ad ($AdmobTestDeviceId): "
+read var
+if [ -n "$var" ] ; then
+ AdmobTestDeviceId="$var"
+ CHANGED=1
+fi
+fi
+if [ -z "$AUTO" -o -z "$AdmobBannerSize" ]; then
+echo
+echo -n "Your AdMob banner size (BANNER/IAB_BANNER/IAB_LEADERBOARD/IAB_MRECT/IAB_WIDE_SKYSCRAPER/SMART_BANNER) ($AdmobBannerSize): "
+read var
+if [ -n "$var" ] ; then
+ AdmobBannerSize="$var"
+ CHANGED=1
+fi
+fi
+fi
+
+if [ -z "$AUTO" -o -z "$MinimumScreenSize" ]; then
+echo
+echo "Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens"
+echo -n "Minimum screen size that application supports: (s)mall / (n)ormal / (l)arge ($MinimumScreenSize): "
+read var
+if [ -n "$var" ] ; then
+ MinimumScreenSize="$var"
+ CHANGED=1
+fi
+fi
+
echo
if [ -n "$CHANGED" ]; then
@@ -615,6 +657,10 @@ echo AppLdflags=\'$AppLdflags\' >> AndroidAppSettings.cfg
echo AppSubdirsBuild=\'$AppSubdirsBuild\' >> AndroidAppSettings.cfg
echo AppCmdline=\'$AppCmdline\' >> AndroidAppSettings.cfg
echo ReadmeText=\'$ReadmeText\' >> AndroidAppSettings.cfg
+echo MinimumScreenSize=$MinimumScreenSize >> AndroidAppSettings.cfg
+echo AdmobPublisherId=$AdmobPublisherId >> AndroidAppSettings.cfg
+echo AdmobTestDeviceId=$AdmobTestDeviceId >> AndroidAppSettings.cfg
+echo AdmobBannerSize=$AdmobBannerSize >> AndroidAppSettings.cfg
fi
AppShortName=`echo $AppName | sed 's/ //g'`
@@ -811,14 +857,6 @@ fi
ReadmeText="`echo $ReadmeText | sed 's/\"/\\\\\\\\\"/g' | sed 's/[&%]//g'`"
-echo Patching project/AndroidManifest.xml
-cat project/AndroidManifestTemplate.xml | \
- sed "s/package=.*/package=\"$AppFullName\"/" | \
- sed "s/android:screenOrientation=.*/android:screenOrientation=\"$ScreenOrientation1\"/" | \
- sed "s^android:versionCode=.*^android:versionCode=\"$AppVersionCode\"^" | \
- sed "s^android:versionName=.*^android:versionName=\"$AppVersionName\"^" > \
- project/AndroidManifest.xml
-
rm -rf project/src
mkdir -p project/src
cd project/java
@@ -829,6 +867,38 @@ for F in *.java; do
done
cd ../..
+echo Patching project/AndroidManifest.xml
+cat project/AndroidManifestTemplate.xml | \
+ sed "s/package=.*/package=\"$AppFullName\"/" | \
+ sed "s/android:screenOrientation=.*/android:screenOrientation=\"$ScreenOrientation1\"/" | \
+ sed "s^android:versionCode=.*^android:versionCode=\"$AppVersionCode\"^" | \
+ sed "s^android:versionName=.*^android:versionName=\"$AppVersionName\"^" > \
+ project/AndroidManifest.xml
+if [ "$AdmobPublisherId" = "n" -o -z "$AdmobPublisherId" ] ; then
+ sed -i "/==ADMOB==/ d" project/AndroidManifest.xml
+ AdmobPublisherId=""
+else
+ F=project/java/admob/Advertisement.java
+ echo Patching $F
+ echo '// DO NOT EDIT THIS FILE - it is automatically generated, edit file under project/java dir' > project/src/Advertisement.java
+ cat $F | sed "s/package .*;/package $AppFullName;/" >> project/src/Advertisement.java
+fi
+
+case "$MinimumScreenSize" in
+ n|m)
+ sed -i "/==SCREEN-SIZE-SMALL==/ d" project/AndroidManifest.xml
+ sed -i "/==SCREEN-SIZE-LARGE==/ d" project/AndroidManifest.xml
+ ;;
+ l)
+ sed -i "/==SCREEN-SIZE-SMALL==/ d" project/AndroidManifest.xml
+ sed -i "/==SCREEN-SIZE-NORMAL==/ d" project/AndroidManifest.xml
+ ;;
+ *)
+ sed -i "/==SCREEN-SIZE-NORMAL==/ d" project/AndroidManifest.xml
+ sed -i "/==SCREEN-SIZE-LARGE==/ d" project/AndroidManifest.xml
+ ;;
+esac
+
echo Patching project/src/Globals.java
cat project/src/Globals.java | \
sed "s/public static String ApplicationName = .*;/public static String ApplicationName = \"$AppShortName\";/" | \
@@ -863,6 +933,9 @@ cat project/src/Globals.java | \
sed "s@public static Settings.Menu FirstStartMenuOptions .*;@public static Settings.Menu FirstStartMenuOptions [] = { $FirstStartMenuOptions };@" | \
sed "s%public static String ReadmeText = .*%public static String ReadmeText = \"$ReadmeText\".replace(\"^\",\"\\\n\");%" | \
sed "s%public static String CommandLine = .*%public static String CommandLine = \"$AppCmdline\";%" | \
+ sed "s/public static String AdmobPublisherId = .*/public static String AdmobPublisherId = \"$AdmobPublisherId\";/" | \
+ sed "s/public static String AdmobTestDeviceId = .*/public static String AdmobTestDeviceId = \"$AdmobTestDeviceId\";/" | \
+ sed "s/public static String AdmobBannerSize = .*/public static String AdmobBannerSize = \"$AdmobBannerSize\";/" | \
sed "s/public static String AppLibraries.*/public static String AppLibraries[] = { $LibrariesToLoad };/" > \
project/src/Globals.java.1
mv -f project/src/Globals.java.1 project/src/Globals.java
@@ -897,7 +970,7 @@ done
cd ../../..
echo Cleaning up dependencies
-rm -rf project/libs/* project/gen
+rm -rf project/libs/*/* project/gen
for OUT in obj; do
rm -rf project/$OUT/local/*/objs*/sdl_main/* project/$OUT/local/*/libsdl_main.so
rm -rf project/$OUT/local/*/libsdl-*.so
diff --git a/project/AndroidManifestTemplate.xml b/project/AndroidManifestTemplate.xml
index cdec4d025..e276a013b 100644
--- a/project/AndroidManifestTemplate.xml
+++ b/project/AndroidManifestTemplate.xml
@@ -22,12 +22,17 @@
+
+
+
+
+
diff --git a/project/java/Accelerometer.java b/project/java/Accelerometer.java
index 8b0d30e94..54e87065c 100644
--- a/project/java/Accelerometer.java
+++ b/project/java/Accelerometer.java
@@ -37,7 +37,8 @@ import android.hardware.SensorEvent;
import android.widget.TextView;
-class AccelerometerReader implements SensorEventListener {
+class AccelerometerReader implements SensorEventListener
+{
private SensorManager _manager = null;
diff --git a/project/java/Advertisement.java b/project/java/Advertisement.java
new file mode 100644
index 000000000..58a1bb6e3
--- /dev/null
+++ b/project/java/Advertisement.java
@@ -0,0 +1,46 @@
+/*
+Simple DirectMedia Layer
+Java source code (C) 2009-2012 Sergii Pylypenko
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+package net.sourceforge.clonekeenplus;
+
+import android.app.Activity;
+import android.content.Context;
+import android.view.MotionEvent;
+import android.view.KeyEvent;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.TextView;
+import android.view.View;
+
+class Advertisement
+{
+ MainActivity parent;
+
+ public Advertisement(MainActivity p)
+ {
+ parent = p;
+ }
+
+ public View getView()
+ {
+ return null;
+ }
+}
diff --git a/project/java/Audio.java b/project/java/Audio.java
index faa464d68..b98e4c2fc 100644
--- a/project/java/Audio.java
+++ b/project/java/Audio.java
@@ -37,7 +37,8 @@ import android.util.Log;
import java.lang.Thread;
-class AudioThread {
+class AudioThread
+{
private MainActivity mParent;
private AudioTrack mAudio;
diff --git a/project/java/DataDownloader.java b/project/java/DataDownloader.java
index 153128f7a..deb046cfa 100644
--- a/project/java/DataDownloader.java
+++ b/project/java/DataDownloader.java
@@ -59,7 +59,8 @@ import java.lang.String;
import android.text.SpannedString;
-class CountingInputStream extends BufferedInputStream {
+class CountingInputStream extends BufferedInputStream
+{
private long bytesReadMark = 0;
private long bytesRead = 0;
diff --git a/project/java/Globals.java b/project/java/Globals.java
index 48a6bf3a8..904270a8c 100644
--- a/project/java/Globals.java
+++ b/project/java/Globals.java
@@ -26,7 +26,8 @@ import android.content.Context;
import java.util.Vector;
import android.view.KeyEvent;
-class Globals {
+class Globals
+{
// These config options are modified by ChangeAppsettings.sh script - see the detailed descriptions there
public static String ApplicationName = "CommanderGenius";
public static String AppLibraries[] = { "sdl-1.2", };
@@ -61,6 +62,9 @@ class Globals {
public static int StartupMenuButtonTimeout = 3000;
public static Settings.Menu HiddenMenuOptions [] = {};
public static Settings.Menu FirstStartMenuOptions [] = { (AppUsesMouse && ! ForceRelativeMouseMode ? new Settings.DisplaySizeConfig(true) : new Settings.DummyMenu()), new Settings.OptionalDownloadConfig(true) };
+ public static String AdmobPublisherId = "";
+ public static String AdmobTestDeviceId = "";
+ public static String AdmobBannerSize = "";
// Phone-specific config, modified by user in "Change phone config" startup dialog, TODO: move this to settings
public static boolean DownloadToSdcard = true;
diff --git a/project/java/Keycodes.java b/project/java/Keycodes.java
index 39ea6aaba..e632781ce 100644
--- a/project/java/Keycodes.java
+++ b/project/java/Keycodes.java
@@ -29,8 +29,8 @@ import java.lang.reflect.Field;
// Autogenerated by hand with a command:
// grep 'SDLK_' SDL_keysym.h | sed 's/SDLK_\([a-zA-Z0-9_]\+\).*[=] \([0-9]\+\).*/public static final int SDLK_\1 = \2;/' >> Keycodes.java
-class SDL_1_2_Keycodes {
-
+class SDL_1_2_Keycodes
+{
public static final int SDLK_UNKNOWN = 0;
public static final int SDLK_BACKSPACE = 8;
public static final int SDLK_TAB = 9;
@@ -269,8 +269,8 @@ class SDL_1_2_Keycodes {
// Autogenerated by hand with a command:
// grep 'SDL_SCANCODE_' SDL_scancode.h | sed 's/SDL_SCANCODE_\([a-zA-Z0-9_]\+\).*[=] \([0-9]\+\).*/public static final int SDLK_\1 = \2;/' >> Keycodes.java
-class SDL_1_3_Keycodes {
-
+class SDL_1_3_Keycodes
+{
public static final int SDLK_UNKNOWN = 0;
public static final int SDLK_A = 4;
public static final int SDLK_B = 5;
diff --git a/project/java/MainActivity.java b/project/java/MainActivity.java
index 09e2a01fb..eb45862bf 100644
--- a/project/java/MainActivity.java
+++ b/project/java/MainActivity.java
@@ -46,6 +46,7 @@ import android.content.Intent;
import android.view.View.OnKeyListener;
import android.view.MenuItem;
import android.view.Menu;
+import android.view.Gravity;
import android.text.method.TextKeyListener;
import java.util.LinkedList;
import java.io.SequenceInputStream;
@@ -71,9 +72,11 @@ import android.os.Message;
import java.util.concurrent.Semaphore;
import android.content.pm.ActivityInfo;
-public class MainActivity extends Activity {
+public class MainActivity extends Activity
+{
@Override
- protected void onCreate(Bundle savedInstanceState) {
+ protected void onCreate(Bundle savedInstanceState)
+ {
super.onCreate(savedInstanceState);
setRequestedOrientation(Globals.HorizontalOrientation ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
@@ -90,12 +93,12 @@ public class MainActivity extends Activity {
System.out.println("libSDL: Creating startup screen");
_layout = new LinearLayout(this);
_layout.setOrientation(LinearLayout.VERTICAL);
- _layout.setLayoutParams(new LinearLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
+ _layout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
_layout2 = new LinearLayout(this);
- _layout2.setLayoutParams(new LinearLayout.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
+ _layout2.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
_btn = new Button(this);
- _btn.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
+ _btn.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
_btn.setText(getResources().getString(R.string.device_change_cfg));
class onClickListener implements View.OnClickListener
{
@@ -125,11 +128,20 @@ public class MainActivity extends Activity {
{
img.setImageResource(R.drawable.publisherlogo);
}
- img.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
+ img.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
_layout.addView(img);
_videoLayout = new FrameLayout(this);
_videoLayout.addView(_layout);
+
+ _ad = new Advertisement(this);
+ if( _ad.getView() != null )
+ {
+ _videoLayout.addView(_ad.getView());
+ _ad.getView().setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | Gravity.RIGHT));
+ _ad.getView().setFocusable(true);
+ _ad.getView().setFocusableInTouchMode(true);
+ }
setContentView(_videoLayout);
@@ -232,6 +244,8 @@ public class MainActivity extends Activity {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
_videoLayout.removeView(_layout);
+ if( _ad.getView() != null )
+ _videoLayout.removeView(_ad.getView());
_layout = null;
_layout2 = null;
_btn = null;
@@ -241,10 +255,18 @@ public class MainActivity extends Activity {
setContentView(_videoLayout);
mGLView = new DemoGLSurfaceView(this);
_videoLayout.addView(mGLView);
- // Receive keyboard events
mGLView.setFocusableInTouchMode(true);
mGLView.setFocusable(true);
mGLView.requestFocus();
+ if( _ad.getView() != null )
+ {
+ _videoLayout.addView(_ad.getView());
+ _ad.getView().setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.TOP | Gravity.RIGHT));
+ _ad.getView().setFocusable(true);
+ _ad.getView().setFocusableInTouchMode(true);
+ _ad.getView().requestFocus();
+ }
+ // Receive keyboard events
DimSystemStatusBar.get().dim(_videoLayout);
DimSystemStatusBar.get().dim(mGLView);
}
@@ -261,6 +283,8 @@ public class MainActivity extends Activity {
_isPaused = true;
if( mGLView != null )
mGLView.onPause();
+ //if( _ad.getView() != null )
+ // _ad.getView().onPause();
super.onPause();
}
@@ -283,6 +307,8 @@ public class MainActivity extends Activity {
initSDL();
}
}
+ //if( _ad.getView() != null )
+ // _ad.getView().onResume();
_isPaused = false;
}
@@ -396,6 +422,41 @@ public class MainActivity extends Activity {
mGLView.requestFocus();
};
+ public void setAdvertisementParams(int visible, int left, int top)
+ {
+ if( _ad.getView() != null )
+ {
+ if( visible == 0 )
+ _ad.getView().setVisibility(View.GONE);
+ else
+ {
+ FrameLayout.LayoutParams layout = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT);
+ layout.leftMargin = left;
+ layout.topMargin = top;
+ _ad.getView().setLayoutParams(layout);
+ _ad.getView().setVisibility(View.VISIBLE);
+ }
+ }
+ }
+
+ public void getAdvertisementParams(int size[])
+ {
+ size[0] = 0;
+ size[1] = 0;
+ size[2] = 0;
+ size[3] = 0;
+ size[4] = 0;
+ if( _ad.getView() != null )
+ {
+ size[0] = _ad.getView().getMeasuredWidth();
+ size[1] = _ad.getView().getMeasuredHeight();
+ size[2] = (_ad.getView().getVisibility() == View.VISIBLE) ? 1 : 0;
+ FrameLayout.LayoutParams layout = (FrameLayout.LayoutParams) _ad.getView().getLayoutParams();
+ size[3] = layout.leftMargin;
+ size[4] = layout.topMargin;
+ }
+ }
+
@Override
public boolean onKeyDown(int keyCode, final KeyEvent event)
{
@@ -442,45 +503,6 @@ public class MainActivity extends Activity {
return true;
}
- // Action bar support for Android 3+, which replaces the Menu button, however in emulator everything works, because it's broken
- // Also this does not work, because that action bar thingie is NOT shown for fullscreen apps, so we're targetting the legacy compatibility mode here
- /*
- @Override
- public boolean onOptionsItemSelected(MenuItem item)
- {
- if( mGLView != null )
- {
- if(item.getItemId() == 2)
- {
- mGLView.nativeKey( KeyEvent.KEYCODE_SEARCH, 1 );
- mGLView.nativeKey( KeyEvent.KEYCODE_SEARCH, 0 );
- }
- else
- {
- mGLView.nativeKey( KeyEvent.KEYCODE_MENU, 1 );
- mGLView.nativeKey( KeyEvent.KEYCODE_MENU, 0 );
- }
- }
- else
- if( keyListener != null )
- {
- if(item.getItemId() == 2)
- keyListener.onKeyEvent(KeyEvent.KEYCODE_SEARCH);
- else
- keyListener.onKeyEvent(KeyEvent.KEYCODE_MENU);
- }
- return true;
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- super.onCreateOptionsMenu(menu);
- menu.add(0, 1, 0, "Menu");
- menu.add(0, 2, 0, "Search");
- return true;
- }
- */
-
@Override
public boolean dispatchTouchEvent(final MotionEvent ev)
{
@@ -488,6 +510,15 @@ public class MainActivity extends Activity {
if(_screenKeyboard != null)
_screenKeyboard.dispatchTouchEvent(ev);
else
+ if( _ad.getView() != null && // User clicked the advertisement, ignore when user moved finger from game screen to advertisement or touches screen with several fingers
+ ((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN ||
+ (ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) &&
+ _ad.getView().getLeft() <= (int)ev.getX() &&
+ _ad.getView().getRight() > (int)ev.getX() &&
+ _ad.getView().getTop() <= (int)ev.getY() &&
+ _ad.getView().getBottom() > (int)ev.getY() )
+ return super.dispatchTouchEvent(ev);
+ else
if(mGLView != null)
mGLView.onTouchEvent(ev);
else
@@ -832,6 +863,7 @@ public class MainActivity extends Activity {
private Button _btn = null;
private LinearLayout _layout = null;
private LinearLayout _layout2 = null;
+ private Advertisement _ad = null;
private FrameLayout _videoLayout = null;
private EditText _screenKeyboard = null;
diff --git a/project/java/Settings.java b/project/java/Settings.java
index 0c3d99b5c..87bbeb59b 100644
--- a/project/java/Settings.java
+++ b/project/java/Settings.java
@@ -60,7 +60,6 @@ import android.content.Intent;
import android.app.PendingIntent;
import android.app.AlarmManager;
-
// TODO: too much code here, split into multiple files, possibly auto-generated menus?
class Settings
{
diff --git a/project/java/admob/Advertisement.java b/project/java/admob/Advertisement.java
new file mode 100644
index 000000000..0844e5403
--- /dev/null
+++ b/project/java/admob/Advertisement.java
@@ -0,0 +1,67 @@
+/*
+Simple DirectMedia Layer
+Java source code (C) 2009-2012 Sergii Pylypenko
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+*/
+
+package net.sourceforge.clonekeenplus;
+
+import android.app.Activity;
+import android.content.Context;
+import android.view.MotionEvent;
+import android.view.KeyEvent;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.TextView;
+import android.view.View;
+
+import com.google.ads.*; // Copy GoogleAdMobAdsSdk.jar to the directory project/libs
+
+class Advertisement
+{
+ private AdView ad;
+ MainActivity parent;
+
+ public Advertisement(MainActivity p)
+ {
+ parent = p;
+ AdSize adSize = AdSize.BANNER;
+ if( Globals.AdmobBannerSize.equals("BANNER") )
+ adSize = AdSize.BANNER;
+ else if( Globals.AdmobBannerSize.equals("IAB_BANNER") )
+ adSize = AdSize.IAB_BANNER;
+ else if( Globals.AdmobBannerSize.equals("IAB_LEADERBOARD") )
+ adSize = AdSize.IAB_LEADERBOARD;
+ else if( Globals.AdmobBannerSize.equals("IAB_MRECT") )
+ adSize = AdSize.IAB_MRECT;
+ else if( Globals.AdmobBannerSize.equals("IAB_WIDE_SKYSCRAPER") )
+ adSize = AdSize.IAB_WIDE_SKYSCRAPER;
+ else if( Globals.AdmobBannerSize.equals("SMART_BANNER") )
+ adSize = AdSize.SMART_BANNER;
+ ad = new AdView(parent, adSize, Globals.AdmobPublisherId);
+ AdRequest adRequest = new AdRequest();
+ adRequest.addTestDevice(AdRequest.TEST_EMULATOR); // Copy GoogleAdMobAdsSdk.jar to the directory project/libs
+ adRequest.addTestDevice(Globals.AdmobTestDeviceId);
+ ad.loadAd(adRequest);
+ }
+
+ public View getView()
+ {
+ return ad;
+ }
+}
diff --git a/project/jni/application/admob-test/AndroidAppSettings.cfg b/project/jni/application/admob-test/AndroidAppSettings.cfg
new file mode 100644
index 000000000..724d296d5
--- /dev/null
+++ b/project/jni/application/admob-test/AndroidAppSettings.cfg
@@ -0,0 +1,51 @@
+# The application settings for Android libSDL port
+AppSettingVersion=17
+LibSdlVersion=1.2
+AppName="Admob test"
+AppFullName=ws.openarena.sdl
+ScreenOrientation=h
+InhibitSuspend=n
+AppDataDownloadUrl="Game data is 1 Mb|ballfield2.zip"
+VideoDepthBpp=16
+NeedDepthBuffer=n
+NeedStencilBuffer=n
+NeedGles2=n
+SwVideoMode=y
+SdlVideoResize=y
+SdlVideoResizeKeepAspect=n
+CompatibilityHacks=n
+CompatibilityHacksStaticInit=n
+CompatibilityHacksTextInputEmulatesHwKeyboard=n
+AppUsesMouse=y
+AppNeedsTwoButtonMouse=y
+ShowMouseCursor=n
+ForceRelativeMouseMode=n
+AppNeedsArrowKeys=n
+AppNeedsTextInput=y
+AppUsesJoystick=n
+AppHandlesJoystickSensitivity=n
+AppUsesMultitouch=y
+NonBlockingSwapBuffers=n
+RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP SPACE ESCAPE"
+AppTouchscreenKeyboardKeysAmount=0
+AppTouchscreenKeyboardKeysAmountAutoFire=0
+RedefinedKeysScreenKb="0 1 2 3 4 5 6 7 8 9"
+StartupMenuButtonTimeout=3000
+HiddenMenuOptions='OptionalDownloadConfig'
+FirstStartMenuOptions=''
+MultiABI=n
+AppVersionCode=101
+AppVersionName="1.01"
+ResetSdlConfigForThisVersion=n
+DeleteFilesOnUpgrade="%"
+CompiledLibraries="sdl_mixer sdl_image"
+CustomBuildScript=n
+AppCflags='-O2 -finline-functions'
+AppLdflags=''
+AppSubdirsBuild=''
+AppCmdline=''
+ReadmeText='^Readme text'
+MinimumScreenSize=s
+AdmobPublisherId=a14fe4dd0ebe974
+AdmobTestDeviceId=66133194946FB6C1CD0ED2EFCCB82539
+AdmobBannerSize=BANNER
diff --git a/project/jni/application/admob-test/AndroidData/ballfield2.zip b/project/jni/application/admob-test/AndroidData/ballfield2.zip
new file mode 100644
index 000000000..655e4ce19
Binary files /dev/null and b/project/jni/application/admob-test/AndroidData/ballfield2.zip differ
diff --git a/project/jni/application/admob-test/ballfield.cpp b/project/jni/application/admob-test/ballfield.cpp
new file mode 100644
index 000000000..cac0f0376
--- /dev/null
+++ b/project/jni/application/admob-test/ballfield.cpp
@@ -0,0 +1,673 @@
+/*
+ * "Ballfield"
+ *
+ * (C) David Olofson , 2002, 2003
+ *
+ * This software is released under the terms of the GPL.
+ *
+ * Contact author for permission if you want to use this
+ * software, or work derived from it, under other terms.
+ */
+
+#include
+#include
+#include
+#include
+
+#include "SDL.h"
+#include "SDL_image.h"
+
+
+/*----------------------------------------------------------
+ Definitions...
+----------------------------------------------------------*/
+
+#define SCREEN_W 320
+#define SCREEN_H 200
+
+
+#define BALLS 300
+
+#define COLORS 2
+
+typedef struct
+{
+ Sint32 x, y, z; /* Position */
+ Uint32 c; /* Color */
+} point_t;
+
+
+/*
+ * Ballfield
+ */
+typedef struct
+{
+ point_t points[BALLS];
+ SDL_Rect *frames;
+ SDL_Surface *gfx[COLORS];
+ int use_alpha;
+} ballfield_t;
+
+
+/*
+ * Size of the biggest ball image in pixels
+ *
+ * Balls are scaled down and *packed*, one pixel
+ * smaller for each frame down to 1x1. The actual
+ * image width is (obviously...) the same as the
+ * width of the first frame.
+ */
+#define BALL_W 32
+#define BALL_H 32
+
+
+
+
+/*----------------------------------------------------------
+ General tool functions
+----------------------------------------------------------*/
+
+/*
+ * Bump areas of low and high alpha to 0% or 100%
+ * respectively, just in case the graphics contains
+ * "alpha noise".
+ */
+SDL_Surface *clean_alpha(SDL_Surface *s)
+{
+ SDL_Surface *work;
+ SDL_Rect r;
+ Uint32 *pixels;
+ int pp;
+ int x, y;
+
+ work = SDL_CreateRGBSurface(SDL_SWSURFACE, s->w, s->h,
+ 32, 0xff000000, 0x00ff0000, 0x0000ff00,
+ 0x000000ff);
+ if(!work)
+ return NULL;
+
+ r.x = r.y = 0;
+ r.w = s->w;
+ r.h = s->h;
+ if(SDL_BlitSurface(s, &r, work, NULL) < 0)
+ {
+ SDL_FreeSurface(work);
+ return NULL;
+ }
+
+ SDL_LockSurface(work);
+ pixels = (Uint32 *)work->pixels;
+ pp = work->pitch / sizeof(Uint32);
+ for(y = 0; y < work->h; ++y)
+ for(x = 0; x < work->w; ++x)
+ {
+ Uint32 pix = pixels[y*pp + x];
+ switch((pix & 0xff) >> 4)
+ {
+ case 0:
+ pix = 0x00000000;
+ break;
+ default:
+ break;
+ case 15:
+ pix |= 0xff;
+ break;
+ }
+ pixels[y*pp + x] = pix;
+ }
+ SDL_UnlockSurface(work);
+
+ return work;
+}
+
+
+/*
+ * Load and convert an antialiazed, zoomed set of sprites.
+ */
+SDL_Surface *load_zoomed(char *name, int alpha)
+{
+ SDL_Surface *sprites;
+ SDL_Surface *temp = IMG_Load(name);
+ if(!temp)
+ return NULL;
+
+ /*
+ sprites = temp;
+ SDL_SetAlpha(sprites, 0, 255);
+ temp = clean_alpha(sprites);
+ SDL_FreeSurface(sprites);
+ */
+ if(!temp)
+ {
+ fprintf(stderr, "Could not clean alpha!\n");
+ return NULL;
+ }
+
+ if(alpha)
+ {
+ SDL_SetAlpha(temp, 0, SDL_ALPHA_OPAQUE);
+ sprites = SDL_DisplayFormatAlpha(temp);
+ }
+ else
+ {
+ SDL_SetColorKey(temp, SDL_SRCCOLORKEY,
+ SDL_MapRGB(temp->format, 0, 0, 0));
+ sprites = SDL_DisplayFormat(temp);
+ }
+ SDL_FreeSurface(temp);
+
+ return sprites;
+}
+
+
+void print_num(SDL_Surface *dst, SDL_Surface *font, int x, int y, float value)
+{
+ char buf[16];
+ int val = (int)(value * 10.0);
+ int pos, p = 0;
+ SDL_Rect from;
+
+ /* Sign */
+ if(val < 0)
+ {
+ buf[p++] = 10;
+ val = -val;
+ }
+
+ /* Integer part */
+ pos = 10000000;
+ while(pos > 1)
+ {
+ int num = val / pos;
+ val -= num * pos;
+ pos /= 10;
+ if(p || num)
+ buf[p++] = num;
+ }
+
+ /* Decimals */
+ if(val / pos)
+ {
+ buf[p++] = 11;
+ while(pos > 0)
+ {
+ int num = val / pos;
+ val -= num * pos;
+ pos /= 10;
+ buf[p++] = num;
+ }
+ }
+
+ /* Render! */
+ from.y = 0;
+ from.w = 7;
+ from.h = 10;
+ for(pos = 0; pos < p; ++pos)
+ {
+ SDL_Rect to;
+ to.x = x + pos * 7;
+ to.y = y;
+ from.x = buf[pos] * 7;
+ SDL_BlitSurface(font, &from, dst, &to);
+ }
+}
+
+void print_num_hex(SDL_Surface *dst, SDL_Surface *font, int x, int y, unsigned val)
+{
+ char buf[8];
+ int pos, p = 0;
+ SDL_Rect from;
+
+ //val = htonl(val); // Big-endian
+
+ /* Render! */
+ from.y = 0;
+ from.w = 7;
+ from.h = 10;
+ for(pos = 0; pos < 8; ++pos)
+ {
+ SDL_Rect to;
+ to.x = 8 * 7 - (x + pos * 7); // Little-endian number wrapped backwards
+ to.y = y;
+ from.x = ( ( val >> (pos * 4) ) & 0xf ) * 7;
+ SDL_BlitSurface(font, &from, dst, &to);
+ }
+}
+
+/*----------------------------------------------------------
+ ballfield_t functions
+----------------------------------------------------------*/
+
+ballfield_t *ballfield_init(void)
+{
+ int i;
+ ballfield_t *bf = (ballfield_t *)calloc(sizeof(ballfield_t), 1);
+ if(!bf)
+ return NULL;
+ for(i = 0; i < BALLS; ++i)
+ {
+ bf->points[i].x = rand() % 0x20000;
+ bf->points[i].y = rand() % 0x20000;
+ bf->points[i].z = 0x20000 * i / BALLS;
+ if(rand() % 100 > 80)
+ bf->points[i].c = 1;
+ else
+ bf->points[i].c = 0;
+ }
+ return bf;
+}
+
+
+void ballfield_free(ballfield_t *bf)
+{
+ int i;
+ for(i = 0; i < COLORS; ++i)
+ SDL_FreeSurface(bf->gfx[i]);
+}
+
+
+static int ballfield_init_frames(ballfield_t *bf)
+{
+ int i, j;
+ /*
+ * Set up source rects for all frames
+ */
+ bf->frames = (SDL_Rect *)calloc(sizeof(SDL_Rect), bf->gfx[0]->w);
+ if(!bf->frames)
+ {
+ fprintf(stderr, "No memory for frame rects!\n");
+ return -1;
+ }
+ for(j = 0, i = 0; i < bf->gfx[0]->w; ++i)
+ {
+ bf->frames[i].x = 0;
+ bf->frames[i].y = j;
+ bf->frames[i].w = bf->gfx[0]->w - i;
+ bf->frames[i].h = bf->gfx[0]->w - i;
+ j += bf->gfx[0]->w - i;
+ }
+ return 0;
+}
+
+
+int ballfield_load_gfx(ballfield_t *bf, char *name, unsigned int color)
+{
+ if(color >= COLORS)
+ return -1;
+
+ bf->gfx[color] = load_zoomed(name, bf->use_alpha);
+ if(!bf->gfx[color])
+ return -2;
+
+ if(!bf->frames)
+ return ballfield_init_frames(bf);
+
+ return 0;
+}
+
+
+void ballfield_move(ballfield_t *bf, Sint32 dx, Sint32 dy, Sint32 dz)
+{
+ int i;
+ for(i = 0; i < BALLS; ++i)
+ {
+ bf->points[i].x += dx;
+ bf->points[i].x &= 0x1ffff;
+ bf->points[i].y += dy;
+ bf->points[i].y &= 0x1ffff;
+ bf->points[i].z += dz;
+ bf->points[i].z &= 0x1ffff;
+ }
+}
+
+
+void ballfield_render(ballfield_t *bf, SDL_Surface *screen)
+{
+ int i, j, z;
+
+ /*
+ * Find the ball with the highest Z.
+ */
+ z = 0;
+ j = 0;
+ for(i = 0; i < BALLS; ++i)
+ {
+ if(bf->points[i].z > z)
+ {
+ j = i;
+ z = bf->points[i].z;
+ }
+ }
+
+ /*
+ * Render all balls in back->front order.
+ */
+ for(i = 0; i < BALLS; ++i)
+ {
+ SDL_Rect r;
+ int f;
+ z = bf->points[j].z;
+ z += 50;
+ f = ((bf->frames[0].w << 12) + 100000) / z;
+ f = bf->frames[0].w - f;
+ if(f < 0)
+ f = 0;
+ else if(f > bf->frames[0].w - 1)
+ f = bf->frames[0].w - 1;
+ z >>= 7;
+ z += 1;
+ r.x = (bf->points[j].x - 0x10000) / z;
+ r.y = (bf->points[j].y - 0x10000) / z;
+ r.x += (screen->w - bf->frames[f].w) >> 1;
+ r.y += (screen->h - bf->frames[f].h) >> 1;
+ SDL_BlitSurface(bf->gfx[bf->points[j].c],
+ &bf->frames[f], screen, &r);
+ if(--j < 0)
+ j = BALLS - 1;
+ }
+}
+
+
+
+/*----------------------------------------------------------
+ Other rendering functions
+----------------------------------------------------------*/
+
+/*
+ * Draw tiled background image with offset.
+ */
+void tiled_back(SDL_Surface *back, SDL_Surface *screen, int xo, int yo)
+{
+ /*
+ int x, y;
+ SDL_Rect r;
+ if(xo < 0)
+ xo += back->w*(-xo/back->w + 1);
+ if(yo < 0)
+ yo += back->h*(-yo/back->h + 1);
+ xo %= back->w;
+ yo %= back->h;
+ for(y = -yo; y < screen->h; y += back->h)
+ for(x = -xo; x < screen->w; x += back->w)
+ {
+ r.x = x;
+ r.y = y;
+ SDL_BlitSurface(back, NULL, screen, &r);
+ }
+ */
+ SDL_Rect r;
+ xo %= back->w/8;
+ yo %= back->h/8;
+ r.x = xo - back->w/2 + screen->w/2;
+ r.y = yo - back->h/2 + screen->h/2;
+ r.w = back->w;
+ r.h = back->h;
+ SDL_BlitSurface(back, NULL, screen, &r);
+}
+
+/*----------------------------------------------------------
+ main()
+----------------------------------------------------------*/
+
+int main(int argc, char* argv[])
+{
+ ballfield_t *balls;
+ SDL_Surface *screen;
+ SDL_Surface *temp_image;
+ SDL_Surface *back, *logo, *font, *font_hex;
+ SDL_Event event;
+ int bpp = 16,
+ flags = SDL_HWSURFACE,
+ alpha = 1;
+ int x_offs = 0, y_offs = 0;
+ long tick,
+ last_tick,
+ last_avg_tick;
+ double t = 0;
+ float dt;
+ int i;
+ float fps = 0.0;
+ int fps_count = 0;
+ int fps_start = 0;
+ float x_speed, y_speed, z_speed;
+
+ SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
+
+ atexit(SDL_Quit);
+
+ screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, bpp, flags);
+ if(!screen)
+ {
+ fprintf(stderr, "Failed to open screen!\n");
+ exit(-1);
+ }
+
+ SDL_WM_SetCaption("Ballfield", "Ballfield");
+ if(flags & SDL_FULLSCREEN)
+ SDL_ShowCursor(0);
+
+ balls = ballfield_init();
+ if(!balls)
+ {
+ fprintf(stderr, "Failed to create ballfield!\n");
+ exit(-1);
+ }
+
+ /*
+ * Load and prepare balls...
+ */
+ balls->use_alpha = alpha;
+ if( ballfield_load_gfx(balls, "blueball.png", 0)
+ ||
+ ballfield_load_gfx(balls, "redball.png", 1) )
+ {
+ fprintf(stderr, "Could not load balls!\n");
+ exit(-1);
+ }
+
+ /*
+ * Load background image
+ */
+ temp_image = IMG_Load("sun.gif");
+ if(!temp_image)
+ {
+ fprintf(stderr, "Could not load background!\n");
+ exit(-1);
+ }
+ back = SDL_DisplayFormat(temp_image);
+ SDL_FreeSurface(temp_image);
+
+ /*
+ * Load logo
+ */
+ temp_image = SDL_LoadBMP("logo.bmp");
+ if(!temp_image)
+ {
+ fprintf(stderr, "Could not load logo!\n");
+ exit(-1);
+ }
+ SDL_SetColorKey(temp_image, SDL_SRCCOLORKEY,
+ SDL_MapRGB(temp_image->format, 255, 0, 255));
+ logo = SDL_DisplayFormat(temp_image);
+ SDL_FreeSurface(temp_image);
+
+ /*
+ * Load font
+ */
+ temp_image = SDL_LoadBMP("font7x10.bmp");
+ if(!temp_image)
+ {
+ fprintf(stderr, "Could not load font!\n");
+ exit(-1);
+ }
+ SDL_SetColorKey(temp_image, SDL_SRCCOLORKEY,
+ SDL_MapRGB(temp_image->format, 255, 0, 255));
+ font = SDL_DisplayFormat(temp_image);
+ SDL_FreeSurface(temp_image);
+
+ temp_image = SDL_LoadBMP("font7x10-hex.bmp");
+ if(!temp_image)
+ {
+ fprintf(stderr, "Could not load hex font!\n");
+ exit(-1);
+ }
+ SDL_SetColorKey(temp_image, SDL_SRCCOLORKEY,
+ SDL_MapRGB(temp_image->format, 255, 0, 255));
+ font_hex = SDL_DisplayFormat(temp_image);
+ SDL_FreeSurface(temp_image);
+
+ last_avg_tick = last_tick = SDL_GetTicks();
+
+ enum { MAX_POINTERS = 16, PTR_PRESSED = 4 };
+ int touchPointers[MAX_POINTERS][5];
+
+ memset(touchPointers, 0, sizeof(touchPointers));
+ SDL_Joystick * joysticks[MAX_POINTERS+1];
+ for(i=0; i>11, y_offs>>11);
+
+ /* Ballfield */
+ ballfield_render(balls, screen);
+
+ /* Logo */
+ r.x = 2;
+ r.y = 2;
+ SDL_BlitSurface(logo, NULL, screen, &r);
+
+ /* FPS counter */
+ if(tick > fps_start + 1000)
+ {
+ fps = (float)fps_count * 1000.0 / (tick - fps_start);
+ fps_count = 0;
+ fps_start = tick;
+ }
+
+ print_num(screen, font, screen->w-37, screen->h-12, fps);
+ ++fps_count;
+
+ for(i=0; i
+#include
+#include
+
+
+#define SDL_VIDEO_DRIVER_ANDROID 1
+#define SDL_VIDEO_OPENGL_ES 1
+#define SDL_VIDEO_RENDER_OGL_ES 1
+#define SDL_VIDEO_RENDER_OGL_ES_GL_CONTEXT_LOSING_IMMUNE 1
+/* SDL uses some OpenGL textures for drawing in-screen keyboard, so application should allocate OpenGL texture ID-s starting from this value */
+#define SDL_GL_FIRST_SAFE_TEXTURE_ID 26
+
+#define SDL_AUDIO_DRIVER_ANDROID 1
+
+#define SDL_CDROM_DISABLED 1
+
+#define SDL_JOYSTICK_ANDROID 1
+
+#define SDL_HAPTIC_DUMMY 1 // TODO: add vibrator and remove that
+#define SDL_HAPTIC_ANDROID 1
+
+#define SDL_POWER_DISABLED 1 // TODO: add battery meter and remove that
+#define SDL_POWER_ANDROID 1
+#undef SDL_POWER_LINUX
+
+#define SDL_LOADSO_DLOPEN 1
+
+#define SDL_THREAD_PTHREAD 1
+#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
+
+#define SDL_TIMER_UNIX 1
+
+#define HAVE_STDIO_H 1
+
+
+#define SIZEOF_VOIDP 4
+#define SDL_HAS_64BIT_TYPE 1
+
+/* FireSlash found that SDL native memcpy crashes sometimes, these defines fix it (and they are faster) */
+#define HAVE_LIBC 1
+
+#define HAVE_ALLOCA_H 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_STDIO_H 1
+#define STDC_HEADERS 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STDARG_H 1
+#define HAVE_MALLOC_H 1
+#define HAVE_MEMORY_H 1
+#define HAVE_STRING_H 1
+#define HAVE_STRINGS_H 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_CTYPE_H 1
+#define HAVE_MATH_H 1
+#undef HAVE_ICONV_H
+#define HAVE_SIGNAL_H 1
+#undef HAVE_ALTIVEC_H
+
+#define HAVE_MALLOC 1
+#define HAVE_CALLOC 1
+#define HAVE_REALLOC 1
+#define HAVE_FREE 1
+#define HAVE_ALLOCA 1
+#define HAVE_GETENV 1
+#define HAVE_PUTENV 1
+#define HAVE_UNSETENV 1
+#define HAVE_QSORT 1
+#define HAVE_ABS 1
+#define HAVE_BCOPY 1
+#define HAVE_MEMSET 1
+#define HAVE_MEMCPY 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MEMCMP 1
+#define HAVE_STRLEN 1
+#define HAVE_STRLCPY 1
+#define HAVE_STRLCAT 1
+#define HAVE_STRDUP 1
+#undef HAVE__STRREV
+#undef HAVE__STRUPR
+#undef HAVE__STRLWR
+#define HAVE_INDEX 1
+#define HAVE_RINDEX 1
+#define HAVE_STRCHR 1
+#define HAVE_STRRCHR 1
+#define HAVE_STRSTR 1
+#undef HAVE_ITOA
+#undef HAVE__LTOA
+#undef HAVE__UITOA
+#undef HAVE__ULTOA
+#define HAVE_STRTOL
+#define HAVE_STRTOUL
+#undef HAVE__I64TOA
+#undef HAVE__UI64TOA
+#define HAVE_STRTOLL 1
+#define HAVE_STRTOULL 1
+#define HAVE_STRTOD 1
+#define HAVE_ATOI 1
+#define HAVE_ATOF 1
+#define HAVE_STRCMP 1
+#define HAVE_STRNCMP 1
+#undef HAVE__STRICMP
+#define HAVE_STRCASECMP 1
+#undef HAVE__STRNICMP
+#define HAVE_STRNCASECMP 1
+#define HAVE_SSCANF 1
+#define HAVE_SNPRINTF 1
+#define HAVE_VSNPRINTF 1
+#undef HAVE_ICONV
+#define HAVE_SIGACTION 1
+#define HAVE_SETJMP 1
+#define HAVE_NANOSLEEP 1
+#define HAVE_CLOCK_GETTIME 1
+#define HAVE_GETPAGESIZE 1
+#define HAVE_MPROTECT 1
+
+#define HAVE_CEIL 1
+#define HAVE_COPYSIGN 1
+#define HAVE_COS 1
+#define HAVE_COSF 1
+#define HAVE_FABS 1
+#define HAVE_FLOOR 1
+#define HAVE_LOG 1
+#define HAVE_M_PI 1
+#define HAVE_POW 1
+#define HAVE_SCALBN 1
+#define HAVE_SETENV 1
+#define HAVE_SIN 1
+#define HAVE_SINF 1
+#define HAVE_SQRT 1
+#define HAVE_ATAN 1
+#define HAVE_ATAN2 1
+#define HAVE_SYSCONF 1
+#undef HAVE_SYSCTLBYNAME
+#undef SDL_ALTIVEC_BLITTERS
+#define SDL_ASSEMBLY_ROUTINES 1 // There is no assembly code for Arm CPU yet
+#define HAVE_GCC_ATOMICS 1
+
+#endif /* _SDL_config_minimal_h */
diff --git a/project/jni/sdl-1.3/include/SDL_android.h b/project/jni/sdl-1.3/include/SDL_android.h
new file mode 120000
index 000000000..3499a7ee3
--- /dev/null
+++ b/project/jni/sdl-1.3/include/SDL_android.h
@@ -0,0 +1 @@
+../../sdl-1.2/include/SDL_android.h
\ No newline at end of file
diff --git a/project/jni/sdl-1.3/include/SDL_config_android.h b/project/jni/sdl-1.3/include/SDL_config_android.h
deleted file mode 100644
index 7e7c34462..000000000
--- a/project/jni/sdl-1.3/include/SDL_config_android.h
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- SDL - Simple DirectMedia Layer
- Copyright (C) 1997-2009 Sam Lantinga
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library 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
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
- Sam Lantinga
- slouken@libsdl.org
-*/
-
-#ifndef _SDL_config_android_h
-#define _SDL_config_android_h
-
-#include "SDL_platform.h"
-
-/* This is the minimal configuration that can be used to build SDL */
-
-#include
-#include
-#include
-
-
-#define SDL_VIDEO_DRIVER_ANDROID 1
-#define SDL_VIDEO_OPENGL_ES 1
-#define SDL_VIDEO_RENDER_OGL_ES 1
-#define SDL_VIDEO_RENDER_OGL_ES_GL_CONTEXT_LOSING_IMMUNE 1
-/* SDL uses some OpenGL textures for drawing in-screen keyboard, so application should allocate OpenGL texture ID-s starting from this value */
-#define SDL_GL_FIRST_SAFE_TEXTURE_ID 26
-
-#define SDL_AUDIO_DRIVER_ANDROID 1
-
-#define SDL_CDROM_DISABLED 1
-
-#define SDL_JOYSTICK_ANDROID 1
-
-#define SDL_HAPTIC_DUMMY 1 // TODO: add vibrator and remove that
-#define SDL_HAPTIC_ANDROID 1
-
-#define SDL_POWER_DISABLED 1 // TODO: add battery meter and remove that
-#define SDL_POWER_ANDROID 1
-#undef SDL_POWER_LINUX
-
-#define SDL_LOADSO_DLOPEN 1
-
-#define SDL_THREAD_PTHREAD 1
-#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
-
-#define SDL_TIMER_UNIX 1
-
-#define HAVE_STDIO_H 1
-
-
-#define SIZEOF_VOIDP 4
-#define SDL_HAS_64BIT_TYPE 1
-
-/* FireSlash found that SDL native memcpy crashes sometimes, these defines fix it (and they are faster) */
-#define HAVE_LIBC 1
-
-#define HAVE_ALLOCA_H 1
-#define HAVE_SYS_TYPES_H 1
-#define HAVE_STDIO_H 1
-#define STDC_HEADERS 1
-#define HAVE_STDLIB_H 1
-#define HAVE_STDARG_H 1
-#define HAVE_MALLOC_H 1
-#define HAVE_MEMORY_H 1
-#define HAVE_STRING_H 1
-#define HAVE_STRINGS_H 1
-#define HAVE_INTTYPES_H 1
-#define HAVE_STDINT_H 1
-#define HAVE_CTYPE_H 1
-#define HAVE_MATH_H 1
-#undef HAVE_ICONV_H
-#define HAVE_SIGNAL_H 1
-#undef HAVE_ALTIVEC_H
-
-#define HAVE_MALLOC 1
-#define HAVE_CALLOC 1
-#define HAVE_REALLOC 1
-#define HAVE_FREE 1
-#define HAVE_ALLOCA 1
-#define HAVE_GETENV 1
-#define HAVE_PUTENV 1
-#define HAVE_UNSETENV 1
-#define HAVE_QSORT 1
-#define HAVE_ABS 1
-#define HAVE_BCOPY 1
-#define HAVE_MEMSET 1
-#define HAVE_MEMCPY 1
-#define HAVE_MEMMOVE 1
-#define HAVE_MEMCMP 1
-#define HAVE_STRLEN 1
-#define HAVE_STRLCPY 1
-#define HAVE_STRLCAT 1
-#define HAVE_STRDUP 1
-#undef HAVE__STRREV
-#undef HAVE__STRUPR
-#undef HAVE__STRLWR
-#define HAVE_INDEX 1
-#define HAVE_RINDEX 1
-#define HAVE_STRCHR 1
-#define HAVE_STRRCHR 1
-#define HAVE_STRSTR 1
-#undef HAVE_ITOA
-#undef HAVE__LTOA
-#undef HAVE__UITOA
-#undef HAVE__ULTOA
-#define HAVE_STRTOL
-#define HAVE_STRTOUL
-#undef HAVE__I64TOA
-#undef HAVE__UI64TOA
-#define HAVE_STRTOLL 1
-#define HAVE_STRTOULL 1
-#define HAVE_STRTOD 1
-#define HAVE_ATOI 1
-#define HAVE_ATOF 1
-#define HAVE_STRCMP 1
-#define HAVE_STRNCMP 1
-#undef HAVE__STRICMP
-#define HAVE_STRCASECMP 1
-#undef HAVE__STRNICMP
-#define HAVE_STRNCASECMP 1
-#define HAVE_SSCANF 1
-#define HAVE_SNPRINTF 1
-#define HAVE_VSNPRINTF 1
-#undef HAVE_ICONV
-#define HAVE_SIGACTION 1
-#define HAVE_SETJMP 1
-#define HAVE_NANOSLEEP 1
-#define HAVE_CLOCK_GETTIME 1
-#define HAVE_GETPAGESIZE 1
-#define HAVE_MPROTECT 1
-
-#define HAVE_CEIL 1
-#define HAVE_COPYSIGN 1
-#define HAVE_COS 1
-#define HAVE_COSF 1
-#define HAVE_FABS 1
-#define HAVE_FLOOR 1
-#define HAVE_LOG 1
-#define HAVE_M_PI 1
-#define HAVE_POW 1
-#define HAVE_SCALBN 1
-#define HAVE_SETENV 1
-#define HAVE_SIN 1
-#define HAVE_SINF 1
-#define HAVE_SQRT 1
-#define HAVE_ATAN 1
-#define HAVE_ATAN2 1
-#define HAVE_SYSCONF 1
-#undef HAVE_SYSCTLBYNAME
-#undef SDL_ALTIVEC_BLITTERS
-#define SDL_ASSEMBLY_ROUTINES 1 // There is no assembly code for Arm CPU yet
-#define HAVE_GCC_ATOMICS 1
-
-/* Prototypes for Android-specific functions */
-
-#include "begin_code.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
-Sets callbacks to be called when OS decides to put application to background, and restored to foreground.
-*/
-typedef void ( * SDL_ANDROID_ApplicationPutToBackgroundCallback_t ) (void);
-
-extern DECLSPEC int SDLCALL SDL_ANDROID_SetApplicationPutToBackgroundCallback(
- SDL_ANDROID_ApplicationPutToBackgroundCallback_t appPutToBackground,
- SDL_ANDROID_ApplicationPutToBackgroundCallback_t appRestored );
-
-/* Use these functions instead of setting volume to 0, that will save CPU and battery on device */
-extern DECLSPEC int SDLCALL SDL_ANDROID_PauseAudioPlayback(void);
-extern DECLSPEC int SDLCALL SDL_ANDROID_ResumeAudioPlayback(void);
-
-#ifdef __cplusplus
-}
-#endif
-#include "close_code.h"
-
-#endif /* _SDL_config_minimal_h */
diff --git a/project/jni/sdl-1.3/include/SDL_config_android.h b/project/jni/sdl-1.3/include/SDL_config_android.h
new file mode 120000
index 000000000..db6a1c3f7
--- /dev/null
+++ b/project/jni/sdl-1.3/include/SDL_config_android.h
@@ -0,0 +1 @@
+../../sdl-1.2/include/SDL_config_android.h
\ No newline at end of file
diff --git a/project/jni/sdl-1.3/src/video/android/SDL_androidvideo.c b/project/jni/sdl-1.3/src/video/android/SDL_androidvideo.c
index a120f5349..bea6e6bc5 100644
--- a/project/jni/sdl-1.3/src/video/android/SDL_androidvideo.c
+++ b/project/jni/sdl-1.3/src/video/android/SDL_androidvideo.c
@@ -37,6 +37,7 @@
#include "SDL_mouse.h"
#include "SDL_mutex.h"
#include "SDL_thread.h"
+#include "SDL_android.h"
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"
@@ -62,6 +63,8 @@ static jobject JavaRenderer = NULL;
static jmethodID JavaSwapBuffers = NULL;
static jmethodID JavaShowScreenKeyboard = NULL;
static jmethodID JavaToggleScreenKeyboardWithoutTextInput = NULL;
+static jmethodID JavaGetAdvertisementParams = NULL;
+static jmethodID JavaSetAdvertisementParams = NULL;
static int glContextLost = 0;
static int showScreenKeyboardDeferred = 0;
static const char * showScreenKeyboardOldText = "";
@@ -291,6 +294,11 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject t
JavaSwapBuffers = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "swapBuffers", "()I");
JavaShowScreenKeyboard = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "showScreenKeyboard", "(Ljava/lang/String;I)V");
JavaToggleScreenKeyboardWithoutTextInput = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "showScreenKeyboardWithoutTextInputField", "()V");
+ // TODO: implement it
+ /*
+ JavaGetAdvertisementParams = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "GetAdvertisementParams", "()V");
+ JavaSetAdvertisementParams = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "SetAdvertisementParams", "(III)V");
+ */
ANDROID_InitOSKeymap();
}