From 6c9b2b972f26132249b93163f589e9df339188c1 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 22 Sep 2014 06:34:40 +1000 Subject: More UI, and get most of the UI working. --- src/net/onefang/toyboxInstaller/MainActivity.java | 55 +++++++++++++++++++++-- 1 file changed, 52 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/net/onefang/toyboxInstaller/MainActivity.java b/src/net/onefang/toyboxInstaller/MainActivity.java index e6c690f..4186c2b 100644 --- a/src/net/onefang/toyboxInstaller/MainActivity.java +++ b/src/net/onefang/toyboxInstaller/MainActivity.java @@ -5,8 +5,9 @@ import android.os.*; import android.view.*; import android.widget.*; import java.lang.System.*; +import android.speech.*; -public class MainActivity extends Activity +public class MainActivity extends Activity implements AdapterView.OnItemSelectedListener { /** Called when the activity is first created. */ @Override @@ -17,20 +18,68 @@ public class MainActivity extends Activity TextView version = (TextView) findViewById(R.id.version); String VERSION = getString(R.string.version); + Spinner versions = (Spinner) findViewById(R.id.versions); + ArrayAdapter VERSIONS = ArrayAdapter.createFromResource(this, R.array.versions, android.R.layout.simple_spinner_item); TextView cpu = (TextView) findViewById(R.id.cpu); String CPU = getString(R.string.cpu); TextView path = (TextView) findViewById(R.id.path); String PATH = getString(R.string.path); + Spinner paths = (Spinner) findViewById(R.id.paths); + ArrayAdapter PATHS; String pathSep = java.lang.System.getProperty("path.separator"); TextView folder = (TextView) findViewById(R.id.folder); String FOLDER = getString(R.string.folder); - + TextView source = (TextView) findViewById(R.id.source); + String SOURCE = getString(R.string.source); + TextView destination = (TextView) findViewById(R.id.destination); + String DESTINATION = getString(R.string.destination); + version.setText(VERSION + " " + "unknown" + ".\n"); + VERSIONS.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + versions.setAdapter(VERSIONS); + versions.setOnItemSelectedListener(this); cpu.setText(CPU + " " + java.lang.System.getProperty("os.arch") + ".\n"); - path.setText(PATH + " " + java.lang.System.getenv("PATH") + "\n"); + PATHS = new ArrayAdapter(this, android.R.layout.simple_spinner_item, + java.lang.System.getenv("PATH").split("\\" + pathSep)); + PATHS.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + paths.setAdapter(PATHS); + paths.setOnItemSelectedListener(this); folder.setText(FOLDER + " " + "" + "\n"); + source.setText(SOURCE + " " + "" + "\n"); + destination.setText(DESTINATION + " " + "" + "\n"); } + @Override + public void onItemSelected(AdapterView parent, View view, int pos, long id) + { + String s = (String) parent.getItemAtPosition(pos); + + switch (parent.getId()) + { + case R.id.versions : + { + TextView source = (TextView) findViewById(R.id.source); + String SOURCE = getString(R.string.source); + + source.setText(SOURCE + " http://landley.net/code/toybox/downloads/binaries/" + s + "/toybox-\n"); + break; + } + case R.id.paths: + { + TextView destination = (TextView) findViewById(R.id.destination); + String DESTINATION = getString(R.string.destination); + + destination.setText(DESTINATION + " " + s + "\n"); + } + } + } + + @Override + public void onNothingSelected(AdapterView parent) + { + // TODO: Nothing to do here, maybe? + } + public void installToybox(View view) { } -- cgit v1.1