[Libreoffice-commits] .: Branch 'feature/remote' - 5 commits - android/sdremote

Andrzej J.R. Hunt ajrhunt at kemper.freedesktop.org
Wed Jul 25 09:40:04 PDT 2012


 android/sdremote/AndroidManifest.xml                                         |   11 -
 android/sdremote/res/drawable/actionbar_none.png                             |binary
 android/sdremote/res/drawable/actionbar_pressed.png                          |binary
 android/sdremote/res/drawable/actionbar_selected.png                         |binary
 android/sdremote/res/drawable/actionbar_thumbs.xml                           |    9 
 android/sdremote/res/drawable/actionbar_toggle.xml                           |    8 
 android/sdremote/res/drawable/empty.png                                      |binary
 android/sdremote/res/drawable/icon_overflow.png                              |binary
 android/sdremote/res/drawable/icon_thumbs.png                                |binary
 android/sdremote/res/layout/fragment_presentation.xml                        |    7 
 android/sdremote/res/layout/fragment_thumbnail.xml                           |    1 
 android/sdremote/res/layout/presentation_actionbar.xml                       |   25 ++
 android/sdremote/res/layout/presentation_clockbar.xml                        |   30 ++
 android/sdremote/res/layout/slide_thumbnail.xml                              |    3 
 android/sdremote/res/menu/actionbar_presentation.xml                         |   21 +
 android/sdremote/res/values/strings.xml                                      |    2 
 android/sdremote/res/values/styles.xml                                       |   28 ++
 android/sdremote/src/org/libreoffice/impressremote/ActionBarManager.java     |   69 ------
 android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java |  107 +++++++++-
 android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java |   93 ++++----
 android/sdremote/src/org/libreoffice/impressremote/TestClient.java           |    1 
 android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java    |   19 +
 22 files changed, 289 insertions(+), 145 deletions(-)

New commits:
commit 9a6f7f37961e316b376151fe8d800b5eeca44a55
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Wed Jul 25 18:30:43 2012 +0200

    Basic clock control bar done.
    
    Change-Id: I Ifd2e56b97f5b53ce29101d9eee7953b7700fb749

diff --git a/android/sdremote/res/layout/presentation_clockbar.xml b/android/sdremote/res/layout/presentation_clockbar.xml
new file mode 100644
index 0000000..5ab7081
--- /dev/null
+++ b/android/sdremote/res/layout/presentation_clockbar.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:orientation="horizontal"
+    android:background="#BB000000">
+
+    <ToggleButton
+        android:id="@+id/clockbar_toggle_clockmode"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+
+        android:text="ToggleButton" />
+
+    <ToggleButton
+        android:id="@+id/clockbar_toggle_stopwatchmode"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:text="@drawable/actionbar_toggle" />
+
+    <ToggleButton
+        android:id="@+id/clockbar_toggle_countdownmode"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:layout_weight="1"
+        android:text="@drawable/actionbar_toggle" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
index 234042d..48e6678 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
@@ -16,6 +16,7 @@ import android.os.IBinder;
 import android.os.Message;
 import android.os.Messenger;
 import android.text.format.DateFormat;
+import android.view.LayoutInflater;
 import android.view.Menu;
 import android.view.View;
 import android.view.View.OnClickListener;
@@ -135,7 +136,7 @@ public class PresentationActivity extends Activity {
 
 			mTimeLabel = (ToggleButton) aBar.getCustomView().findViewById(
 			                R.id.actionbar_time);
-			mThumbnailButton.setOnClickListener(this);
+			mTimeLabel.setOnClickListener(this);
 
 			// Listen for fragment changes
 			getFragmentManager().addOnBackStackChangedListener(this);
@@ -184,7 +185,11 @@ public class PresentationActivity extends Activity {
 					getFragmentManager().popBackStack();
 				}
 			} else if (aSource == mTimeLabel) {
-
+				System.out.println("added");
+				LayoutInflater aInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+				View v = aInflater.inflate(R.layout.presentation_clockbar,
+				                mLayout);
+				//				mLayout.addView(v);
 			}
 
 		}
commit 8c16a9119531d728e00657ecd05f2661b2d8520d
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Wed Jul 25 18:01:22 2012 +0200

    Prepared clock button.
    
    Change-Id: I481885d7f9508dca887380d7f577bb35b04d6b07

diff --git a/android/sdremote/res/layout/presentation_actionbar.xml b/android/sdremote/res/layout/presentation_actionbar.xml
index 818748b..1fd3bae 100644
--- a/android/sdremote/res/layout/presentation_actionbar.xml
+++ b/android/sdremote/res/layout/presentation_actionbar.xml
@@ -12,10 +12,12 @@
         android:textOff=""
         android:textOn="" />
 
-    <TextView
+    <ToggleButton
         android:id="@+id/actionbar_time"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
+        android:layout_gravity="center"
+        android:background="@drawable/actionbar_toggle"
         android:gravity="center"
         android:textColor="#FFFFFF"
         android:textSize="22dp" />
diff --git a/android/sdremote/res/values/styles.xml b/android/sdremote/res/values/styles.xml
index 04143c4..bb11845 100644
--- a/android/sdremote/res/values/styles.xml
+++ b/android/sdremote/res/values/styles.xml
@@ -13,6 +13,7 @@
 
     <style name="Theme.ImpressRemote.ActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
         <item name="android:background">@color/orange</item>
+        <item name="android:displayOptions">showCustom</item>
     </style>
 
     <style name="Theme.ImpressRemote.ActionBarWidget" parent="android:style/Widget.Holo.Light">
diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
index 795ab53..234042d 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
@@ -20,7 +20,6 @@ import android.view.Menu;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.FrameLayout;
-import android.widget.TextView;
 import android.widget.ToggleButton;
 
 public class PresentationActivity extends Activity {
@@ -107,7 +106,7 @@ public class PresentationActivity extends Activity {
 	private class ActionBarManager implements OnClickListener,
 	                FragmentManager.OnBackStackChangedListener {
 
-		private TextView mTimeLabel;
+		private ToggleButton mTimeLabel;
 		private ToggleButton mThumbnailButton;
 
 		private String aTimeFormat = getResources().getString(
@@ -134,7 +133,7 @@ public class PresentationActivity extends Activity {
 			                .findViewById(R.id.actionbar_thumbnailtoggle);
 			mThumbnailButton.setOnClickListener(this);
 
-			mTimeLabel = (TextView) aBar.getCustomView().findViewById(
+			mTimeLabel = (ToggleButton) aBar.getCustomView().findViewById(
 			                R.id.actionbar_time);
 			mThumbnailButton.setOnClickListener(this);
 
commit b6ecca12f1cd1b7aca8249fb771444e2c512d4b1
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Wed Jul 25 16:51:41 2012 +0200

    Added proper toggling for thumbnail button.
    
    Change-Id: I2dc83bd3503c17d27c6461cd925cc22af7f61af8

diff --git a/android/sdremote/res/drawable/actionbar_none.png b/android/sdremote/res/drawable/actionbar_none.png
new file mode 100644
index 0000000..d7895e5
Binary files /dev/null and b/android/sdremote/res/drawable/actionbar_none.png differ
diff --git a/android/sdremote/res/drawable/actionbar_pressed.png b/android/sdremote/res/drawable/actionbar_pressed.png
new file mode 100644
index 0000000..812c92b
Binary files /dev/null and b/android/sdremote/res/drawable/actionbar_pressed.png differ
diff --git a/android/sdremote/res/drawable/actionbar_selected.png b/android/sdremote/res/drawable/actionbar_selected.png
new file mode 100644
index 0000000..9c471a3
Binary files /dev/null and b/android/sdremote/res/drawable/actionbar_selected.png differ
diff --git a/android/sdremote/res/drawable/actionbar_thumbs.xml b/android/sdremote/res/drawable/actionbar_thumbs.xml
new file mode 100644
index 0000000..2dbf5ea
--- /dev/null
+++ b/android/sdremote/res/drawable/actionbar_thumbs.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item android:drawable="@drawable/actionbar_toggle"/>
+    <item><bitmap
+        android:src="@drawable/icon_thumbs"
+        android:gravity="center"  /></item>
+
+</layer-list>
\ No newline at end of file
diff --git a/android/sdremote/res/drawable/actionbar_toggle.xml b/android/sdremote/res/drawable/actionbar_toggle.xml
new file mode 100644
index 0000000..3f53266
--- /dev/null
+++ b/android/sdremote/res/drawable/actionbar_toggle.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:drawable="@drawable/actionbar_selected" android:state_checked="true" />
+    <item android:drawable="@drawable/actionbar_pressed" android:state_pressed="true"/>
+    <item android:drawable="@drawable/actionbar_none"/>
+
+</selector>
\ No newline at end of file
diff --git a/android/sdremote/res/layout/fragment_thumbnail.xml b/android/sdremote/res/layout/fragment_thumbnail.xml
index 068ab78..ecd8855 100644
--- a/android/sdremote/res/layout/fragment_thumbnail.xml
+++ b/android/sdremote/res/layout/fragment_thumbnail.xml
@@ -7,6 +7,7 @@
     android:gravity="center"
     android:horizontalSpacing="10dp"
     android:numColumns="auto_fit"
+    android:paddingTop="10dp"
     android:stretchMode="columnWidth"
     android:verticalSpacing="10dp" >
 
diff --git a/android/sdremote/res/layout/presentation_actionbar.xml b/android/sdremote/res/layout/presentation_actionbar.xml
index 01f0d51..818748b 100644
--- a/android/sdremote/res/layout/presentation_actionbar.xml
+++ b/android/sdremote/res/layout/presentation_actionbar.xml
@@ -4,19 +4,20 @@
     android:layout_height="match_parent"
     android:orientation="horizontal" >
 
-    <ImageButton
+    <ToggleButton
         android:id="@+id/actionbar_thumbnailtoggle"
         android:layout_width="wrap_content"
         android:layout_height="match_parent"
-        android:background="@drawable/empty"
-        android:src="@drawable/icon_thumbs" />
+        android:background="@drawable/actionbar_thumbs"
+        android:textOff=""
+        android:textOn="" />
 
     <TextView
         android:id="@+id/actionbar_time"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:gravity="center"
-        android:textSize="22dp"
-        android:textColor="#FFFFFF"/>
+        android:textColor="#FFFFFF"
+        android:textSize="22dp" />
 
 </LinearLayout>
\ No newline at end of file
diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
index 8b6d75f..795ab53 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
@@ -20,8 +20,8 @@ import android.view.Menu;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.FrameLayout;
-import android.widget.ImageButton;
 import android.widget.TextView;
+import android.widget.ToggleButton;
 
 public class PresentationActivity extends Activity {
 	private CommunicationService mCommunicationService;
@@ -104,10 +104,11 @@ public class PresentationActivity extends Activity {
 		}
 	}
 
-	private class ActionBarManager implements OnClickListener {
+	private class ActionBarManager implements OnClickListener,
+	                FragmentManager.OnBackStackChangedListener {
 
 		private TextView mTimeLabel;
-		private ImageButton mThumbnailButton;
+		private ToggleButton mThumbnailButton;
 
 		private String aTimeFormat = getResources().getString(
 		                R.string.actionbar_timeformat);
@@ -129,14 +130,17 @@ public class PresentationActivity extends Activity {
 			aBar.setCustomView(R.layout.presentation_actionbar);
 
 			// Set up the various components
-			mThumbnailButton = (ImageButton) aBar.getCustomView().findViewById(
-			                R.id.actionbar_thumbnailtoggle);
+			mThumbnailButton = (ToggleButton) aBar.getCustomView()
+			                .findViewById(R.id.actionbar_thumbnailtoggle);
 			mThumbnailButton.setOnClickListener(this);
 
 			mTimeLabel = (TextView) aBar.getCustomView().findViewById(
 			                R.id.actionbar_time);
 			mThumbnailButton.setOnClickListener(this);
 
+			// Listen for fragment changes
+			getFragmentManager().addOnBackStackChangedListener(this);
+
 			// Setup the auto updater
 			timerHandler.removeCallbacks(timerUpdateThread);
 			timerHandler.postDelayed(timerUpdateThread, 50);
@@ -170,17 +174,28 @@ public class PresentationActivity extends Activity {
 		@Override
 		public void onClick(View aSource) {
 			if (aSource == mThumbnailButton) {
-				FragmentTransaction ft = getFragmentManager()
-				                .beginTransaction();
-				ft.replace(R.id.framelayout, mThumbnailFragment);
-				ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
-				ft.addToBackStack(null);
-				ft.commit();
+				if (!mThumbnailFragment.isVisible()) {
+					FragmentTransaction ft = getFragmentManager()
+					                .beginTransaction();
+					ft.replace(R.id.framelayout, mThumbnailFragment);
+					ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+					ft.addToBackStack(null);
+					ft.commit();
+				} else {
+					getFragmentManager().popBackStack();
+				}
 			} else if (aSource == mTimeLabel) {
 
 			}
 
 		}
+
+		@Override
+		public void onBackStackChanged() {
+			if (getFragmentManager().getBackStackEntryCount() == 0) {
+				mThumbnailButton.setChecked(false);
+			}
+		}
 	}
 
 }
commit dfbd492dbea708847fd329ba19d64f5c58f39cf2
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Wed Jul 25 15:42:46 2012 +0200

    Fully fixed coverflow resizing, added menu, fixed fragment changes.
    
    Change-Id: Iaec671f81dada2dd9c667bde48b34ae2e89a321d

diff --git a/android/sdremote/res/drawable/icon_overflow.png b/android/sdremote/res/drawable/icon_overflow.png
new file mode 100644
index 0000000..5265c45
Binary files /dev/null and b/android/sdremote/res/drawable/icon_overflow.png differ
diff --git a/android/sdremote/res/layout/fragment_presentation.xml b/android/sdremote/res/layout/fragment_presentation.xml
index 2b58bde..03c4ee7 100644
--- a/android/sdremote/res/layout/fragment_presentation.xml
+++ b/android/sdremote/res/layout/fragment_presentation.xml
@@ -19,7 +19,9 @@
         android:id="@+id/presentation_slidenumber"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        />
+        android:layout_gravity="center_horizontal"
+        android:text="" />
+
     <ImageView
         android:id="@+id/presentation_handle"
         android:layout_width="fill_parent"
diff --git a/android/sdremote/res/layout/slide_thumbnail.xml b/android/sdremote/res/layout/slide_thumbnail.xml
index 448b3ed..d3834c7 100644
--- a/android/sdremote/res/layout/slide_thumbnail.xml
+++ b/android/sdremote/res/layout/slide_thumbnail.xml
@@ -9,7 +9,8 @@
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_gravity="center_horizontal"
-        android:src="@drawable/ic_launcher" />
+        android:src="@drawable/ic_launcher"
+        android:adjustViewBounds="true"/>
 
     <TextView
         android:id="@+id/sub_number"
diff --git a/android/sdremote/res/menu/actionbar_presentation.xml b/android/sdremote/res/menu/actionbar_presentation.xml
index 03524ef..a48aad5 100644
--- a/android/sdremote/res/menu/actionbar_presentation.xml
+++ b/android/sdremote/res/menu/actionbar_presentation.xml
@@ -3,7 +3,8 @@
 
     <item
         android:id="@+id/actionbar_presentation_submenu"
-        android:showAsAction="always">
+        android:showAsAction="always"
+        android:icon="@drawable/icon_overflow">
         <menu>
             <item
                 android:id="@+id/actionbar_presentation_submenu_blank"
diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java
index 7862539..ed6e86f 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java
@@ -38,6 +38,9 @@ public class PresentationFragment extends Fragment {
 	private CommunicationService mCommunicationService;
 	private SlideShow mSlideShow;
 
+	private float mOriginalCoverflowWidth;
+	private float mOriginalCoverflowHeight;
+
 	public View onCreateView(LayoutInflater inflater, ViewGroup container,
 	                Bundle savedInstanceState) {
 		mContext = container.getContext();
@@ -66,6 +69,9 @@ public class PresentationFragment extends Fragment {
 		// Call again to set things up if necessary.
 		setCommunicationService(mCommunicationService);
 
+		// Save the height/width for future reference
+		mOriginalCoverflowHeight = mTopView.getImageHeight();
+		mOriginalCoverflowWidth = mTopView.getImageWidth();
 		return v;
 	}
 
@@ -84,38 +90,51 @@ public class PresentationFragment extends Fragment {
 				break;
 			case MotionEvent.ACTION_MOVE:
 				LayoutParams aParams = mTopView.getLayoutParams();
-				int aHeightOriginal = mTopView.getHeight();
 				int aHeight = mTopView.getHeight();
+				int aViewSize = mLayout.getHeight();
 
 				final int DRAG_MARGIN = 120;
 
-				// Set Height
-
-				aParams.height = aHeight + (int) (aEvent.getY());
-				int aViewSize = mLayout.getHeight();
-				if (aParams.height < DRAG_MARGIN) {
-					aParams.height = DRAG_MARGIN;
-				} else if (aParams.height > aViewSize - DRAG_MARGIN) {
-					aParams.height = aViewSize - DRAG_MARGIN;
+				// Calculate height change, taking limits into account
+				int aDiff = (int) (aEvent.getY());
+				System.out.println("Diff1 is :" + aDiff);
+				if (aDiff + aHeight < DRAG_MARGIN) {
+					aDiff = DRAG_MARGIN - aHeight;
+				} else if ((aHeight + aDiff) > (aViewSize - DRAG_MARGIN)) {
+					aDiff = (aViewSize - DRAG_MARGIN) - aHeight;
 				}
 
-				int aDiff = aParams.height - aHeightOriginal;
-				mTopView.setLayoutParams(aParams);
-
 				// Now deal with the internal height
-				System.out.println("Before:W:" + mTopView.getImageWidth()
-				                + ":H:" + mTopView.getImageHeight());
 				AbstractCoverFlowImageAdapter aAdapter = (AbstractCoverFlowImageAdapter) mTopView
 				                .getAdapter();
-				int aHeightNew = (int) (mTopView.getImageHeight() + aDiff);
+
+				double aRatio = mOriginalCoverflowWidth
+				                / mOriginalCoverflowHeight;
+				System.out.println("Diff2 is :" + aDiff);
+				float aHeightNew = mTopView.getImageHeight() + aDiff;
+				float aWidthNew = (float) (aRatio * aHeightNew);
+
+				//				 Too wide -- so scale down
+				if (aWidthNew > mLayout.getWidth() - 50) {
+					aWidthNew = mLayout.getWidth() - 50;
+					aHeightNew = (float) (aWidthNew / aRatio);
+					aDiff = (int) (aHeightNew - mTopView.getImageHeight());
+				}
+
+				// Set the new settings -- it turns out that changing the
+				// internal height now works, and changing the views height
+				// is unnecessary / even causes problems.
+				//				aParams.height += aDiff;
+				//				mTopView.setLayoutParams(aParams);
+
 				aAdapter.setHeight(aHeightNew);
 				mTopView.setImageHeight(aHeightNew);
-				int aWidthNew = aHeightNew * 180 / 150;
 				aAdapter.setWidth(aWidthNew);
 				mTopView.setImageWidth(aWidthNew);
+
+				// We need to update the view now
 				aAdapter.notifyDataSetChanged();
-				System.out.println("After:W:" + mTopView.getImageWidth()
-				                + ":H:" + mTopView.getImageHeight());
+
 				break;
 			}
 			// TODO Auto-generated method stub
@@ -162,7 +181,7 @@ public class PresentationFragment extends Fragment {
 			int aSlide = aData.getInt("slide_number");
 			mTopView.setSelection(aSlide, true);
 
-			mNumberText.setText(mSlideShow.getCurrentSlide() + "/"
+			mNumberText.setText((mSlideShow.getCurrentSlide() + 1) + "/"
 			                + mSlideShow.getSize());
 
 			break;
diff --git a/android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java b/android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java
index 2653277..74a806d 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java
@@ -58,6 +58,15 @@ public class ThumbnailFragment extends Fragment {
 	}
 
 	@Override
+	public void onDestroyView() {
+		super.onDestroyView();
+		mGrid = null;
+		mContext = null;
+		mCurrentImage = null;
+		mCurrentText = null;
+	}
+
+	@Override
 	public void onCreate(Bundle savedInstanceState) {
 		super.onCreate(savedInstanceState);
 
@@ -192,14 +201,14 @@ public class ThumbnailFragment extends Fragment {
 			}
 
 			Bitmap aBitmap = mSlideShow.getImage(position);
-			if (aBitmap != null) {
-				aImage.setImageBitmap(aBitmap);
-			}
-
 			// Width
 			int aWidth = (mGrid.getWidth()) / 3 - 20;
 			aImage.setMaxWidth(aWidth);
-			aImage.setScaleType(ScaleType.MATRIX);
+			aImage.setScaleType(ScaleType.FIT_CENTER);
+
+			if (aBitmap != null) {
+				aImage.setImageBitmap(aBitmap);
+			}
 
 			aText.setText(String.valueOf(position + 1));
 
commit 2f2e3b2410b45a93a5909352a370cbc9ddb8eaa7
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Wed Jul 25 14:28:59 2012 +0200

    First piece of ActionBar implemented.
    
    Change-Id: I3b0a920da177ef4f11347fa50ddc3a44597b6824

diff --git a/android/sdremote/AndroidManifest.xml b/android/sdremote/AndroidManifest.xml
index 689e0ec..4543b71 100644
--- a/android/sdremote/AndroidManifest.xml
+++ b/android/sdremote/AndroidManifest.xml
@@ -13,10 +13,12 @@
     <application
         android:icon="@drawable/ic_launcher"
         android:label="@string/app_name"
+        android:logo="@drawable/empty"
         android:theme="@style/Theme.ImpressRemote" >
         <activity
             android:name="TestClient"
-            android:label="@string/app_name" >
+            android:label=""
+            >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
 
@@ -27,16 +29,9 @@
         <service android:name=".communication.CommunicationService" >
         </service>
 
-        <activity android:name=".ThumbnailFragment" >
-        </activity>
         <activity
             android:name=".PresentationActivity"
             android:label="@string/title_activity_presentation" >
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-
-                <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
         </activity>
     </application>
 
diff --git a/android/sdremote/res/drawable/empty.png b/android/sdremote/res/drawable/empty.png
new file mode 100644
index 0000000..8705a3d
Binary files /dev/null and b/android/sdremote/res/drawable/empty.png differ
diff --git a/android/sdremote/res/drawable/icon_thumbs.png b/android/sdremote/res/drawable/icon_thumbs.png
new file mode 100644
index 0000000..ae10acc
Binary files /dev/null and b/android/sdremote/res/drawable/icon_thumbs.png differ
diff --git a/android/sdremote/res/layout/fragment_presentation.xml b/android/sdremote/res/layout/fragment_presentation.xml
index 2d17759..2b58bde 100644
--- a/android/sdremote/res/layout/fragment_presentation.xml
+++ b/android/sdremote/res/layout/fragment_presentation.xml
@@ -15,6 +15,11 @@
         coverflow:imageWidth="180dip"
         coverflow:withReflection="false" />
 
+    <TextView
+        android:id="@+id/presentation_slidenumber"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        />
     <ImageView
         android:id="@+id/presentation_handle"
         android:layout_width="fill_parent"
diff --git a/android/sdremote/res/layout/presentation_actionbar.xml b/android/sdremote/res/layout/presentation_actionbar.xml
new file mode 100644
index 0000000..01f0d51
--- /dev/null
+++ b/android/sdremote/res/layout/presentation_actionbar.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="horizontal" >
+
+    <ImageButton
+        android:id="@+id/actionbar_thumbnailtoggle"
+        android:layout_width="wrap_content"
+        android:layout_height="match_parent"
+        android:background="@drawable/empty"
+        android:src="@drawable/icon_thumbs" />
+
+    <TextView
+        android:id="@+id/actionbar_time"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:gravity="center"
+        android:textSize="22dp"
+        android:textColor="#FFFFFF"/>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/android/sdremote/res/menu/actionbar_presentation.xml b/android/sdremote/res/menu/actionbar_presentation.xml
index 020fae1..03524ef 100644
--- a/android/sdremote/res/menu/actionbar_presentation.xml
+++ b/android/sdremote/res/menu/actionbar_presentation.xml
@@ -1,17 +1,17 @@
 <?xml version="1.0" encoding="utf-8"?>
 <menu xmlns:android="http://schemas.android.com/apk/res/android" >
-    <item android:id="@+id/actionbar_presenation_thumbnail"></item>
-    <item android:id="@+id/actionbar_presentation_timer">
-        <menu>
-            <item android:id="@+id/actionbar_presentation_timer_pause"/>
-        </menu>
-    </item>
-    <item android:id="@+id/actionbar_presentation_submenu">
+
+    <item
+        android:id="@+id/actionbar_presentation_submenu"
+        android:showAsAction="always">
         <menu>
-            <item android:id="@+id/actionbar_presentation_submenu_blank" android:title="@string/presentation_blank_screen"/>
-            <item android:id="@+id/actionbar_presentation_submenu_options" android:title="@string/options"/>
+            <item
+                android:id="@+id/actionbar_presentation_submenu_blank"
+                android:title="@string/presentation_blank_screen"/>
+            <item
+                android:id="@+id/actionbar_presentation_submenu_options"
+                android:title="@string/options"/>
         </menu>
     </item>
 
-
 </menu>
\ No newline at end of file
diff --git a/android/sdremote/res/values/strings.xml b/android/sdremote/res/values/strings.xml
index c677dcb..7c9dae3 100644
--- a/android/sdremote/res/values/strings.xml
+++ b/android/sdremote/res/values/strings.xml
@@ -7,6 +7,6 @@
     <string name="presentation_ui_resizehandle">Handle to resize view.</string>
     <string name="presentation_blank_screen">Blank Screen</string>
     <string name="options">Options</string>
-    <string name="actionbar_timeformat">HH:mm</string>
+    <string name="actionbar_timeformat">hh:mm</string>
     <string name="actionbar_timerformat">h:m:ss</string>
 </resources>
\ No newline at end of file
diff --git a/android/sdremote/res/values/styles.xml b/android/sdremote/res/values/styles.xml
index fdc3926..04143c4 100644
--- a/android/sdremote/res/values/styles.xml
+++ b/android/sdremote/res/values/styles.xml
@@ -1,7 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
-<resources>
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
 
     <color name="orange">#EE4400</color>
+    <color name="grey">#303030</color>
+    <color name="white">#FFFFFF</color>
     <color name="light_grey">#E8E9E8</color>
 
     <integer name="thumbnail_border_width">3</integer>
@@ -13,8 +15,31 @@
         <item name="android:background">@color/orange</item>
     </style>
 
+    <style name="Theme.ImpressRemote.ActionBarWidget" parent="android:style/Widget.Holo.Light">
+        <item name="android:background">@color/orange</item>
+        <item name="android:textColor">@color/white</item>
+        <item name="android:textSize">22dp</item>
+    </style>
+
+    <style name="Theme.ImpressRemote.ActionBarMenu" parent="android:style/Widget.Holo.Light.ListPopupWindow">
+        <item name="android:background">@color/grey</item>
+        <!-- <item name="android:popupBackground">@color/black</item> -->
+    </style>
+
+    <style name="Theme.ImpressRemote.ActionBarMenuItem" parent="android:style/Widget.Holo.Light.ListView.DropDown">
+        <item name="android:background">@color/grey</item>
+        <item name="android:textColor">@color/white</item>
+        <item name="android:textSize">16dp</item>
+    </style>
+
     <style name="Theme.ImpressRemote" parent="android:style/Theme.Holo.Light">
         <item name="android:actionBarStyle">@style/Theme.ImpressRemote.ActionBar</item>
+        <item name="android:popupMenuStyle">@style/Theme.ImpressRemote.ActionBarMenu</item>
+
+        <item name="android:dropDownListViewStyle">@style/Theme.ImpressRemote.ActionBarMenuItem</item>
+        <item name="android:textAppearanceLargePopupMenu">@style/Theme.ImpressRemote.ActionBarMenuItem</item>        <!-- <item name="android:actionBarWidgetTheme">@style/Theme.ImpressRemote.ActionBarWidget</item> -->
+        <item name="android:actionDropDownStyle">@style/Theme.ImpressRemote.ActionBarMenu</item>
         <item name="android:windowBackground">@color/light_grey</item>
     </style>
+
 </resources>
\ No newline at end of file
diff --git a/android/sdremote/src/org/libreoffice/impressremote/ActionBarManager.java b/android/sdremote/src/org/libreoffice/impressremote/ActionBarManager.java
deleted file mode 100644
index 33ea95c..0000000
--- a/android/sdremote/src/org/libreoffice/impressremote/ActionBarManager.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-package org.libreoffice.impressremote;
-
-import org.libreoffice.impressremote.communication.CommunicationService;
-
-import android.content.Context;
-import android.os.Handler;
-import android.text.format.DateFormat;
-import android.view.Menu;
-
-/**
- * Used to manage the action bar whenever a presentation is running.
- *
- */
-public class ActionBarManager {
-
-	private Context mContext;
-	private Menu mMenu;
-	private CommunicationService mCommunicationService;
-
-	/*
-	 * True if the timer is being used as a timer, false if we are showing a
-	 * clock.
-	 */
-	private boolean mTimerOn = false;
-
-	public ActionBarManager(Context aContext, Menu aMenu,
-	                CommunicationService aCommunicationService) {
-		mContext = aContext;
-		mMenu = aMenu;
-		mCommunicationService = aCommunicationService;
-		timerHandler.removeCallbacks(timerUpdateThread);
-		timerHandler.postDelayed(timerUpdateThread, 50);
-	}
-
-	private Handler timerHandler = new Handler();
-
-	private Thread timerUpdateThread = new Thread() {
-
-		@Override
-		public void run() {
-			//			invalidateOptionsMenu();
-			CharSequence aTimeString;
-			long aTime = mCommunicationService.getSlideShow().getTimer()
-			                .getTimeMillis();
-			if (mTimerOn) {
-				aTimeString = DateFormat.format(mContext.getResources()
-				                .getString(R.string.actionbar_timerformat),
-				                aTime);
-			} else {
-				aTimeString = DateFormat.format(mContext.getResources()
-				                .getString(R.string.actionbar_timeformat),
-				                System.currentTimeMillis());
-			}
-			// TODO: set the string
-			timerHandler.postDelayed(this, 50);
-
-		}
-
-	};
-}
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
index 05c5c4a..8b6d75f 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
@@ -2,6 +2,7 @@ package org.libreoffice.impressremote;
 
 import org.libreoffice.impressremote.communication.CommunicationService;
 
+import android.app.ActionBar;
 import android.app.Activity;
 import android.app.FragmentManager;
 import android.app.FragmentTransaction;
@@ -14,8 +15,13 @@ import android.os.Handler;
 import android.os.IBinder;
 import android.os.Message;
 import android.os.Messenger;
+import android.text.format.DateFormat;
 import android.view.Menu;
+import android.view.View;
+import android.view.View.OnClickListener;
 import android.widget.FrameLayout;
+import android.widget.ImageButton;
+import android.widget.TextView;
 
 public class PresentationActivity extends Activity {
 	private CommunicationService mCommunicationService;
@@ -53,8 +59,7 @@ public class PresentationActivity extends Activity {
 	@Override
 	public boolean onCreateOptionsMenu(Menu menu) {
 		getMenuInflater().inflate(R.menu.actionbar_presentation, menu);
-		mActionBarManager = new ActionBarManager(this, menu,
-		                mCommunicationService);
+		mActionBarManager = new ActionBarManager();
 		return true;
 	}
 
@@ -99,4 +104,83 @@ public class PresentationActivity extends Activity {
 		}
 	}
 
+	private class ActionBarManager implements OnClickListener {
+
+		private TextView mTimeLabel;
+		private ImageButton mThumbnailButton;
+
+		private String aTimeFormat = getResources().getString(
+		                R.string.actionbar_timeformat);
+		private String aTimerFormat = getResources().getString(
+		                R.string.actionbar_timerformat);
+		/*
+		 * True if the timer is being used as a timer, false if we are showing a
+		 * clock.
+		 */
+		private boolean mTimerOn = false;
+
+		public ActionBarManager() {
+
+			ActionBar aBar = getActionBar();
+			// Set custom view and unset the title.
+			aBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
+			                ActionBar.DISPLAY_SHOW_CUSTOM
+			                                | ActionBar.DISPLAY_SHOW_TITLE);
+			aBar.setCustomView(R.layout.presentation_actionbar);
+
+			// Set up the various components
+			mThumbnailButton = (ImageButton) aBar.getCustomView().findViewById(
+			                R.id.actionbar_thumbnailtoggle);
+			mThumbnailButton.setOnClickListener(this);
+
+			mTimeLabel = (TextView) aBar.getCustomView().findViewById(
+			                R.id.actionbar_time);
+			mThumbnailButton.setOnClickListener(this);
+
+			// Setup the auto updater
+			timerHandler.removeCallbacks(timerUpdateThread);
+			timerHandler.postDelayed(timerUpdateThread, 50);
+
+		}
+
+		private Handler timerHandler = new Handler();
+
+		private Thread timerUpdateThread = new Thread() {
+
+			@Override
+			public void run() {
+				//			invalidateOptionsMenu();
+				CharSequence aTimeString;
+				long aTime = mCommunicationService.getSlideShow().getTimer()
+				                .getTimeMillis();
+				if (mTimerOn) {
+					aTimeString = DateFormat.format(aTimerFormat, aTime);
+				} else {
+					aTimeString = DateFormat.format(aTimeFormat,
+					                System.currentTimeMillis());
+				}
+				mTimeLabel.setText(aTimeString);
+				// TODO: set the string
+				timerHandler.postDelayed(this, 50);
+
+			}
+
+		};
+
+		@Override
+		public void onClick(View aSource) {
+			if (aSource == mThumbnailButton) {
+				FragmentTransaction ft = getFragmentManager()
+				                .beginTransaction();
+				ft.replace(R.id.framelayout, mThumbnailFragment);
+				ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+				ft.addToBackStack(null);
+				ft.commit();
+			} else if (aSource == mTimeLabel) {
+
+			}
+
+		}
+	}
+
 }
diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java
index aec285b..7862539 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java
@@ -24,6 +24,7 @@ import android.webkit.WebView;
 import android.widget.AdapterView;
 import android.widget.AdapterView.OnItemSelectedListener;
 import android.widget.ImageView;
+import android.widget.TextView;
 
 public class PresentationFragment extends Fragment {
 
@@ -32,6 +33,7 @@ public class PresentationFragment extends Fragment {
 	private View mLayout;
 	private WebView mNotes;
 	private Context mContext;
+	private TextView mNumberText;
 
 	private CommunicationService mCommunicationService;
 	private SlideShow mSlideShow;
@@ -56,6 +58,8 @@ public class PresentationFragment extends Fragment {
 
 		mLayout = v.findViewById(R.id.presentation_layout);
 
+		mNumberText = (TextView) v.findViewById(R.id.presentation_slidenumber);
+
 		mHandle = (ImageView) v.findViewById(R.id.presentation_handle);
 		mHandle.setOnTouchListener(new SizeListener());
 
@@ -157,6 +161,10 @@ public class PresentationFragment extends Fragment {
 		case CommunicationService.MSG_SLIDE_CHANGED:
 			int aSlide = aData.getInt("slide_number");
 			mTopView.setSelection(aSlide, true);
+
+			mNumberText.setText(mSlideShow.getCurrentSlide() + "/"
+			                + mSlideShow.getSize());
+
 			break;
 		case CommunicationService.MSG_SLIDE_PREVIEW:
 			int aNSlide = aData.getInt("slide_number");
@@ -185,32 +193,6 @@ public class PresentationFragment extends Fragment {
 			return mSlideShow.getSize();
 		}
 
-		// @Override
-		// public View getView(int position, View convertView, ViewGroup parent)
-		// {
-		// LayoutInflater aInflater = (LayoutInflater) mContext
-		// .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-		// View v = aInflater.inflate(R.layout.slide_thumbnail, null);
-		//
-		// ImageView aImage = (ImageView) v.findViewById(R.id.sub_thumbnail);
-		// TextView aText = (TextView) v.findViewById(R.id.sub_number);
-		//
-		// // Do the image & number styling
-		// int aBorderWidth = getResources().getInteger(
-		// R.integer.thumbnail_border_width);
-		// aImage.setPadding(aBorderWidth, aBorderWidth, aBorderWidth,
-		// aBorderWidth);
-		//
-		// Bitmap aBitmap = mSlideShow.getImage(position);
-		// if (aBitmap != null) {
-		// aImage.setImageBitmap(aBitmap);
-		// }
-		//
-		// aText.setText(String.valueOf(position + 1));
-		//
-		// return v;
-		// }
-
 		@Override
 		protected Bitmap createBitmap(int position) {
 			Bitmap aBitmap = mSlideShow.getImage(position);
@@ -219,9 +201,6 @@ public class PresentationFragment extends Fragment {
 			Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
 			p.setShadowLayer(borderWidth, 0, 0, Color.BLACK);
 
-			//			RectF aRect = new RectF(borderWidth, borderWidth, borderWidth
-			//			                + aBitmap.getWidth(), borderWidth
-			//			                + aBitmap.getHeight());
 			RectF aRect = new RectF(borderWidth, borderWidth, borderWidth
 			                + aBitmap.getWidth(), borderWidth
 			                + aBitmap.getHeight());
@@ -231,7 +210,6 @@ public class PresentationFragment extends Fragment {
 			Canvas canvas = new Canvas(aOut);
 			canvas.drawColor(Color.TRANSPARENT);
 			canvas.drawRect(aRect, p);
-			//canvas.drawBitmap(aBitmap, null, aRect, null);
 			canvas.drawBitmap(aBitmap, null, aRect, null);
 
 			return aOut;
diff --git a/android/sdremote/src/org/libreoffice/impressremote/TestClient.java b/android/sdremote/src/org/libreoffice/impressremote/TestClient.java
index 5620c5b..501cf97 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/TestClient.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/TestClient.java
@@ -50,6 +50,7 @@ public class TestClient extends Activity {
 	protected void onResume() {
 		super.onResume();
 		doBindService();
+
 	}
 
 	// FIXME: move all necessary code to CommunicationService.onUnbind


More information about the Libreoffice-commits mailing list