diff --git a/project/AndroidManifestTemplate.xml b/project/AndroidManifestTemplate.xml
index cb6e16cd4..9f13ae286 100644
--- a/project/AndroidManifestTemplate.xml
+++ b/project/AndroidManifestTemplate.xml
@@ -30,6 +30,14 @@
+
diff --git a/project/java/MainActivity.java b/project/java/MainActivity.java
index b799121be..29ae9cac1 100644
--- a/project/java/MainActivity.java
+++ b/project/java/MainActivity.java
@@ -1276,6 +1276,8 @@ public class MainActivity extends Activity
void setScreenOrientation()
{
+ if( !Globals.AutoDetectOrientation && getIntent().getBooleanExtra(RestartMainActivity.ACTIVITY_AUTODETECT_SCREEN_ORIENTATION, false) )
+ Globals.AutoDetectOrientation = true;
if( Globals.AutoDetectOrientation )
{
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
diff --git a/project/java/RestartMainActivity.java b/project/java/RestartMainActivity.java
new file mode 100644
index 000000000..218b6bbc7
--- /dev/null
+++ b/project/java/RestartMainActivity.java
@@ -0,0 +1,144 @@
+/*
+Simple DirectMedia Layer
+Java source code (C) 2009-2014 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.app.Service;
+import android.content.Context;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.view.MotionEvent;
+import android.view.KeyEvent;
+import android.view.Window;
+import android.view.WindowManager;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+import android.widget.EditText;
+import android.text.Editable;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.FrameLayout;
+import android.graphics.drawable.Drawable;
+import android.graphics.Color;
+import android.content.res.Configuration;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+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;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.FileOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.zip.*;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.Set;
+import android.text.SpannedString;
+import java.io.BufferedReader;
+import java.io.BufferedInputStream;
+import java.io.InputStreamReader;
+import android.view.inputmethod.InputMethodManager;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.os.Handler;
+import android.os.Message;
+import android.os.SystemClock;
+import java.util.concurrent.Semaphore;
+import android.content.pm.ActivityInfo;
+import android.view.Display;
+import android.util.DisplayMetrics;
+import android.text.InputType;
+import android.util.Log;
+import android.view.Surface;
+import android.app.ProgressDialog;
+import android.app.KeyguardManager;
+import android.view.ViewTreeObserver;
+import android.graphics.Rect;
+
+
+public class RestartMainActivity extends Activity
+{
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ Log.i("SDL", "Restarting main activity");
+ super.onCreate(savedInstanceState);
+
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+
+ _layout = new LinearLayout(this);
+ _layout.setOrientation(LinearLayout.VERTICAL);
+ _layout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
+
+ //Get the display so we can know the screen size
+ Display display = getWindowManager().getDefaultDisplay();
+ int width = display.getWidth();
+ int height = display.getHeight();
+ _tv = new TextView(this);
+ _tv.setMaxLines(2);
+ _tv.setMinLines(2);
+ _tv.setText(R.string.restarting_please_wait);
+ _tv.setPadding((int)(width * 0.1), (int)(height * 0.1), (int)(width * 0.1), 0);
+
+ _videoLayout = new FrameLayout(this);
+ _videoLayout.addView(_layout);
+
+ setContentView(_videoLayout);
+
+ new Thread(new Runnable()
+ {
+ public void run()
+ {
+ try{
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {}
+ Intent intent = new Intent(RestartMainActivity.this, MainActivity.class);
+ intent.putExtra(ACTIVITY_AUTODETECT_SCREEN_ORIENTATION, getIntent().getBooleanExtra(ACTIVITY_AUTODETECT_SCREEN_ORIENTATION, false));
+ RestartMainActivity.this.startActivity(intent);
+ try{
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {}
+ System.exit(0);
+ }
+ }).start();
+ }
+
+ private TextView _tv = null;
+ private LinearLayout _layout = null;
+ private FrameLayout _videoLayout = null;
+
+ public static final String ACTIVITY_AUTODETECT_SCREEN_ORIENTATION = "libsdl.org.ACTIVITY_AUTODETECT_SCREEN_ORIENTATION";
+}
diff --git a/project/java/Settings.java b/project/java/Settings.java
index bd45db53f..1134bbcf7 100644
--- a/project/java/Settings.java
+++ b/project/java/Settings.java
@@ -498,9 +498,9 @@ class Settings
} catch( FileNotFoundException e ) {
} catch ( IOException e ) { }
new File( p.getFilesDir() + "/" + SettingsFileName ).delete();
- PendingIntent intent = PendingIntent.getActivity(p, 0, new Intent(p.getIntent()), p.getIntent().getFlags());
- AlarmManager mgr = (AlarmManager) p.getSystemService(Context.ALARM_SERVICE);
- mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, intent);
+
+ Intent intent = new Intent(context, RestartMainActivity.class);
+ context.startActivity(intent);
System.exit(0);
}
diff --git a/project/java/Video.java b/project/java/Video.java
index 8c83692a7..42403e928 100644
--- a/project/java/Video.java
+++ b/project/java/Video.java
@@ -620,7 +620,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
{
// Samsung multiwindow will swap screen dimensionswhen unlocking the lockscreen, sleep a while so we won't use these temporary values
try{
- Thread.sleep(3000);
+ Thread.sleep(2000);
} catch (InterruptedException e) {}
int ww = w;
int hh = h;
@@ -633,9 +633,12 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
if(mWidth != 0 && mHeight != 0 && (mWidth != ww || mHeight != hh))
{
Log.w("SDL", "libSDL: DemoRenderer.onWindowResize(): screen size changed from " + mWidth + "x" + mHeight + " to " + ww + "x" + hh + " - restarting application");
- PendingIntent intent = PendingIntent.getActivity(context, 0, new Intent(context.getIntent()), context.getIntent().getFlags());
- AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
- mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, intent);
+ Intent intent = new Intent(context, RestartMainActivity.class);
+ intent.putExtra(RestartMainActivity.ACTIVITY_AUTODETECT_SCREEN_ORIENTATION, true);
+ context.startActivity(intent);
+ try{
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {}
System.exit(0);
}
}
diff --git a/project/java/translations/values/strings.xml b/project/java/translations/values/strings.xml
index 642b30edf..6a36e9aec 100644
--- a/project/java/translations/values/strings.xml
+++ b/project/java/translations/values/strings.xml
@@ -197,4 +197,6 @@
==GOOGLEPLAYGAMESERVICES_APP_ID==
+ Restarting, please wait.
+