aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-09-22 13:54:58 +1000
committerDavid Walter Seikel2014-09-22 13:54:58 +1000
commit0aa778b33578a613729b6fd5a561632ca74a7031 (patch)
tree465a614c0ee5818a91d07d5870a473bcdf38ff50
parentAdd a spinner for CPUs, plus some clean up. (diff)
downloadtoyboxInstaller-0aa778b33578a613729b6fd5a561632ca74a7031.zip
toyboxInstaller-0aa778b33578a613729b6fd5a561632ca74a7031.tar.gz
toyboxInstaller-0aa778b33578a613729b6fd5a561632ca74a7031.tar.bz2
toyboxInstaller-0aa778b33578a613729b6fd5a561632ca74a7031.tar.xz
White space cleanups.
-rw-r--r--AndroidManifest.xml42
-rw-r--r--res/layout/main.xml114
-rw-r--r--res/values/strings.xml92
-rw-r--r--src/net/onefang/toyboxInstaller/MainActivity.java182
4 files changed, 224 insertions, 206 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index bfd6400..35e0ff7 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,25 +1,31 @@
1<?xml version="1.0" encoding="utf-8"?> 1<?xml version="1.0" encoding="utf-8"?>
2<manifest xmlns:android="http://schemas.android.com/apk/res/android" 2<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 package="net.onefang.toyboxInstaller" 3 package="net.onefang.toyboxInstaller"
4 android:versionCode="1" 4 android:versionCode="1"
5 android:versionName="0.4.9" > 5 android:versionName="0.4.9" >
6 6
7 <uses-sdk 7 <!-- min versien used to be 4, 9 is needed for DownloadManager. -->
8 android:minSdkVersion="4" 8 <uses-sdk
9 android:targetSdkVersion="16" /> 9 android:minSdkVersion="9"
10 android:targetSdkVersion="16" />
10 11
11 <application 12 <!--uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission-->
12 android:icon="@drawable/ic_launch_placitas_green_pillow" 13 <!--uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission-->
13 android:label="@string/app_name" > 14 <!--uses-permission android:name="android.permission.INTERNET"></uses-permission-->
14 <activity 15 <!--uses-permission android:name="android.permission.WRITE_EXTERNAL_STOROGE"></uses-permission-->
15 android:label="@string/app_name"
16 android:name=".MainActivity" >
17 <intent-filter >
18 <action android:name="android.intent.action.MAIN" />
19 16
20 <category android:name="android.intent.category.LAUNCHER" /> 17 <application
21 </intent-filter> 18 android:icon="@drawable/ic_launch_placitas_green_pillow"
22 </activity> 19 android:label="@string/app_name" >
23 </application> 20 <activity
21 android:label="@string/app_name"
22 android:name=".MainActivity" >
23 <intent-filter >
24 <action android:name="android.intent.action.MAIN" />
25
26 <category android:name="android.intent.category.LAUNCHER" />
27 </intent-filter>
28 </activity>
29 </application>
24 30
25</manifest> 31</manifest>
diff --git a/res/layout/main.xml b/res/layout/main.xml
index eec86f2..0b27286 100644
--- a/res/layout/main.xml
+++ b/res/layout/main.xml
@@ -1,73 +1,73 @@
1<?xml version="1.0" encoding="utf-8"?> 1<?xml version="1.0" encoding="utf-8"?>
2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="fill_parent" 3 android:layout_width="fill_parent"
4 android:layout_height="fill_parent" 4 android:layout_height="fill_parent"
5 android:gravity="center" 5 android:gravity="center"
6 android:orientation="vertical" > 6 android:orientation="vertical" >
7 7
8 <TextView android:id="@+id/hello" 8 <TextView android:id="@+id/hello"
9 android:layout_width="wrap_content" 9 android:layout_width="wrap_content"
10 android:layout_height="wrap_content" 10 android:layout_height="wrap_content"
11 android:text="@string/hello" /> 11 android:text="@string/hello" />
12 12
13 <TextView android:id="@+id/version" 13 <TextView android:id="@+id/version"
14 android:layout_width="wrap_content" 14 android:layout_width="wrap_content"
15 android:layout_height="wrap_content" 15 android:layout_height="wrap_content"
16 android:text="@string/version" /> 16 android:text="@string/version" />
17 17
18 <TextView android:id="@+id/versionsPrompt" 18 <TextView android:id="@+id/versionsPrompt"
19 android:layout_width="wrap_content" 19 android:layout_width="wrap_content"
20 android:layout_height="wrap_content" 20 android:layout_height="wrap_content"
21 android:text="@string/versionsPrompt" /> 21 android:text="@string/versionsPrompt" />
22 22
23 <Spinner android:id="@+id/versions" 23 <Spinner android:id="@+id/versions"
24 android:layout_width="wrap_content" 24 android:layout_width="wrap_content"
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/cpusPrompt" 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/cpusPrompt" /> 31 android:text="@string/cpusPrompt" />
32 32
33 <Spinner android:id="@+id/cpus" 33 <Spinner android:id="@+id/cpus"
34 android:layout_width="wrap_content" 34 android:layout_width="wrap_content"
35 android:layout_height="wrap_content" 35 android:layout_height="wrap_content"
36 android:prompt="@+id/cpusPrompt" /> 36 android:prompt="@+id/cpusPrompt" />
37 37
38 <TextView android:id="@+id/path" 38 <TextView android:id="@+id/path"
39 android:layout_width="wrap_content" 39 android:layout_width="wrap_content"
40 android:layout_height="wrap_content" 40 android:layout_height="wrap_content"
41 android:text="@string/path" /> 41 android:text="@string/path" />
42 42
43 <TextView android:id="@+id/pathsPrompt" 43 <TextView android:id="@+id/pathsPrompt"
44 android:layout_width="wrap_content" 44 android:layout_width="wrap_content"
45 android:layout_height="wrap_content" 45 android:layout_height="wrap_content"
46 android:text="@string/pathsPrompt" /> 46 android:text="@string/pathsPrompt" />
47 47
48 <Spinner android:id="@+id/paths" 48 <Spinner android:id="@+id/paths"
49 android:layout_width="wrap_content" 49 android:layout_width="wrap_content"
50 android:layout_height="wrap_content" 50 android:layout_height="wrap_content"
51 android:prompt="@+id/pathsPrompt" /> 51 android:prompt="@+id/pathsPrompt" />
52 52
53 <TextView android:id="@+id/folder" 53 <TextView android:id="@+id/folder"
54 android:layout_width="wrap_content" 54 android:layout_width="wrap_content"
55 android:layout_height="wrap_content" 55 android:layout_height="wrap_content"
56 android:text="@string/folder" /> 56 android:text="@string/folder" />
57 57
58 <Button android:id="@+id/install" 58 <Button android:id="@+id/install"
59 android:layout_width="wrap_content" 59 android:layout_width="wrap_content"
60 android:layout_height="wrap_content" 60 android:layout_height="wrap_content"
61 android:text="@string/button_install" 61 android:text="@string/button_install"
62 android:onClick="installToybox" /> 62 android:onClick="installToybox" />
63 63
64 <TextView android:id="@+id/source" 64 <TextView android:id="@+id/source"
65 android:layout_width="wrap_content" 65 android:layout_width="wrap_content"
66 android:layout_height="wrap_content" 66 android:layout_height="wrap_content"
67 android:text="@string/source" /> 67 android:text="@string/source" />
68 68
69 <TextView android:id="@+id/destination" 69 <TextView android:id="@+id/destination"
70 android:layout_width="wrap_content" 70 android:layout_width="wrap_content"
71 android:layout_height="wrap_content" 71 android:layout_height="wrap_content"
72 android:text="@string/destination" /> 72 android:text="@string/destination" />
73</LinearLayout> 73</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6502964..b0f8aed 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1,51 +1,51 @@
1<?xml version="1.0" encoding="utf-8"?> 1<?xml version="1.0" encoding="utf-8"?>
2<resources> 2<resources>
3 3
4 <string name="app_name">toyboxInstaller</string> 4 <string name="app_name">toyboxInstaller</string>
5 <string name="hello"> 5 <string name="hello">
6This app is used for installing Rob Landley\'s toybox.\n\n\"Toybox combines common Linux command line utilities together into a single BSD-licensed executable that\'s simple, small, fast, reasonably standards-compliant, and powerful enough to turn Android into a development environment.\"\n\nAt least that\'s Rob\'s plan, toybox is not yet feature complete.\n\n</string> 6This app is used for installing Rob Landley\'s toybox.\n\n\"Toybox combines common Linux command line utilities together into a single BSD-licensed executable that\'s simple, small, fast, reasonably standards-compliant, and powerful enough to turn Android into a development environment.\"\n\nAt least that\'s Rob\'s plan, toybox is not yet feature complete.\n\n</string>
7 <string name="version">The currently installed toybox version is</string> 7 <string name="version">The currently installed toybox version is</string>
8 <string name="versionsPrompt">Select a version to install:-</string> 8 <string name="versionsPrompt">Select a version to install:-</string>
9 <string-array name="versions"> 9 <string-array name="versions">
10 <item>latest</item> 10 <item>latest</item>
11 <item>0.3.0</item> 11 <item>0.3.0</item>
12 <item>0.3.1</item> 12 <item>0.3.1</item>
13 <item>0.4.0</item> 13 <item>0.4.0</item>
14 <item>0.4.1</item> 14 <item>0.4.1</item>
15 <item>0.4.2</item> 15 <item>0.4.2</item>
16 <item>0.4.3</item> 16 <item>0.4.3</item>
17 <item>0.4.5</item> 17 <item>0.4.5</item>
18 <item>0.4.6</item> 18 <item>0.4.6</item>
19 <item>0.4.7</item> 19 <item>0.4.7</item>
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="cpusPrompt">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> 24 <string name="cpusPrompt2">, but you may need to select a close match :-</string>
25 <string-array name="cpus"> 25 <string-array name="cpus">
26 <item>armv4eb</item> 26 <item>armv4eb</item>
27 <item>armv4l</item> 27 <item>armv4l</item>
28 <item>armv4tl</item> 28 <item>armv4tl</item>
29 <item>armv5l</item> 29 <item>armv5l</item>
30 <item>armv6l</item> 30 <item>armv6l</item>
31 <item>armv7l</item> 31 <item>armv7l</item>
32 <item>i486</item> 32 <item>i486</item>
33 <item>i586</item> 33 <item>i586</item>
34 <item>i686</item> 34 <item>i686</item>
35 <item>m68k</item> 35 <item>m68k</item>
36 <item>mips</item> 36 <item>mips</item>
37 <item>mips64</item> 37 <item>mips64</item>
38 <item>mipsel</item> 38 <item>mipsel</item>
39 <item>powerpc</item> 39 <item>powerpc</item>
40 <item>powerpc-440fp</item> 40 <item>powerpc-440fp</item>
41 <item>sh4</item> 41 <item>sh4</item>
42 <item>sparc</item> 42 <item>sparc</item>
43 <item>x86_64</item> 43 <item>x86_64</item>
44 </string-array> 44 </string-array>
45 <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>
46 <string name="pathsPrompt">... into the $PATH :-\n</string> 46 <string name="pathsPrompt">... into the $PATH :-\n</string>
47 <string name="folder">... or into a folder :-\n</string> 47 <string name="folder">... or into a folder :-\n</string>
48 <string name="button_install">Install toybox.</string> 48 <string name="button_install">Install toybox.</string>
49 <string name="source">Install from</string> 49 <string name="source">Install from</string>
50 <string name="destination">Install to</string> 50 <string name="destination">Install to</string>
51</resources> 51</resources>
diff --git a/src/net/onefang/toyboxInstaller/MainActivity.java b/src/net/onefang/toyboxInstaller/MainActivity.java
index 27051bf..36b2b5f 100644
--- a/src/net/onefang/toyboxInstaller/MainActivity.java
+++ b/src/net/onefang/toyboxInstaller/MainActivity.java
@@ -5,100 +5,112 @@ import android.os.*;
5import android.view.*; 5import android.view.*;
6import android.widget.*; 6import android.widget.*;
7import java.lang.System.*; 7import java.lang.System.*;
8import android.net.*;
8import android.speech.*; 9import android.speech.*;
9 10
10public class MainActivity extends Activity implements AdapterView.OnItemSelectedListener 11public class MainActivity extends Activity implements AdapterView.OnItemSelectedListener
11{ 12{
12 private String requstedVersion = "latest"; 13 private String requstedVersion = "latest";
13 private String requestedCPU = ""; 14 private String requestedCPU = "";
14 private String requestedPath = ""; 15 private String requestedPath = "";
15 16
16 /** Called when the activity is first created. */ 17 /** Called when the activity is first created. */
17 @Override 18 @Override
18 public void onCreate(Bundle savedInstanceState) 19 public void onCreate(Bundle savedInstanceState)
19 { 20 {
20 super.onCreate(savedInstanceState); 21 super.onCreate(savedInstanceState);
21 setContentView(R.layout.main); 22 setContentView(R.layout.main);
22 requestedCPU = java.lang.System.getProperty("os.arch"); 23 requestedCPU = java.lang.System.getProperty("os.arch");
23 24
24 TextView version = (TextView) findViewById(R.id.version); 25 TextView version = (TextView) findViewById(R.id.version);
25 String VERSION = getString(R.string.version); 26 String VERSION = getString(R.string.version);
26 Spinner versions = (Spinner) findViewById(R.id.versions); 27 Spinner versions = (Spinner) findViewById(R.id.versions);
27 ArrayAdapter<CharSequence> VERSIONS = ArrayAdapter.createFromResource(this, R.array.versions, android.R.layout.simple_spinner_item); 28 ArrayAdapter<CharSequence> VERSIONS = ArrayAdapter.createFromResource(this, R.array.versions, android.R.layout.simple_spinner_item);
28 TextView cpu = (TextView) findViewById(R.id.cpusPrompt); 29 TextView cpu = (TextView) findViewById(R.id.cpusPrompt);
29 String CPU = getString(R.string.cpusPrompt); 30 String CPU = getString(R.string.cpusPrompt);
30 String CPU2 = getString(R.string.cpusPrompt2); 31 String CPU2 = getString(R.string.cpusPrompt2);
31 Spinner cpus = (Spinner) findViewById(R.id.cpus); 32 Spinner cpus = (Spinner) findViewById(R.id.cpus);
32 ArrayAdapter<CharSequence> CPUS = ArrayAdapter.createFromResource(this, R.array.cpus, android.R.layout.simple_spinner_item); 33 ArrayAdapter<CharSequence> CPUS = ArrayAdapter.createFromResource(this, R.array.cpus, android.R.layout.simple_spinner_item);
33 TextView path = (TextView) findViewById(R.id.path); 34 TextView path = (TextView) findViewById(R.id.path);
34 String PATH = getString(R.string.path); 35 String PATH = getString(R.string.path);
35 Spinner paths = (Spinner) findViewById(R.id.paths); 36 Spinner paths = (Spinner) findViewById(R.id.paths);
36 ArrayAdapter<String> PATHS; 37 ArrayAdapter<String> PATHS;
37 String pathSep = java.lang.System.getProperty("path.separator"); 38 String pathSep = java.lang.System.getProperty("path.separator");
38 TextView folder = (TextView) findViewById(R.id.folder); 39 TextView folder = (TextView) findViewById(R.id.folder);
39 String FOLDER = getString(R.string.folder); 40 String FOLDER = getString(R.string.folder);
40 TextView source = (TextView) findViewById(R.id.source); 41 TextView source = (TextView) findViewById(R.id.source);
41 String SOURCE = getString(R.string.source); 42 String SOURCE = getString(R.string.source);
42 TextView destination = (TextView) findViewById(R.id.destination); 43 TextView destination = (TextView) findViewById(R.id.destination);
43 String DESTINATION = getString(R.string.destination); 44 String DESTINATION = getString(R.string.destination);
44
45 version.setText(VERSION + " " + "unknown" + ".\n");
46 VERSIONS.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
47 versions.setAdapter(VERSIONS);
48 versions.setOnItemSelectedListener(this);
49 cpu.setText(CPU + " " + requestedCPU + " " + CPU2 + "\n");
50 CPUS.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
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));
56 PATHS.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
57 paths.setAdapter(PATHS);
58 paths.setOnItemSelectedListener(this);
59 folder.setText(FOLDER + " " + "" + "\n");
60 source.setText(SOURCE + " " + "" + "\n");
61 destination.setText(DESTINATION + " " + "" + "\n");
62 }
63 45
64 @Override 46 version.setText(VERSION + " " + "unknown" + ".\n");
65 public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) 47 VERSIONS.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
66 { 48 versions.setAdapter(VERSIONS);
67 String s = (String) parent.getItemAtPosition(pos); 49 versions.setOnItemSelectedListener(this);
68 TextView source = (TextView) findViewById(R.id.source); 50 cpu.setText(CPU + " " + requestedCPU + " " + CPU2 + "\n");
69 String SOURCE = getString(R.string.source); 51 CPUS.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
70 TextView destination = (TextView) findViewById(R.id.destination); 52 cpus.setAdapter(CPUS);
71 String DESTINATION = getString(R.string.destination); 53 cpus.setSelection(CPUS.getPosition(requestedCPU));
72 54 cpus.setOnItemSelectedListener(this);
73 switch (parent.getId()) 55 PATHS = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
74 { 56 java.lang.System.getenv("PATH").split("\\" + pathSep));
75 case R.id.versions : 57 PATHS.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
76 { 58 paths.setAdapter(PATHS);
77 requstedVersion = s; 59 paths.setOnItemSelectedListener(this);
78 break; 60 folder.setText(FOLDER + " " + "" + "\n");
79 } 61 source.setText(SOURCE + " " + "" + "\n");
80 case R.id.cpus : 62 destination.setText(DESTINATION + " " + "" + "\n");
81 { 63 }
82 requestedCPU = s;
83 break;
84 }
85 case R.id.paths:
86 {
87 requestedPath = s;
88 break;
89 }
90 }
91 source.setText(SOURCE + " http://landley.net/code/toybox/downloads/binaries/" + requstedVersion + "/toybox-" + requestedCPU + "\n");
92 destination.setText(DESTINATION + " " + requestedPath + "\n");
93 }
94 64
95 @Override 65 @Override
96 public void onNothingSelected(AdapterView<?> parent) 66 public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)
97 { 67 {
98 // TODO: Nothing to do here, maybe? 68 String s = (String) parent.getItemAtPosition(pos);
99 } 69 TextView source = (TextView) findViewById(R.id.source);
70 String SOURCE = getString(R.string.source);
71 TextView destination = (TextView) findViewById(R.id.destination);
72 String DESTINATION = getString(R.string.destination);
100 73
101 public void installToybox(View view) 74 switch (parent.getId())
102 { 75 {
76 case R.id.versions :
77 {
78 requstedVersion = s;
79 break;
80 }
81
82 case R.id.cpus :
83 {
84 requestedCPU = s;
85 break;
86 }
87
88 case R.id.paths:
89 {
90 requestedPath = s;
91 break;
92 }
103 } 93 }
94 source.setText(SOURCE + " http://landley.net/code/toybox/downloads/binaries/" + requstedVersion + "/toybox-" + requestedCPU + "\n");
95 destination.setText(DESTINATION + " " + requestedPath + "\n");
96 }
97
98 @Override
99 public void onNothingSelected(AdapterView<?> parent)
100 {
101 // TODO: Nothing to do here, maybe?
102 }
103
104 public void installToybox(View view)
105 {
106 String url = "http://landley.net/code/toybox/downloads/binaries/" + requstedVersion + "/toybox-" + requestedCPU;
107 DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
108 DownloadManager manager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
109
110 request.setDescription("toybox v" + requstedVersion + " for " + requestedCPU);
111 request.setTitle("toybox");
112 request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
113 request.setDestinationInExternalFilesDir(this, Environment.DIRECTORY_DOWNLOADS, requstedVersion + "/toybox-" + requestedCPU);
114 manager.enqueue(request);
115 }
104} 116}