diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2012-09-17 17:06:43 +0200 |
---|---|---|
committer | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2012-09-17 17:08:46 +0200 |
commit | 5962129ea8076ae816900684e620498ca90103cc (patch) | |
tree | 92c1ea743803a39e5093b6cb981df1482160eab0 /android | |
parent | 543158edba6678d3d76eee983a9d4edd2a422fee (diff) |
Dialog for connection, more activity launching cleanup.
Change-Id: I1ff8508daa2863020c6d7fa735f0f23b1ce96d8f
Diffstat (limited to 'android')
7 files changed, 52 insertions, 19 deletions
diff --git a/android/sdremote/AndroidManifest.xml b/android/sdremote/AndroidManifest.xml index e60bc67abe47..6db223ee7d00 100644 --- a/android/sdremote/AndroidManifest.xml +++ b/android/sdremote/AndroidManifest.xml @@ -14,7 +14,9 @@ <application android:label="@string/app_name" - android:theme="@style/Theme.ImpressRemote" > + android:theme="@style/Theme.ImpressRemote" + android:title="@string/app_name" + android:icon="@drawable/ic_launcher" > <activity android:name=".SelectorActivity" android:icon="@drawable/actionbar_icon_computer" diff --git a/android/sdremote/res/values/strings.xml b/android/sdremote/res/values/strings.xml index 3a5fbb58ed3f..4f576769aaa5 100644 --- a/android/sdremote/res/values/strings.xml +++ b/android/sdremote/res/values/strings.xml @@ -25,6 +25,7 @@ <string name="selector_noservers">Searching for computers…</string> <string name="selector_delete">Remove server</string> <string name="selector_choose_a_computer">Choose a Computer</string> + <string name="selector_dialog_connecting">Attempting to connect to {0}...</string> <string name="pairing_instructions_1">In Impress, click on the "Slideshow" menu and select "Impress Remote".</string> <string name="pairing_instructions_2_deviceName">Choose \"{0}\" as your device.</string> <string name="pairing_instructions_3">Then input this PIN:</string> diff --git a/android/sdremote/src/org/libreoffice/impressremote/ActivityChangeBroadcastProcessor.java b/android/sdremote/src/org/libreoffice/impressremote/ActivityChangeBroadcastProcessor.java index 4e0eb91e8aac..3df8874984b8 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/ActivityChangeBroadcastProcessor.java +++ b/android/sdremote/src/org/libreoffice/impressremote/ActivityChangeBroadcastProcessor.java @@ -29,6 +29,7 @@ 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); } public void onReceive(Context aContext, Intent aIntent) { @@ -44,6 +45,11 @@ public class ActivityChangeBroadcastProcessor { 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)) { + 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/SelectorActivity.java b/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java index b26d9ee7f862..0803045fcac7 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java +++ b/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java @@ -8,6 +8,7 @@ */ package org.libreoffice.impressremote; +import java.text.MessageFormat; import java.util.Arrays; import java.util.HashMap; import java.util.Map.Entry; @@ -17,6 +18,7 @@ import org.libreoffice.impressremote.communication.Server; import org.libreoffice.impressremote.communication.Server.Protocol; import android.app.AlertDialog; +import android.app.ProgressDialog; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; @@ -51,6 +53,8 @@ public class SelectorActivity extends SherlockActivity { private TextView mNoServerLabel; private ActivityChangeBroadcastProcessor mBroadcastProcessor; + ProgressDialog mProgressDialog = null; + /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { @@ -160,6 +164,9 @@ public class SelectorActivity extends SherlockActivity { mCommunicationService.stopSearching(); } doUnbindService(); + if (mProgressDialog != null) { + mProgressDialog.dismiss(); + } } void doBindService() { @@ -303,9 +310,17 @@ public class SelectorActivity extends SherlockActivity { } if (aDesiredServer != null) { mCommunicationService.connectTo(aDesiredServer); - Intent aIntent = new Intent(SelectorActivity.this, - PairingActivity.class); - startActivity(aIntent); + // Connect Service and wait for broadcast + String aFormat = getResources().getString( + R.string.selector_dialog_connecting); + String aDialogText = MessageFormat.format(aFormat, + aDesiredServer.getName()); + + mProgressDialog = ProgressDialog.show(SelectorActivity.this, + "", aDialogText, true); + // Intent aIntent = new Intent(SelectorActivity.this, + // PairingActivity.class); + // startActivity(aIntent); } } diff --git a/android/sdremote/src/org/libreoffice/impressremote/StartPresentationActivity.java b/android/sdremote/src/org/libreoffice/impressremote/StartPresentationActivity.java index 43f0d1458a77..ab59946a6a96 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/StartPresentationActivity.java +++ b/android/sdremote/src/org/libreoffice/impressremote/StartPresentationActivity.java @@ -66,12 +66,6 @@ public class StartPresentationActivity extends SherlockActivity { mCommunicationService = ((CommunicationService.CBinder) aService) .getService(); - if (mCommunicationService.isSlideShowRunning()) { - Intent nIntent = new Intent(StartPresentationActivity.this, - PresentationActivity.class); - startActivity(nIntent); - } - } @Override diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java index ff46f2624790..085cdff98b9f 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java @@ -192,6 +192,8 @@ public class CommunicationService extends Service implements Runnable { */ public static final String STATUS_CONNECTED_NOSLIDESHOW = "STATUS_CONNECTED_NOSLIDESHOW"; + public static final String STATUS_PAIRING_PINVALIDATION = "STATUS_PAIRING_PINVALIDATION"; + private Transmitter mTransmitter; private Client mClient; diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java b/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java index 24b62771e02a..f875a056db38 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java @@ -56,17 +56,30 @@ public class NetworkClient extends Client { + "\n\n"); // Wait until we get the appropriate string back... - System.out.println("SF:waiting"); String aTemp = mReader.readLine(); - System.out.println("SF:waited"); - if (!aTemp.equals("LO_SERVER_SERVER_PAIRED")) { - return; - } else { - aIntent = new Intent( - CommunicationService.MSG_PAIRING_SUCCESSFUL); - LocalBroadcastManager.getInstance(mCommunicationService) - .sendBroadcast(aIntent); + + while (!aTemp.equals("LO_SERVER_SERVER_PAIRED")) { + if (aTemp.equals("LO_SERVER_VALIDATING_PIN")) { + // Broadcast that we need a pin screen. + aIntent = new Intent( + CommunicationService.STATUS_PAIRING_PINVALIDATION); + aIntent.putExtra("PIN", aPin); + mPin = aPin; + LocalBroadcastManager.getInstance(mCommunicationService) + .sendBroadcast(aIntent); + while (mReader.readLine().length() != 0) { + // Read off empty lines + } + aTemp = mReader.readLine(); + } else { + return; + } } + + aIntent = new Intent(CommunicationService.MSG_PAIRING_SUCCESSFUL); + LocalBroadcastManager.getInstance(mCommunicationService) + .sendBroadcast(aIntent); + while (mReader.readLine().length() != 0) { // Get rid of extra lines System.out.println("SF: empty line"); |