Skip to content

Commit d03fa31

Browse files
committed
ANDROID: tidyup
1 parent 9a57547 commit d03fa31

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

src/platform/android/app/src/main/java/net/sourceforge/smallbasic/MainActivity.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,13 @@ public int ask(final byte[] titleBytes, final byte[] promptBytes, final boolean
150150
public void run() {
151151
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
152152
builder.setTitle(title).setMessage(prompt);
153-
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
153+
builder.setPositiveButton(R.string.YES, new DialogInterface.OnClickListener() {
154154
public void onClick(DialogInterface dialog, int which) {
155155
result.setYes();
156156
mutex.release();
157157
}
158158
});
159-
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
159+
builder.setNegativeButton(R.string.NO, new DialogInterface.OnClickListener() {
160160
public void onClick(DialogInterface dialog, int which) {
161161
result.setNo();
162162
mutex.release();
@@ -170,7 +170,7 @@ public void onCancel(DialogInterface dialog) {
170170
}
171171
});
172172
if (cancel) {
173-
builder.setNeutralButton("Cancel", new DialogInterface.OnClickListener() {
173+
builder.setNeutralButton(R.string.CANCEL, new DialogInterface.OnClickListener() {
174174
public void onClick(DialogInterface dialog, int which) {
175175
result.setCancel();
176176
mutex.release();
@@ -502,8 +502,7 @@ public void setClipboardText(final byte[] textBytes) {
502502
final String text = new String(textBytes, CP1252);
503503
runOnUiThread(new Runnable() {
504504
public void run() {
505-
ClipboardManager clipboard =
506-
(ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
505+
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
507506
if (clipboard != null) {
508507
ClipData clip = ClipData.newPlainText("text", text);
509508
clipboard.setPrimaryClip(clip);
@@ -578,7 +577,8 @@ public void showAlert(final byte[] titleBytes, final byte[] messageBytes) {
578577
runOnUiThread(new Runnable() {
579578
public void run() {
580579
new AlertDialog.Builder(activity)
581-
.setTitle(title).setMessage(message)
580+
.setTitle(title)
581+
.setMessage(message)
582582
.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
583583
public void onClick(DialogInterface dialog, int which) {}
584584
}).show();
@@ -806,11 +806,11 @@ private void processSettings() {
806806
is = getApplication().openFileInput("settings.txt");
807807
Properties p = new Properties();
808808
p.load(is);
809-
int socket = Integer.parseInt(p.getProperty("serverSocket", "-1"));
809+
int port = Integer.parseInt(p.getProperty("serverSocket", "-1"));
810810
String token = p.getProperty("serverToken", new Date().toString());
811-
if (socket > 1023 && socket < 65536) {
811+
if (port > 1023 && port < 65536) {
812812
WebServer webServer = new WebServerImpl();
813-
webServer.run(socket, token);
813+
webServer.run(port, token);
814814
} else {
815815
Log.i(TAG, "Web service disabled");
816816
}
@@ -862,13 +862,14 @@ private void requestHostPermission(String remoteHost) {
862862
runOnUiThread(new Runnable() {
863863
public void run() {
864864
new AlertDialog.Builder(activity)
865-
.setTitle(R.string.PORTAL_PROMPT).setMessage(getString(R.string.PORTAL_QUESTION, remoteHost))
865+
.setTitle(R.string.PORTAL_PROMPT)
866+
.setMessage(getString(R.string.PORTAL_QUESTION, remoteHost))
866867
.setPositiveButton(R.string.OK, new DialogInterface.OnClickListener() {
867868
public void onClick(DialogInterface dialog, int which) {
868869
permittedHost.put(remoteHost, Boolean.TRUE);
869870
}
870871
})
871-
.setNegativeButton(R.string.Cancel, new DialogInterface.OnClickListener() {
872+
.setNegativeButton(R.string.CANCEL, new DialogInterface.OnClickListener() {
872873
public void onClick(DialogInterface dialog, int which) {
873874
permittedHost.put(remoteHost, Boolean.FALSE);
874875
}

src/platform/android/app/src/main/java/net/sourceforge/smallbasic/WebServer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ public WebServer() {
5050
/**
5151
* Runs the WebServer in a new thread
5252
*/
53-
public void run(final int socketNum, final String token) {
53+
public void run(final int portNum, final String token) {
5454
Thread socketThread = new Thread(new Runnable() {
5555
public void run() {
5656
try {
57-
runServer(socketNum, token);
57+
runServer(portNum, token);
5858
} catch (Exception e) {
5959
log("Server failed to start: ", e);
6060
}
@@ -76,12 +76,12 @@ public void run() {
7676
/**
7777
* WebServer main loop to be run in a separate thread
7878
*/
79-
private void runServer(final int socketNum, final String token) throws IOException {
80-
log("Listening :" + socketNum);
79+
private void runServer(final int portNum, final String token) throws IOException {
80+
log("Listening :" + portNum);
8181
log("Token :" + token);
8282
ServerSocket serverSocket;
8383
try {
84-
serverSocket = new ServerSocket(socketNum);
84+
serverSocket = new ServerSocket(portNum);
8585
} catch (IllegalArgumentException e) {
8686
log("Failed to start server: ", e);
8787
throw new IOException(e);

src/platform/android/app/src/main/res/values/strings.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
<string name="PORTAL_PROMPT">Allow Web portal access?</string>
66
<string name="PORTAL_QUESTION">Do you wish to allow anyone with IP address [%s] to gain access to the portal?</string>
77
<string name="OK">OK</string>
8-
<string name="Cancel">Cancel</string>
8+
<string name="CANCEL">Cancel</string>
9+
<string name="YES">Yes</string>
10+
<string name="NO">No</string>
911
<style name="SBTheme" parent="android:Theme.Holo.Light">
1012
<item name="android:windowActionBar">false</item>
1113
<item name="android:windowNoTitle">true</item>

0 commit comments

Comments
 (0)