diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml new file mode 100644 index 00000000..7b9dc7cf --- /dev/null +++ b/android/AndroidManifest.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + diff --git a/android/build-manual.sh b/android/build-manual.sh new file mode 100644 index 00000000..34b828b2 --- /dev/null +++ b/android/build-manual.sh @@ -0,0 +1,13 @@ +ANDROID_JAR=../android-13.jar +AAPT=./../aapt +DX=./../dx +APKBUILDER=./../apkbuilder +NAME=mod +mkdir bin +mkdir bin/classes +$AAPT package -M AndroidManifest.xml -m -S res -I $ANDROID_JAR +$JAVA_HOME/bin/javac -d bin/classes -s bin/classes -cp $ANDROID_JAR src/in/celest/xash3d/LauncherActivity.java +$DX --dex --output=bin/classes.dex bin/classes/ +$AAPT package -f -M AndroidManifest.xml -S res -I $ANDROID_JAR -F bin/$NAME.apk.unaligned +$APKBUILDER bin/$NAME.apk -u -nf libs/ -rj libs -f bin/classes.dex -z bin/$NAME.apk.unaligned +#java -jar /mnt/app/apktool/signapk.jar /mnt/app/apktool/testkey.x509.pem /mnt/app/apktool/testkey.pk8 bin/$NAME.apk bin/$NAME-signed.apk diff --git a/android/build.sh b/android/build.sh new file mode 100755 index 00000000..28b24e57 --- /dev/null +++ b/android/build.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +ndk-build NDK_TOOLCHAIN_VERSION=4.8 NDK_DEBUG=1 V=1 -j5 APP_CFLAGS="-w" +ant debug +#jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../myks.keystore bin/mod-unsigned.apk xashdroid -tsa https://timestamp.geotrust.com/tsa +#zipalign 4 bin/cs16-client-unsigned.apk bin/mod.apk diff --git a/android/build.xml b/android/build.xml new file mode 100644 index 00000000..88f6fb88 --- /dev/null +++ b/android/build.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/jni/Android.mk b/android/jni/Android.mk new file mode 100644 index 00000000..79964494 --- /dev/null +++ b/android/jni/Android.mk @@ -0,0 +1,6 @@ +override TARGET_arm_release_CFLAGS := +override TARGET_thumb_release_CFLAGS := +override TARGET_arm_debug_CFLAGS := +override TARGET_thumb_debug_CFLAGS := +override TARGET_CFLAGS := +include $(call all-subdir-makefiles) diff --git a/android/jni/Application.mk b/android/jni/Application.mk new file mode 100644 index 00000000..7322d629 --- /dev/null +++ b/android/jni/Application.mk @@ -0,0 +1,11 @@ +CFLAGS_OPT := -O3 -fomit-frame-pointer -ggdb -funsafe-math-optimizations -ftree-vectorize -fgraphite-identity -floop-interchange -floop-block -funsafe-loop-optimizations -finline-limit=1024 +CFLAGS_OPT_ARM := -mthumb -mfpu=neon -mcpu=cortex-a9 -pipe -mvectorize-with-neon-quad -DVECTORIZE_SINCOS +CFLAGS_OPT_ARMv5 :=-march=armv6 -mfpu=vfp -marm -pipe +CFLAGS_OPT_X86 := -mtune=atom -march=atom -mssse3 -mfpmath=sse -funroll-loops -pipe -DVECTORIZE_SINCOS +CFLAGS_HARDFP := -D_NDK_MATH_NO_SOFTFP=1 -mhard-float -mfloat-abi=hard -DLOAD_HARDFP -DSOFTFP_LINK +APPLICATIONMK_PATH = $(call my-dir) + +XASH3D_CONFIG := $(APPLICATIONMK_PATH)/mod_config.mk + +APP_ABI := x86 armeabi-v7a-hard armeabi +APP_MODULES := server diff --git a/android/jni/mod_config.mk b/android/jni/mod_config.mk new file mode 100644 index 00000000..5c0dc6bf --- /dev/null +++ b/android/jni/mod_config.mk @@ -0,0 +1,14 @@ +LOCAL_CFLAGS += $(CFLAGS_OPT) +ifeq ($(TARGET_ARCH_ABI),armeabi-v7a-hard) +LOCAL_CFLAGS += $(CFLAGS_OPT_ARM) $(CFLAGS_HARDFP) +endif +ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) +LOCAL_CFLAGS += $(CFLAGS_OPT_ARM) -mfloat-abi=softfp +endif +ifeq ($(TARGET_ARCH_ABI),armeabi) +LOCAL_CFLAGS += $(CFLAGS_OPT_ARMv5) +endif +ifeq ($(TARGET_ARCH_ABI),x86) +LOCAL_CFLAGS += $(CFLAGS_OPT_X86) +endif + diff --git a/android/jni/server b/android/jni/server new file mode 120000 index 00000000..e8dd6263 --- /dev/null +++ b/android/jni/server @@ -0,0 +1 @@ +../../dlls \ No newline at end of file diff --git a/android/project.properties b/android/project.properties new file mode 100644 index 00000000..4513a1e4 --- /dev/null +++ b/android/project.properties @@ -0,0 +1,11 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "build.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-3 diff --git a/android/res/drawable/gravgun.png b/android/res/drawable/gravgun.png new file mode 100644 index 00000000..184e83e9 Binary files /dev/null and b/android/res/drawable/gravgun.png differ diff --git a/android/src/in/celest/xash3d/LauncherActivity.java b/android/src/in/celest/xash3d/LauncherActivity.java new file mode 100644 index 00000000..91619ee3 --- /dev/null +++ b/android/src/in/celest/xash3d/LauncherActivity.java @@ -0,0 +1,73 @@ +package in.celest.xash3d; + +import android.app.Activity; +import android.os.Bundle; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.content.Intent; +import android.widget.EditText; +import android.widget.CheckBox; +import android.widget.CompoundButton; +import android.widget.LinearLayout; +import android.widget.LinearLayout.LayoutParams; +import android.widget.Button; +import android.widget.TextView; +import android.content.ComponentName; +import android.content.pm.PackageManager; +import android.content.SharedPreferences; + +public class LauncherActivity extends Activity { + static EditText cmdArgs; + static SharedPreferences mPref; + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + // Build layout + LinearLayout launcher = new LinearLayout(this); + launcher.setOrientation(LinearLayout.VERTICAL); + launcher.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); + TextView titleView = new TextView(this); + titleView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); + titleView.setText("Command-line arguments"); + titleView.setTextAppearance(this, android.R.attr.textAppearanceLarge); + cmdArgs = new EditText(this); + cmdArgs.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); + Button startButton = new Button(this); + // Set launch button title here + startButton.setText("Launch with gravgun!"); + LayoutParams buttonParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); + buttonParams.gravity = 5; + startButton.setLayoutParams(buttonParams); + startButton.setOnClickListener( new View.OnClickListener() { + @Override + public void onClick(View v) { + startXash(v); + } + }); + launcher.addView(titleView); + launcher.addView(cmdArgs); + // Add other options here + launcher.addView(startButton); + setContentView(launcher); + mPref = getSharedPreferences("mod", 0); + cmdArgs.setText(mPref.getString("argv","-dev 3 -log")); + } + + public void startXash(View view) + { + Intent intent = new Intent(); + intent.setAction("in.celest.xash3d.START"); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + + SharedPreferences.Editor editor = mPref.edit(); + editor.putString("argv", cmdArgs.getText().toString()); + editor.commit(); + editor.apply(); + if(cmdArgs.length() != 0) intent.putExtra("argv", cmdArgs.getText().toString()); + // Uncomment to set gamedir here + // intent.putExtra("gamedir", "mod" ); + intent.putExtra("gamelibdir", getFilesDir().getAbsolutePath().replace("/files","/lib")); + startActivity(intent); + } +}