Skip to content

Commit

Permalink
Merge pull request #290 from Ghabry/android
Browse files Browse the repository at this point in the history
Android: ICU
  • Loading branch information
Ghabry committed Jul 2, 2014
2 parents bc9c79f + a217a2b commit 865f469
Show file tree
Hide file tree
Showing 11 changed files with 341 additions and 43 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ resources/player.aps
/builds/archive
/builds/*/toolchain.cmake
/builds/android/android
/builds/android/local.properties
/builds/android/assets/
/builds/vs20*/Debug*
/builds/vs20*/Release*
/builds/vs20*/*.*sdf
Expand Down
Empty file added builds/android/assets/.gitkeep
Empty file.
4 changes: 2 additions & 2 deletions builds/android/jni/src/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ LOCAL_SRC_FILES := SDL_android_main.c \

LOCAL_SHARED_LIBRARIES := SDL2 SDL2_mixer iconv #smpeg2 #freetype2-static pixman png

LOCAL_LDLIBS := -L$(EASYDEV_ANDROID)/libs/armeabi-v7a -lGLESv1_CM -llog -lz -lfreetype2-static -lpixman -lpng -lcpufeatures
LOCAL_LDLIBS := -L$(EASYDEV_ANDROID)/libs/armeabi-v7a -lGLESv1_CM -llog -lz -lfreetype2-static -lpixman -lpng -licui18n -licuuc -licudata -lcpufeatures

LOCAL_CFLAGS := -O2 -Wall -Wextra -fno-rtti -DUSE_SDL -DHAVE_SDL_MIXER -DNDEBUG -DUNIX
LOCAL_CFLAGS := -O2 -Wall -Wextra -fno-rtti -DUSE_SDL -DHAVE_SDL_MIXER -DLCF_SUPPORT_ICU
LOCAL_CPPFLAGS = $(LOCAL_C_FLAGS) -fno-exceptions -std=c++0x

include $(BUILD_SHARED_LIBRARY)
66 changes: 59 additions & 7 deletions builds/android/res/layout/region_menu.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
<RadioGroup
android:id="@+id/rg"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>

<RadioButton
android:id="@+id/rd_autodetect"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/autodetect" />

<RadioButton
android:id="@+id/rd_west"
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/west_europe" />

<RadioButton
android:id="@+id/rd_east"
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/east_europe" />


<RadioButton
android:id="@+id/rd_cyrillic"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/cyrillic" />

<RadioButton
android:id="@+id/rd_jp"
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/japan" />

<RadioButton
android:id="@+id/rd_korean"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/korean" />

<RadioButton
android:id="@+id/rd_chinese_simple"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/chinese_simple" />

<RadioButton
android:id="@+id/rd_chinese_traditional"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/chinese_traditional" />

<RadioButton
android:id="@+id/rd_greek"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/greek" />

<RadioButton
android:id="@+id/rd_turkish"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/turkish" />

<RadioButton
android:id="@+id/rd_baltic"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/baltic" />
</RadioGroup>

<Button
Expand All @@ -35,4 +87,4 @@
android:layout_centerInParent="true"
android:text="@string/cancel" />
</RelativeLayout>

</ScrollView>
18 changes: 15 additions & 3 deletions builds/android/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@
<string name="toggle_fps">Toggle FPS</string>
<string name="toggle_ui">Toggle Virtual Buttons</string>
<string name="end_game">End Game</string>
<string name="west_europe">Western Europe</string>
<string name="east_europe">Eastern Europe</string>
<string name="japan">Japan</string>
<string name="autodetect">Autodetect Region (Recommended)</string>
<string name="west_europe">Western European</string>
<string name="east_europe">Central/Eastern European</string>
<string name="cyrillic">Cyrillic</string>
<string name="japan">Japanese</string>
<string name="korean">Korean</string>
<string name="chinese_simple">Chinese (Simplified)</string>
<string name="chinese_traditional">Chinese (Traditional)</string>
<string name="greek">Greek</string>
<string name="turkish">Turkish</string>
<string name="hebrew">Hebrew</string>
<string name="arabic">Arabic</string>
<string name="baltic">Baltic</string>
<string name="thai">Thai</string>
<string name="vietnamese">Vietnamese</string>
<string name="cancel">Cancel</string>
</resources>
126 changes: 126 additions & 0 deletions builds/android/src/org/easyrpg/player/AssetUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* This file is part of EasyRPG Player
*
* Copyright (c) 2013 EasyRPG Project. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/

package org.easyrpg.player;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import android.content.res.AssetManager;
import android.os.Environment;
import android.util.Log;

// based on https://stackoverflow.com/q/15574983/

public class AssetUtils {
public static void copyFolder(AssetManager assetManager, String source, String target) {
// "Name" is the name of your folder!
String[] files = null;

String state = Environment.getExternalStorageState();

if (Environment.MEDIA_MOUNTED.equals(state)) {
// We can read and write the media
// Checking file on assets subfolder
try {
files = assetManager.list(source);
} catch (IOException e) {
Log.e("ERROR", "Failed to get asset file list.", e);
}
// Analyzing all file on assets subfolder
for (String filename : files) {
InputStream in = null;
OutputStream out = null;
// First: checking if there is already a target folder
File folder = new File(target);
boolean success = true;
if (!folder.exists()) {
success = folder.mkdir();
}
if (success) {
// Moving all the files on external SD
String sourceFile = source + "/" + filename;
String targetFile = folder.getAbsolutePath() + "/" + filename;
try {
in = assetManager.open(sourceFile);
out = new FileOutputStream(targetFile);
/*Log.i("WEBVIEW",
Environment.getExternalStorageDirectory()
+ "/yourTargetFolder/" + name + "/"
+ filename);*/
copyFile(in, out);
in.close();
in = null;
out.flush();
out.close();
out = null;
} catch (IOException e) {
try {
assetManager.list(sourceFile);
} catch (IOException f) {
Log.e("ERROR",
"Failed to copy asset file: " + filename, f);
continue;
}

copyFolder(assetManager, sourceFile, targetFile);
}
} else {
// Do something else on failure
}
}
} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
// We can only read the media
} else {
// Something else is wrong. It may be one of many other states, but
// all we need
// is to know is we can neither read nor write
}
}

// Method used by copyAssets() on purpose to copy a file.
private static void copyFile(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[1024];
int read;
while ((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
}

public static boolean exists(AssetManager assetManager, String source) {
try {
String[] s = assetManager.list(source);
if (s == null || s.length == 0) {
return false;
}

return true;
} catch (IOException e) {
return false;
}
}
}
30 changes: 16 additions & 14 deletions builds/android/src/org/easyrpg/player/EasyRpgPlayerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

package org.easyrpg.player;

import java.io.File;

import org.libsdl.app.SDLActivity;

import android.os.Build;
Expand Down Expand Up @@ -51,24 +53,20 @@
*/

public class EasyRpgPlayerActivity extends SDLActivity {
ImageView aView, bView, cView;
boolean uiVisible = true;
private ImageView aView, bView, cView;
private boolean uiVisible = true;

@Override
protected void onCreate(Bundle savedInstanceState) {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

try {

if (Build.VERSION.SDK_INT >= 11) {

// Api 11: FLAG_HARDWARE_ACCELERATED

getWindow().setFlags(0x01000000, 0x01000000);

}

} catch (Exception e) {}

mLayout = (RelativeLayout)findViewById(R.id.main_layout);
mLayout.addView(mSurface);

Expand All @@ -78,8 +76,8 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK )&&(!
event.isAltPressed()))
// Alt-Test for working around ugly Xperia Play button mapping
if ((keyCode == KeyEvent.KEYCODE_BACK) && (!event.isAltPressed()))
{
showEndGameDialog();
}
Expand Down Expand Up @@ -166,9 +164,13 @@ public String getProjectPath() {
* @return Full path to the timidity.cfg
*/
public String getTimidityPath() {
String str = Environment.getExternalStorageDirectory().getPath() + "/easyrpg/timidity";
//Log.v("SDL", "getTimidity " + str);
return str;
//Log.v("SDL", "getTimidity " + getApplication().getApplicationInfo().dataDir);
String s = getApplication().getApplicationInfo().dataDir + "/timidity";
if (new File(s).exists()) {
return s;
}

return Environment.getExternalStorageDirectory().getPath() + "/easyrpg/timidity";
}

/**
Expand Down Expand Up @@ -212,7 +214,7 @@ public int getScreenWidth() {
*/
private Paint getPainter() {
Paint uiPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
uiPaint.setColor(Color.argb(64, 255, 255, 255));
uiPaint.setColor(Color.argb(128, 255, 255, 255));
uiPaint.setStyle(Style.STROKE);
uiPaint.setStrokeWidth((float)3.0);
return uiPaint;
Expand Down
Loading

0 comments on commit 865f469

Please sign in to comment.