├── assets ├── find.png ├── led.png ├── phone.png ├── sms.png ├── missed.png ├── test36.png └── download.png ├── res ├── values │ ├── dimensions.xml │ ├── colors.xml │ ├── sytles.xml │ └── strings.xml ├── drawable-hdpi │ ├── inner_lv.png │ └── olv_icon.png └── layout │ ├── user_main_screen.xml │ ├── test_activity_left.xml │ ├── test_activity.xml │ ├── test_activity_right.xml │ └── entry_screen.xml ├── libs └── android-support-v4.jar ├── src └── com │ └── pedronveloso │ └── openliveview │ ├── protocol │ ├── LiveViewRequest.java │ ├── MenuItemCountResponse.java │ ├── DateTimeRequest.java │ ├── UnknownResponse.java │ ├── LEDResponse.java │ ├── StandByRequest.java │ ├── VibrateResponse.java │ ├── StandByResponse.java │ ├── SWVersionRequest.java │ ├── Request.java │ ├── GetAllMenuItemsRequest.java │ ├── MenuItemCountRequest.java │ ├── ScreenPropertiesRequest.java │ ├── AckMessage.java │ ├── SWVersionResponse.java │ ├── VibrateRequest.java │ ├── LEDRequest.java │ ├── DateTimeResponse.java │ ├── GetMenuIconResponse.java │ ├── Response.java │ └── ScreenPropertiesResponse.java │ ├── Utils │ ├── StaticImages.java │ ├── CommandResult.java │ ├── Utils.java │ └── Constants.java │ ├── activities │ ├── UserMainActivity.java │ ├── EntryActivity.java │ └── DevMainActivity.java │ ├── server │ ├── StateManager.java │ ├── Menu.java │ └── BtServer.java │ └── services │ └── CommService.java ├── .gitignore ├── project.properties ├── LICENSE.txt ├── README.markdown └── AndroidManifest.xml /assets/find.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pedronveloso/OpenLiveView/HEAD/assets/find.png -------------------------------------------------------------------------------- /assets/led.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pedronveloso/OpenLiveView/HEAD/assets/led.png -------------------------------------------------------------------------------- /assets/phone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pedronveloso/OpenLiveView/HEAD/assets/phone.png -------------------------------------------------------------------------------- /assets/sms.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pedronveloso/OpenLiveView/HEAD/assets/sms.png -------------------------------------------------------------------------------- /assets/missed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pedronveloso/OpenLiveView/HEAD/assets/missed.png -------------------------------------------------------------------------------- /assets/test36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pedronveloso/OpenLiveView/HEAD/assets/test36.png -------------------------------------------------------------------------------- /assets/download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pedronveloso/OpenLiveView/HEAD/assets/download.png -------------------------------------------------------------------------------- /res/values/dimensions.xml: -------------------------------------------------------------------------------- 1 | 2 | 10dip 3 | -------------------------------------------------------------------------------- /libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pedronveloso/OpenLiveView/HEAD/libs/android-support-v4.jar -------------------------------------------------------------------------------- /res/drawable-hdpi/inner_lv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pedronveloso/OpenLiveView/HEAD/res/drawable-hdpi/inner_lv.png -------------------------------------------------------------------------------- /res/drawable-hdpi/olv_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pedronveloso/OpenLiveView/HEAD/res/drawable-hdpi/olv_icon.png -------------------------------------------------------------------------------- /res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ffffff 4 | #000000 5 | -------------------------------------------------------------------------------- /res/values/sytles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/protocol/LiveViewRequest.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.protocol; 2 | 3 | public abstract class LiveViewRequest extends Response { 4 | 5 | public abstract Request answer(); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | /liveview_output.txt 3 | /gen/ 4 | /out/ 5 | /bin/ 6 | /ant.properties 7 | /OpenLiveView.iml 8 | /local.properties 9 | /proguard.cfg 10 | /.classpath 11 | /.metadata 12 | /.settings 13 | /default.properties 14 | /.project 15 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/Utils/StaticImages.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.Utils; 2 | 3 | public class StaticImages { 4 | 5 | //TODO: replace with own icons instead of proprietary ones 6 | 7 | /** 8 | * This is the 'All Events' Icon 9 | */ 10 | public static byte[] staticIconAllEvents; 11 | } 12 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/protocol/MenuItemCountResponse.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.protocol; 2 | 3 | import java.io.DataInputStream; 4 | import java.io.IOException; 5 | 6 | public class MenuItemCountResponse extends Response { 7 | 8 | @Override 9 | protected void readPayload(DataInputStream input, int payloadLength) 10 | throws IOException { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-10 12 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/protocol/DateTimeRequest.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.protocol; 2 | 3 | import java.io.DataInputStream; 4 | import java.io.IOException; 5 | 6 | public class DateTimeRequest extends LiveViewRequest { 7 | 8 | @Override 9 | public Request answer() { 10 | return new DateTimeResponse(); 11 | } 12 | 13 | @Override 14 | protected void readPayload(DataInputStream input, int payloadLength) 15 | throws IOException { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /res/layout/user_main_screen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/protocol/UnknownResponse.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.protocol; 2 | 3 | import java.io.DataInputStream; 4 | import java.io.IOException; 5 | 6 | public class UnknownResponse extends Response { 7 | 8 | private byte[] mBuffer; 9 | 10 | @Override 11 | protected void readPayload(DataInputStream input, int payloadLength) 12 | throws IOException { 13 | mBuffer = new byte[payloadLength]; 14 | input.read(mBuffer); 15 | } 16 | 17 | public byte[] getBuffer() { 18 | return mBuffer; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /res/layout/test_activity_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/Utils/CommandResult.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.Utils; 2 | 3 | public class CommandResult { 4 | 5 | private int commandID; 6 | private int commandSuccessCode; 7 | 8 | public CommandResult(int commandSuccessCode, int commandID) { 9 | this.commandSuccessCode = commandSuccessCode; 10 | this.commandID = commandID; 11 | } 12 | 13 | public int getCommandID() { 14 | return commandID; 15 | } 16 | 17 | public int getCommandSuccessCode() { 18 | return commandSuccessCode; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2012 OpenLiveView 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/protocol/LEDResponse.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.protocol; 2 | 3 | import com.pedronveloso.openliveview.Utils.Constants; 4 | 5 | import java.io.DataInputStream; 6 | import java.io.IOException; 7 | 8 | public class LEDResponse extends Response { 9 | 10 | private boolean mOk = false; 11 | 12 | @Override 13 | protected void readPayload(DataInputStream input, int payloadLength) throws IOException { 14 | mOk = (payloadLength == Constants.SIZE_BYTE) && input.readByte() == Constants.MSG_OK; 15 | } 16 | 17 | public boolean getOk() { 18 | return mOk; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/protocol/StandByRequest.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.protocol; 2 | 3 | import java.io.DataInputStream; 4 | import java.io.IOException; 5 | 6 | public class StandByRequest extends LiveViewRequest { 7 | 8 | private int mState; 9 | 10 | public int getState() { 11 | return mState; 12 | } 13 | 14 | @Override 15 | public Request answer() { 16 | return new StandByResponse(); 17 | } 18 | 19 | @Override 20 | protected void readPayload(DataInputStream input, int payloadLength) 21 | throws IOException { 22 | mState = input.readUnsignedByte(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/protocol/VibrateResponse.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.protocol; 2 | 3 | import com.pedronveloso.openliveview.Utils.Constants; 4 | 5 | import java.io.DataInputStream; 6 | import java.io.IOException; 7 | 8 | public class VibrateResponse extends Response { 9 | 10 | private boolean mOk = false; 11 | 12 | @Override 13 | protected void readPayload(DataInputStream input, int payloadLength) throws IOException { 14 | mOk = (payloadLength == Constants.SIZE_BYTE) && (input.readByte() == Constants.MSG_OK); 15 | } 16 | 17 | public boolean getOk() { 18 | return mOk; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/protocol/StandByResponse.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.protocol; 2 | 3 | import com.pedronveloso.openliveview.Utils.Constants; 4 | 5 | import java.io.DataOutputStream; 6 | import java.io.IOException; 7 | 8 | public class StandByResponse extends Request { 9 | 10 | @Override 11 | protected byte getMessageId() { 12 | return Constants.RESPONSE_STANDBY; 13 | } 14 | 15 | @Override 16 | protected int getPayloadSize() { 17 | return Constants.SIZE_BYTE; 18 | } 19 | 20 | @Override 21 | protected void WritePayload(DataOutputStream writer) throws IOException { 22 | writer.writeByte(Constants.MSG_OK); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/protocol/SWVersionRequest.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.protocol; 2 | 3 | import com.pedronveloso.openliveview.Utils.Constants; 4 | 5 | import java.io.DataOutputStream; 6 | import java.io.IOException; 7 | 8 | public class SWVersionRequest extends Request{ 9 | 10 | public SWVersionRequest() { 11 | } 12 | 13 | @Override 14 | protected byte getMessageId() { 15 | return Constants.REQUEST_SW_VERSION; 16 | } 17 | 18 | @Override 19 | protected int getPayloadSize() { 20 | return Constants.SIZE_BYTE; // MSG_OK 21 | } 22 | 23 | @Override 24 | protected void WritePayload(DataOutputStream writer) throws IOException { 25 | writer.writeByte(Constants.MSG_OK); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/protocol/Request.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.protocol; 2 | 3 | import com.pedronveloso.openliveview.Utils.Constants; 4 | 5 | import java.io.DataOutputStream; 6 | import java.io.IOException; 7 | 8 | public abstract class Request { 9 | 10 | protected abstract byte getMessageId(); 11 | 12 | protected abstract int getPayloadSize(); 13 | 14 | protected abstract void WritePayload(DataOutputStream writer) throws IOException; 15 | 16 | 17 | public void Write(DataOutputStream stream) throws IOException { 18 | stream.writeByte(getMessageId()); 19 | stream.writeByte(Constants.SIZE_INT); 20 | stream.writeInt(getPayloadSize()); 21 | WritePayload(stream); 22 | stream.flush(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/protocol/GetAllMenuItemsRequest.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.protocol; 2 | 3 | import java.io.DataInputStream; 4 | import java.io.IOException; 5 | 6 | import com.pedronveloso.openliveview.Utils.Constants; 7 | 8 | public class GetAllMenuItemsRequest extends LiveViewRequest { 9 | 10 | private boolean mOk; 11 | 12 | @Override 13 | public Request answer() { 14 | return null; // Should be handled somewhere else 15 | // cause there will be more then one response 16 | } 17 | 18 | @Override 19 | protected void readPayload(DataInputStream input, int payloadLength) 20 | throws IOException { 21 | mOk = input.readByte() == Constants.MSG_OK; 22 | } 23 | 24 | public boolean getOk() { 25 | return mOk; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/protocol/MenuItemCountRequest.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.protocol; 2 | 3 | import java.io.DataOutputStream; 4 | import java.io.IOException; 5 | 6 | import com.pedronveloso.openliveview.Utils.Constants; 7 | 8 | public class MenuItemCountRequest extends Request { 9 | 10 | private int mItemCount; 11 | 12 | public MenuItemCountRequest(int itemCount) { 13 | mItemCount = itemCount; 14 | } 15 | 16 | @Override 17 | protected byte getMessageId() { 18 | return Constants.REQUEST_MENU_ITEM_COUNT; 19 | } 20 | 21 | @Override 22 | protected int getPayloadSize() { 23 | return Constants.SIZE_BYTE; 24 | } 25 | 26 | @Override 27 | protected void WritePayload(DataOutputStream writer) throws IOException { 28 | writer.write(mItemCount); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/protocol/ScreenPropertiesRequest.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.protocol; 2 | 3 | import com.pedronveloso.openliveview.Utils.Constants; 4 | 5 | import java.io.DataOutputStream; 6 | import java.io.IOException; 7 | 8 | public class ScreenPropertiesRequest extends Request { 9 | 10 | @Override 11 | protected byte getMessageId() { 12 | return Constants.REQUEST_SCREEN_PROPERTIES; 13 | } 14 | 15 | @Override 16 | protected int getPayloadSize() { 17 | return Constants.PROTOCOL_VERSION.length + 18 | Constants.SIZE_BYTE; // String Terminator 19 | } 20 | 21 | @Override 22 | protected void WritePayload(DataOutputStream writer) throws IOException { 23 | writer.write(Constants.PROTOCOL_VERSION); 24 | writer.writeByte(0); // String Terminator 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/protocol/AckMessage.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.protocol; 2 | 3 | import java.io.DataOutputStream; 4 | import java.io.IOException; 5 | 6 | import com.pedronveloso.openliveview.Utils.Constants; 7 | 8 | public class AckMessage extends Request { 9 | 10 | private byte mAckMessage; 11 | 12 | public AckMessage(byte ackMessage) { 13 | mAckMessage = ackMessage; 14 | } 15 | 16 | @Override 17 | protected byte getMessageId() { 18 | // TODO Auto-generated method stub 19 | return Constants.RESPONSE_ACK; 20 | } 21 | 22 | @Override 23 | protected int getPayloadSize() { 24 | return Constants.SIZE_BYTE; 25 | } 26 | 27 | @Override 28 | protected void WritePayload(DataOutputStream writer) throws IOException { 29 | writer.writeByte(mAckMessage); 30 | 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/protocol/SWVersionResponse.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.protocol; 2 | 3 | import java.io.DataInputStream; 4 | import java.io.IOException; 5 | 6 | import com.pedronveloso.openliveview.Utils.Utils; 7 | import com.pedronveloso.openliveview.server.Menu; 8 | 9 | public class SWVersionResponse extends LiveViewRequest { 10 | 11 | private String mVersion; 12 | 13 | @Override 14 | protected void readPayload(DataInputStream input, int payloadLength) throws IOException { 15 | byte[] buffer = new byte[payloadLength]; 16 | input.read(buffer); 17 | mVersion = Utils.getString(buffer); 18 | } 19 | 20 | public String getVersion() { 21 | return mVersion; 22 | } 23 | 24 | @Override 25 | public Request answer() { 26 | return new MenuItemCountRequest(Menu.instance().size()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/activities/UserMainActivity.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.activities; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import com.pedronveloso.openliveview.R; 7 | import com.pedronveloso.openliveview.Utils.Constants; 8 | import com.pedronveloso.openliveview.services.CommService; 9 | 10 | /** 11 | * User: Pedro Veloso 12 | */ 13 | public class UserMainActivity extends Activity { 14 | 15 | public void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.user_main_screen); 18 | Intent commService = new Intent(UserMainActivity.this, CommService.class); 19 | commService.putExtra(Constants.EXTRA_START_SERVICE,1); 20 | startService(commService); 21 | } 22 | } -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/protocol/VibrateRequest.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.protocol; 2 | 3 | import com.pedronveloso.openliveview.Utils.Constants; 4 | 5 | import java.io.DataOutputStream; 6 | import java.io.IOException; 7 | 8 | public class VibrateRequest extends Request { 9 | 10 | private short mDelay; 11 | private short mDuration; 12 | 13 | public VibrateRequest(short delay, short duration) { 14 | super(); 15 | mDelay = delay; 16 | mDuration = duration; 17 | } 18 | 19 | @Override 20 | protected byte getMessageId() { 21 | return Constants.REQUEST_VIBRATE; 22 | } 23 | 24 | @Override 25 | protected int getPayloadSize() { 26 | return Constants.SIZE_SHORT // Delay 27 | + Constants.SIZE_SHORT; // Duration 28 | } 29 | 30 | @Override 31 | protected void WritePayload(DataOutputStream writer) throws IOException { 32 | writer.writeShort(mDelay); 33 | writer.writeShort(mDuration); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /res/layout/test_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 16 | 17 | 22 | 23 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | # About # 2 | 3 | This project's goal is to become a complete open source replacement of the LiveView official application, and even extend its original capabilities at some point. 4 | 5 | # WHAT WORKS # 6 | 7 | * Connecting to the LiveView device via Bluetooth 8 | * Basic protocol stack: Vibrate, Led, StandBy, Screen Properties, Date and Time, Protocol Version, Firmware Version 9 | * Basic stacking of commands 10 | * Send Menu Items to LiveView 11 | 12 | # WHAT REMAINS TO BE DONE # 13 | 14 | * Better connection handling 15 | * Handle menu input 16 | * LiveView official plugins support 17 | * Menu theming support 18 | * Integration with CyanogenMod ? 19 | * ... 20 | 21 | # CREDITS # 22 | 23 | This projects initial inspiration was this thread here on XDA: http://forum.xda-developers.com/showthread.php?t=1422106 24 | 25 | This project is maintained by: 26 | 27 | * Pedro Veloso (pedronveloso, aka pedrodh on XDA) 28 | * Florian Sundermann (boombuler) 29 | 30 | ## Special thanks to ## 31 | 32 | * archivator for initiate the project and reverse reverse engineering effort 33 | * AJ256 for firmware reserve engineering effort 34 | * x942 35 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/protocol/LEDRequest.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.protocol; 2 | 3 | import com.pedronveloso.openliveview.Utils.Constants; 4 | import com.pedronveloso.openliveview.Utils.Utils; 5 | 6 | import java.io.DataOutputStream; 7 | import java.io.IOException; 8 | 9 | public class LEDRequest extends Request{ 10 | 11 | private int mColor; 12 | private short mDelay; 13 | private short mDuration; 14 | 15 | public LEDRequest(int color, short delay, short duration) { 16 | mColor = color; 17 | mDelay = delay; 18 | mDuration = duration; 19 | } 20 | 21 | @Override 22 | protected byte getMessageId() { 23 | return Constants.REQUEST_LED; 24 | } 25 | 26 | @Override 27 | protected int getPayloadSize() { 28 | return Constants.SIZE_SHORT + // Color 29 | Constants.SIZE_SHORT + // Delay 30 | Constants.SIZE_SHORT; // Duration 31 | } 32 | 33 | @Override 34 | protected void WritePayload(DataOutputStream writer) throws IOException { 35 | writer.writeShort(Utils.colorToRGB565(mColor)); 36 | writer.writeShort(mDelay); 37 | writer.writeShort(mDuration); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 11 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/protocol/DateTimeResponse.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.protocol; 2 | 3 | import android.text.format.DateFormat; 4 | 5 | import com.pedronveloso.openliveview.Utils.Constants; 6 | import com.pedronveloso.openliveview.server.BtServer; 7 | 8 | import java.io.DataOutputStream; 9 | import java.io.IOException; 10 | import java.util.Calendar; 11 | import java.util.Date; 12 | 13 | 14 | public class DateTimeResponse extends Request { 15 | 16 | @Override 17 | protected byte getMessageId() { 18 | return Constants.RESPONSE_DATE_TIME; 19 | } 20 | 21 | @Override 22 | protected int getPayloadSize() { 23 | return Constants.SIZE_INT + // Time 24 | Constants.SIZE_BYTE; // Display 24h format 25 | } 26 | 27 | @Override 28 | protected void WritePayload(DataOutputStream writer) throws IOException { 29 | Calendar rightNow = Calendar.getInstance(); 30 | int time =(int)((rightNow.get(Calendar.ZONE_OFFSET) + 31 | rightNow.get(Calendar.DST_OFFSET) + 32 | new Date().getTime()) / 1000L); 33 | writer.writeInt(time); 34 | writer.writeByte(DateFormat.is24HourFormat(BtServer.instance().getContext()) ? 1 : 0); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/server/StateManager.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.server; 2 | 3 | import com.pedronveloso.openliveview.protocol.*; 4 | 5 | /* 6 | * Keeps track of the device state 7 | */ 8 | public class StateManager implements BtServer.Callback { 9 | 10 | private String mSoftwareVersion; 11 | private int mScreenState; 12 | 13 | private static StateManager sInstance; 14 | 15 | private StateManager() { 16 | super(); 17 | } 18 | 19 | public static StateManager instance() { 20 | if (sInstance == null) 21 | sInstance = new StateManager(); 22 | return sInstance; 23 | } 24 | 25 | public void handleResponse(Response aResponse) { 26 | if (aResponse instanceof SWVersionResponse) { 27 | mSoftwareVersion = ((SWVersionResponse)aResponse).getVersion(); 28 | } else if (aResponse instanceof ScreenPropertiesResponse) { 29 | // TODO 30 | } else if (aResponse instanceof StandByRequest) { 31 | mScreenState = ((StandByRequest)aResponse).getState(); 32 | } 33 | } 34 | 35 | public void isReadyChanged(boolean isReady) { 36 | // ignore... 37 | } 38 | 39 | public int getScreenState() { 40 | return mScreenState; 41 | } 42 | 43 | public String getSoftwareVersion() { 44 | return mSoftwareVersion; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/activities/EntryActivity.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.activities; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.view.View; 7 | import android.widget.Button; 8 | import com.pedronveloso.openliveview.R; 9 | 10 | /** 11 | * Author: Pedro Veloso 12 | */ 13 | public class EntryActivity extends Activity implements View.OnClickListener { 14 | 15 | public void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.entry_screen); 18 | Button btnProceed = (Button) findViewById(R.id.btn_next); 19 | btnProceed.setOnClickListener(this); 20 | btnProceed = (Button) findViewById(R.id.btn_next_dev); 21 | btnProceed.setOnClickListener(this); 22 | } 23 | 24 | public void onClick(View view) { 25 | switch (view.getId()){ 26 | case R.id.btn_next: 27 | startActivity(new Intent(EntryActivity.this,UserMainActivity.class)); 28 | break; 29 | 30 | case R.id.btn_next_dev: 31 | startActivity(new Intent(EntryActivity.this,DevMainActivity.class)); 32 | break; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/com/pedronveloso/openliveview/Utils/Utils.java: -------------------------------------------------------------------------------- 1 | package com.pedronveloso.openliveview.Utils; 2 | 3 | import android.graphics.Color; 4 | import android.util.Log; 5 | 6 | import java.io.UnsupportedEncodingException; 7 | 8 | public class Utils { 9 | 10 | public static final boolean enableLogging = true; 11 | 12 | public static void log(String msg) { 13 | if (enableLogging) 14 | Log.d(Constants.LOG_TAG, msg); 15 | } 16 | 17 | public static void logError(String msg) { 18 | //always log errors 19 | Log.e(Constants.LOG_TAG, msg); 20 | } 21 | 22 | public static String getString(byte[] bytes) { 23 | try { 24 | return new String(bytes, Constants.STRING_ENCODING); 25 | } catch (UnsupportedEncodingException e) { 26 | e.printStackTrace(); 27 | return ""; 28 | } 29 | } 30 | 31 | public static byte[] prepareString(String string) { 32 | try { 33 | return string.getBytes(Constants.STRING_ENCODING); 34 | } catch (UnsupportedEncodingException e) { 35 | e.printStackTrace(); 36 | return new byte[0]; 37 | } 38 | } 39 | 40 | public static short colorToRGB565(int color) { 41 | int r = Color.red(color) >> 3; 42 | int g = Color.green(color) >> 2; 43 | int b = Color.blue(color) >> 3; 44 | return (short)((r<<(5+6)) + (g << 5) + (b)); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /res/layout/test_activity_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 11 | 12 |