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
f38715f7
Kaydet (Commit)
f38715f7
authored
Eyl 17, 2012
tarafından
Andrzej J.R. Hunt
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Modify and simplify activity starting and backstack usage.
Change-Id: Ic4c4806ea3e791d0d75621e678166d0ffbbfa96a
üst
e3b2030c
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
156 additions
and
36 deletions
+156
-36
AndroidManifest.xml
android/sdremote/AndroidManifest.xml
+3
-1
ActivityChangeBroadcastProcessor.java
...ffice/impressremote/ActivityChangeBroadcastProcessor.java
+50
-0
PairingActivity.java
...te/src/org/libreoffice/impressremote/PairingActivity.java
+7
-2
PresentationActivity.java
...c/org/libreoffice/impressremote/PresentationActivity.java
+32
-0
SelectorActivity.java
...e/src/org/libreoffice/impressremote/SelectorActivity.java
+7
-0
StartPresentationActivity.java
.../libreoffice/impressremote/StartPresentationActivity.java
+15
-7
BluetoothClient.java
...reoffice/impressremote/communication/BluetoothClient.java
+2
-2
Client.java
...c/org/libreoffice/impressremote/communication/Client.java
+4
-5
CommunicationService.java
...ice/impressremote/communication/CommunicationService.java
+17
-3
NetworkClient.java
...ibreoffice/impressremote/communication/NetworkClient.java
+3
-2
Receiver.java
...org/libreoffice/impressremote/communication/Receiver.java
+16
-14
No files found.
android/sdremote/AndroidManifest.xml
Dosyayı görüntüle @
f38715f7
...
...
@@ -19,6 +19,7 @@
android:name=
".SelectorActivity"
android:icon=
"@drawable/actionbar_icon_computer"
android:label=
"@string/selector_choose_a_computer"
android:title=
"@string/app_name"
android:uiOptions=
"splitActionBarWhenNarrow"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
...
...
@@ -28,7 +29,8 @@
</activity>
<activity
android:name=
".PairingActivity"
android:icon=
"@drawable/actionbar_icon_computer"
>
android:icon=
"@drawable/actionbar_icon_computer"
android:noHistory=
"true"
>
</activity>
<service
android:name=
".communication.CommunicationService"
>
...
...
android/sdremote/src/org/libreoffice/impressremote/ActivityChangeBroadcastProcessor.java
0 → 100644
Dosyayı görüntüle @
f38715f7
package
org
.
libreoffice
.
impressremote
;
import
org.libreoffice.impressremote.communication.CommunicationService
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
/**
* This class is used to centralise the processing of Broadcasts concerning
* presentation/connection status changes which result in a change of activity.
*
* I.e. this will switch to the correct activity and correctly set up the
* activity backstack when switching activity.
*
* To use create this on activity startup, and pass messages from your
* BroadcastReceiver's onReceive.
*
*/
public
class
ActivityChangeBroadcastProcessor
{
private
Activity
mActivity
;
public
ActivityChangeBroadcastProcessor
(
Activity
aActivity
)
{
mActivity
=
aActivity
;
}
public
void
addToFilter
(
IntentFilter
aFilter
)
{
aFilter
.
addAction
(
CommunicationService
.
STATUS_CONNECTED_NOSLIDESHOW
);
aFilter
.
addAction
(
CommunicationService
.
STATUS_CONNECTED_SLIDESHOW_RUNNING
);
}
public
void
onReceive
(
Context
aContext
,
Intent
aIntent
)
{
if
(
aIntent
.
getAction
().
equals
(
CommunicationService
.
STATUS_CONNECTED_NOSLIDESHOW
))
{
Intent
nIntent
=
new
Intent
(
mActivity
,
StartPresentationActivity
.
class
);
nIntent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
);
mActivity
.
startActivity
(
nIntent
);
}
else
if
(
aIntent
.
getAction
()
.
equals
(
CommunicationService
.
STATUS_CONNECTED_SLIDESHOW_RUNNING
))
{
Intent
nIntent
=
new
Intent
(
mActivity
,
PresentationActivity
.
class
);
nIntent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_REORDER_TO_FRONT
);
mActivity
.
startActivity
(
nIntent
);
}
}
}
android/sdremote/src/org/libreoffice/impressremote/PairingActivity.java
Dosyayı görüntüle @
f38715f7
...
...
@@ -29,18 +29,23 @@ import com.actionbarsherlock.app.SherlockActivity;
public
class
PairingActivity
extends
SherlockActivity
{
private
CommunicationService
mCommunicationService
;
private
TextView
mPinText
;
private
ActivityChangeBroadcastProcessor
mBroadcastProcessor
;
/** Called when the activity is first created. */
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
mBroadcastProcessor
=
new
ActivityChangeBroadcastProcessor
(
this
);
bindService
(
new
Intent
(
this
,
CommunicationService
.
class
),
mConnection
,
Context
.
BIND_IMPORTANT
);
IntentFilter
aFilter
=
new
IntentFilter
(
CommunicationService
.
MSG_PAIRING_STARTED
);
aFilter
.
addAction
(
CommunicationService
.
MSG_PAIRING_SUCCESSFUL
);
mBroadcastProcessor
=
new
ActivityChangeBroadcastProcessor
(
this
);
mBroadcastProcessor
.
addToFilter
(
aFilter
);
LocalBroadcastManager
.
getInstance
(
this
).
registerReceiver
(
mListener
,
aFilter
);
...
...
@@ -106,7 +111,7 @@ public class PairingActivity extends SherlockActivity {
StartPresentationActivity
.
class
);
startActivity
(
nIntent
);
}
mBroadcastProcessor
.
onReceive
(
aContext
,
aIntent
);
}
};
...
...
android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
Dosyayı görüntüle @
f38715f7
...
...
@@ -8,9 +8,11 @@ import org.libreoffice.impressremote.communication.CommunicationService;
import
org.libreoffice.impressremote.communication.SlideShow.Timer
;
import
android.app.AlertDialog
;
import
android.content.BroadcastReceiver
;
import
android.content.ComponentName
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.content.ServiceConnection
;
import
android.content.SharedPreferences
;
import
android.os.Bundle
;
...
...
@@ -19,6 +21,7 @@ import android.os.IBinder;
import
android.preference.PreferenceManager
;
import
android.support.v4.app.FragmentManager
;
import
android.support.v4.app.FragmentTransaction
;
import
android.support.v4.content.LocalBroadcastManager
;
import
android.text.format.DateFormat
;
import
android.util.AttributeSet
;
import
android.view.KeyEvent
;
...
...
@@ -41,14 +44,23 @@ public class PresentationActivity extends SherlockFragmentActivity {
private
ThumbnailFragment
mThumbnailFragment
;
private
PresentationFragment
mPresentationFragment
;
private
static
ActionBarManager
mActionBarManager
;
private
ActivityChangeBroadcastProcessor
mBroadcastProcessor
;
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
mBroadcastProcessor
=
new
ActivityChangeBroadcastProcessor
(
this
);
bindService
(
new
Intent
(
this
,
CommunicationService
.
class
),
mConnection
,
Context
.
BIND_IMPORTANT
);
IntentFilter
aFilter
=
new
IntentFilter
();
mBroadcastProcessor
=
new
ActivityChangeBroadcastProcessor
(
this
);
mBroadcastProcessor
.
addToFilter
(
aFilter
);
LocalBroadcastManager
.
getInstance
(
this
).
registerReceiver
(
mListener
,
aFilter
);
//((FrameLayout) findViewById(R.id.framelayout)).addView(mLayout);
setContentView
(
R
.
layout
.
activity_presentation
);
if
(
savedInstanceState
==
null
)
{
...
...
@@ -66,6 +78,18 @@ public class PresentationActivity extends SherlockFragmentActivity {
mOuterLayout
=
(
FrameLayout
)
findViewById
(
R
.
id
.
framelayout
);
}
@Override
public
void
onBackPressed
()
{
if
(
getSupportFragmentManager
().
getBackStackEntryCount
()
>
0
)
{
super
.
onBackPressed
();
return
;
}
Intent
aIntent
=
new
Intent
(
this
,
SelectorActivity
.
class
);
aIntent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
);
startActivity
(
aIntent
);
mCommunicationService
.
disconnect
();
}
@Override
protected
void
onDestroy
()
{
mActionBarManager
.
stop
();
...
...
@@ -501,4 +525,12 @@ public class PresentationActivity extends SherlockFragmentActivity {
}
}
private
BroadcastReceiver
mListener
=
new
BroadcastReceiver
()
{
@Override
public
void
onReceive
(
Context
aContext
,
Intent
aIntent
)
{
mBroadcastProcessor
.
onReceive
(
aContext
,
aIntent
);
}
};
}
android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java
Dosyayı görüntüle @
f38715f7
...
...
@@ -49,6 +49,7 @@ public class SelectorActivity extends SherlockActivity {
private
View
mNetworkContainer
;
private
LinearLayout
mNetworkList
;
private
TextView
mNoServerLabel
;
private
ActivityChangeBroadcastProcessor
mBroadcastProcessor
;
/** Called when the activity is first created. */
@Override
...
...
@@ -58,6 +59,10 @@ public class SelectorActivity extends SherlockActivity {
IntentFilter
aFilter
=
new
IntentFilter
(
CommunicationService
.
MSG_SERVERLIST_CHANGED
);
mBroadcastProcessor
=
new
ActivityChangeBroadcastProcessor
(
this
);
mBroadcastProcessor
.
addToFilter
(
aFilter
);
LocalBroadcastManager
.
getInstance
(
this
).
registerReceiver
(
mListener
,
aFilter
);
...
...
@@ -191,7 +196,9 @@ public class SelectorActivity extends SherlockActivity {
if
(
aIntent
.
getAction
().
equals
(
CommunicationService
.
MSG_SERVERLIST_CHANGED
))
{
refreshLists
();
return
;
}
mBroadcastProcessor
.
onReceive
(
aContext
,
aIntent
);
}
};
...
...
android/sdremote/src/org/libreoffice/impressremote/StartPresentationActivity.java
Dosyayı görüntüle @
f38715f7
...
...
@@ -19,11 +19,13 @@ import com.actionbarsherlock.app.SherlockActivity;
public
class
StartPresentationActivity
extends
SherlockActivity
{
private
CommunicationService
mCommunicationService
=
null
;
private
boolean
mIsBound
=
false
;
private
ActivityChangeBroadcastProcessor
mBroadcastProcessor
;
/** Called when the activity is first created. */
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_startpresentation
);
bindService
(
new
Intent
(
this
,
CommunicationService
.
class
),
mConnection
,
Context
.
BIND_IMPORTANT
);
...
...
@@ -31,6 +33,10 @@ public class StartPresentationActivity extends SherlockActivity {
IntentFilter
aFilter
=
new
IntentFilter
(
CommunicationService
.
MSG_SLIDESHOW_STARTED
);
mBroadcastProcessor
=
new
ActivityChangeBroadcastProcessor
(
this
);
mBroadcastProcessor
.
addToFilter
(
aFilter
);
LocalBroadcastManager
.
getInstance
(
this
).
registerReceiver
(
mListener
,
aFilter
);
...
...
@@ -38,6 +44,14 @@ public class StartPresentationActivity extends SherlockActivity {
mClickListener
);
}
@Override
public
void
onBackPressed
()
{
Intent
aIntent
=
new
Intent
(
this
,
SelectorActivity
.
class
);
aIntent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_CLEAR_TOP
);
startActivity
(
aIntent
);
mCommunicationService
.
disconnect
();
}
@Override
protected
void
onDestroy
()
{
super
.
onDestroy
();
...
...
@@ -81,13 +95,7 @@ public class StartPresentationActivity extends SherlockActivity {
@Override
public
void
onReceive
(
Context
aContext
,
Intent
aIntent
)
{
if
(
aIntent
.
getAction
().
equals
(
CommunicationService
.
MSG_SLIDESHOW_STARTED
))
{
Intent
nIntent
=
new
Intent
(
StartPresentationActivity
.
this
,
PresentationActivity
.
class
);
startActivity
(
nIntent
);
}
mBroadcastProcessor
.
onReceive
(
aContext
,
aIntent
);
}
};
}
android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothClient.java
Dosyayı görüntüle @
f38715f7
...
...
@@ -30,8 +30,8 @@ public class BluetoothClient extends Client {
public
BluetoothClient
(
Server
aServer
,
CommunicationService
aCommunicationService
,
boolean
aBluetoothWasEnabled
)
{
super
(
aServer
,
aCommunicationService
);
Receiver
aReceiver
,
boolean
aBluetoothWasEnabled
)
{
super
(
aServer
,
aCommunicationService
,
aReceiver
);
try
{
mAdapter
=
BluetoothAdapter
.
getDefaultAdapter
();
mBluetoothWasEnabled
=
aBluetoothWasEnabled
;
...
...
android/sdremote/src/org/libreoffice/impressremote/communication/Client.java
Dosyayı görüntüle @
f38715f7
...
...
@@ -45,14 +45,13 @@ public abstract class Client {
protected
CommunicationService
mCommunicationService
;
protected
Client
(
Server
aServer
,
CommunicationService
aCommunicationService
)
{
protected
Client
(
Server
aServer
,
CommunicationService
aCommunicationService
,
Receiver
aReceiver
)
{
mServer
=
aServer
;
mCommunicationService
=
aCommunicationService
;
latestInstance
=
this
;
}
public
void
setReceiver
(
Receiver
aReceiver
)
{
mReceiver
=
aReceiver
;
latestInstance
=
this
;
}
protected
void
startListening
()
{
...
...
android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
Dosyayı görüntüle @
f38715f7
...
...
@@ -73,7 +73,6 @@ public class CommunicationService extends Service implements Runnable {
while
(
true
)
{
// Condition
try
{
wait
();
}
catch
(
InterruptedException
e
)
{
// We have finished
...
...
@@ -84,21 +83,23 @@ public class CommunicationService extends Service implements Runnable {
if
((
mStateDesired
==
State
.
CONNECTED
&&
mState
==
State
.
CONNECTED
)
||
(
mStateDesired
==
State
.
DISCONNECTED
&&
mState
==
State
.
CONNECTED
))
{
mClient
.
closeConnection
();
mClient
=
null
;
mState
=
State
.
DISCONNECTED
;
}
if
(
mStateDesired
==
State
.
CONNECTED
)
{
mState
=
State
.
CONNECTING
;
switch
(
mServerDesired
.
getProtocol
())
{
case
NETWORK:
mClient
=
new
NetworkClient
(
mServerDesired
,
this
);
mClient
=
new
NetworkClient
(
mServerDesired
,
this
,
mReceiver
);
break
;
case
BLUETOOTH:
mClient
=
new
BluetoothClient
(
mServerDesired
,
this
,
mReceiver
,
mBluetoothPreviouslyEnabled
);
break
;
}
mTransmitter
=
new
Transmitter
(
mClient
);
mClient
.
setReceiver
(
mReceiver
);
mState
=
State
.
CONNECTED
;
}
}
...
...
@@ -178,6 +179,19 @@ public class CommunicationService extends Service implements Runnable {
public
static
final
String
MSG_PAIRING_STARTED
=
"PAIRING_STARTED"
;
public
static
final
String
MSG_PAIRING_SUCCESSFUL
=
"PAIRING_SUCCESSFUL"
;
/**
* Notify the UI that the service has connected to a server AND a slideshow
* is running.
* In this case the PresentationActivity should be started.
*/
public
static
final
String
STATUS_CONNECTED_SLIDESHOW_RUNNING
=
"STATUS_CONNECTED_SLIDESHOW_RUNNING"
;
/**
* Notify the UI that the service has connected to a server AND no slideshow
* is running.
* In this case the StartPresentationActivity should be started.
*/
public
static
final
String
STATUS_CONNECTED_NOSLIDESHOW
=
"STATUS_CONNECTED_NOSLIDESHOW"
;
private
Transmitter
mTransmitter
;
private
Client
mClient
;
...
...
android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java
Dosyayı görüntüle @
f38715f7
...
...
@@ -32,8 +32,9 @@ public class NetworkClient extends Client {
private
Socket
mSocket
;
public
NetworkClient
(
Server
aServer
,
CommunicationService
aCommunicationService
)
{
super
(
aServer
,
aCommunicationService
);
CommunicationService
aCommunicationService
,
Receiver
aReceiver
)
{
super
(
aServer
,
aCommunicationService
,
aReceiver
);
try
{
mName
=
aServer
.
getName
();
mSocket
=
new
Socket
(
aServer
.
getAddress
(),
PORT
);
...
...
android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java
Dosyayı görüntüle @
f38715f7
...
...
@@ -10,9 +10,6 @@ package org.libreoffice.impressremote.communication;
import
java.util.ArrayList
;
import
org.libreoffice.impressremote.PresentationActivity
;
import
org.libreoffice.impressremote.StartPresentationActivity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.support.v4.content.LocalBroadcastManager
;
...
...
@@ -46,19 +43,24 @@ public class Receiver {
int
aCurrentSlide
=
Integer
.
parseInt
(
aCommand
.
get
(
2
));
mSlideShow
.
setLength
(
aSlideShowlength
);
mSlideShow
.
setCurrentSlide
(
aCurrentSlide
);
// Intent aIntent = new Intent(
// CommunicationService.MSG_SLIDESHOW_STARTED);
// LocalBroadcastManager.getInstance(mContext).sendBroadcast(aIntent);
Intent
aIntent
=
new
Intent
(
mContext
.
getApplicationContext
(),
PresentationActivity
.
class
);
aIntent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
mContext
.
getApplicationContext
().
startActivity
(
aIntent
);
// 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
);
}
else
if
(
aInstruction
.
equals
(
"slideshow_finished"
))
{
mSlideShow
=
new
SlideShow
(
mContext
);
Intent
aIntent
=
new
Intent
(
mContext
.
getApplicationContext
(),
StartPresentationActivity
.
class
);
aIntent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
mContext
.
getApplicationContext
().
startActivity
(
aIntent
);
// 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
;
...
...
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