diff options
author | David Walter Seikel | 2014-09-22 13:29:34 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-09-22 13:29:34 +1000 |
commit | 3ae8982fa1a851918fe5d902b42905ce0ceda87c (patch) | |
tree | f29b0b81eb94baecee90662540016912695f97d7 /src | |
parent | Update README. (diff) | |
download | toyboxInstaller-3ae8982fa1a851918fe5d902b42905ce0ceda87c.zip toyboxInstaller-3ae8982fa1a851918fe5d902b42905ce0ceda87c.tar.gz toyboxInstaller-3ae8982fa1a851918fe5d902b42905ce0ceda87c.tar.bz2 toyboxInstaller-3ae8982fa1a851918fe5d902b42905ce0ceda87c.tar.xz |
Add a spinner for CPUs, plus some clean up.
Diffstat (limited to 'src')
-rw-r--r-- | src/net/onefang/toyboxInstaller/MainActivity.java | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/src/net/onefang/toyboxInstaller/MainActivity.java b/src/net/onefang/toyboxInstaller/MainActivity.java index 4186c2b..27051bf 100644 --- a/src/net/onefang/toyboxInstaller/MainActivity.java +++ b/src/net/onefang/toyboxInstaller/MainActivity.java | |||
@@ -9,19 +9,27 @@ import android.speech.*; | |||
9 | 9 | ||
10 | public class MainActivity extends Activity implements AdapterView.OnItemSelectedListener | 10 | public class MainActivity extends Activity implements AdapterView.OnItemSelectedListener |
11 | { | 11 | { |
12 | private String requstedVersion = "latest"; | ||
13 | private String requestedCPU = ""; | ||
14 | private String requestedPath = ""; | ||
15 | |||
12 | /** Called when the activity is first created. */ | 16 | /** Called when the activity is first created. */ |
13 | @Override | 17 | @Override |
14 | public void onCreate(Bundle savedInstanceState) | 18 | public void onCreate(Bundle savedInstanceState) |
15 | { | 19 | { |
16 | super.onCreate(savedInstanceState); | 20 | super.onCreate(savedInstanceState); |
17 | setContentView(R.layout.main); | 21 | setContentView(R.layout.main); |
22 | requestedCPU = java.lang.System.getProperty("os.arch"); | ||
18 | 23 | ||
19 | TextView version = (TextView) findViewById(R.id.version); | 24 | TextView version = (TextView) findViewById(R.id.version); |
20 | String VERSION = getString(R.string.version); | 25 | String VERSION = getString(R.string.version); |
21 | Spinner versions = (Spinner) findViewById(R.id.versions); | 26 | Spinner versions = (Spinner) findViewById(R.id.versions); |
22 | ArrayAdapter<CharSequence> VERSIONS = ArrayAdapter.createFromResource(this, R.array.versions, android.R.layout.simple_spinner_item); | 27 | ArrayAdapter<CharSequence> VERSIONS = ArrayAdapter.createFromResource(this, R.array.versions, android.R.layout.simple_spinner_item); |
23 | TextView cpu = (TextView) findViewById(R.id.cpu); | 28 | TextView cpu = (TextView) findViewById(R.id.cpusPrompt); |
24 | String CPU = getString(R.string.cpu); | 29 | String CPU = getString(R.string.cpusPrompt); |
30 | String CPU2 = getString(R.string.cpusPrompt2); | ||
31 | Spinner cpus = (Spinner) findViewById(R.id.cpus); | ||
32 | ArrayAdapter<CharSequence> CPUS = ArrayAdapter.createFromResource(this, R.array.cpus, android.R.layout.simple_spinner_item); | ||
25 | TextView path = (TextView) findViewById(R.id.path); | 33 | TextView path = (TextView) findViewById(R.id.path); |
26 | String PATH = getString(R.string.path); | 34 | String PATH = getString(R.string.path); |
27 | Spinner paths = (Spinner) findViewById(R.id.paths); | 35 | Spinner paths = (Spinner) findViewById(R.id.paths); |
@@ -38,9 +46,13 @@ public class MainActivity extends Activity implements AdapterView.OnItemSelected | |||
38 | VERSIONS.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); | 46 | VERSIONS.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
39 | versions.setAdapter(VERSIONS); | 47 | versions.setAdapter(VERSIONS); |
40 | versions.setOnItemSelectedListener(this); | 48 | versions.setOnItemSelectedListener(this); |
41 | cpu.setText(CPU + " " + java.lang.System.getProperty("os.arch") + ".\n"); | 49 | cpu.setText(CPU + " " + requestedCPU + " " + CPU2 + "\n"); |
42 | PATHS = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, | 50 | CPUS.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
43 | java.lang.System.getenv("PATH").split("\\" + pathSep)); | 51 | cpus.setAdapter(CPUS); |
52 | cpus.setSelection(CPUS.getPosition(requestedCPU)); | ||
53 | cpus.setOnItemSelectedListener(this); | ||
54 | PATHS = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, | ||
55 | java.lang.System.getenv("PATH").split("\\" + pathSep)); | ||
44 | PATHS.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); | 56 | PATHS.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); |
45 | paths.setAdapter(PATHS); | 57 | paths.setAdapter(PATHS); |
46 | paths.setOnItemSelectedListener(this); | 58 | paths.setOnItemSelectedListener(this); |
@@ -53,25 +65,31 @@ public class MainActivity extends Activity implements AdapterView.OnItemSelected | |||
53 | public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) | 65 | public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) |
54 | { | 66 | { |
55 | String s = (String) parent.getItemAtPosition(pos); | 67 | String s = (String) parent.getItemAtPosition(pos); |
56 | 68 | TextView source = (TextView) findViewById(R.id.source); | |
69 | String SOURCE = getString(R.string.source); | ||
70 | TextView destination = (TextView) findViewById(R.id.destination); | ||
71 | String DESTINATION = getString(R.string.destination); | ||
72 | |||
57 | switch (parent.getId()) | 73 | switch (parent.getId()) |
58 | { | 74 | { |
59 | case R.id.versions : | 75 | case R.id.versions : |
60 | { | 76 | { |
61 | TextView source = (TextView) findViewById(R.id.source); | 77 | requstedVersion = s; |
62 | String SOURCE = getString(R.string.source); | ||
63 | |||
64 | source.setText(SOURCE + " http://landley.net/code/toybox/downloads/binaries/" + s + "/toybox-\n"); | ||
65 | break; | 78 | break; |
66 | } | 79 | } |
67 | case R.id.paths: | 80 | case R.id.cpus : |
81 | { | ||
82 | requestedCPU = s; | ||
83 | break; | ||
84 | } | ||
85 | case R.id.paths: | ||
68 | { | 86 | { |
69 | TextView destination = (TextView) findViewById(R.id.destination); | 87 | requestedPath = s; |
70 | String DESTINATION = getString(R.string.destination); | 88 | break; |
71 | |||
72 | destination.setText(DESTINATION + " " + s + "\n"); | ||
73 | } | 89 | } |
74 | } | 90 | } |
91 | source.setText(SOURCE + " http://landley.net/code/toybox/downloads/binaries/" + requstedVersion + "/toybox-" + requestedCPU + "\n"); | ||
92 | destination.setText(DESTINATION + " " + requestedPath + "\n"); | ||
75 | } | 93 | } |
76 | 94 | ||
77 | @Override | 95 | @Override |