2015-05-26 00:11:50 +06:00
|
|
|
package in.celest.xash3d;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
2015-08-16 22:52:54 +06:00
|
|
|
import android.app.Dialog;
|
2015-05-26 00:11:50 +06:00
|
|
|
import android.os.Bundle;
|
2015-11-08 01:09:57 +06:00
|
|
|
import android.os.Build;
|
2015-05-26 00:11:50 +06:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.View;
|
|
|
|
import android.content.Intent;
|
2016-04-29 21:43:56 +03:00
|
|
|
import android.view.Window;
|
2015-05-26 00:11:50 +06:00
|
|
|
import android.widget.EditText;
|
2015-07-24 06:56:03 +06:00
|
|
|
import android.widget.CheckBox;
|
|
|
|
import android.widget.CompoundButton;
|
2015-11-08 01:09:57 +06:00
|
|
|
import android.widget.Button;
|
2015-07-24 06:56:03 +06:00
|
|
|
import android.content.ComponentName;
|
2015-11-08 01:09:57 +06:00
|
|
|
import android.content.Context;
|
2015-07-24 06:56:03 +06:00
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
import android.content.SharedPreferences;
|
2015-08-16 22:52:54 +06:00
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.DialogInterface.OnDismissListener;
|
2015-11-08 01:09:57 +06:00
|
|
|
import android.net.Uri;
|
|
|
|
import android.os.Environment;
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
import java.util.List;
|
|
|
|
import java.io.File;
|
2016-04-29 21:29:56 +03:00
|
|
|
import android.widget.TabHost;
|
|
|
|
import android.widget.ToggleButton;
|
2015-05-26 00:11:50 +06:00
|
|
|
|
|
|
|
import in.celest.xash3d.hl.R;
|
|
|
|
|
|
|
|
public class LauncherActivity extends Activity {
|
2015-07-24 06:56:03 +06:00
|
|
|
// public final static String ARGV = "in.celest.xash3d.MESSAGE";
|
|
|
|
static EditText cmdArgs;
|
2016-04-29 21:29:56 +03:00
|
|
|
static ToggleButton useVolume;
|
2015-07-24 06:56:03 +06:00
|
|
|
static EditText resPath;
|
|
|
|
static SharedPreferences mPref;
|
2015-11-08 01:09:57 +06:00
|
|
|
String getDefaultPath()
|
|
|
|
{
|
|
|
|
File dir = Environment.getExternalStorageDirectory();
|
|
|
|
if( dir != null && dir.exists() )
|
|
|
|
return dir.getPath() + "/xash";
|
|
|
|
return "/sdcard/xash";
|
|
|
|
}
|
2015-05-26 00:11:50 +06:00
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
2016-04-29 21:29:56 +03:00
|
|
|
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
2016-05-01 12:53:36 +00:00
|
|
|
//super.setTheme( 0x01030005 );
|
|
|
|
if ( Build.VERSION.SDK_INT >= 21 )
|
|
|
|
super.setTheme( 0x01030224 );
|
2016-04-29 22:01:59 +03:00
|
|
|
setContentView(R.layout.activity_launcher);
|
|
|
|
|
2016-04-29 21:29:56 +03:00
|
|
|
TabHost tabHost = (TabHost) findViewById(R.id.tabhost);
|
|
|
|
|
|
|
|
tabHost.setup();
|
|
|
|
|
|
|
|
TabHost.TabSpec tabSpec;
|
|
|
|
tabSpec = tabHost.newTabSpec("tabtag1");
|
|
|
|
tabSpec.setIndicator(getString(R.string.text_tab1));
|
|
|
|
tabSpec.setContent(R.id.tab1);
|
|
|
|
tabHost.addTab(tabSpec);
|
|
|
|
|
|
|
|
tabSpec = tabHost.newTabSpec("tabtag2");
|
|
|
|
tabSpec.setIndicator(getString(R.string.text_tab2));
|
|
|
|
tabSpec.setContent(R.id.tab2);
|
|
|
|
tabHost.addTab(tabSpec);
|
|
|
|
|
2015-11-08 01:09:57 +06:00
|
|
|
Button selectFolder = ( Button ) findViewById( R.id.button_select );
|
2016-05-01 03:18:32 +03:00
|
|
|
// if ( Build.VERSION.SDK_INT < 21 )
|
|
|
|
// selectFolder.setVisibility( View.GONE );
|
|
|
|
mPref = getSharedPreferences("engine", 0);
|
|
|
|
cmdArgs = (EditText)findViewById(R.id.cmdArgs);
|
|
|
|
cmdArgs.setText(mPref.getString("argv","-dev 3 -log"));
|
|
|
|
useVolume = ( ToggleButton ) findViewById( R.id.useVolume );
|
|
|
|
useVolume.setChecked(mPref.getBoolean("usevolume",true));
|
|
|
|
resPath = ( EditText ) findViewById( R.id.cmdPath );
|
|
|
|
resPath.setText(mPref.getString("basedir", getDefaultPath()));
|
2015-11-08 01:09:57 +06:00
|
|
|
}
|
2015-05-26 00:11:50 +06:00
|
|
|
|
|
|
|
public void startXash(View view)
|
|
|
|
{
|
2015-06-16 22:45:30 +07:00
|
|
|
Intent intent = new Intent(this, org.libsdl.app.SDLActivity.class);
|
2015-07-26 01:30:00 +06:00
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
2015-07-24 06:56:03 +06:00
|
|
|
|
|
|
|
SharedPreferences.Editor editor = mPref.edit();
|
|
|
|
editor.putString("argv", cmdArgs.getText().toString());
|
2015-09-10 08:30:17 +07:00
|
|
|
editor.putBoolean("usevolume",useVolume.isChecked());
|
2015-07-24 06:56:03 +06:00
|
|
|
editor.putString("basedir", resPath.getText().toString());
|
|
|
|
editor.commit();
|
|
|
|
editor.apply();
|
2015-05-26 00:11:50 +06:00
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
|
2015-08-16 22:52:54 +06:00
|
|
|
public void aboutXash(View view)
|
|
|
|
{
|
|
|
|
final Activity a = this;
|
|
|
|
this.runOnUiThread(new Runnable() {
|
|
|
|
public void run()
|
|
|
|
{
|
|
|
|
final Dialog dialog = new Dialog(a);
|
|
|
|
dialog.setContentView(R.layout.about);
|
|
|
|
dialog.setCancelable(true);
|
|
|
|
|
|
|
|
dialog.show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2015-11-08 01:09:57 +06:00
|
|
|
|
|
|
|
public void selectFolder(View view)
|
|
|
|
{
|
2016-05-01 03:18:32 +03:00
|
|
|
Intent intent = new Intent(this, in.celest.xash3d.FPicker.class);
|
|
|
|
//intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
// Intent intent = new Intent("android.intent.action.OPEN_DOCUMENT_TREE");
|
2015-11-08 01:09:57 +06:00
|
|
|
startActivityForResult(intent, 42);
|
|
|
|
resPath.setEnabled(false);
|
|
|
|
}
|
|
|
|
|
2016-05-01 03:18:32 +03:00
|
|
|
public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
|
2015-11-08 01:09:57 +06:00
|
|
|
if (resultCode == RESULT_OK) {
|
|
|
|
try{
|
2016-05-01 03:18:32 +03:00
|
|
|
|
|
|
|
resPath = ( EditText ) findViewById( R.id.cmdPath );
|
|
|
|
resPath.setText( resultData.getStringExtra("GetPath"));
|
|
|
|
|
|
|
|
// final List<String> paths = resultData.getData().getPathSegments();
|
|
|
|
// String[] parts = paths.get(1).split(":");
|
|
|
|
// String storagepath = Environment.getExternalStorageDirectory().getPath() + "/";
|
|
|
|
// String path = storagepath + parts[1];
|
|
|
|
// if( path != null)
|
|
|
|
// resPath.setText( path );
|
2015-11-08 01:09:57 +06:00
|
|
|
resPath.setEnabled(true);
|
|
|
|
}
|
|
|
|
catch(Exception e)
|
|
|
|
{
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
resPath.setEnabled(true);
|
|
|
|
}
|
|
|
|
|
2015-09-04 20:55:37 +07:00
|
|
|
public void createShortcut(View view)
|
|
|
|
{
|
|
|
|
Intent intent = new Intent(this, ShortcutActivity.class);
|
2015-12-20 18:52:09 +06:00
|
|
|
intent.putExtra( "basedir", resPath.getText().toString() );
|
|
|
|
intent.putExtra( "name", "Xash3D" );
|
|
|
|
intent.putExtra( "argv", cmdArgs.getText().toString() );
|
2015-09-04 20:55:37 +07:00
|
|
|
startActivity(intent);
|
|
|
|
}
|
2015-08-16 22:52:54 +06:00
|
|
|
|
2015-05-26 00:11:50 +06:00
|
|
|
@Override
|
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
|
// Inflate the menu; this adds items to the action bar if it is present.
|
|
|
|
//getMenuInflater().inflate(R.menu.menu_launcher, menu);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
// Handle action bar item clicks here. The action bar will
|
|
|
|
// automatically handle clicks on the Home/Up button, so long
|
|
|
|
// as you specify a parent activity in AndroidManifest.xml.
|
|
|
|
int id = item.getItemId();
|
|
|
|
|
|
|
|
//noinspection SimplifiableIfStatement
|
|
|
|
/*if (id == R.id.action_settings) {
|
|
|
|
return true;
|
|
|
|
}*/
|
|
|
|
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
}
|
|
|
|
}
|