[Libreoffice-commits] .: android/sdremote

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Aug 21 06:41:51 PDT 2012


 android/sdremote/res/layout-land/fragment_presentation.xml                   |   11 ++--
 android/sdremote/src/org/libreoffice/impressremote/PairingActivity.java      |   10 ++-
 android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java |   27 ++++++----
 android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java |    3 -
 android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java     |    7 +-
 5 files changed, 36 insertions(+), 22 deletions(-)

New commits:
commit 2f88fd3f94702edff29e212771d5d1922566aa94
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Tue Aug 21 15:40:45 2012 +0200

    Further style fixes + use Local BroadcastManager.
    
    Change-Id: I2af6acbcb27c6c8000e638ac5414fa1d89583b1c

diff --git a/android/sdremote/res/layout-land/fragment_presentation.xml b/android/sdremote/res/layout-land/fragment_presentation.xml
index 2f04f0e..7ac884b 100644
--- a/android/sdremote/res/layout-land/fragment_presentation.xml
+++ b/android/sdremote/res/layout-land/fragment_presentation.xml
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res/org.libreoffice.impressremote"
     android:id="@+id/presentation_layout"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
@@ -8,16 +7,18 @@
 
     <LinearLayout
         android:layout_width="wrap_content"
-        android:layout_height="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_vertical"
         android:orientation="vertical" >
 
         <pl.polidea.coverflow.CoverFlow
             xmlns:coverflow="http://schemas.android.com/apk/res/org.libreoffice.impressremote"
             android:id="@+id/presentation_coverflow"
             android:layout_width="wrap_content"
-            android:layout_height="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_gravity="center_vertical"
             android:layout_margin="5dp"
-            android:layout_marginLeft="10dp"
+            android:layout_marginLeft="15dp"
             coverflow:imageHeight="200dip"
             coverflow:imageWidth="240dip"
             coverflow:withReflection="false" />
@@ -26,7 +27,7 @@
             android:id="@+id/presentation_slidenumber"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_gravity="center_horizontal"
+            android:layout_gravity="center_horizontal|center_vertical"
             android:text="" />
     </LinearLayout>
 
diff --git a/android/sdremote/src/org/libreoffice/impressremote/PairingActivity.java b/android/sdremote/src/org/libreoffice/impressremote/PairingActivity.java
index e01a909..76641f9 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/PairingActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/PairingActivity.java
@@ -28,7 +28,6 @@ import com.actionbarsherlock.app.SherlockActivity;
 
 public class PairingActivity extends SherlockActivity {
     private CommunicationService mCommunicationService;
-    private boolean mIsBound = false;
     private TextView mPinText;
 
     /** Called when the activity is first created. */
@@ -38,7 +37,6 @@ public class PairingActivity extends SherlockActivity {
 
         bindService(new Intent(this, CommunicationService.class), mConnection,
                         Context.BIND_IMPORTANT);
-        mIsBound = true;
 
         IntentFilter aFilter = new IntentFilter(
                         CommunicationService.MSG_PAIRING_STARTED);
@@ -48,6 +46,12 @@ public class PairingActivity extends SherlockActivity {
 
     }
 
+    @Override
+    protected void onPause() {
+        super.onPause();
+        unbindService(mConnection);
+    }
+
     private ServiceConnection mConnection = new ServiceConnection() {
         @Override
         public void onServiceConnected(ComponentName aClassName,
@@ -60,7 +64,7 @@ public class PairingActivity extends SherlockActivity {
                             .setText(MessageFormat
                                             .format(getResources()
                                                             .getString(R.string.pairing_instructions_2_deviceName),
-                                                            mCommunicationService
+                                                            CommunicationService
                                                                             .getDeviceName()));
 
             if (mCommunicationService.getState() == State.CONNECTING) {
diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
index 4d21d40..a99b9cc 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
@@ -36,7 +36,6 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
 
 public class PresentationActivity extends SherlockFragmentActivity {
     private CommunicationService mCommunicationService;
-    private boolean mIsBound = false;
     private FrameLayout mLayout;
     private FrameLayout mOuterLayout;
     private ThumbnailFragment mThumbnailFragment;
@@ -49,7 +48,6 @@ public class PresentationActivity extends SherlockFragmentActivity {
 
         bindService(new Intent(this, CommunicationService.class), mConnection,
                         Context.BIND_IMPORTANT);
-        mIsBound = true;
 
         setContentView(R.layout.activity_presentation);
         mOuterLayout = (FrameLayout) findViewById(R.id.framelayout);
@@ -59,21 +57,30 @@ public class PresentationActivity extends SherlockFragmentActivity {
         mLayout.setId(R.id.presentation_innerFrame);
 
         //((FrameLayout) findViewById(R.id.framelayout)).addView(mLayout);
-        mThumbnailFragment = new ThumbnailFragment();
-        mPresentationFragment = new PresentationFragment();
+        if (savedInstanceState == null) {
+            mThumbnailFragment = new ThumbnailFragment();
+            mPresentationFragment = new PresentationFragment();
 
-        FragmentManager fragmentManager = getSupportFragmentManager();
-        FragmentTransaction fragmentTransaction = fragmentManager
-                        .beginTransaction();
-        fragmentTransaction.add(R.id.presentation_innerFrame,
-                        mPresentationFragment, "fragment_presentation");
-        fragmentTransaction.commit();
+            FragmentManager fragmentManager = getSupportFragmentManager();
 
+            FragmentTransaction fragmentTransaction = fragmentManager
+                            .beginTransaction();
+            fragmentTransaction.add(R.id.presentation_innerFrame,
+                            mPresentationFragment, "fragment_presentation");
+            fragmentTransaction.commit();
+        }
+    }
+
+    @Override
+    protected void onSaveInstanceState(Bundle outState) {
+        super.onSaveInstanceState(outState);
+        outState.putBoolean("thumbnail_enabled", mThumbnailFragment.isVisible());
     }
 
     @Override
     protected void onDestroy() {
         mActionBarManager.stop();
+        unbindService(mConnection);
         super.onDestroy();
     }
 
diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java
index 4e90ee0..2ca4a21 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java
@@ -59,8 +59,7 @@ public class PresentationFragment extends SherlockFragment {
             if (mTopView != null) {
                 mTopView.setAdapter(new ThumbnailAdapter(mContext,
                                 mCommunicationService.getSlideShow()));
-                mTopView.setSelection(mCommunicationService.getSlideShow()
-                                .getCurrentSlide(), true);
+                mTopView.setSelection(mCommunicationService.getSlideShow().getCurrentSlide(), true);
                 mTopView.setOnItemSelectedListener(new ClickListener());
             }
 
diff --git a/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java b/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java
index 82cb81c..5c83e5a 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/SelectorActivity.java
@@ -24,6 +24,7 @@ import android.content.IntentFilter;
 import android.content.ServiceConnection;
 import android.os.Bundle;
 import android.os.IBinder;
+import android.support.v4.content.LocalBroadcastManager;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.LinearLayout;
@@ -49,7 +50,8 @@ public class SelectorActivity extends SherlockActivity {
 
         IntentFilter aFilter = new IntentFilter(
                         CommunicationService.MSG_SERVERLIST_CHANGED);
-        registerReceiver(mListener, aFilter);
+        LocalBroadcastManager.getInstance(this).registerReceiver(mListener,
+                        aFilter);
 
         mBluetoothContainer = findViewById(R.id.selector_container_bluetooth);
         mBluetoothList = (LinearLayout) findViewById(R.id.selector_list_bluetooth);
@@ -63,7 +65,7 @@ public class SelectorActivity extends SherlockActivity {
     @Override
     protected void onDestroy() {
         super.onDestroy();
-        unregisterReceiver(mListener);
+        LocalBroadcastManager.getInstance(this).unregisterReceiver(mListener);
     }
 
     @Override
@@ -112,6 +114,7 @@ public class SelectorActivity extends SherlockActivity {
             mCommunicationService = ((CommunicationService.CBinder) aService)
                             .getService();
             mCommunicationService.startSearching();
+            refreshLists();
         }
 
         @Override


More information about the Libreoffice-commits mailing list