SDL: Android 2.3 compatibility is back
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
/>
|
||||
</application>
|
||||
|
||||
<uses-sdk android:minSdkVersion="11" android:targetSdkVersion="21"/>
|
||||
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="21"/>
|
||||
<!-- ==INTERNET== --> <uses-permission android:name="android.permission.INTERNET"></uses-permission>
|
||||
<!-- ==EXTERNAL_STORAGE== --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
|
||||
<!-- ==EXTERNAL_STORAGE== --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
|
||||
|
||||
140
project/java/Clipboard.java
Normal file
140
project/java/Clipboard.java
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
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.os.Bundle;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.AssetManager;
|
||||
import android.app.Activity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.InputDevice;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.ClipboardManager.OnPrimaryClipChangedListener;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.AlarmManager;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.view.Display;
|
||||
|
||||
|
||||
public abstract class Clipboard
|
||||
{
|
||||
public static Clipboard get()
|
||||
{
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB)
|
||||
return NewerClipboard.Holder.Instance;
|
||||
return OlderClipboard.Holder.Instance;
|
||||
}
|
||||
public abstract void set(final Context context, final String text);
|
||||
public abstract String get(final Context context);
|
||||
public abstract void setListener(final Context context, final Runnable listener);
|
||||
|
||||
private static class NewerClipboard extends Clipboard
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final NewerClipboard Instance = new NewerClipboard();
|
||||
}
|
||||
public void set(final Context context, final String text)
|
||||
{
|
||||
try {
|
||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
|
||||
if( clipboard != null )
|
||||
clipboard.setText(text);
|
||||
} catch (Exception e) {
|
||||
Log.i("SDL", "setClipboardText() exception: " + e.toString());
|
||||
}
|
||||
}
|
||||
public String get(final Context context)
|
||||
{
|
||||
String ret = "";
|
||||
try {
|
||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
|
||||
if( clipboard != null && clipboard.getText() != null )
|
||||
ret = clipboard.getText().toString();
|
||||
} catch (Exception e) {
|
||||
Log.i("SDL", "getClipboardText() exception: " + e.toString());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public void setListener(final Context context, final Runnable listener)
|
||||
{
|
||||
Log.i("SDL", "Cannot set clipboard listener on Android 2.3 or older");
|
||||
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
|
||||
clipboard.addPrimaryClipChangedListener(new OnPrimaryClipChangedListener()
|
||||
{
|
||||
public void onPrimaryClipChanged()
|
||||
{
|
||||
listener.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static class OlderClipboard extends Clipboard
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final OlderClipboard Instance = new OlderClipboard();
|
||||
}
|
||||
public void set(final Context context, final String text)
|
||||
{
|
||||
try {
|
||||
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
|
||||
if( clipboard != null )
|
||||
clipboard.setText(text);
|
||||
} catch (Exception e) {
|
||||
Log.i("SDL", "setClipboardText() exception: " + e.toString());
|
||||
}
|
||||
}
|
||||
public String get(final Context context)
|
||||
{
|
||||
String ret = "";
|
||||
try {
|
||||
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
|
||||
if( clipboard != null && clipboard.getText() != null )
|
||||
ret = clipboard.getText().toString();
|
||||
} catch (Exception e) {
|
||||
Log.i("SDL", "getClipboardText() exception: " + e.toString());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public void setListener(final Context context, final Runnable listener)
|
||||
{
|
||||
Log.i("SDL", "Cannot set clipboard listener on Android 2.3 or older");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,6 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.ClipboardManager.OnPrimaryClipChangedListener;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.AlarmManager;
|
||||
import android.content.Intent;
|
||||
@@ -570,16 +568,14 @@ abstract class DifferentTouchInput
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
{
|
||||
public DemoRenderer(MainActivity _context)
|
||||
{
|
||||
context = _context;
|
||||
clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
|
||||
clipboard.addPrimaryClipChangedListener(new OnPrimaryClipChangedListener()
|
||||
Clipboard.get().setListener(context, new Runnable()
|
||||
{
|
||||
public void onPrimaryClipChanged()
|
||||
public void run()
|
||||
{
|
||||
nativeClipboardChanged();
|
||||
}
|
||||
@@ -818,24 +814,12 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
|
||||
public String getClipboardText() // Called from native code
|
||||
{
|
||||
String ret = "";
|
||||
try {
|
||||
if( clipboard != null && clipboard.getText() != null )
|
||||
ret = clipboard.getText().toString();
|
||||
} catch (Exception e) {
|
||||
Log.i("SDL", "getClipboardText() exception: " + e.toString());
|
||||
}
|
||||
return ret;
|
||||
return Clipboard.get().get(context);
|
||||
}
|
||||
|
||||
public void setClipboardText(final String s) // Called from native code
|
||||
{
|
||||
try {
|
||||
if( clipboard != null )
|
||||
clipboard.setText(s);
|
||||
} catch (Exception e) {
|
||||
Log.i("SDL", "setClipboardText() exception: " + e.toString());
|
||||
}
|
||||
Clipboard.get().set(context, s);
|
||||
}
|
||||
|
||||
public void exitApp()
|
||||
@@ -1008,7 +992,6 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
private boolean mFirstTimeStart = true;
|
||||
public int mWidth = 0;
|
||||
public int mHeight = 0;
|
||||
private ClipboardManager clipboard = null;
|
||||
int mOrientationFrameHackyCounter = 0;
|
||||
|
||||
public static final boolean mRatelimitTouchEvents = true; //(Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO);
|
||||
|
||||
@@ -213,7 +213,7 @@ FirstStartMenuOptions='SettingsMenu.DummyMenu'
|
||||
|
||||
# Specify architectures to compile, 'all' or 'y' to compile for all architectures.
|
||||
# Available architectures: armeabi armeabi-v7a armeabi-v7a-hard x86 mips
|
||||
MultiABI='armeabi-v7a armeabi'
|
||||
MultiABI='armeabi-v7a'
|
||||
|
||||
# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower
|
||||
AppMinimumRAM=0
|
||||
|
||||
@@ -7,10 +7,10 @@ AppName="XServer XSDL"
|
||||
AppFullName=x.org.server
|
||||
|
||||
# Application version code (integer)
|
||||
AppVersionCode=11122
|
||||
AppVersionCode=11123
|
||||
|
||||
# Application user-visible version name (string)
|
||||
AppVersionName="1.11.22"
|
||||
AppVersionName="1.11.23"
|
||||
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user