[Libreoffice-commits] .: android/sdremote

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Sep 17 08:09:21 PDT 2012


 android/sdremote/AndroidManifest.xml                                                       |    4 -
 android/sdremote/res/values/strings.xml                                                    |    1 
 android/sdremote/src/org/libreoffice/impressremote/ActivityChangeBroadcastProcessor.java   |    6 +
 android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java                   |   21 +++++-
 android/sdremote/src/org/libreoffice/impressremote/StartPresentationActivity.java          |    6 -
 android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java |    2 
 android/sdremote/src/org/libreoffice/impressremote/communication/NetworkClient.java        |   31 +++++++---
 7 files changed, 52 insertions(+), 19 deletions(-)

New commits:
commit 5962129ea8076ae816900684e620498ca90103cc
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Mon Sep 17 17:06:43 2012 +0200

    Dialog for connection, more activity launching cleanup.
    
    Change-Id: I1ff8508daa2863020c6d7fa735f0f23b1ce96d8f

diff --git a/android/sdremote/AndroidManifest.xml b/android/sdremote/AndroidManifest.xml
index e60bc67..6db223e 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 3a5fbb5..4f57676 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 4e0eb91..3df8874 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 b26d9ee..0803045 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 43f0d14..ab59946 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 ff46f26..085cdff 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 24b6277..f875a05 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");


More information about the Libreoffice-commits mailing list