Commit 8766ec37 authored by Marijn van der Werf's avatar Marijn van der Werf
Browse files

Add Android project

parent 5f5f12a6
Showing with 2582 additions and 1 deletion
+2582 -1
# OPENRCT2
sdl
/sdl
# Compiled dll
openrct2.dll
# Distribution
distribution/windows/*.exe
distribution/android/*/external/
# Build artifacts
artifacts
......
......@@ -86,6 +86,42 @@ matrix:
curl -o - -v --form "key=$OPENRCT2_ORG_TOKEN" --form "fileName=OpenRCT2-${OPENRCT2_VERSION}${FILENAME_PART}-macos.zip" --form "version=${OPENRCT2_VERSION}" --form "gitHash=$TRAVIS_COMMIT" --form "gitBranch=$PUSH_BRANCH" --form "flavourId=3" --form "file=@openrct2-macos.zip" "https://openrct2.org/altapi/?command=push-build"; else
curl --progress-bar --upload-file openrct2-macos.zip https://transfer.sh/openrct2-macos.zip -o link && cat link;
fi
- os: linux
language: android
dist: precise
before_install: []
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libstdc++6-4.7-dev
android:
components:
- build-tools-25.0.2
jdk: oraclejdk8
before_script:
- pushd ~
- wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
- unzip -qo sdk-tools-linux-3859397.zip
- rm -Rf "$ANDROID_HOME/tools"
- mv tools "$ANDROID_HOME/tools"
- popd
- 'echo "count=0" > ~/.android/repositories.cfg'
- '"$ANDROID_HOME/tools/bin/sdkmanager" --list'
- 'echo y | "$ANDROID_HOME/tools/bin/sdkmanager" platform-tools'
- 'echo y | "$ANDROID_HOME/tools/bin/sdkmanager" "platforms;android-25"'
- 'echo y | "$ANDROID_HOME/tools/bin/sdkmanager" "cmake;3.6.3155560"'
- '"$ANDROID_HOME/tools/bin/sdkmanager" ndk-bundle'
- '"$ANDROID_HOME/tools/bin/sdkmanager" --list'
- 'export ANDROID_NDK_HOME="$ANDROID_HOME/ndk-bundle"'
- 'cd src/openrct2-android'
- TERM=dumb # Makes Gradle use 'boring' output
script:
- './gradlew app:assemblePR'
after_success:
- curl --progress-bar --upload-file app/build/outputs/apk/app-arm-pr.apk https://transfer.sh/openrct2-android-arm.apk -o link && cat link
- curl --progress-bar --upload-file app/build/outputs/apk/app-x86-pr.apk https://transfer.sh/openrct2-android-x86.apk -o link && cat link
# Following entries used to be included in testing, but they only proved useful while changing things in CMake setup.
# They are meant to be used when there are changes to CMakeLists.txt
# - os: linux
......
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# Intellij
*.iml
# Keystore files
*.jks
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
defaultConfig {
applicationId 'website.openrct2'
minSdkVersion 16
targetSdkVersion 25
versionCode 2
versionName '0.0.8'
externalNativeBuild {
cmake {
arguments '-DANDROID_STL=c++_shared'
targets 'openrct2', 'openrct2-ui'
}
}
}
signingConfigs {
debug {
storeFile file('external/debug.keystore')
}
}
buildTypes {
debug {
applicationIdSuffix '.debug'
versionNameSuffix '-DEBUG'
}
pr {
applicationIdSuffix '.debug'
signingConfig signingConfigs.debug
}
develop {
applicationIdSuffix '.develop'
versionNameSuffix '-DEVELOP'
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.debug
}
}
externalNativeBuild {
cmake {
path 'src/main/CMakeLists.txt'
}
}
productFlavors {
arm7 {
ndk {
abiFilters 'armeabi-v7a'
}
}
arm {
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a'
}
}
x86 {
ndk {
abiFilters 'x86', 'x86_64'
}
}
}
}
apply plugin: 'de.undercouch.download'
android.applicationVariants.all { variant ->
variant.mergeAssets.doLast {
copy {
from '../../../data'
into "$variant.mergeAssets.outputDir/data"
}
download {
src 'https://github.com/marijnvdwerf/openrct2-dependencies-android/releases/download/v0.7/g2.dat'
dest "$variant.mergeAssets.outputDir/data"
}
download {
src 'https://github.com/OpenRCT2/title-sequences/releases/download/v0.0.5/title-sequence-v0.0.5.zip'
dest new File(buildDir, 'title-sequence.zip')
}
copy {
from zipTree(new File(buildDir, 'title-sequence.zip'))
into "$variant.mergeAssets.outputDir/data/title"
}
}
}
dependencies {
compile 'commons-io:commons-io:2.5'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.android.gms:play-services-analytics:10.2.1'
}
apply plugin: 'com.google.gms.google-services'
File added
{
"project_info": {
"project_number": "",
"project_id": ""
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "",
"android_client_info": {
"package_name": "website.openrct2.debug"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": ""
}
],
"services": {
"analytics_service": {
"status": 2,
"analytics_property": {
"tracking_id": "UA-XXXXXXXX-1"
}
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 1
}
}
},
{
"client_info": {
"mobilesdk_app_id": "",
"android_client_info": {
"package_name": "website.openrct2.develop"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": ""
}
],
"services": {
"analytics_service": {
"status": 2,
"analytics_property": {
"tracking_id": "UA-XXXXXXXX-1"
}
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 1
}
}
},
{
"client_info": {
"mobilesdk_app_id": "",
"android_client_info": {
"package_name": "website.openrct2"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": ""
}
],
"services": {
"analytics_service": {
"status": 2,
"analytics_property": {
"tracking_id": "UA-XXXXXXXX-1"
}
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 1
}
}
}
],
"configuration_version": "1"
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="website.openrct2">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:name=".OpenRCT2App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/AppTheme.Splash">
<activity
android:name=".MainActivity"
android:theme="@style/AppTheme.Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".GameActivity"
android:configChanges="keyboardHidden|orientation|screenSize">
</activity>
</application>
</manifest>
\ No newline at end of file
cmake_minimum_required(VERSION 3.6.0)
set(CMAKE_VERBOSE_MAKEFILE on)
set(lib_src_DIR ${CMAKE_SOURCE_DIR}/../../../libs)
set(lib_build_DIR $ENV{HOME}/tmp)
file(MAKE_DIRECTORY ${lib_build_DIR})
set(DEBUG_LEVEL 0 CACHE STRING "Select debug level for compilation. Use value in range 0–3.")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDEBUG=${DEBUG_LEVEL}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG=${DEBUG_LEVEL}")
include(ExternalProject)
ExternalProject_Add(libs
URL https://github.com/marijnvdwerf/openrct2-dependencies-android/releases/download/v0.7/openrct2-libs-android-${ANDROID_ABI}.zip
SOURCE_DIR "${CMAKE_BINARY_DIR}/libs"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
BUILD_BYPRODUCTS
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}freetype${CMAKE_SHARED_LIBRARY_SUFFIX}
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}jansson${CMAKE_SHARED_LIBRARY_SUFFIX}
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}png16${CMAKE_SHARED_LIBRARY_SUFFIX}
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}SDL2-2.0${CMAKE_SHARED_LIBRARY_SUFFIX}
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2main${CMAKE_STATIC_LIBRARY_SUFFIX}
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}speexdsp${CMAKE_SHARED_LIBRARY_SUFFIX}
LOG_DOWNLOAD 1
LOG_UPDATE 1
LOG_CONFIGURE 1
LOG_BUILD 1
LOG_TEST 1
LOG_INSTALL 1
)
add_custom_command(TARGET libs POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/libs/lib/*.so" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
)
add_library(freetype SHARED IMPORTED)
set_target_properties(freetype PROPERTIES IMPORTED_LOCATION
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}freetype${CMAKE_SHARED_LIBRARY_SUFFIX}
)
add_dependencies(freetype libs)
add_library(jansson SHARED IMPORTED)
set_target_properties(jansson PROPERTIES IMPORTED_LOCATION
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}jansson${CMAKE_SHARED_LIBRARY_SUFFIX}
)
add_dependencies(jansson libs)
add_library(png SHARED IMPORTED)
set_target_properties(png PROPERTIES IMPORTED_LOCATION
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}png16${CMAKE_SHARED_LIBRARY_SUFFIX}
)
add_dependencies(png libs)
add_library(SDL2 SHARED IMPORTED)
set_target_properties(SDL2 PROPERTIES IMPORTED_LOCATION
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}SDL2-2.0${CMAKE_SHARED_LIBRARY_SUFFIX}
)
add_dependencies(SDL2 libs)
add_library(SDL2main STATIC IMPORTED)
set_target_properties(SDL2main PROPERTIES IMPORTED_LOCATION
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2main${CMAKE_STATIC_LIBRARY_SUFFIX}
)
add_dependencies(SDL2main libs)
add_library(speexdsp SHARED IMPORTED)
set_target_properties(speexdsp PROPERTIES IMPORTED_LOCATION
${CMAKE_BINARY_DIR}/libs/lib/${CMAKE_SHARED_LIBRARY_PREFIX}speexdsp${CMAKE_SHARED_LIBRARY_SUFFIX}
)
add_dependencies(speexdsp libs)
include_directories("${CMAKE_BINARY_DIR}/libs/include")
include_directories("${CMAKE_BINARY_DIR}/libs/include/freetype2")
include_directories("${CMAKE_BINARY_DIR}/libs/include/SDL2")
# now build app's shared lib
include_directories(./ndk_helper
${ANDROID_NDK}/sources/android/cpufeatures)
add_definitions(-DDISABLE_HTTP -DDISABLE_TWITCH -DDISABLE_NETWORK -DDISABLE_OPENGL -DGL_GLEXT_PROTOTYPES -D__STDC_LIMIT_MACROS -DNO_RCT2 -DNO_TTF -DSDL_MAIN_HANDLED)
# Fix SpeexDSP compilation
add_definitions(-DHAVE_STDINT_H)
set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -fstrict-aliasing -Werror -Wundef -Wmissing-declarations -Winit-self -Wall -Wno-unknown-pragmas -Wno-unused-function -Wno-missing-braces ")
set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -Wno-comment -Wshadow -Wmissing-declarations -Wnonnull")
set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -fPIC")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--undefined=Java_org_libsdl_app_SDLActivity_nativeInit")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11 ${COMMON_COMPILE_OPTIONS} -Wimplicit")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14 ${COMMON_COMPILE_OPTIONS} -Wnon-virtual-dtor")
get_filename_component(ORCT2_ROOT "${CMAKE_SOURCE_DIR}/../../../../../" REALPATH)
file(GLOB_RECURSE LIBOPENRCT2_SOURCES
"${ORCT2_ROOT}/src/openrct2/*.c"
"${ORCT2_ROOT}/src/openrct2/*.cpp"
"${ORCT2_ROOT}/src/openrct2/*.h"
"${ORCT2_ROOT}/src/openrct2/*.hpp")
file(GLOB_RECURSE OPENRCT2_GUI_SOURCES
"${ORCT2_ROOT}/src/openrct2-ui/*.c"
"${ORCT2_ROOT}/src/openrct2-ui/*.cpp"
"${ORCT2_ROOT}/src/openrct2-ui/*.h"
"${ORCT2_ROOT}/src/openrct2-ui/*.hpp")
add_library(openrct2 SHARED ${LIBOPENRCT2_SOURCES})
target_link_libraries(openrct2
android log dl GLESv1_CM GLESv2 z
SDL2 png jansson speexdsp
)
add_library(openrct2-ui SHARED ${OPENRCT2_GUI_SOURCES})
target_link_libraries(openrct2-ui openrct2 SDL2main)
target_include_directories(openrct2-ui PRIVATE "${ORCT2_ROOT}/src")
\ No newline at end of file
This diff is collapsed.
package website.openrct2;
import org.libsdl.app.SDLActivity;
public class GameActivity extends SDLActivity {
public float getDefaultScale() {
return getResources().getDisplayMetrics().density;
}
@Override
protected String[] getLibraries() {
return new String[]{
"c++_shared",
"speexdsp",
"jansson",
"png16",
"SDL2-2.0",
"openrct2",
"openrct2-ui"
};
}
protected String[] getArguments() {
if (getIntent().hasExtra("commandLineArgs")) {
return getIntent().getStringArrayExtra("commandLineArgs");
}
return new String[0];
}
}
package website.openrct2;
import java.io.UnsupportedEncodingException;
public class Localisation {
static final String TAG = Localisation.class.getSimpleName();
public static String win1252ToUtf8(byte[] src) {
try {
return new String(src, "CP1252");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return "";
}
}
package website.openrct2;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.graphics.Point;
import android.graphics.PointF;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.Surface;
import com.google.android.gms.analytics.HitBuilders;
import com.google.android.gms.analytics.Tracker;
import org.apache.commons.io.IOUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class MainActivity extends AppCompatActivity {
public static final String TAG = "OpenRCT2";
private boolean assetsCopied = false;
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (hasRequiredPermissions()) {
startGame();
}
}
private String[] getSupportedAbis() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return Build.SUPPORTED_ABIS;
}
if (!TextUtils.isEmpty(Build.CPU_ABI2)) {
return new String[]{Build.CPU_ABI, Build.CPU_ABI2};
}
return new String[]{Build.CPU_ABI};
}
private PointF getResolutionDips() {
PointF out = new PointF();
Point pixelSize = new Point();
Display display = getWindowManager().getDefaultDisplay();
DisplayMetrics metrics = new DisplayMetrics();
display.getMetrics(metrics);
boolean success = false;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
display.getRealSize(pixelSize);
display.getRealMetrics(metrics);
success = true;
} else {
try {
Method getRawHeight = Display.class.getMethod("getRawHeight");
Method getRawWidth = Display.class.getMethod("getRawWidth");
pixelSize.x = (Integer) getRawWidth.invoke(display);
pixelSize.y = (Integer) getRawHeight.invoke(display);
success = true;
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
if (!success) {
// Fall back to viewport size
display.getSize(pixelSize);
}
int rotation = display.getRotation();
if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
pixelSize = new Point(pixelSize.y, pixelSize.x);
}
out.x = ((float) pixelSize.x) / metrics.density;
out.y = ((float) pixelSize.y) / metrics.density;
return out;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String[] supportedAbis = getSupportedAbis();
PointF resolution = getResolutionDips();
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
Tracker tracker = ((OpenRCT2App) getApplication()).getDefaultTracker();
tracker.setScreenName("Main");
tracker.setScreenResolution(Math.round(resolution.x), Math.round(resolution.y));
tracker.send(new HitBuilders.ScreenViewBuilder()
.setCustomDimension(1, Float.toString(displayMetrics.density))
.setCustomDimension(2, TextUtils.join(", ", supportedAbis))
.build()
);
}
@Override
protected void onStart() {
super.onStart();
if (!hasRequiredPermissions()) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
} else {
startGame();
}
}
private boolean hasRequiredPermissions() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) {
return false;
}
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) {
return false;
}
return true;
}
private void startGame() {
copyAssets();
Intent intent = new Intent(this, GameActivity.class);
if (getIntent().hasExtra("commandLineArgs")) {
intent.putExtra("commandLineArgs", getIntent().getStringArrayExtra("commandLineArgs"));
}
startActivity(intent);
finish();
}
private void copyAssets() {
File dataDir = new File("/sdcard/openrct2/");
try {
copyAsset(getAssets(), "data", dataDir, "");
} catch (IOException e) {
Log.e(TAG, "Error extracting files", e);
return;
}
assetsCopied = true;
}
private void copyAsset(AssetManager assets, String srcPath, File dataDir, String destPath) throws IOException {
String[] list = assets.list(srcPath);
if (list.length == 0) {
InputStream input = assets.open(srcPath);
File extractedFile = new File(dataDir, destPath);
File parentFile = extractedFile.getParentFile();
if (!parentFile.exists()) {
boolean success = parentFile.mkdirs();
if (!success) {
Log.d(TAG, String.format("Error creating folder '%s'", parentFile));
}
}
FileOutputStream output = new FileOutputStream(extractedFile);
IOUtils.copyLarge(input, output);
output.close();
input.close();
return;
}
for (String fileName : list) {
copyAsset(assets, srcPath + File.separator + fileName, dataDir, destPath + File.separator + fileName);
}
}
}
package website.openrct2;
import android.app.Application;
import com.google.android.gms.analytics.GoogleAnalytics;
import com.google.android.gms.analytics.Tracker;
public class OpenRCT2App extends Application {
private Tracker mTracker;
/**
* Gets the default {@link Tracker} for this {@link Application}.
*
* @return tracker
*/
synchronized public Tracker getDefaultTracker() {
if (mTracker == null) {
GoogleAnalytics analytics = GoogleAnalytics.getInstance(this);
// To enable debug logging use: adb shell setprop log.tag.GAv4 DEBUG
mTracker = analytics.newTracker(R.xml.global_tracker);
}
return mTracker;
}
}
package website.openrct2;
import android.util.Log;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class ZipArchive {
private final ZipFile _zipArchive;
public ZipArchive(String path) throws IOException {
_zipArchive = new ZipFile(path);
}
public void close() {
try {
_zipArchive.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public int getNumFiles() {
return _zipArchive.size();
}
private ZipEntry getZipEntry(int index) {
Enumeration<? extends ZipEntry> entries = _zipArchive.entries();
int i = 0;
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (index == i) {
return entry;
}
i++;
}
return null;
}
public String getFileName(int index) {
ZipEntry entry = getZipEntry(index);
if (entry != null) {
return entry.getName();
}
return null;
}
public long getFileSize(int index) {
ZipEntry entry = getZipEntry(index);
if (entry != null) {
return entry.getSize();
}
return -1;
}
public int getFileIndex(String path) {
Enumeration<? extends ZipEntry> entries = _zipArchive.entries();
int i = 0;
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (entry.getName().equalsIgnoreCase(path)) {
return i;
}
i++;
}
return -1;
}
public long getFile(int index) throws IOException {
ZipEntry entry = getZipEntry(index);
if (entry == null) {
return 0;
}
InputStream inputStream = _zipArchive.getInputStream(entry);
int numBytesToRead = (int) entry.getSize();
if (numBytesToRead == -1) {
Log.e("ZipArchive", "Unknown length for zip entry");
return 0;
}
byte[] inBuffer = new byte[numBytesToRead];
IOUtils.read(inputStream, inBuffer);
return allocBytes(inBuffer, numBytesToRead);
}
native static long allocBytes(byte[] input, int size);
}
src/openrct2-android/app/src/main/res/drawable-mdpi/logo_icon.png

4.47 KB

src/openrct2-android/app/src/main/res/drawable-mdpi/logo_text.png

5.21 KB

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="org.openrct2.android.MainActivity">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/logo_icon"
android:id="@+id/imageView"
android:layout_centerHorizontal="false" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/logo_text"
android:id="@+id/imageView2"
android:layout_marginTop="18dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="false"
android:layout_marginLeft="104dp" />
</RelativeLayout>
</RelativeLayout>
src/openrct2-android/app/src/main/res/mipmap-hdpi/ic_launcher.png

5.42 KB

src/openrct2-android/app/src/main/res/mipmap-mdpi/ic_launcher.png

2.91 KB

src/openrct2-android/app/src/main/res/mipmap-xhdpi/ic_launcher.png

7.9 KB

Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment