diff options
-rw-r--r-- | res/layout/main.xml | 9 | ||||
-rw-r--r-- | res/values/strings.xml | 23 | ||||
-rw-r--r-- | src/net/onefang/toyboxInstaller/MainActivity.java | 48 |
3 files changed, 62 insertions, 18 deletions
diff --git a/res/layout/main.xml b/res/layout/main.xml index 18c9ec9..eec86f2 100644 --- a/res/layout/main.xml +++ b/res/layout/main.xml | |||
@@ -25,10 +25,15 @@ | |||
25 | android:layout_height="wrap_content" | 25 | android:layout_height="wrap_content" |
26 | android:prompt="@+id/versionsPrompt" /> | 26 | android:prompt="@+id/versionsPrompt" /> |
27 | 27 | ||
28 | <TextView android:id="@+id/cpu" | 28 | <TextView android:id="@+id/cpusPrompt" |
29 | android:layout_width="wrap_content" | 29 | android:layout_width="wrap_content" |
30 | android:layout_height="wrap_content" | 30 | android:layout_height="wrap_content" |
31 | android:text="@string/cpu" /> | 31 | android:text="@string/cpusPrompt" /> |
32 | |||
33 | <Spinner android:id="@+id/cpus" | ||
34 | android:layout_width="wrap_content" | ||
35 | android:layout_height="wrap_content" | ||
36 | android:prompt="@+id/cpusPrompt" /> | ||
32 | 37 | ||
33 | <TextView android:id="@+id/path" | 38 | <TextView android:id="@+id/path" |
34 | android:layout_width="wrap_content" | 39 | android:layout_width="wrap_content" |
diff --git a/res/values/strings.xml b/res/values/strings.xml index 517af71..6502964 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml | |||
@@ -20,7 +20,28 @@ This app is used for installing Rob Landley\'s toybox.\n\n\"Toybox combines comm | |||
20 | <item>0.4.8</item> | 20 | <item>0.4.8</item> |
21 | <item>0.4.9</item> | 21 | <item>0.4.9</item> |
22 | </string-array> | 22 | </string-array> |
23 | <string name="cpu">The CPU type here is</string> | 23 | <string name="cpusPrompt">The CPU type here is</string> |
24 | <string name="cpusPrompt2">, but you may need to select a close match :-</string> | ||
25 | <string-array name="cpus"> | ||
26 | <item>armv4eb</item> | ||
27 | <item>armv4l</item> | ||
28 | <item>armv4tl</item> | ||
29 | <item>armv5l</item> | ||
30 | <item>armv6l</item> | ||
31 | <item>armv7l</item> | ||
32 | <item>i486</item> | ||
33 | <item>i586</item> | ||
34 | <item>i686</item> | ||
35 | <item>m68k</item> | ||
36 | <item>mips</item> | ||
37 | <item>mips64</item> | ||
38 | <item>mipsel</item> | ||
39 | <item>powerpc</item> | ||
40 | <item>powerpc-440fp</item> | ||
41 | <item>sh4</item> | ||
42 | <item>sparc</item> | ||
43 | <item>x86_64</item> | ||
44 | </string-array> | ||
24 | <string name="path">Select where you want to install toybox ...\n</string> | 45 | <string name="path">Select where you want to install toybox ...\n</string> |
25 | <string name="pathsPrompt">... into the $PATH :-\n</string> | 46 | <string name="pathsPrompt">... into the $PATH :-\n</string> |
26 | <string name="folder">... or into a folder :-\n</string> | 47 | <string name="folder">... or into a folder :-\n</string> |
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 |