Added styling and Timer code.
Change-Id: I I044efc4e317fa56f9e3670c7b68d287dcc74ed53
This commit is contained in:
parent
6794e94bfd
commit
3e0b7a7141
19 changed files with 372 additions and 55 deletions
11
android/sdremote/.settings/org.eclipse.jdt.core.prefs
Normal file
11
android/sdremote/.settings/org.eclipse.jdt.core.prefs
Normal file
|
@ -0,0 +1,11 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
|
@ -5,11 +5,15 @@
|
|||
android:versionName="1.0" >
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14"/>
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="14"
|
||||
android:targetSdkVersion="14" />
|
||||
|
||||
<application
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name" >
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.ImpressRemote" >
|
||||
<activity
|
||||
android:name="TestClient"
|
||||
android:label="@string/app_name" >
|
||||
|
@ -22,7 +26,18 @@
|
|||
|
||||
<service android:name=".communication.CommunicationService" >
|
||||
</service>
|
||||
<activity android:name=".ThumbnailActivity"></activity>
|
||||
|
||||
<activity android:name=".ThumbnailActivity" >
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".PresentationActivity"
|
||||
android:label="@string/title_activity_presentation" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
BIN
android/sdremote/res/drawable-hdpi/ic_action_search.png
Normal file
BIN
android/sdremote/res/drawable-hdpi/ic_action_search.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3 KiB |
BIN
android/sdremote/res/drawable-mdpi/ic_action_search.png
Normal file
BIN
android/sdremote/res/drawable-mdpi/ic_action_search.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3 KiB |
BIN
android/sdremote/res/drawable-xhdpi/ic_action_search.png
Normal file
BIN
android/sdremote/res/drawable-xhdpi/ic_action_search.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
14
android/sdremote/res/layout/activity_presentation.xml
Normal file
14
android/sdremote/res/layout/activity_presentation.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:text="@string/hello_world"
|
||||
tools:context=".PresentationActivity" />
|
||||
|
||||
</RelativeLayout>
|
6
android/sdremote/res/menu/activity_presentation.xml
Normal file
6
android/sdremote/res/menu/activity_presentation.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/menu_settings"
|
||||
android:title="@string/menu_settings"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never" />
|
||||
</menu>
|
|
@ -1,4 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Launcher</string>
|
||||
</resources>
|
||||
|
||||
<string name="app_name">LibreOffice Remote</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
<string name="menu_settings">Settings</string>
|
||||
<string name="title_activity_presentation">PresentationActivity</string>
|
||||
|
||||
</resources>
|
20
android/sdremote/res/values/styles.xml
Normal file
20
android/sdremote/res/values/styles.xml
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<color name="orange">#EE4400</color>
|
||||
<color name="light_grey">#E8E9E8</color>
|
||||
|
||||
<integer name="thumbnail_border_width">3</integer>
|
||||
|
||||
<color name="thumbnail_border">#B4B4B4</color>
|
||||
<color name="thumbnail_border_selected">#EE4400</color>
|
||||
|
||||
<style name="Theme.ImpressRemote.ActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
|
||||
<item name="android:background">@color/orange</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.ImpressRemote" parent="android:style/Theme.Holo.Light">
|
||||
<item name="android:actionBarStyle">@style/Theme.ImpressRemote.ActionBar</item>
|
||||
<item name="android:windowBackground">@color/light_grey</item>
|
||||
</style>
|
||||
</resources>
|
|
@ -0,0 +1,18 @@
|
|||
/* -*- Mode: C++; 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;
|
||||
|
||||
/**
|
||||
* Used to manage the action bar whenever a presentation is running.
|
||||
*
|
||||
*/
|
||||
public class ActionBarManager {
|
||||
|
||||
}
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -1,3 +1,11 @@
|
|||
/* -*- Mode: C++; 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;
|
||||
|
||||
import android.app.Activity;
|
||||
|
@ -12,3 +20,4 @@ public class Launcher extends Activity {
|
|||
}
|
||||
|
||||
}
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -0,0 +1,20 @@
|
|||
package org.libreoffice.impressremote;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.view.Menu;
|
||||
|
||||
public class PresentationActivity extends Activity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_presentation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.activity_presentation, menu);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,13 +1,21 @@
|
|||
/* -*- Mode: C++; 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;
|
||||
|
||||
import org.libreoffice.impressremote.communication.CommunicationService;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
|
@ -25,8 +33,6 @@ public class TestClient extends Activity {
|
|||
|
||||
private boolean mIsBound = false;
|
||||
|
||||
private int mCurrentSlide = 0;
|
||||
|
||||
private CommunicationService mCommunicationService;
|
||||
|
||||
final Messenger mMessenger = new Messenger(new MessageHandler());
|
||||
|
@ -51,25 +57,32 @@ public class TestClient extends Activity {
|
|||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
doUnbindService();
|
||||
// doUnbindService();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// TODO Auto-generated method stub
|
||||
stopService(new Intent(this, CommunicationService.class));
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
// TODO Auto-generated method stub
|
||||
super.onStop();
|
||||
// mCommunicationService.disconnect();
|
||||
stopService(new Intent(this, CommunicationService.class));
|
||||
// mCommunicationService.disconnect();
|
||||
// stopService(new Intent(this, CommunicationService.class));
|
||||
}
|
||||
|
||||
private ServiceConnection mConnection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName aClassName,
|
||||
IBinder aService) {
|
||||
IBinder aService) {
|
||||
mCommunicationService = ((CommunicationService.CBinder) aService)
|
||||
.getService();
|
||||
.getService();
|
||||
mCommunicationService.connectTo(
|
||||
CommunicationService.Protocol.NETWORK, "10.0.2.2");
|
||||
CommunicationService.Protocol.NETWORK, "10.0.2.2");
|
||||
mCommunicationService.setActivityMessenger(mMessenger);
|
||||
enableButtons(true);
|
||||
}
|
||||
|
@ -84,8 +97,7 @@ public class TestClient extends Activity {
|
|||
void doBindService() {
|
||||
Intent aIntent = new Intent(this, CommunicationService.class);
|
||||
startService(aIntent);
|
||||
bindService(aIntent, mConnection,
|
||||
Context.BIND_IMPORTANT);
|
||||
bindService(aIntent, mConnection, Context.BIND_IMPORTANT);
|
||||
mIsBound = true;
|
||||
}
|
||||
|
||||
|
@ -138,8 +150,9 @@ public class TestClient extends Activity {
|
|||
mThumbnailButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent aIntent = new Intent(TestClient.this, ThumbnailActivity.class);
|
||||
startActivity( aIntent);
|
||||
Intent aIntent = new Intent(TestClient.this,
|
||||
ThumbnailActivity.class);
|
||||
startActivity(aIntent);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -162,9 +175,9 @@ public class TestClient extends Activity {
|
|||
// We continue on to try and update the image.
|
||||
case CommunicationService.MSG_SLIDE_PREVIEW:
|
||||
int aSlideNumber = aData.getInt("slide_number");
|
||||
if ( mCurrentPreviewImageMissing ) {
|
||||
Bitmap aImage = mCommunicationService
|
||||
.getSlideShow().getImage(aSlideNumber);
|
||||
if (mCurrentPreviewImageMissing) {
|
||||
Bitmap aImage = mCommunicationService.getSlideShow()
|
||||
.getImage(aSlideNumber);
|
||||
if (aImage != null) {
|
||||
mImageView.setImageBitmap(aImage);
|
||||
mCurrentPreviewImageMissing = false;
|
||||
|
@ -176,3 +189,4 @@ public class TestClient extends Activity {
|
|||
}
|
||||
}
|
||||
}
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -1,6 +1,13 @@
|
|||
/* -*- Mode: C++; 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;
|
||||
|
||||
import org.libreoffice.impressremote.TestClient.MessageHandler;
|
||||
import org.libreoffice.impressremote.communication.CommunicationService;
|
||||
import org.libreoffice.impressremote.communication.SlideShow;
|
||||
|
||||
|
@ -10,7 +17,6 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
|
@ -43,7 +49,7 @@ public class ThumbnailActivity extends Activity {
|
|||
setContentView(R.layout.activity_thumbnail);
|
||||
|
||||
bindService(new Intent(this, CommunicationService.class), mConnection,
|
||||
Context.BIND_ADJUST_WITH_ACTIVITY);
|
||||
Context.BIND_ADJUST_WITH_ACTIVITY);
|
||||
mIsBound = true;
|
||||
|
||||
mGrid = (GridView) findViewById(R.id.thumbnail_grid);
|
||||
|
@ -61,24 +67,44 @@ public class ThumbnailActivity extends Activity {
|
|||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// MenuInflater inflater = getMenuInflater();
|
||||
// inflater.inflate(R.menu.main_activity, menu);
|
||||
// return true;
|
||||
// }
|
||||
|
||||
private void setSelected(int position) {
|
||||
if (mCurrentImage != null) {
|
||||
mCurrentImage.setPadding(0, 0, 0, 0);
|
||||
}
|
||||
if (mCurrentText != null) {
|
||||
mCurrentText.setTypeface(Typeface.create(
|
||||
mCurrentText.getTypeface(), Typeface.NORMAL));
|
||||
}
|
||||
formatUnselected(mCurrentImage, mCurrentText);
|
||||
|
||||
View aV = mGrid.getChildAt(position);
|
||||
if (aV != null) {
|
||||
mCurrentImage = (ImageView) aV.findViewById(R.id.sub_thumbnail);
|
||||
mCurrentText = (TextView) aV.findViewById(R.id.sub_number);
|
||||
|
||||
mCurrentImage.setBackgroundColor(Color.RED);
|
||||
mCurrentImage.setPadding(2, 2, 2, 2);
|
||||
mCurrentText.setTypeface(Typeface.create(mCurrentText.getTypeface(),
|
||||
Typeface.BOLD));
|
||||
formatSelected(mCurrentImage, mCurrentText);
|
||||
}
|
||||
}
|
||||
|
||||
private void formatUnselected(ImageView aImage, TextView aText) {
|
||||
if (aImage != null) {
|
||||
aImage.setBackgroundColor(getResources().getColor(
|
||||
R.color.thumbnail_border));
|
||||
}
|
||||
if (aText != null) {
|
||||
aText.setTypeface(Typeface.create(mCurrentText.getTypeface(),
|
||||
Typeface.NORMAL));
|
||||
}
|
||||
}
|
||||
|
||||
private void formatSelected(ImageView aImage, TextView aText) {
|
||||
if (aImage != null) {
|
||||
aImage.setBackgroundColor(getResources().getColor(
|
||||
R.color.thumbnail_border_selected));
|
||||
}
|
||||
if (aText != null) {
|
||||
aText.setTypeface(Typeface.create(mCurrentText.getTypeface(),
|
||||
Typeface.BOLD));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,13 +114,13 @@ public class ThumbnailActivity extends Activity {
|
|||
private ServiceConnection mConnection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName aClassName,
|
||||
IBinder aService) {
|
||||
IBinder aService) {
|
||||
mCommunicationService = ((CommunicationService.CBinder) aService)
|
||||
.getService();
|
||||
.getService();
|
||||
mCommunicationService.setActivityMessenger(mMessenger);
|
||||
mSlideShow = mCommunicationService.getSlideShow();
|
||||
mGrid.setAdapter(new ThumbnailAdapter(ThumbnailActivity.this,
|
||||
mSlideShow));
|
||||
mSlideShow));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -106,7 +132,7 @@ public class ThumbnailActivity extends Activity {
|
|||
// ----------------------------------------------------- CLICK LISTENER ----
|
||||
protected class ClickListener implements AdapterView.OnItemClickListener {
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position,
|
||||
long id) {
|
||||
long id) {
|
||||
mCommunicationService.getTransmitter().gotoSlide(position);
|
||||
}
|
||||
}
|
||||
|
@ -160,12 +186,25 @@ public class ThumbnailActivity extends Activity {
|
|||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
LayoutInflater aInflater = (LayoutInflater) mContext
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View v = aInflater.inflate(R.layout.slide_thumbnail, null);
|
||||
|
||||
ImageView aImage = (ImageView) v.findViewById(R.id.sub_thumbnail);
|
||||
TextView aText = (TextView) v.findViewById(R.id.sub_number);
|
||||
|
||||
// Do the image & number styling
|
||||
int aBorderWidth = getResources().getInteger(
|
||||
R.integer.thumbnail_border_width);
|
||||
aImage.setPadding(aBorderWidth, aBorderWidth, aBorderWidth,
|
||||
aBorderWidth);
|
||||
|
||||
if ((mSlideShow != null)
|
||||
&& (position == mSlideShow.getCurrentSlide())) {
|
||||
formatSelected(aImage, aText);
|
||||
} else {
|
||||
formatUnselected(aImage, aText);
|
||||
}
|
||||
|
||||
Bitmap aBitmap = mSlideShow.getImage(position);
|
||||
if (aBitmap != null) {
|
||||
aImage.setImageBitmap(aBitmap);
|
||||
|
@ -173,13 +212,8 @@ public class ThumbnailActivity extends Activity {
|
|||
|
||||
aText.setText(String.valueOf(position + 1));
|
||||
|
||||
// if ((mSlideShow != null)
|
||||
// && (position == mSlideShow.getCurrentSlide())) {
|
||||
// setSelected(position);
|
||||
// }
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -1,3 +1,11 @@
|
|||
/* -*- Mode: C++; 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 java.io.BufferedReader;
|
||||
|
@ -8,10 +16,6 @@ import java.io.OutputStream;
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.http.util.ByteArrayBuffer;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* Generic Client for the remote control. To implement a Client for a specific
|
||||
* transport medium you must provide input and output streams (
|
||||
|
@ -50,7 +54,7 @@ public abstract class Client {
|
|||
BufferedReader aReader;
|
||||
try {
|
||||
aReader = new BufferedReader(new InputStreamReader(mInputStream,
|
||||
CHARSET));
|
||||
CHARSET));
|
||||
while (true) {
|
||||
ArrayList<String> aList = new ArrayList<String>();
|
||||
String aTemp;
|
||||
|
@ -82,10 +86,11 @@ public abstract class Client {
|
|||
mOutputStream.write(command.getBytes(CHARSET));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new Error("Specified network encoding [" + CHARSET
|
||||
+ " not available.");
|
||||
+ " not available.");
|
||||
} catch (IOException e) {
|
||||
// TODO Notify that stream has closed.
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -1,9 +1,15 @@
|
|||
/* -*- Mode: C++; 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.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.Messenger;
|
||||
|
@ -59,6 +65,24 @@ public class CommunicationService extends Service {
|
|||
return mTransmitter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to a specific server. This method cannot be called on the main
|
||||
* activity thread.
|
||||
*
|
||||
* @param aServer
|
||||
* The Server to connect to.
|
||||
*/
|
||||
public void connectTo(Server aServer) {
|
||||
connectTo(aServer.getProtocol(), aServer.getAddress());
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to a specific server. This method cannot be called on the main
|
||||
* activity thread.
|
||||
*
|
||||
* @param aProtocol
|
||||
* @param address
|
||||
*/
|
||||
public void connectTo(Protocol aProtocol, String address) {
|
||||
switch (aProtocol) {
|
||||
case NETWORK:
|
||||
|
@ -66,11 +90,19 @@ public class CommunicationService extends Service {
|
|||
mTransmitter = new Transmitter(mClient);
|
||||
mClient.setReceiver(mReceiver);
|
||||
break;
|
||||
case BLUETOOTH:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Server[] getServers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
mClient.closeConnection();
|
||||
}
|
||||
|
@ -79,5 +111,39 @@ public class CommunicationService extends Service {
|
|||
return mReceiver.getSlideShow();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------- SERVER -------------
|
||||
/**
|
||||
* Class describing a remote server.
|
||||
*/
|
||||
public class Server {
|
||||
private Protocol mProtocol;
|
||||
private String mAddress;
|
||||
private String mName;
|
||||
|
||||
protected Server(Protocol aProtocol, String aAddress, String aName) {
|
||||
mProtocol = aProtocol;
|
||||
mAddress = aAddress;
|
||||
mName = aName;
|
||||
}
|
||||
|
||||
public Protocol getProtocol() {
|
||||
return mProtocol;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return mAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a human friendly name for the server.
|
||||
*
|
||||
* @return The name.
|
||||
*/
|
||||
public String getName() {
|
||||
return mName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -1,3 +1,11 @@
|
|||
/* -*- Mode: C++; 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 java.io.IOException;
|
||||
|
@ -20,7 +28,7 @@ public class NetworkClient extends Client {
|
|||
public NetworkClient(String ipAddress) {
|
||||
// FIXME: eventually networking will be fully threaded.
|
||||
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
|
||||
.permitAll().build();
|
||||
.permitAll().build();
|
||||
StrictMode.setThreadPolicy(policy);
|
||||
try {
|
||||
mSocket = new Socket(ipAddress, PORT);
|
||||
|
@ -49,3 +57,4 @@ public class NetworkClient extends Client {
|
|||
}
|
||||
|
||||
}
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -1,3 +1,11 @@
|
|||
/* -*- Mode: C++; 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.graphics.Bitmap;
|
||||
|
@ -34,4 +42,57 @@ public class SlideShow {
|
|||
byte[] aImage = mPreviewImages.get(aSlide);
|
||||
return BitmapFactory.decodeByteArray(aImage, 0, aImage.length);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------- TIMER --------------
|
||||
private Timer mTimer = new Timer();
|
||||
|
||||
public Timer getTimer() {
|
||||
return mTimer;
|
||||
}
|
||||
|
||||
public class Timer {
|
||||
/**
|
||||
* This stores the starting time of the timer if running.
|
||||
*
|
||||
* If paused this stores how long the timer was previously running.
|
||||
*/
|
||||
private long aTime = 0;
|
||||
|
||||
private boolean mIsRunning = false;
|
||||
|
||||
public boolean isRunning() {
|
||||
return mIsRunning;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the timer, and stop it it was running.
|
||||
*/
|
||||
public void reset() {
|
||||
mIsRunning = false;
|
||||
aTime = 0;
|
||||
}
|
||||
|
||||
public void startTimer() {
|
||||
if (mIsRunning)
|
||||
return;
|
||||
|
||||
aTime = System.currentTimeMillis() - aTime;
|
||||
}
|
||||
|
||||
public void stopTimer() {
|
||||
if (!mIsRunning)
|
||||
return;
|
||||
|
||||
aTime = System.currentTimeMillis() - aTime;
|
||||
}
|
||||
|
||||
public long getTimeMillis() {
|
||||
if (mIsRunning)
|
||||
return (System.currentTimeMillis() - aTime);
|
||||
else
|
||||
return aTime;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -1,3 +1,11 @@
|
|||
/* -*- Mode: C++; 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.graphics.Color;
|
||||
|
@ -40,6 +48,7 @@ public class Transmitter {
|
|||
/**
|
||||
* Set the screen to a specific colour. Only use if a non default colour is
|
||||
* needed.
|
||||
*
|
||||
* @param aColor
|
||||
*/
|
||||
public void blankScreen(Color aColor) {
|
||||
|
@ -55,3 +64,4 @@ public class Transmitter {
|
|||
mClient.sendCommand("presentation_stop\n\n");
|
||||
}
|
||||
}
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
Loading…
Reference in a new issue