summaryrefslogtreecommitdiff
path: root/android/sdremote
diff options
context:
space:
mode:
authorAndrzej J. R. Hunt <andrzej@ahunt.org>2012-07-12 22:10:33 +0100
committerMichael Meeks <michael.meeks@suse.com>2012-08-06 10:22:55 +0100
commit01234d6aa88fed2f88b6080eabeeae5d391ebdbf (patch)
tree78e45344fc373ac54de4d1518d3e3f970901268e /android/sdremote
parentdf3b6372e9366135d14f9e5da4c7d0e5a4ddfd60 (diff)
Pure text for Client->Server. Json removed. Namespace cleanup.
Change-Id: I60e5acac2d47aefec5dd195a5eca599eb1cb8586
Diffstat (limited to 'android/sdremote')
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/TestClient.java10
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/communication/Client.java9
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java3
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java3
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/communication/Transmitter.java34
5 files changed, 13 insertions, 46 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/TestClient.java b/android/sdremote/src/org/libreoffice/impressremote/TestClient.java
index ff25d0fb7aa4..83f4c71a6534 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/TestClient.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/TestClient.java
@@ -1,5 +1,8 @@
package org.libreoffice.impressremote;
+import java.util.ArrayList;
+import java.util.HashMap;
+
import org.libreoffice.impressremote.communication.CommunicationService;
import android.app.Activity;
import android.content.ComponentName;
@@ -21,6 +24,8 @@ import android.widget.TextView;
public class TestClient extends Activity {
+ HashMap<Integer, Bitmap> aPreviewImages = new HashMap<Integer, Bitmap>();
+
private boolean mIsBound = false;
private CommunicationService mCommunicationService;
@@ -139,12 +144,13 @@ public class TestClient extends Activity {
// TODO: set slide;
break;
case CommunicationService.MSG_SLIDE_PREVIEW:
- int slideNumber = aData.getInt("slide_number");
+ int aSlideNumber = aData.getInt("slide_number");
byte[] aPreviewImage = aData.getByteArray("preview_image");
Bitmap aBitmap = BitmapFactory.decodeByteArray(aPreviewImage,
0, aPreviewImage.length);
+ aPreviewImages.put(aSlideNumber, aBitmap);
mImageView.setImageBitmap(aBitmap);
- // TODO: update
+ // TODO: remove above line, use slide changed to show image.
break;
}
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/Client.java b/android/sdremote/src/org/libreoffice/impressremote/communication/Client.java
index 47321e58b41e..d4c1c4e05d69 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/Client.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/Client.java
@@ -49,7 +49,6 @@ public abstract class Client {
private void listen() {
BufferedReader aReader;
try {
- System.out.println("deb:Listening");
aReader = new BufferedReader(new InputStreamReader(mInputStream,
CHARSET));
while (true) {
@@ -57,10 +56,8 @@ public abstract class Client {
String aTemp;
// read until empty line
while ((aTemp = aReader.readLine()).length() != 0) {
- System.out.println("deb__:" + aTemp);
aList.add(aTemp);
}
- System.out.println("deb:parsing");
mReceiver.parseCommand(aList);
}
} catch (UnsupportedEncodingException e) {
@@ -80,13 +77,7 @@ public abstract class Client {
* Must be a valid JSON string.
*/
public void sendCommand(String command) {
- String aLengthString = Integer.toString(command.length());
- byte[] aLengthBytes;
try {
- aLengthBytes = aLengthString.getBytes(CHARSET);
-
- mOutputStream.write(aLengthBytes);
- mOutputStream.write(0x0d);
mOutputStream.write(command.getBytes(CHARSET));
} catch (UnsupportedEncodingException e) {
throw new Error("Specified network encoding [" + CHARSET
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java b/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java
index 3a2b4bf52ebd..d8bd86dd8e1d 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java
@@ -18,13 +18,12 @@ public class NetworkClient extends Client {
private Socket mSocket;
public NetworkClient(String ipAddress) {
+ // FIXME: eventually networking will be fully threaded.
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.permitAll().build();
StrictMode.setThreadPolicy(policy);
- System.out.println("Attempting to open port.");
try {
mSocket = new Socket(ipAddress, PORT);
- System.out.println("We seem to have opened.");
mInputStream = mSocket.getInputStream();
mOutputStream = mSocket.getOutputStream();
startListening();
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java b/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java
index 40c491b0badb..e26ef3128295 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java
@@ -10,9 +10,6 @@ package org.libreoffice.impressremote.communication;
import java.util.ArrayList;
-import org.json.JSONException;
-import org.json.JSONObject;
-
import android.os.Bundle;
import android.os.Message;
import android.os.Messenger;
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/Transmitter.java b/android/sdremote/src/org/libreoffice/impressremote/communication/Transmitter.java
index 2861498bcbc7..40bb9183f6ee 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/Transmitter.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/Transmitter.java
@@ -1,8 +1,5 @@
package org.libreoffice.impressremote.communication;
-import org.json.JSONException;
-import org.json.JSONObject;
-
/**
* Interface to send commands to the server.
*
@@ -17,39 +14,16 @@ public class Transmitter {
}
public void nextTransition() {
- JSONObject aCommand = new JSONObject();
- try {
- aCommand.put("command", "transition_next");
- } catch (JSONException e) {
- e.printStackTrace();
- // TODO: clean
- }
- // Create JSON
- mClient.sendCommand(aCommand.toString());
+ mClient.sendCommand("transition_next\n\n");
}
public void previousTransition() {
- JSONObject aCommand = new JSONObject();
- try {
- aCommand.put("command", "transition_previous");
- } catch (JSONException e) {
- e.printStackTrace();
- // TODO: clean
- }
- // Create JSON
- mClient.sendCommand(aCommand.toString());
+
+ mClient.sendCommand("transition_previous\n\n");
}
public void gotoSlide(int slide) {
- JSONObject aCommand = new JSONObject();
- try {
- aCommand.put("command", "goto_slide");
- aCommand.put("slide_numer", slide);
- } catch (JSONException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- mClient.sendCommand(aCommand.toString());
+ mClient.sendCommand("goto_slide\n" + slide + "\n\n");
}
}