Use shared prefs and setenv

This commit is contained in:
mittorn
2015-07-24 06:56:03 +06:00
parent 56670e9015
commit fa72090ea1
5 changed files with 117 additions and 48 deletions
+60 -9
View File
@@ -7,30 +7,81 @@ 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.content.ComponentName;
import android.content.pm.PackageManager;
import android.content.SharedPreferences;
import in.celest.xash3d.hl.R;
import com.beloko.touchcontrols.TouchControlsSettings;
public class LauncherActivity extends Activity {
public final static String ARGV = "in.celest.xash3d.MESSAGE";
// public final static String ARGV = "in.celest.xash3d.MESSAGE";
static TouchControlsSettings mSettings;
static EditText cmdArgs;
static CheckBox useControls;
static EditText resPath;
static CheckBox showIcon;
static SharedPreferences mPref;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_launcher);
mSettings=new TouchControlsSettings();
mSettings.setup(this, null);
mSettings.loadSettings(this);
mPref = getSharedPreferences("engine", 0);
cmdArgs = (EditText)findViewById(R.id.cmdArgs);
cmdArgs.setText(mPref.getString("argv","-dev 3 -console -log"));
useControls = ( CheckBox ) findViewById( R.id.useControls );
useControls.setChecked(mPref.getBoolean("controls",true));
resPath = ( EditText ) findViewById( R.id.cmdPath );
resPath.setText(mPref.getString("basedir","/sdcard/xash/"));
showIcon = ( CheckBox ) findViewById( R.id.showIcon );
showIcon.setChecked(mPref.getBoolean("show_icon",true));
// it is broken, so disable it now
showIcon.setEnabled(false);
showIcon.setActivated(false);
/*showIcon.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
ComponentName componentName = new ComponentName("in.celest.xash3d.hl","org.libsdl.app.SDLActivity");
PackageManager p = getPackageManager();
if ( isChecked )
{
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
}
else
{
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}
}
});
*/
}
public void startXash(View view)
{
Intent intent = new Intent(this, org.libsdl.app.SDLActivity.class);
//Intent intent = new Intent(this, in.celest.xash3d.XashActivity.class);
EditText cmdArgs = (EditText)findViewById(R.id.cmdArgs);
String sArgv = cmdArgs.getText().toString();
intent.putExtra(ARGV, sArgv);
SharedPreferences.Editor editor = mPref.edit();
editor.putString("argv", cmdArgs.getText().toString());
editor.putBoolean("controls",useControls.isChecked());
editor.putString("basedir", resPath.getText().toString());
editor.putBoolean("show_icon", showIcon.isChecked());
editor.commit();
editor.apply();
startActivity(intent);
}
public void controlsSettings(View view)
{
mSettings.loadSettings(this);
mSettings.showSettings();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {