Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
d6dceb2b
Kaydet (Commit)
d6dceb2b
authored
Eyl 03, 2012
tarafından
Andrzej J.R. Hunt
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Implemented automatic reconnection + reconnection activity.
Change-Id: I445fe2acb24ab6992aad4c75f6886f517bdcc0b0
üst
51f9e894
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
111 additions
and
33 deletions
+111
-33
warning_exclamation.png
android/sdremote/res/drawable/warning_exclamation.png
+0
-0
activity_reconnect.xml
android/sdremote/res/layout/activity_reconnect.xml
+47
-0
strings.xml
android/sdremote/res/values/strings.xml
+3
-1
BluetoothClient.java
...reoffice/impressremote/communication/BluetoothClient.java
+7
-12
Client.java
...c/org/libreoffice/impressremote/communication/Client.java
+25
-9
CommunicationService.java
...ice/impressremote/communication/CommunicationService.java
+1
-2
NetworkClient.java
...ibreoffice/impressremote/communication/NetworkClient.java
+10
-9
ReconnectionActivity.java
...ice/impressremote/communication/ReconnectionActivity.java
+18
-0
No files found.
android/sdremote/res/drawable/warning_exclamation.png
0 → 100644
Dosyayı görüntüle @
d6dceb2b
3.25 KB
android/sdremote/res/layout/activity_reconnect.xml
0 → 100644
Dosyayı görüntüle @
d6dceb2b
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_centerHorizontal=
"true"
android:layout_centerVertical=
"true"
android:orientation=
"vertical"
>
<ImageView
android:id=
"@+id/imageView1"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:src=
"@drawable/warning_exclamation"
android:layout_marginBottom=
"50dp"
/>
<TextView
android:id=
"@+id/textView1"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginLeft=
"10dp"
android:layout_marginRight=
"10dp"
android:gravity=
"center_horizontal"
android:text=
"@string/reconnect_description1"
android:textAppearance=
"?android:attr/textAppearanceMedium"
/>
<TextView
android:id=
"@+id/textView2"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_horizontal"
android:layout_marginLeft=
"10dp"
android:layout_marginRight=
"10dp"
android:gravity=
"center_horizontal"
android:text=
"@string/reconnect_description2"
android:textAppearance=
"?android:attr/textAppearanceMedium"
/>
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
android/sdremote/res/values/strings.xml
Dosyayı görüntüle @
d6dceb2b
...
...
@@ -39,5 +39,6 @@
<string
name=
"addserver_remember"
>
Remember this server next time
</string>
<string
name=
"addserver_add"
>
Add
</string>
<string
name=
"addserver_cancel"
>
Cancel
</string>
<string
name=
"reconnect_description1"
>
Your connection has been dropped.
</string>
<string
name=
"reconnect_description2"
>
Attempting to reconnect…
</string>
</resources>
\ No newline at end of file
android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothClient.java
Dosyayı görüntüle @
d6dceb2b
...
...
@@ -10,13 +10,11 @@ package org.libreoffice.impressremote.communication;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
import
java.net.Socket
;
import
java.util.UUID
;
import
android.bluetooth.BluetoothAdapter
;
import
android.bluetooth.BluetoothDevice
;
import
android.bluetooth.BluetoothSocket
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.support.v4.content.LocalBroadcastManager
;
...
...
@@ -27,17 +25,13 @@ import android.support.v4.content.LocalBroadcastManager;
*/
public
class
BluetoothClient
extends
Client
{
private
static
final
int
PORT
=
5
;
private
Socket
mSocket
;
public
BluetoothClient
(
String
bluetoothAddress
,
Context
aContext
)
{
super
(
aContext
);
public
BluetoothClient
(
Server
aServer
,
CommunicationService
aCommunicationService
)
{
super
(
aServer
,
aCommunicationService
);
try
{
BluetoothAdapter
aAdapter
=
BluetoothAdapter
.
getDefaultAdapter
();
System
.
out
.
println
(
"Attemtping to connect to:"
+
bluetoothAddress
);
BluetoothDevice
aDevice
=
aAdapter
.
getRemoteDevice
(
bluetoothAddress
);
BluetoothDevice
aDevice
=
aAdapter
.
getRemoteDevice
(
aServer
.
getAddress
());
aAdapter
.
cancelDiscovery
();
BluetoothSocket
aSocket
=
aDevice
.
createRfcommSocketToServiceRecord
(
UUID
...
...
@@ -69,7 +63,8 @@ public class BluetoothClient extends Client {
}
Intent
aIntent
=
new
Intent
(
CommunicationService
.
MSG_PAIRING_SUCCESSFUL
);
LocalBroadcastManager
.
getInstance
(
mContext
).
sendBroadcast
(
aIntent
);
LocalBroadcastManager
.
getInstance
(
mCommunicationService
)
.
sendBroadcast
(
aIntent
);
startListening
();
// Pairing.
// Random aRandom = new Random();
...
...
android/sdremote/src/org/libreoffice/impressremote/communication/Client.java
Dosyayı görüntüle @
d6dceb2b
...
...
@@ -15,7 +15,7 @@ import java.io.OutputStream;
import
java.io.UnsupportedEncodingException
;
import
java.util.ArrayList
;
import
android.content.
Contex
t
;
import
android.content.
Inten
t
;
/**
* Generic Client for the remote control. To implement a Client for a specific
...
...
@@ -40,10 +40,13 @@ public abstract class Client {
private
Receiver
mReceiver
;
protected
Context
mContext
;
protected
Server
mServer
;
public
Client
(
Context
aContext
)
{
mContext
=
aContext
;
protected
CommunicationService
mCommunicationService
;
protected
Client
(
Server
aServer
,
CommunicationService
aCommunicationService
)
{
mServer
=
aServer
;
mCommunicationService
=
aCommunicationService
;
latestInstance
=
this
;
}
...
...
@@ -62,25 +65,37 @@ public abstract class Client {
t
.
start
();
}
private
void
listen
()
{
private
final
void
listen
()
{
try
{
while
(
true
)
{
ArrayList
<
String
>
aList
=
new
ArrayList
<
String
>();
String
aTemp
;
// read until empty line
while
((
aTemp
=
mReader
.
readLine
()).
length
()
!=
0
)
{
while
((
aTemp
=
mReader
.
readLine
())
!=
null
&&
aTemp
.
length
()
!=
0
)
{
aList
.
add
(
aTemp
);
}
if
(
aTemp
==
null
)
{
mCommunicationService
.
connectTo
(
mServer
);
Intent
aIntent
=
new
Intent
(
mCommunicationService
.
getApplicationContext
(),
ReconnectionActivity
.
class
);
aIntent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
mCommunicationService
.
getApplicationContext
()
.
startActivity
(
aIntent
);
return
;
}
mReceiver
.
parseCommand
(
aList
);
}
}
catch
(
UnsupportedEncodingException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
IOException
e1
)
{
// TODO stream couldn't be opened.
e1
.
printStackTrace
();
}
finally
{
latestInstance
=
null
;
}
latestInstance
=
null
;
}
...
...
@@ -105,7 +120,8 @@ public abstract class Client {
throw
new
Error
(
"Specified network encoding ["
+
CHARSET
+
" not available."
);
}
catch
(
IOException
e
)
{
// TODO Notify that stream has closed.
// I.e. connection closed. This will be dealt with by the listening
// loop.
}
}
...
...
android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
Dosyayı görüntüle @
d6dceb2b
...
...
@@ -89,8 +89,7 @@ public class CommunicationService extends Service implements Runnable {
mClient
=
new
NetworkClient
(
mServerDesired
,
this
);
break
;
case
BLUETOOTH:
mClient
=
new
BluetoothClient
(
mServerDesired
.
getAddress
(),
this
);
mClient
=
new
BluetoothClient
(
mServerDesired
,
this
);
break
;
}
mTransmitter
=
new
Transmitter
(
mClient
);
...
...
android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java
Dosyayı görüntüle @
d6dceb2b
...
...
@@ -15,7 +15,6 @@ import java.net.Socket;
import
java.net.UnknownHostException
;
import
java.util.Random
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences.Editor
;
...
...
@@ -32,8 +31,9 @@ public class NetworkClient extends Client {
private
Socket
mSocket
;
public
NetworkClient
(
Server
aServer
,
Context
aContext
)
{
super
(
aContext
);
public
NetworkClient
(
Server
aServer
,
CommunicationService
aCommunicationService
)
{
super
(
aServer
,
aCommunicationService
);
try
{
mSocket
=
new
Socket
(
aServer
.
getAddress
(),
PORT
);
mInputStream
=
mSocket
.
getInputStream
();
...
...
@@ -46,7 +46,8 @@ public class NetworkClient extends Client {
CommunicationService
.
MSG_PAIRING_STARTED
);
aIntent
.
putExtra
(
"PIN"
,
aPin
);
mPin
=
aPin
;
LocalBroadcastManager
.
getInstance
(
mContext
).
sendBroadcast
(
aIntent
);
LocalBroadcastManager
.
getInstance
(
mCommunicationService
)
.
sendBroadcast
(
aIntent
);
// Send out
String
aName
=
CommunicationService
.
getDeviceName
();
// TODO: get the proper name
sendCommand
(
"LO_SERVER_CLIENT_PAIR\n"
+
aName
+
"\n"
+
aPin
...
...
@@ -61,8 +62,8 @@ public class NetworkClient extends Client {
}
else
{
aIntent
=
new
Intent
(
CommunicationService
.
MSG_PAIRING_SUCCESSFUL
);
LocalBroadcastManager
.
getInstance
(
mCo
ntext
).
sendBroadcast
(
aIntent
);
LocalBroadcastManager
.
getInstance
(
mCo
mmunicationService
)
.
sendBroadcast
(
aIntent
);
}
while
(
mReader
.
readLine
().
length
()
!=
0
)
{
// Get rid of extra lines
...
...
@@ -82,9 +83,9 @@ public class NetworkClient extends Client {
private
String
setupPin
(
Server
aServer
)
{
// Get settings
SharedPreferences
aPreferences
=
mCo
ntext
.
getSharedPreferences
(
"sdremote_authorisedremotes"
,
android
.
content
.
Context
.
MODE_PRIVATE
);
SharedPreferences
aPreferences
=
mCo
mmunicationService
.
getSharedPreferences
(
"sdremote_authorisedremotes"
,
android
.
content
.
Context
.
MODE_PRIVATE
);
if
(
aPreferences
.
contains
(
aServer
.
getName
()))
{
return
aPreferences
.
getString
(
aServer
.
getName
(),
""
);
}
else
{
...
...
android/sdremote/src/org/libreoffice/impressremote/communication/ReconnectionActivity.java
0 → 100644
Dosyayı görüntüle @
d6dceb2b
package
org
.
libreoffice
.
impressremote
.
communication
;
import
org.libreoffice.impressremote.R
;
import
android.os.Bundle
;
import
com.actionbarsherlock.app.SherlockActivity
;
public
class
ReconnectionActivity
extends
SherlockActivity
{
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
// TODO Auto-generated method stub
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_reconnect
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment