Skip to content
This repository has been archived by the owner on Sep 6, 2020. It is now read-only.

Commit

Permalink
Update launcher template.
Browse files Browse the repository at this point in the history
  • Loading branch information
nekonomicon committed Mar 29, 2018
1 parent 7215cca commit 4943900
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 35 deletions.
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="23"/>
<!-- Set your application name here -->
<application android:label="They Hunger"
android:debuggable="true"
android:debuggable="false"
android:icon="@drawable/logo_xash_th">
<!-- Set your launcher title here -->
<activity android:name="in.celest.xash3d.LauncherActivity"
Expand Down
2 changes: 1 addition & 1 deletion jni/Application.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
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 := -O3 -fomit-frame-pointer -DNDEBUG -funsafe-math-optimizations -ftree-vectorize -fgraphite-identity -floop-interchange -floop-block -funsafe-loop-optimizations -finline-limit=1024 -fno-rtti -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables
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
Expand Down
2 changes: 1 addition & 1 deletion project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
# project structure.

# Project target.
target=android-23
target=android-27
28 changes: 28 additions & 0 deletions res/layout/activity_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_launcher"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#252525"
android:weightSum="1"
tools:context="su.xash.xash3d.LauncherActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cmd_args_text"
android:id="@+id/textView_args"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/cmdArgs"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button_launch"
android:text="@string/launch_button"
android:layout_gravity="right"
android:onClick="startXash"/>
</LinearLayout>
6 changes: 6 additions & 0 deletions res/values-ru/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="launch_button">Запустить They Hunger!</string>
<string name="cmd_args_text">Аргументы командной строки</string>
<string name="alert_dialog_text">не установлен!</string>
</resources>
6 changes: 6 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="launch_button">Launch They Hunger!</string>
<string name="cmd_args_text">Command-line arguments</string>
<string name="alert_dialog_text">not installed!</string>
</resources>
62 changes: 30 additions & 32 deletions src/in/celest/xash3d/LauncherActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package in.celest.xash3d;

import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
Expand All @@ -17,57 +18,54 @@
import android.content.pm.PackageManager;
import android.content.SharedPreferences;

import in.celest.xash3d.hunger.R;

public class LauncherActivity extends Activity {
static EditText cmdArgs;
static SharedPreferences mPref;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(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));
cmdArgs.setSingleLine(true);
Button startButton = new Button(this);
// Set launch button title here
startButton.setText("Launch " + "They Hunger" + "!");
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);
setContentView(R.layout.activity_launcher);
cmdArgs = (EditText)findViewById(R.id.cmdArgs);
cmdArgs.setSingleLine(true);
mPref = getSharedPreferences("mod", 0);
cmdArgs.setText(mPref.getString("argv","-dev 3 -log"));
cmdArgs.setText(mPref.getString("argv","-dev 3 -log"));
}

public void startXash(View view)
{
String argv = cmdArgs.getText().toString();
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.putString("argv", argv);
editor.commit();
if(cmdArgs.length() != 0) intent.putExtra("argv", cmdArgs.getText().toString());
if(cmdArgs.length() != 0) intent.putExtra("argv", argv);
// Uncomment to set gamedir here
intent.putExtra("gamedir", "Hunger" );
intent.putExtra("gamelibdir", getFilesDir().getAbsolutePath().replace("/files","/lib"));
startActivity(intent);

PackageManager pm = getPackageManager();
if(intent.resolveActivity(pm) != null)
{
startActivity(intent);
}
else
{
showXashInstallDialog("Xash3D FWGS ");
}
}

public void showXashInstallDialog(String msg)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);

builder.setTitle("Xash error")
.setMessage(msg + getString(R.string.alert_dialog_text))
.show();
}
}

0 comments on commit 4943900

Please sign in to comment.