diff options
author | Artur Dryomov <artur.dryomov@gmail.com> | 2013-07-12 21:26:18 +0300 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2013-07-25 18:01:54 +0100 |
commit | c81c82f801e6e12454affb8c3f3946079c5ab688 (patch) | |
tree | 095027e553fea819bfff12d9ad9ddc1495797c5b /android | |
parent | Change TcpServersFinder to handle multiple threads properly. (diff) | |
download | core-c81c82f801e6e12454affb8c3f3946079c5ab688.tar.gz core-c81c82f801e6e12454affb8c3f3946079c5ab688.zip |
Add static factory for intents.
* Remove intents actions from the CommunicationService.
* Move all intents extras names to a single place.
* Move intents creation to a single place.
So we avoid duplications and possible typos.
Change-Id: Ic486727522962763e2fefbf96b65125cf2e3d466
Diffstat (limited to 'android')
12 files changed, 167 insertions, 110 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/ActivityChangeBroadcastProcessor.java b/android/sdremote/src/org/libreoffice/impressremote/ActivityChangeBroadcastProcessor.java index 92003bf7bf76..0855423f92a3 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/ActivityChangeBroadcastProcessor.java +++ b/android/sdremote/src/org/libreoffice/impressremote/ActivityChangeBroadcastProcessor.java @@ -8,8 +8,6 @@ */ package org.libreoffice.impressremote; -import org.libreoffice.impressremote.communication.CommunicationService; - import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -35,26 +33,26 @@ public class ActivityChangeBroadcastProcessor { } public void addToFilter(IntentFilter aFilter) { - aFilter.addAction(CommunicationService.STATUS_CONNECTED_NOSLIDESHOW); - aFilter.addAction(CommunicationService.STATUS_CONNECTED_SLIDESHOW_RUNNING); - aFilter.addAction(CommunicationService.STATUS_PAIRING_PINVALIDATION); + aFilter.addAction(Intents.Actions.SLIDE_SHOW_STOPPED); + aFilter.addAction(Intents.Actions.SLIDE_SHOW_RUNNING); + aFilter.addAction(Intents.Actions.PAIRING_VALIDATION); } public void onReceive(Context aContext, Intent aIntent) { if (aIntent.getAction().equals( - CommunicationService.STATUS_CONNECTED_NOSLIDESHOW)) { + Intents.Actions.SLIDE_SHOW_STOPPED)) { 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)) { + .equals(Intents.Actions.SLIDE_SHOW_RUNNING)) { Intent nIntent = new Intent(mActivity, PresentationActivity.class); nIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); mActivity.startActivity(nIntent); } else if (aIntent.getAction().equals( - CommunicationService.STATUS_PAIRING_PINVALIDATION)) { + Intents.Actions.PAIRING_VALIDATION)) { Intent nIntent = new Intent(mActivity, PairingActivity.class); nIntent.putExtras(aIntent.getExtras()); // Pass on pin and other info. mActivity.startActivity(nIntent); diff --git a/android/sdremote/src/org/libreoffice/impressremote/ComputerConnectionActivity.java b/android/sdremote/src/org/libreoffice/impressremote/ComputerConnectionActivity.java index ac15e2a0f1b3..aa256bbb1c90 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/ComputerConnectionActivity.java +++ b/android/sdremote/src/org/libreoffice/impressremote/ComputerConnectionActivity.java @@ -30,7 +30,7 @@ public class ComputerConnectionActivity extends SherlockFragmentActivity { } private Server extractReceivedComputer() { - return getIntent().getParcelableExtra("COMPUTER"); + return getIntent().getParcelableExtra(Intents.Extras.SERVER); } @Override diff --git a/android/sdremote/src/org/libreoffice/impressremote/ComputerConnectionFragment.java b/android/sdremote/src/org/libreoffice/impressremote/ComputerConnectionFragment.java index fd97bed6c9ba..c3df6fed0668 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/ComputerConnectionFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/ComputerConnectionFragment.java @@ -126,7 +126,7 @@ public class ComputerConnectionFragment extends SherlockFragment implements Serv @Override public void onReceive(Context aContext, Intent aIntent) { - if (CommunicationService.MSG_PAIRING_STARTED.equals(aIntent.getAction())) { + if (Intents.Actions.PAIRING_STARTED.equals(aIntent.getAction())) { String aPin = aIntent.getStringExtra("PIN"); mComputerConnectionFragment.setUpPinValidationInstructions(aPin); @@ -134,13 +134,13 @@ public class ComputerConnectionFragment extends SherlockFragment implements Serv return; } - if (CommunicationService.MSG_PAIRING_SUCCESSFUL.equals(aIntent.getAction())) { + if (Intents.Actions.PAIRING_SUCCESSFUL.equals(aIntent.getAction())) { mComputerConnectionFragment.setUpPresentation(); return; } - if (CommunicationService.STATUS_CONNECTION_FAILED.equals(aIntent.getAction())) { + if (Intents.Actions.CONNECTION_FAILED.equals(aIntent.getAction())) { mComputerConnectionFragment.setUpErrorMessage(); } } @@ -148,9 +148,9 @@ public class ComputerConnectionFragment extends SherlockFragment implements Serv private IntentFilter buildIntentsReceiverFilter() { IntentFilter aIntentFilter = new IntentFilter(); - aIntentFilter.addAction(CommunicationService.MSG_PAIRING_STARTED); - aIntentFilter.addAction(CommunicationService.MSG_PAIRING_SUCCESSFUL); - aIntentFilter.addAction(CommunicationService.STATUS_CONNECTION_FAILED); + aIntentFilter.addAction(Intents.Actions.PAIRING_STARTED); + aIntentFilter.addAction(Intents.Actions.PAIRING_SUCCESSFUL); + aIntentFilter.addAction(Intents.Actions.CONNECTION_FAILED); return aIntentFilter; } diff --git a/android/sdremote/src/org/libreoffice/impressremote/ComputersFragment.java b/android/sdremote/src/org/libreoffice/impressremote/ComputersFragment.java index 5dcb2431c3e8..ba17da2f8602 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/ComputersFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/ComputersFragment.java @@ -131,7 +131,7 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo @Override public void onReceive(Context aContext, Intent aIntent) { - if (CommunicationService.MSG_SERVERLIST_CHANGED.equals(aIntent.getAction())) { + if (Intents.Actions.SERVERS_LIST_CHANGED.equals(aIntent.getAction())) { mComputersFragment.loadComputers(); } } @@ -139,7 +139,7 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo private IntentFilter buildIntentsReceiverFilter() { IntentFilter aIntentFilter = new IntentFilter(); - aIntentFilter.addAction(CommunicationService.MSG_SERVERLIST_CHANGED); + aIntentFilter.addAction(Intents.Actions.SERVERS_LIST_CHANGED); return aIntentFilter; } @@ -224,8 +224,7 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo public void onListItemClick(ListView aListView, View aView, int aPosition, long aId) { Server aComputer = getComputersAdapter().getItem(aPosition); - Intent aIntent = new Intent(getActivity(), ComputerConnectionActivity.class); - aIntent.putExtra("COMPUTER", aComputer); + Intent aIntent = Intents.buildComputerConnectionIntent(getActivity(), aComputer); startActivity(aIntent); } } diff --git a/android/sdremote/src/org/libreoffice/impressremote/Intents.java b/android/sdremote/src/org/libreoffice/impressremote/Intents.java new file mode 100644 index 000000000000..055af77fbf25 --- /dev/null +++ b/android/sdremote/src/org/libreoffice/impressremote/Intents.java @@ -0,0 +1,107 @@ +package org.libreoffice.impressremote; + +import android.content.Context; +import android.content.Intent; + +import org.libreoffice.impressremote.communication.Server; + +public final class Intents { + private Intents() { + } + + public static final class Actions { + private Actions() { + } + + public static final String SERVERS_LIST_CHANGED = "SERVERS_LIST_CHANGED"; + + public static final String PAIRING_STARTED = "PAIRING_STARTED"; + public static final String PAIRING_SUCCESSFUL = "PAIRING_SUCCESSFUL"; + public static final String PAIRING_VALIDATION = "PAIRING_VALIDATION"; + + public static final String CONNECTION_FAILED = "CONNECTION_FAILED"; + + public static final String SLIDE_SHOW_STARTED = "SLIDE_SHOW_STARTED"; + public static final String SLIDE_SHOW_RUNNING = "SLIDE_SHOW_RUNNING"; + public static final String SLIDE_SHOW_STOPPED = "SLIDE_SHOW_STOPPED"; + + public static final String SLIDE_CHANGED = "SLIDE_CHANGED"; + public static final String SLIDE_PREVIEW = "SLIDE_PREVIEW"; + public static final String SLIDE_NOTES = "SLIDE_NOTES"; + } + + public static final class Extras { + private Extras() { + } + + public static final String PIN = "PIN"; + + public static final String SERVER = "SERVER"; + public static final String SERVER_NAME = "SERVER_NAME"; + + public static final String SLIDE_INDEX = "SLIDE_INDEX"; + } + + public static Intent buildServersListChangedIntent() { + return new Intent(Actions.SERVERS_LIST_CHANGED); + } + + public static Intent buildPairingStartedIntent(String aPin) { + Intent aIntent = new Intent(Actions.PAIRING_STARTED); + aIntent.putExtra(Extras.PIN, aPin); + + return aIntent; + } + + public static Intent buildPairingSuccessfulIntent() { + return new Intent(Actions.PAIRING_SUCCESSFUL); + } + + public static Intent buildPairingValidationIntent(String aPin, String aServerName) { + Intent aIntent = new Intent(Actions.PAIRING_VALIDATION); + aIntent.putExtra(Extras.PIN, aPin); + aIntent.putExtra(Extras.SERVER_NAME, aServerName); + + return aIntent; + } + + public static Intent buildConnectionFailedIntent() { + return new Intent(Actions.CONNECTION_FAILED); + } + + public static Intent buildSlideShowRunningIntent() { + return new Intent(Actions.SLIDE_SHOW_RUNNING); + } + + public static Intent buildSlideShowStoppedIntent() { + return new Intent(Actions.SLIDE_SHOW_STOPPED); + } + + public static Intent buildSlideChangedIntent(int aSlideIndex) { + Intent aIntent = new Intent(Actions.SLIDE_CHANGED); + aIntent.putExtra(Extras.SLIDE_INDEX, aSlideIndex); + + return aIntent; + } + + public static Intent buildSlidePreviewIntent(int aSlideIndex) { + Intent aIntent = new Intent(Actions.SLIDE_PREVIEW); + aIntent.putExtra(Extras.SLIDE_INDEX, aSlideIndex); + + return aIntent; + } + + public static Intent buildSlideNotesIntent(int aSlideIndex) { + Intent aIntent = new Intent(Actions.SLIDE_NOTES); + aIntent.putExtra(Extras.SLIDE_INDEX, aSlideIndex); + + return aIntent; + } + + public static Intent buildComputerConnectionIntent(Context aContext, Server aServer) { + Intent aIntent = new Intent(aContext, ComputerConnectionActivity.class); + aIntent.putExtra(Extras.SERVER, aServer); + + return aIntent; + } +} diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java index 1834c2d604ab..9a3abcb52efe 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java @@ -127,9 +127,9 @@ public class PresentationFragment extends SherlockFragment { } IntentFilter aFilter = new IntentFilter( - CommunicationService.MSG_SLIDE_CHANGED); - aFilter.addAction(CommunicationService.MSG_SLIDE_NOTES); - aFilter.addAction(CommunicationService.MSG_SLIDE_PREVIEW); + Intents.Actions.SLIDE_CHANGED); + aFilter.addAction(Intents.Actions.SLIDE_NOTES); + aFilter.addAction(Intents.Actions.SLIDE_PREVIEW); LocalBroadcastManager .getInstance(getActivity().getApplicationContext()) .registerReceiver(mListener, aFilter); @@ -261,7 +261,7 @@ public class PresentationFragment extends SherlockFragment { if (mTopView == null || mTopView.getAdapter() == null) return; if (aIntent.getAction().equals( - CommunicationService.MSG_SLIDE_CHANGED)) { + Intents.Actions.SLIDE_CHANGED)) { int aSlide = aIntent.getExtras().getInt("slide_number"); if (aSlide == mTopView.getSelectedItemPosition()) @@ -271,11 +271,11 @@ public class PresentationFragment extends SherlockFragment { } mTopView.setSelection(aSlide, true); } else if (aIntent.getAction().equals( - CommunicationService.MSG_SLIDE_PREVIEW)) { + Intents.Actions.SLIDE_PREVIEW)) { ThumbnailAdapter aThumbAdaptor = (ThumbnailAdapter) mTopView.getAdapter(); aThumbAdaptor.notifyDataSetChanged(); } else if (aIntent.getAction().equals( - CommunicationService.MSG_SLIDE_NOTES)) { + Intents.Actions.SLIDE_NOTES)) { int aPosition = aIntent.getExtras().getInt("slide_number"); if ( aPosition == mTopView.getSelectedItemPosition() ) { mNotes.loadDataWithBaseURL(null, mCommunicationService.getSlideShow() diff --git a/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java b/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java index a3d88dabe6fd..7f58b85fb29b 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java +++ b/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java @@ -66,8 +66,8 @@ public class SelectorActivity extends SherlockActivity { if (mCommunicationService != null) mCommunicationService.disconnect(); IntentFilter aFilter = new IntentFilter( - CommunicationService.MSG_SERVERLIST_CHANGED); - aFilter.addAction(CommunicationService.STATUS_CONNECTION_FAILED); + Intents.Actions.SERVERS_LIST_CHANGED); + aFilter.addAction(Intents.Actions.CONNECTION_FAILED); mBroadcastProcessor = new ActivityChangeBroadcastProcessor(this); mBroadcastProcessor.addToFilter(aFilter); @@ -217,11 +217,11 @@ public class SelectorActivity extends SherlockActivity { @Override public void onReceive(Context aContext, Intent aIntent) { if (aIntent.getAction().equals( - CommunicationService.MSG_SERVERLIST_CHANGED)) { + Intents.Actions.SERVERS_LIST_CHANGED)) { refreshLists(); return; } else if (aIntent.getAction().equals( - CommunicationService.STATUS_CONNECTION_FAILED)) { + Intents.Actions.CONNECTION_FAILED)) { if (mProgressDialog != null) { mProgressDialog.dismiss(); diff --git a/android/sdremote/src/org/libreoffice/impressremote/StartPresentationActivity.java b/android/sdremote/src/org/libreoffice/impressremote/StartPresentationActivity.java index 163b8fa6ba44..5a4af1a07ce2 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/StartPresentationActivity.java +++ b/android/sdremote/src/org/libreoffice/impressremote/StartPresentationActivity.java @@ -41,7 +41,7 @@ public class StartPresentationActivity extends SherlockActivity { getSupportActionBar().setDisplayHomeAsUpEnabled(true); IntentFilter aFilter = new IntentFilter( - CommunicationService.MSG_SLIDESHOW_STARTED); + Intents.Actions.SLIDE_SHOW_STARTED); mBroadcastProcessor = new ActivityChangeBroadcastProcessor(this); mBroadcastProcessor.addToFilter(aFilter); diff --git a/android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java b/android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java index 81184df6fca7..97948bf778a8 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java @@ -61,8 +61,8 @@ public class ThumbnailFragment extends SherlockFragment { } IntentFilter aFilter = new IntentFilter( - CommunicationService.MSG_SLIDE_CHANGED); - aFilter.addAction(CommunicationService.MSG_SLIDE_PREVIEW); + Intents.Actions.SLIDE_CHANGED); + aFilter.addAction(Intents.Actions.SLIDE_PREVIEW); LocalBroadcastManager .getInstance(getActivity().getApplicationContext()) .registerReceiver(mListener, aFilter); @@ -147,11 +147,11 @@ public class ThumbnailFragment extends SherlockFragment { if (mGrid == null) return; if (aIntent.getAction().equals( - CommunicationService.MSG_SLIDE_CHANGED)) { + Intents.Actions.SLIDE_CHANGED)) { int aSlide = aIntent.getExtras().getInt("slide_number"); setSelected(aSlide); } else if (aIntent.getAction().equals( - CommunicationService.MSG_SLIDE_PREVIEW)) { + Intents.Actions.SLIDE_PREVIEW)) { mGrid.invalidateViews(); } diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServersFinder.java b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServersFinder.java index 93a1f8453872..7828197c127f 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServersFinder.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServersFinder.java @@ -22,6 +22,7 @@ import android.content.IntentFilter; import android.os.Handler; import android.support.v4.content.LocalBroadcastManager; +import org.libreoffice.impressremote.Intents; import org.libreoffice.impressremote.communication.Server.Protocol; public class BluetoothServersFinder extends BroadcastReceiver implements ServersFinder, Runnable { @@ -97,11 +98,8 @@ public class BluetoothServersFinder extends BroadcastReceiver implements Servers } private void callUpdatingServersList() { - Intent aServersListUpdatedIntent = new Intent( - CommunicationService.MSG_SERVERLIST_CHANGED); - - LocalBroadcastManager.getInstance(mContext) - .sendBroadcast(aServersListUpdatedIntent); + Intent aIntent = Intents.buildServersListChangedIntent(); + LocalBroadcastManager.getInstance(mContext).sendBroadcast(aIntent); } private void startDiscoveryDelayed() { diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java index 4309cc52bca6..1a24af517925 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java @@ -18,6 +18,7 @@ import android.os.Build; import android.os.IBinder; import android.support.v4.content.LocalBroadcastManager; +import org.libreoffice.impressremote.Intents; import org.libreoffice.impressremote.Preferences; public class CommunicationService extends Service implements Runnable, MessagesListener { @@ -25,21 +26,6 @@ public class CommunicationService extends Service implements Runnable, MessagesL DISCONNECTED, SEARCHING, CONNECTING, CONNECTED } - public static final String MSG_SLIDESHOW_STARTED = "SLIDESHOW_STARTED"; - public static final String MSG_SLIDE_CHANGED = "SLIDE_CHANGED"; - public static final String MSG_SLIDE_PREVIEW = "SLIDE_PREVIEW"; - public static final String MSG_SLIDE_NOTES = "SLIDE_NOTES"; - - public static final String MSG_SERVERLIST_CHANGED = "SERVERLIST_CHANGED"; - public static final String MSG_PAIRING_STARTED = "PAIRING_STARTED"; - public static final String MSG_PAIRING_SUCCESSFUL = "PAIRING_SUCCESSFUL"; - - public static final String STATUS_CONNECTED_SLIDESHOW_RUNNING = "STATUS_CONNECTED_SLIDESHOW_RUNNING"; - public static final String STATUS_CONNECTED_NOSLIDESHOW = "STATUS_CONNECTED_NOSLIDESHOW"; - - public static final String STATUS_PAIRING_PINVALIDATION = "STATUS_PAIRING_PINVALIDATION"; - public static final String STATUS_CONNECTION_FAILED = "STATUS_CONNECTION_FAILED"; - /** * Used to protect all writes to mState, mStateDesired, and mServerDesired. */ @@ -161,10 +147,8 @@ public class CommunicationService extends Service implements Runnable, MessagesL } private void startPairingActivity() { - Intent aPairingIntent = new Intent(MSG_PAIRING_STARTED); - aPairingIntent.putExtra("PIN", loadPin()); - - LocalBroadcastManager.getInstance(this).sendBroadcast(aPairingIntent); + Intent aIntent = Intents.buildPairingStartedIntent(loadPin()); + LocalBroadcastManager.getInstance(this).sendBroadcast(aIntent); } private String loadPin() { @@ -186,8 +170,8 @@ public class CommunicationService extends Service implements Runnable, MessagesL private void connectionFailed() { mState = State.DISCONNECTED; - Intent aIntent = new Intent( - CommunicationService.STATUS_CONNECTION_FAILED); + + Intent aIntent = Intents.buildConnectionFailedIntent(); LocalBroadcastManager.getInstance(this).sendBroadcast(aIntent); } @@ -284,27 +268,17 @@ public class CommunicationService extends Service implements Runnable, MessagesL @Override public void onPinValidation() { - startPinValidation(); - } - - private void startPinValidation() { - Intent aPairingIntent = new Intent(STATUS_PAIRING_PINVALIDATION); - aPairingIntent.putExtra("PIN", loadPin()); - aPairingIntent.putExtra("SERVERNAME", mServerDesired.getName()); + String aPin = loadPin(); + String aServerName = mServerDesired.getName(); - LocalBroadcastManager.getInstance(this).sendBroadcast(aPairingIntent); + Intent aIntent = Intents.buildPairingValidationIntent(aPin, aServerName); + LocalBroadcastManager.getInstance(this).sendBroadcast(aIntent); } @Override public void onSuccessfulPairing() { - callSuccessfulPairing(); - } - - private void callSuccessfulPairing() { - Intent aSuccessfulPairingIntent = new Intent(MSG_PAIRING_SUCCESSFUL); - - LocalBroadcastManager.getInstance(this).sendBroadcast( - aSuccessfulPairingIntent); + Intent aIntent = Intents.buildPairingSuccessfulIntent(); + LocalBroadcastManager.getInstance(this).sendBroadcast(aIntent); } private SlideShow mSlideShow; @@ -313,61 +287,43 @@ public class CommunicationService extends Service implements Runnable, MessagesL public void onSlideShowStart(int aSlidesCount, int aCurrentSlideIndex) { mSlideShow = new SlideShow(); mSlideShow.setSlidesCount(aSlidesCount); - mSlideShow.setCurrentSlideIndex(aCurrentSlideIndex); - Intent aStatusConnectedSlideShowRunningIntent = new Intent( - STATUS_CONNECTED_SLIDESHOW_RUNNING); - Intent aSlideChangedIntent = new Intent(MSG_SLIDE_CHANGED); - aSlideChangedIntent.putExtra("slide_number", aCurrentSlideIndex); + Intent aIntent = Intents.buildSlideShowRunningIntent(); + LocalBroadcastManager.getInstance(this).sendBroadcast(aIntent); - LocalBroadcastManager.getInstance(this) - .sendBroadcast(aStatusConnectedSlideShowRunningIntent); - LocalBroadcastManager.getInstance(this) - .sendBroadcast(aSlideChangedIntent); + onSlideChanged(aCurrentSlideIndex); } @Override public void onSlideShowFinish() { mSlideShow = new SlideShow(); - Intent aStatusConnectedNoSlideShowIntent = new Intent( - STATUS_CONNECTED_NOSLIDESHOW); - - LocalBroadcastManager.getInstance(this) - .sendBroadcast(aStatusConnectedNoSlideShowIntent); + Intent aIntent = Intents.buildSlideShowStoppedIntent(); + LocalBroadcastManager.getInstance(this).sendBroadcast(aIntent); } @Override public void onSlideChanged(int aCurrentSlideIndex) { mSlideShow.setCurrentSlideIndex(aCurrentSlideIndex); - Intent aSlideChangedIntent = new Intent(MSG_SLIDE_CHANGED); - aSlideChangedIntent.putExtra("slide_number", aCurrentSlideIndex); - - LocalBroadcastManager.getInstance(this) - .sendBroadcast(aSlideChangedIntent); + Intent aIntent = Intents.buildSlideChangedIntent(aCurrentSlideIndex); + LocalBroadcastManager.getInstance(this).sendBroadcast(aIntent); } @Override public void onSlidePreview(int aSlideIndex, byte[] aPreview) { mSlideShow.setSlidePreview(aSlideIndex, aPreview); - Intent aSlidePreviewChangedIntent = new Intent(MSG_SLIDE_PREVIEW); - aSlidePreviewChangedIntent.putExtra("slide_number", aSlideIndex); - - LocalBroadcastManager.getInstance(this) - .sendBroadcast(aSlidePreviewChangedIntent); + Intent aIntent = Intents.buildSlidePreviewIntent(aSlideIndex); + LocalBroadcastManager.getInstance(this).sendBroadcast(aIntent); } @Override public void onSlideNotes(int aSlideIndex, String aNotes) { mSlideShow.setSlideNotes(aSlideIndex, aNotes); - Intent aSlideNotesChangedIntent = new Intent(MSG_SLIDE_NOTES); - aSlideNotesChangedIntent.putExtra("slide_number", aSlideIndex); - - LocalBroadcastManager.getInstance(this) - .sendBroadcast(aSlideNotesChangedIntent); + Intent aIntent = Intents.buildSlideNotesIntent(aSlideIndex); + LocalBroadcastManager.getInstance(this).sendBroadcast(aIntent); } } diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/TcpServersFinder.java b/android/sdremote/src/org/libreoffice/impressremote/communication/TcpServersFinder.java index bf8f9506c4cb..ef8f6079dedf 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/TcpServersFinder.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/TcpServersFinder.java @@ -29,6 +29,8 @@ import android.content.Intent; import android.support.v4.content.LocalBroadcastManager; import android.text.TextUtils; +import org.libreoffice.impressremote.Intents; + public class TcpServersFinder implements ServersFinder, Runnable { private static final int SEARCH_DELAY_IN_SECONDS = 10; private static final int BLOCKING_TIMEOUT_IN_MILLISECONDS = 1000 * 10; @@ -155,11 +157,8 @@ public class TcpServersFinder implements ServersFinder, Runnable { } private void callUpdatingServersList() { - Intent aServersListUpdatedIntent = new Intent( - CommunicationService.MSG_SERVERLIST_CHANGED); - - LocalBroadcastManager.getInstance(mContext) - .sendBroadcast(aServersListUpdatedIntent); + Intent aIntent = Intents.buildServersListChangedIntent(); + LocalBroadcastManager.getInstance(mContext).sendBroadcast(aIntent); } private void tearDownSearchSocket() { |