Refactor Receiver, Transmitter, Server and SlideShow classes.

Introduce the Protocol class which contains all static information about
the remote protocol: server messages, client commands, etc. It will help
to avoid duplicates and possible typos.

Change-Id: Ic96a17899b3cec13c4081d671e2296c647bf328c
This commit is contained in:
Artur Dryomov 2013-06-15 15:56:01 +03:00 committed by Michael Meeks
parent 9f161a847a
commit fa309d0e22
9 changed files with 313 additions and 215 deletions

View File

@ -39,8 +39,8 @@ public class BlankScreenFragment extends SherlockFragment {
View v = inflater.inflate(R.layout.fragment_blankscreen, container,
false);
Bitmap aBitmap = mCommunicationService.getSlideShow().getImage(
mCommunicationService.getSlideShow().getCurrentSlide());
Bitmap aBitmap = mCommunicationService.getSlideShow().getSlidePreview(
mCommunicationService.getSlideShow().getCurrentSlideIndex());
// Process the image
final int borderWidth = 8;
@ -74,14 +74,14 @@ public class BlankScreenFragment extends SherlockFragment {
v.findViewById(R.id.blankscreen_slidepreview).setOnClickListener(
aListener);
v.findViewById(R.id.blankscreen_return).setOnClickListener(aListener);
mCommunicationService.getTransmitter().blankScreen();
mCommunicationService.getTransmitter().setUpBlankScreen();
return v;
}
@Override
public void onDestroyView() {
super.onDestroyView();
mCommunicationService.getTransmitter().resume();
mCommunicationService.getTransmitter().resumePresentation();
}
}

View File

@ -127,12 +127,12 @@ public class PresentationActivity extends SherlockFragmentActivity {
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
if (action == KeyEvent.ACTION_UP) {
mCommunicationService.getTransmitter().nextTransition();
mCommunicationService.getTransmitter().performNextTransition();
}
return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
if (action == KeyEvent.ACTION_DOWN) {
mCommunicationService.getTransmitter().previousTransition();
mCommunicationService.getTransmitter().performPreviousTransition();
}
return true;
}

View File

@ -66,12 +66,12 @@ public class PresentationFragment extends SherlockFragment {
mTopView.setAdapter(new ThumbnailAdapter(mContext,
mCommunicationService.getSlideShow()));
mTopView.setSelection(mCommunicationService.getSlideShow()
.getCurrentSlide(), true);
.getCurrentSlideIndex(), true);
mTopView.setOnItemSelectedListener(new ClickListener());
}
updateSlideNumberDisplay(mCommunicationService.getSlideShow()
.getCurrentSlide());
.getCurrentSlideIndex());
}
@ -151,9 +151,9 @@ public class PresentationFragment extends SherlockFragment {
private void updateSlideNumberDisplay(int aPosition) {
// int aSlide = mCommunicationService.getSlideShow().getCurrentSlide();
mNumberText.setText((aPosition + 1) + "/"
+ mCommunicationService.getSlideShow().getSize());
+ mCommunicationService.getSlideShow().getSlidesCount());
mNotes.loadDataWithBaseURL(null, mCommunicationService.getSlideShow()
.getNotes(aPosition), "text/html", "UTF-8", null);
.getSlideNotes(aPosition), "text/html", "UTF-8", null);
}
// -------------------------------------------------- RESIZING LISTENER ----
@ -241,7 +241,8 @@ public class PresentationFragment extends SherlockFragment {
public void onItemSelected(AdapterView<?> arg0, View arg1,
int aPosition, long arg3) {
if (mCommunicationService != null)
mCommunicationService.getTransmitter().gotoSlide(aPosition);
mCommunicationService.getTransmitter().setCurrentSlide(
aPosition);
lastUpdateTime = System.currentTimeMillis();
updateSlideNumberDisplay(aPosition);
}
@ -278,7 +279,7 @@ public class PresentationFragment extends SherlockFragment {
int aPosition = aIntent.getExtras().getInt("slide_number");
if ( aPosition == mTopView.getSelectedItemPosition() ) {
mNotes.loadDataWithBaseURL(null, mCommunicationService.getSlideShow()
.getNotes(aPosition), "text/html", "UTF-8", null);
.getSlideNotes(aPosition), "text/html", "UTF-8", null);
}
}
@ -297,12 +298,12 @@ public class PresentationFragment extends SherlockFragment {
@Override
public int getCount() {
return mSlideShow.getSize();
return mSlideShow.getSlidesCount();
}
@Override
protected Bitmap createBitmap(int position) {
return mSlideShow.getImage(position);
return mSlideShow.getSlidePreview(position);
}
}
}

View File

@ -125,7 +125,7 @@ public class ThumbnailFragment extends SherlockFragment {
public void onItemClick(AdapterView<?> parent, View v, int position,
long id) {
if (mCommunicationService != null)
mCommunicationService.getTransmitter().gotoSlide(position);
mCommunicationService.getTransmitter().setCurrentSlide(position);
}
}
@ -172,7 +172,7 @@ public class ThumbnailFragment extends SherlockFragment {
@Override
public int getCount() {
return mSlideShow.getSize();
return mSlideShow.getSlidesCount();
}
@Override
@ -201,7 +201,7 @@ public class ThumbnailFragment extends SherlockFragment {
aBorderWidth);
if ((mSlideShow != null)
&& (position == mSlideShow.getCurrentSlide())) {
&& (position == mSlideShow.getCurrentSlideIndex())) {
formatSelected(aImage, aText);
mCurrentImage = aImage;
mCurrentText = aText;
@ -209,7 +209,7 @@ public class ThumbnailFragment extends SherlockFragment {
formatUnselected(aImage, aText);
}
Bitmap aBitmap = mSlideShow.getImage(position);
Bitmap aBitmap = mSlideShow.getSlidePreview(position);
// Width
int aWidth = (mGrid.getWidth()) / 3 - 20;
aImage.setMaxWidth(aWidth);

View File

@ -0,0 +1,55 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.libreoffice.impressremote.communication;
import android.text.TextUtils;
final class Protocol {
private Protocol() {
}
public static final class Messages {
private Messages() {
}
public static final String SLIDESHOW_STARTED = "slideshow_started";
public static final String SLIDESHOW_FINISHED = "slideshow_finished";
public static final String SLIDE_UPDATED = "slide_updated";
public static final String SLIDE_PREVIEW = "slide_preview";
public static final String SLIDE_NOTES = "slide_notes";
}
public static final class Commands {
private Commands() {
}
public static final String TRANSITION_NEXT = "transition_next";
public static final String TRANSITION_PREVIOUS = "transition_previous";
public static final String GOTO_SLIDE = "goto_slide";
public static final String PRESENTATION_BLANK_SCREEN = "presentation_blank_screen";
public static final String PRESENTATION_RESUME = "presentation_resume";
public static final String PRESENTATION_START = "presentation_start";
public static final String PRESENTATION_STOP = "presentation_stop";
private static final String DELIMITER_PARAMETER = "\n";
private static final String DELIMITER_COMMAND = "\n\n";
public static String prepareCommand(String aCommand) {
return String.format("%s%s", aCommand, DELIMITER_COMMAND);
}
public static String prepareCommand(String... aParameters) {
String aCommand = TextUtils.join(DELIMITER_PARAMETER, aParameters);
return prepareCommand(aCommand);
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -8,7 +8,7 @@
*/
package org.libreoffice.impressremote.communication;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.content.Intent;
@ -16,106 +16,133 @@ import android.support.v4.content.LocalBroadcastManager;
import android.util.Base64;
public class Receiver {
public Receiver(Context aContext) {
mContext = aContext;
mSlideShow = new SlideShow(mContext);
}
private Context mContext;
private final Context mContext;
private SlideShow mSlideShow;
public Receiver(Context aContext) {
this.mContext = aContext;
this.mSlideShow = new SlideShow(mContext);
}
public SlideShow getSlideShow() {
return mSlideShow;
}
public boolean isSlideShowRunning() {
return (mSlideShow.getSize() > 0);
return mSlideShow.getSlidesCount() > 0;
}
public void parseCommand(ArrayList<String> aCommand) {
if (aCommand.size() == 0)
return; // E.g. if empty line received for whatever reason.
String aInstruction = aCommand.get(0);
if (aInstruction.equals("slideshow_started")) {
int aSlideShowlength = Integer.parseInt(aCommand.get(1));
int aCurrentSlide = Integer.parseInt(aCommand.get(2));
mSlideShow.setLength(aSlideShowlength);
mSlideShow.setCurrentSlide(aCurrentSlide);
// Intent aIntent = new Intent(mContext.getApplicationContext(),
// PresentationActivity.class);
// aIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// aIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
// mContext.getApplicationContext().startActivity(aIntent);
Intent aIntent = new Intent(
CommunicationService.STATUS_CONNECTED_SLIDESHOW_RUNNING);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(aIntent);
aIntent = new Intent(
CommunicationService.MSG_SLIDE_CHANGED);
aIntent.putExtra("slide_number", aCurrentSlide);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(aIntent);
} else if (aInstruction.equals("slideshow_finished")) {
mSlideShow = new SlideShow(mContext);
// Intent aIntent = new Intent(mContext.getApplicationContext(),
// StartPresentationActivity.class);
// aIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// aIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
// mContext.getApplicationContext().startActivity(aIntent);
Intent aIntent = new Intent(
CommunicationService.STATUS_CONNECTED_NOSLIDESHOW);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(aIntent);
} else {
if (mSlideShow == null)
return;
if (aInstruction.equals("slide_updated")) {
int aSlideNumber = Integer.parseInt(aCommand.get(1));
mSlideShow.setCurrentSlide(aSlideNumber);
Intent aIntent = new Intent(
CommunicationService.MSG_SLIDE_CHANGED);
aIntent.putExtra("slide_number", aSlideNumber);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(
aIntent);
} else if (aInstruction.equals("slide_preview")) {
int aSlideNumber = Integer.parseInt(aCommand.get(1));
String aImageString = aCommand.get(2);
try {
byte[] aImage = Base64.decode(aImageString, Base64.DEFAULT);
// Store image internally
mSlideShow.putImage(aSlideNumber, aImage);
Intent aIntent = new Intent(
CommunicationService.MSG_SLIDE_PREVIEW);
aIntent.putExtra("slide_number", aSlideNumber);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(
aIntent);
} catch (IllegalArgumentException e) {
// Bad data - tough luck
}
} else if (aInstruction.equals("slide_notes")) {
int aSlideNumber = Integer.parseInt(aCommand.get(1));
StringBuilder aNotes = new StringBuilder();
for (int i = 2; i < aCommand.size(); i++) {
aNotes.append(aCommand.get(i));
}
// Store image internally
mSlideShow.putNotes(aSlideNumber, aNotes.toString());
Intent aIntent = new Intent(
CommunicationService.MSG_SLIDE_NOTES);
aIntent.putExtra("slide_number", aSlideNumber);
LocalBroadcastManager.getInstance(mContext).sendBroadcast(
aIntent);
}
public void parseCommand(List<String> aInstruction) {
if (aInstruction.isEmpty()) {
return;
}
String aCommand = aInstruction.get(0);
if (aCommand.equals(Protocol.Messages.SLIDESHOW_STARTED)) {
startSlideShow(aInstruction);
return;
}
if (aCommand.equals(Protocol.Messages.SLIDESHOW_FINISHED)) {
finishSlideShow();
return;
}
if (mSlideShow == null) {
return;
}
if (aCommand.equals(Protocol.Messages.SLIDE_UPDATED)) {
setUpCurrentSlide(aInstruction);
return;
}
if (aCommand.equals(Protocol.Messages.SLIDE_PREVIEW)) {
setUpSlidePreview(aInstruction);
return;
}
if (aCommand.equals(Protocol.Messages.SLIDE_NOTES)) {
setUpSlideNotes(aInstruction);
}
}
private void startSlideShow(List<String> aInstruction) {
int aSlideShowSlidesCount = Integer.parseInt(aInstruction.get(1));
int aCurrentSlideIndex = Integer.parseInt(aInstruction.get(2));
mSlideShow.setSlidesCount(aSlideShowSlidesCount);
mSlideShow.setCurrentSlideIndex(aCurrentSlideIndex);
Intent aStatusConnectedSlideShowRunningIntent = new Intent(
CommunicationService.STATUS_CONNECTED_SLIDESHOW_RUNNING);
Intent aSlideChangedIntent = new Intent(
CommunicationService.MSG_SLIDE_CHANGED);
aSlideChangedIntent.putExtra("slide_number", aCurrentSlideIndex);
LocalBroadcastManager.getInstance(mContext)
.sendBroadcast(aStatusConnectedSlideShowRunningIntent);
LocalBroadcastManager.getInstance(mContext)
.sendBroadcast(aSlideChangedIntent);
}
private void finishSlideShow() {
this.mSlideShow = new SlideShow(mContext);
Intent aStatusConnectedNoSlideShowIntent = new Intent(
CommunicationService.STATUS_CONNECTED_NOSLIDESHOW);
LocalBroadcastManager.getInstance(mContext)
.sendBroadcast(aStatusConnectedNoSlideShowIntent);
}
private void setUpCurrentSlide(List<String> aInstruction) {
int aCurrentSlideIndex = Integer.parseInt(aInstruction.get(1));
mSlideShow.setCurrentSlideIndex(aCurrentSlideIndex);
Intent aSlideChangedIntent = new Intent(
CommunicationService.MSG_SLIDE_CHANGED);
aSlideChangedIntent.putExtra("slide_number", aCurrentSlideIndex);
LocalBroadcastManager.getInstance(mContext)
.sendBroadcast(aSlideChangedIntent);
}
private void setUpSlidePreview(List<String> aInstruction) {
int aSlideIndex = Integer.parseInt(aInstruction.get(1));
String aImageAsString = aInstruction.get(2);
byte[] aImage = Base64.decode(aImageAsString, Base64.DEFAULT);
mSlideShow.setSlidePreview(aSlideIndex, aImage);
Intent aSlidePreviewChangedIntent = new Intent(
CommunicationService.MSG_SLIDE_PREVIEW);
aSlidePreviewChangedIntent.putExtra("slide_number", aSlideIndex);
LocalBroadcastManager.getInstance(mContext)
.sendBroadcast(aSlidePreviewChangedIntent);
}
private void setUpSlideNotes(List<String> aInstruction) {
int aSlideIndex = Integer.parseInt(aInstruction.get(1));
StringBuilder aNotesBuilder = new StringBuilder();
for (int aNoteIndex = 2; aNoteIndex < aInstruction
.size(); aNoteIndex++) {
aNotesBuilder.append(aInstruction.get(aNoteIndex));
}
String aNotes = aNotesBuilder.toString();
mSlideShow.setSlideNotes(aSlideIndex, aNotes);
Intent aSlideNotesChangedIntent = new Intent(
CommunicationService.MSG_SLIDE_NOTES);
aSlideNotesChangedIntent.putExtra("slide_number", aSlideIndex);
LocalBroadcastManager.getInstance(mContext)
.sendBroadcast(aSlideNotesChangedIntent);
}
}

View File

@ -12,27 +12,28 @@ import android.os.Parcel;
import android.os.Parcelable;
public class Server implements Parcelable {
private static final int SPECIAL_PARCELABLE_OBJECTS_BITMASK = 0;
public enum Protocol {
public static enum Protocol {
NETWORK, BLUETOOTH
}
private Protocol mProtocol;
private String mAddress;
private String mName;
private long mTimeDiscovered;
private final Protocol mProtocol;
private final String mAddress;
private final String mName;
private final long mTimeDiscovered;
/**
* Signifies a Server that shouldn't be automatically removed from the list.
* Used e.g. for the emulator.
*/
protected boolean mNoTimeout = false;
protected Server(Protocol aProtocol, String aAddress, String aName,
long aTimeDiscovered) {
mProtocol = aProtocol;
mAddress = aAddress;
mName = aName;
mTimeDiscovered = aTimeDiscovered;
protected Server(Protocol aProtocol, String aAddress, String aName, long aTimeDiscovered) {
this.mProtocol = aProtocol;
this.mAddress = aAddress;
this.mName = aName;
this.mTimeDiscovered = aTimeDiscovered;
}
public Protocol getProtocol() {
@ -43,11 +44,6 @@ public class Server implements Parcelable {
return mAddress;
}
/**
* Get a human friendly name for the server.
*
* @return The name.
*/
public String getName() {
return mName;
}
@ -57,25 +53,26 @@ public class Server implements Parcelable {
}
public String toString() {
return getClass().getName() + '@' + Integer.toHexString(hashCode()) + ":{" + mAddress + "," + mName + "}";
return getClass().getName() + '@' + Integer
.toHexString(hashCode()) + ":{" + mAddress + "," + mName + "}";
}
@Override
public int describeContents() {
return 0;
return SPECIAL_PARCELABLE_OBJECTS_BITMASK;
}
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeString(mAddress);
out.writeString(mName);
out.writeString(mProtocol.name());
out.writeLong(mTimeDiscovered);
public void writeToParcel(Parcel parcel, int flags) {
parcel.writeString(mAddress);
parcel.writeString(mName);
parcel.writeString(mProtocol.name());
parcel.writeLong(mTimeDiscovered);
}
public static final Parcelable.Creator<Server> CREATOR = new Parcelable.Creator<Server>() {
public Server createFromParcel(Parcel in) {
return new Server(in);
public Server createFromParcel(Parcel parcel) {
return new Server(parcel);
}
public Server[] newArray(int size) {
@ -83,11 +80,11 @@ public class Server implements Parcelable {
}
};
private Server(Parcel in) {
mAddress = in.readString();
mName = in.readString();
mProtocol = Protocol.valueOf(in.readString());
mTimeDiscovered = in.readLong();
private Server(Parcel parcel) {
this.mAddress = parcel.readString();
this.mName = parcel.readString();
this.mProtocol = Protocol.valueOf(parcel.readString());
this.mTimeDiscovered = parcel.readLong();
}
}

View File

@ -8,8 +8,6 @@
*/
package org.libreoffice.impressremote.communication;
import org.libreoffice.impressremote.R;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@ -19,69 +17,79 @@ import android.graphics.Paint;
import android.graphics.RectF;
import android.util.SparseArray;
import org.libreoffice.impressremote.R;
public class SlideShow {
private final Context mContext;
private SparseArray<Bitmap> mPreviews = new SparseArray<Bitmap>();
private SparseArray<String> mNotes = new SparseArray<String>();
private int mSlidesCount;
private int mCurrentSlideIndex;
private int mSize = 0;
private int mCurrentSlide = 0;
private Context mContext;
private final SparseArray<Bitmap> mSlidePreviews;
private final SparseArray<String> mSlideNotes;
protected SlideShow(Context aContext) {
mContext = aContext;
public SlideShow(Context aContext) {
this.mContext = aContext;
this.mSlidesCount = 0;
this.mCurrentSlideIndex = 0;
this.mSlidePreviews = new SparseArray<Bitmap>();
this.mSlideNotes = new SparseArray<String>();
}
protected void setLength(int aSize) {
mSize = aSize;
public void setSlidesCount(int aSlidesCount) {
this.mSlidesCount = aSlidesCount;
}
public int getSize() {
return mSize;
public int getSlidesCount() {
return mSlidesCount;
}
public int getCurrentSlide() {
return mCurrentSlide;
public void setCurrentSlideIndex(int aCurrentSlideIndex) {
this.mCurrentSlideIndex = aCurrentSlideIndex;
}
protected void setCurrentSlide(int aSlide) {
mCurrentSlide = aSlide;
public int getCurrentSlideIndex() {
return mCurrentSlideIndex;
}
protected void putImage(int aSlide, byte[] aImage) {
Bitmap aBitmap = BitmapFactory.decodeByteArray(aImage, 0, aImage.length);
public void setSlidePreview(int aSlideIndex, byte[] aSlidePreview) {
Bitmap aBitmap = BitmapFactory
.decodeByteArray(aSlidePreview, 0, aSlidePreview.length);
final int borderWidth = 8;
Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
p.setShadowLayer(borderWidth, 0, 0, Color.BLACK);
RectF aRect = new RectF(borderWidth, borderWidth, borderWidth
+ aBitmap.getWidth(), borderWidth
+ aBitmap.getHeight());
+ aBitmap.getWidth(), borderWidth
+ aBitmap.getHeight());
Bitmap aOut = Bitmap.createBitmap(aBitmap.getWidth() + 2
* borderWidth, aBitmap.getHeight() + 2
* borderWidth, aBitmap.getConfig());
* borderWidth, aBitmap.getHeight() + 2
* borderWidth, aBitmap.getConfig());
Canvas canvas = new Canvas(aOut);
canvas.drawColor(mContext.getResources().getColor(R.color.light_grey));
canvas.drawRect(aRect, p);
canvas.drawBitmap(aBitmap, null, aRect, null);
mPreviews.put(aSlide, aOut);
mSlidePreviews.put(aSlideIndex, aOut);
}
public Bitmap getImage(int aSlide) {
return mPreviews.get(aSlide);
public Bitmap getSlidePreview(int aSlideIndex) {
return mSlidePreviews.get(aSlideIndex);
}
protected void putNotes(int aSlide, String aNotes) {
mNotes.put(aSlide, aNotes);
public void setSlideNotes(int aSlideIndex, String aSlideNotes) {
mSlideNotes.put(aSlideIndex, aSlideNotes);
}
public String getNotes(int aSlide) {
String aNote = mNotes.get(aSlide);
if (aNote != null) {
return aNote;
public String getSlideNotes(int aSlideIndex) {
String aSlideNotes = mSlideNotes.get(aSlideIndex);
if (aSlideNotes != null) {
return aSlideNotes;
} else {
return "";
}
@ -97,7 +105,7 @@ public class SlideShow {
public class Timer {
/**
* This stores the starting time of the timer if running.
*
* <p/>
* If paused this stores how long the timer was previously running.
*/
private long aTime = 0;
@ -110,8 +118,8 @@ public class SlideShow {
/**
* Set whether this timer should be a normal or a countdown timer.
* @param aIsCountdown
* Whether this should be a countdown timer.
*
* @param aIsCountdown Whether this should be a countdown timer.
*/
public void setCountdown(boolean aIsCountdown) {
mIsCountdown = aIsCountdown;
@ -124,8 +132,8 @@ public class SlideShow {
/**
* Set the countdown time. Can be set, and isn't lost, whatever mode
* the timer is running in.
* @param aCountdownTime
* The countdown time.
*
* @param aCountdownTime The countdown time.
*/
public void setCountdownTime(long aCountdownTime) {
mCountdownTime = aCountdownTime;
@ -170,6 +178,7 @@ public class SlideShow {
/**
* Get either how long this timer has been running, or how long the
* timer still has left to run.
*
* @return
*/
public long getTimeMillis() {

View File

@ -14,57 +14,66 @@ import android.graphics.Color;
* Interface to send commands to the server.
*/
public class Transmitter {
private final Client mClient;
private Client mClient;
public Transmitter(Client aClient) {
this.mClient = aClient;
}
public Transmitter(Client aClient) {
mClient = aClient;
}
public void performNextTransition() {
mClient.sendCommand(Protocol.Commands
.prepareCommand(Protocol.Commands.TRANSITION_NEXT));
}
public void nextTransition() {
mClient.sendCommand("transition_next\n\n");
}
public void performPreviousTransition() {
mClient.sendCommand(Protocol.Commands
.prepareCommand(Protocol.Commands.TRANSITION_PREVIOUS));
}
public void previousTransition() {
public void setCurrentSlide(int slideIndex) {
mClient.sendCommand(Protocol.Commands
.prepareCommand(Protocol.Commands.GOTO_SLIDE,
Integer.toString(slideIndex)));
}
mClient.sendCommand("transition_previous\n\n");
}
/**
* Blank the screen to the default colour (set server-side), which is
* generally black. This is slightly faster than using
* <code> setUpBlankScreen( colour ) </code>.
*/
public void setUpBlankScreen() {
mClient.sendCommand(Protocol.Commands
.prepareCommand(Protocol.Commands.PRESENTATION_BLANK_SCREEN));
}
public void gotoSlide(int slide) {
mClient.sendCommand("goto_slide\n" + slide + "\n\n");
}
/**
* Set the screen to a specific colour. Only use if a non default colour is
* needed.
*
* @param aColor blank screen color
*/
public void setUpBlankScreen(Color aColor) {
// FIXME: check how to get colour in integer form.
/**
* Blank the screen to the default colour (set server-side), which is
* generally black. This is slightly faster than using
* <code> blankScreen( colour ) </code>.
*/
public void blankScreen() {
mClient.sendCommand("presentation_blank_screen\n\n");
}
mClient.sendCommand(Protocol.Commands
.prepareCommand(Protocol.Commands.PRESENTATION_BLANK_SCREEN,
aColor.toString()));
}
/**
* Set the screen to a specific colour. Only use if a non default colour is
* needed.
*
* @param aColor
*/
public void blankScreen(Color aColor) {
// FIXME: check how to get colour in integer form.
mClient.sendCommand("presentation_blank_screen\n" + aColor + "\n\n");
}
public void resumePresentation() {
mClient.sendCommand(Protocol.Commands
.prepareCommand(Protocol.Commands.PRESENTATION_RESUME));
}
public void resume() {
mClient.sendCommand("presentation_resume\n\n");
}
public void startPresentation() {
mClient.sendCommand(Protocol.Commands
.prepareCommand(Protocol.Commands.PRESENTATION_START));
}
public void startPresentation() {
mClient.sendCommand("presentation_start\n\n");
}
public void stopPresentation() {
mClient.sendCommand("presentation_stop\n\n");
}
public void stopPresentation() {
mClient.sendCommand(Protocol.Commands
.prepareCommand(Protocol.Commands.PRESENTATION_STOP));
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */