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

Andrzej J.R. Hunt ajrhunt at kemper.freedesktop.org
Sat Jul 28 08:47:43 PDT 2012


 android/sdremote/AndroidManifest.xml                                              |   10 -
 android/sdremote/res/drawable/icon_options.png                                    |binary
 android/sdremote/res/drawable/rectangle_black.xml                                 |   11 +
 android/sdremote/res/drawable/up_indicator_white.png                              |binary
 android/sdremote/res/layout/activity_settings.xml                                 |    6 
 android/sdremote/res/layout/fragment_blankscreen.xml                              |   44 +++++
 android/sdremote/res/values/strings.xml                                           |    7 
 android/sdremote/res/values/styles.xml                                            |   13 +
 android/sdremote/res/xml/preferences.xml                                          |   15 ++
 android/sdremote/src/org/libreoffice/impressremote/BlankScreenFragment.java       |   65 ++++++++
 android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java      |   74 +++++++++-
 android/sdremote/src/org/libreoffice/impressremote/SettingsActivity.java          |   27 +++
 android/sdremote/src/org/libreoffice/impressremote/SettingsFragment.java          |   13 +
 android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java         |    5 
 android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java    |    4 
 android/sdremote/src/org/libreoffice/impressremote/communication/SlideShow.java   |    5 
 android/sdremote/src/org/libreoffice/impressremote/communication/Transmitter.java |    6 
 17 files changed, 289 insertions(+), 16 deletions(-)

New commits:
commit cc05a22a2d12d4e25be0f3fa15098e375363915b
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Sat Jul 28 16:36:13 2012 +0200

    Fixed some bugs affecting resuming of slideshow.
    
    Change-Id: I I I8797eca1fc4f992374a09f74454a5f034b47a96a

diff --git a/android/sdremote/res/values/strings.xml b/android/sdremote/res/values/strings.xml
index b803ff0..ac51b86 100644
--- a/android/sdremote/res/values/strings.xml
+++ b/android/sdremote/res/values/strings.xml
@@ -14,8 +14,11 @@
     <string name="clock_timer_restart">Restart</string>
     <string name="clock_timer_reset">Reset</string>
     <string name="clock_timer_resume">Resume</string>
-    <string name="options_autodecline">Auto-decline calls</string>
-    <string name="options_volumeswitching">Change slides using volume buttons</string>
+    <string name="options_autodecline">Decline Calls</string>
+    <string name="options_description">Automatically decline all incoming calls.</string>
+    <string name="options_volumeswitching">Volume Switching</string>
+    <string name="options_volumeswitching_descripton">Change slides using volume buttons</string>
     <string name="options_switchcomputer">Switch computer</string>
     <string name="blankscreen_return">Return to Slide</string>
+
 </resources>
\ No newline at end of file
diff --git a/android/sdremote/res/xml/preferences.xml b/android/sdremote/res/xml/preferences.xml
index e039995..5d7e68b 100644
--- a/android/sdremote/res/xml/preferences.xml
+++ b/android/sdremote/res/xml/preferences.xml
@@ -5,7 +5,8 @@
     <SwitchPreference
         android:defaultValue="false"
         android:key="option_volumeswitching"
-        android:title="@string/options_volumeswitching" />
+        android:title="@string/options_volumeswitching"
+         android:summary="@string/options_volumeswitching_descripton"/>
 
     <Preference
         android:key="option_switchcomputer"
diff --git a/android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java b/android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java
index 74a806d..1de6c01 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/ThumbnailFragment.java
@@ -136,11 +136,14 @@ public class ThumbnailFragment extends Fragment {
 	}
 
 	public void handleMessage(Message aMessage) {
+		if (!isVisible()) {
+			return;
+		}
+
 		Bundle aData = aMessage.getData();
 		switch (aMessage.what) {
 		case CommunicationService.MSG_SLIDE_CHANGED:
 			int aSlide = aData.getInt("slide_number");
-			setSelected(aSlide);
 			break;
 		case CommunicationService.MSG_SLIDE_PREVIEW:
 			mGrid.invalidateViews();
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java b/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java
index 6a0496f..e78f07e 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/Receiver.java
@@ -20,7 +20,7 @@ public class Receiver {
 
 	private Messenger mActivityMessenger;
 
-	private SlideShow mSlideShow = null;
+	private SlideShow mSlideShow = new SlideShow();
 
 	public SlideShow getSlideShow() {
 		return mSlideShow;
@@ -38,7 +38,7 @@ public class Receiver {
 		if (aInstruction.equals("slideshow_started")) {
 			int aSlideShowlength = Integer.parseInt(aCommand.get(1));
 			int aCurrentSlide = Integer.parseInt(aCommand.get(2));
-			mSlideShow = new SlideShow(aSlideShowlength);
+			mSlideShow.setLength(aSlideShowlength);
 			mSlideShow.setCurrentSlide(aCurrentSlide);
 
 			Message aMessage = Message.obtain(null,
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/SlideShow.java b/android/sdremote/src/org/libreoffice/impressremote/communication/SlideShow.java
index 34cf8aa..75b13a8 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/SlideShow.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/SlideShow.java
@@ -18,7 +18,10 @@ public class SlideShow {
 	private int mSize = 0;
 	private int mCurrentSlide = 0;
 
-	protected SlideShow(int aSize) {
+	protected SlideShow() {
+	}
+
+	protected void setLength(int aSize) {
 		mSize = aSize;
 	}
 
commit 18a807397931fbf6847e4951ce4ee9854fd35a34
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Sat Jul 28 16:26:49 2012 +0200

    Blank screen essentially working.
    
    Change-Id: I I I645fab156d9803a2f076b7e5b45a5035a6854fab

diff --git a/android/sdremote/src/org/libreoffice/impressremote/BlankScreenFragment.java b/android/sdremote/src/org/libreoffice/impressremote/BlankScreenFragment.java
index d87565c..4418431 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/BlankScreenFragment.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/BlankScreenFragment.java
@@ -1,5 +1,7 @@
 package org.libreoffice.impressremote;
 
+import org.libreoffice.impressremote.communication.CommunicationService;
+
 import android.app.Fragment;
 import android.graphics.Bitmap;
 import android.graphics.Canvas;
@@ -14,10 +16,10 @@ import android.widget.ImageView;
 
 public class BlankScreenFragment extends Fragment {
 
-	Bitmap mBitmap;
+	CommunicationService mCommunicationService;
 
-	public BlankScreenFragment(Bitmap aBitmap) {
-		mBitmap = aBitmap;
+	public BlankScreenFragment(CommunicationService aCommunicationService) {
+		mCommunicationService = aCommunicationService;
 	}
 
 	@Override
@@ -27,6 +29,9 @@ public class BlankScreenFragment extends Fragment {
 		View v = inflater.inflate(R.layout.fragment_blankscreen, container,
 		                false);
 
+		Bitmap aBitmap = mCommunicationService.getSlideShow().getImage(
+		                mCommunicationService.getSlideShow().getCurrentSlide());
+
 		// Process the image
 		final int borderWidth = 8;
 
@@ -34,19 +39,27 @@ public class BlankScreenFragment extends Fragment {
 		p.setShadowLayer(borderWidth, 0, 0, Color.BLACK);
 
 		RectF aRect = new RectF(borderWidth, borderWidth, borderWidth
-		                + mBitmap.getWidth(), borderWidth + mBitmap.getHeight());
-		Bitmap aOut = Bitmap.createBitmap(mBitmap.getWidth() + 2 * borderWidth,
-		                mBitmap.getHeight() + 2 * borderWidth,
-		                mBitmap.getConfig());
+		                + aBitmap.getWidth(), borderWidth + aBitmap.getHeight());
+		Bitmap aOut = Bitmap.createBitmap(aBitmap.getWidth() + 2 * borderWidth,
+		                aBitmap.getHeight() + 2 * borderWidth,
+		                aBitmap.getConfig());
 		Canvas canvas = new Canvas(aOut);
 		canvas.drawColor(Color.TRANSPARENT);
 		canvas.drawRect(aRect, p);
-		canvas.drawBitmap(mBitmap, null, aRect, null);
+		canvas.drawBitmap(aBitmap, null, aRect, null);
 
 		ImageView aImage = (ImageView) v
 		                .findViewById(R.id.blankscreen_slidepreview);
 		aImage.setImageBitmap(aOut);
+
+		mCommunicationService.getTransmitter().blankScreen();
 		// TODO Auto-generated method stub
 		return v;
 	}
+
+	@Override
+	public void onDestroyView() {
+		super.onDestroyView();
+		mCommunicationService.getTransmitter().resume();
+	}
 }
diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
index a6f6d38..c6b80fe 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
@@ -17,7 +17,6 @@ import android.content.Context;
 import android.content.Intent;
 import android.content.ServiceConnection;
 import android.content.SharedPreferences;
-import android.graphics.Bitmap;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.IBinder;
@@ -152,11 +151,9 @@ public class PresentationActivity extends Activity {
 			boolean aRelevantFragmentVisible = mPresentationFragment
 			                .isVisible() || mThumbnailFragment.isVisible();
 			if (aRelevantFragmentVisible) {
-				Bitmap aBitmap = mCommunicationService.getSlideShow().getImage(
-				                mCommunicationService.getSlideShow()
-				                                .getCurrentSlide());
 
-				BlankScreenFragment aFragment = new BlankScreenFragment(aBitmap);
+				BlankScreenFragment aFragment = new BlankScreenFragment(
+				                mCommunicationService);
 
 				FragmentTransaction ft = getFragmentManager()
 				                .beginTransaction();
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/Transmitter.java b/android/sdremote/src/org/libreoffice/impressremote/communication/Transmitter.java
index 8c3c69f..1a95604 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/Transmitter.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/Transmitter.java
@@ -52,10 +52,14 @@ public class Transmitter {
 	 * @param aColor
 	 */
 	public void blankScreen(Color aColor) {
-		// Fixme: check how to get colour in integer form.
+		// FIXME: check how to get colour in integer form.
 		mClient.sendCommand("presentation_blank_screen\n" + aColor + "\n\n");
 	}
 
+	public void resume() {
+		mClient.sendCommand("presentation_resume\n\n");
+	}
+
 	public void startPresentation() {
 		mClient.sendCommand("presentation_start\n\n");
 	}
commit 45923c50b320d94d7cbd70946162196d6287a93e
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Sat Jul 28 16:13:31 2012 +0200

    Blank screen view showing.
    
    Change-Id: Ica6b740029bb1eb7d55dedec189c944af0027566

diff --git a/android/sdremote/src/org/libreoffice/impressremote/BlankScreenFragment.java b/android/sdremote/src/org/libreoffice/impressremote/BlankScreenFragment.java
index 934baea..d87565c 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/BlankScreenFragment.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/BlankScreenFragment.java
@@ -1,7 +1,52 @@
 package org.libreoffice.impressremote;
 
 import android.app.Fragment;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.RectF;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
 
 public class BlankScreenFragment extends Fragment {
 
+	Bitmap mBitmap;
+
+	public BlankScreenFragment(Bitmap aBitmap) {
+		mBitmap = aBitmap;
+	}
+
+	@Override
+	public View onCreateView(LayoutInflater inflater, ViewGroup container,
+	                Bundle savedInstanceState) {
+
+		View v = inflater.inflate(R.layout.fragment_blankscreen, container,
+		                false);
+
+		// Process the image
+		final int borderWidth = 8;
+
+		Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
+		p.setShadowLayer(borderWidth, 0, 0, Color.BLACK);
+
+		RectF aRect = new RectF(borderWidth, borderWidth, borderWidth
+		                + mBitmap.getWidth(), borderWidth + mBitmap.getHeight());
+		Bitmap aOut = Bitmap.createBitmap(mBitmap.getWidth() + 2 * borderWidth,
+		                mBitmap.getHeight() + 2 * borderWidth,
+		                mBitmap.getConfig());
+		Canvas canvas = new Canvas(aOut);
+		canvas.drawColor(Color.TRANSPARENT);
+		canvas.drawRect(aRect, p);
+		canvas.drawBitmap(mBitmap, null, aRect, null);
+
+		ImageView aImage = (ImageView) v
+		                .findViewById(R.id.blankscreen_slidepreview);
+		aImage.setImageBitmap(aOut);
+		// TODO Auto-generated method stub
+		return v;
+	}
 }
diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
index efb3ae8..a6f6d38 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
@@ -17,6 +17,7 @@ import android.content.Context;
 import android.content.Intent;
 import android.content.ServiceConnection;
 import android.content.SharedPreferences;
+import android.graphics.Bitmap;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.IBinder;
@@ -143,15 +144,27 @@ public class PresentationActivity extends Activity {
 		Intent aIntent;
 		switch (item.getItemId()) {
 		case R.id.actionbar_presentation_submenu_options:
-			//			FragmentTransaction ft = getFragmentManager().beginTransaction();
-			//			ft.replace(R.id.presentation_innerFrame, new SettingsFragment());
-			//			ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
-			//			ft.addToBackStack(null);
-			//			ft.commit();
+
 			aIntent = new Intent(this, SettingsActivity.class);
 			startActivity(aIntent);
 			return true;
 		case R.id.actionbar_presentation_submenu_blank:
+			boolean aRelevantFragmentVisible = mPresentationFragment
+			                .isVisible() || mThumbnailFragment.isVisible();
+			if (aRelevantFragmentVisible) {
+				Bitmap aBitmap = mCommunicationService.getSlideShow().getImage(
+				                mCommunicationService.getSlideShow()
+				                                .getCurrentSlide());
+
+				BlankScreenFragment aFragment = new BlankScreenFragment(aBitmap);
+
+				FragmentTransaction ft = getFragmentManager()
+				                .beginTransaction();
+				ft.replace(R.id.presentation_innerFrame, aFragment);
+				ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+				ft.addToBackStack(null);
+				ft.commit();
+			}
 			return true;
 		default:
 			return super.onOptionsItemSelected(item);
commit 99029f1de9af2ae86124718329804a802ae2fc90
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Sat Jul 28 15:32:24 2012 +0200

    Initial Blank screen layout.
    
    Change-Id: I I I I7af89267be559a44cc3ed2c3ae999a252709b730

diff --git a/android/sdremote/res/drawable/rectangle_black.xml b/android/sdremote/res/drawable/rectangle_black.xml
new file mode 100644
index 0000000..f854e60
--- /dev/null
+++ b/android/sdremote/res/drawable/rectangle_black.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle" >
+
+    <size
+        android:height="240dip"
+        android:width="320dip" />
+
+    <solid android:color="@color/black" />
+
+</shape>
\ No newline at end of file
diff --git a/android/sdremote/res/layout/fragment_blankscreen.xml b/android/sdremote/res/layout/fragment_blankscreen.xml
new file mode 100644
index 0000000..f717f24
--- /dev/null
+++ b/android/sdremote/res/layout/fragment_blankscreen.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:layout_margin="10dip"
+    android:gravity="left"
+    android:orientation="vertical" >
+
+    <ImageView
+        android:id="@+id/blankscreen_blankimage"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:scaleType="fitXY"
+        android:src="@drawable/rectangle_black" />
+
+    <ImageView
+        android:id="@+id/blankscreen_divider"
+        android:layout_width="fill_parent"
+        android:layout_height="1dip"
+        android:layout_below="@+id/blankscreen_blankimage"
+        android:layout_centerHorizontal="true"
+        android:layout_marginTop="10dip"
+        android:src="@color/medium_grey" />
+
+    <ImageView
+        android:id="@+id/blankscreen_slidepreview"
+        android:layout_width="0dip"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_below="@id/blankscreen_divider"
+        android:layout_toLeftOf="@+id/blankscreen_return"
+        android:src="@drawable/rectangle_black" />
+
+    <TextView
+        android:id="@+id/blankscreen_return"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentBottom="true"
+        android:layout_alignParentRight="true"
+        android:gravity="center"
+        android:layout_below="@id/blankscreen_divider"
+        android:text="@string/blankscreen_return" />
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/android/sdremote/res/values/strings.xml b/android/sdremote/res/values/strings.xml
index c3117cf..b803ff0 100644
--- a/android/sdremote/res/values/strings.xml
+++ b/android/sdremote/res/values/strings.xml
@@ -17,4 +17,5 @@
     <string name="options_autodecline">Auto-decline calls</string>
     <string name="options_volumeswitching">Change slides using volume buttons</string>
     <string name="options_switchcomputer">Switch computer</string>
+    <string name="blankscreen_return">Return to Slide</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 8fa0c2d..c95fb0c 100644
--- a/android/sdremote/res/values/styles.xml
+++ b/android/sdremote/res/values/styles.xml
@@ -4,7 +4,9 @@
     <color name="orange">#EE4400</color>
     <color name="grey">#303030</color>
     <color name="white">#FFFFFF</color>
+    <color name="black">#000000</color>
     <color name="light_grey">#E8E9E8</color>
+    <color name="medium_grey">#C1C2C1</color>
 
     <integer name="thumbnail_border_width">3</integer>
 
@@ -45,7 +47,7 @@
         <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>
-         <item name="android:homeAsUpIndicator">@drawable/up_indicator_white</item>
+        <item name="android:homeAsUpIndicator">@drawable/up_indicator_white</item>
     </style>
 
 </resources>
\ No newline at end of file
diff --git a/android/sdremote/src/org/libreoffice/impressremote/BlankScreenFragment.java b/android/sdremote/src/org/libreoffice/impressremote/BlankScreenFragment.java
new file mode 100644
index 0000000..934baea
--- /dev/null
+++ b/android/sdremote/src/org/libreoffice/impressremote/BlankScreenFragment.java
@@ -0,0 +1,7 @@
+package org.libreoffice.impressremote;
+
+import android.app.Fragment;
+
+public class BlankScreenFragment extends Fragment {
+
+}
commit 9e7325a4461f66d2c987e8619ba776e0bf66a456
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Sat Jul 28 14:50:15 2012 +0200

    Volume button switching now setting dependent.
    
    Change-Id: I29b2f4652937995b2cecd10f6f2d7934f25b4b81

diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
index dbcc2e7..efb3ae8 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
@@ -16,11 +16,13 @@ import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.content.ServiceConnection;
+import android.content.SharedPreferences;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.IBinder;
 import android.os.Message;
 import android.os.Messenger;
+import android.preference.PreferenceManager;
 import android.text.format.DateFormat;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
@@ -71,7 +73,13 @@ public class PresentationActivity extends Activity {
 
 	@Override
 	public boolean dispatchKeyEvent(KeyEvent event) {
-		if (mPresentationFragment.isVisible() || mThumbnailFragment.isVisible()) {
+		SharedPreferences aPref = PreferenceManager
+		                .getDefaultSharedPreferences(this);
+		boolean aVolumeSwitching = aPref.getBoolean("option_volumeswitching",
+		                false);
+		boolean aRelevantFragmentVisible = mPresentationFragment.isVisible()
+		                || mThumbnailFragment.isVisible();
+		if (aVolumeSwitching && aRelevantFragmentVisible) {
 
 			int action = event.getAction();
 			int keyCode = event.getKeyCode();
commit 4aedd7cd01d712f9b0863bf7f7bb7aa0e33fbc04
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Sat Jul 28 14:46:44 2012 +0200

    Enabled switching slides with volume buttons.
    
    Change-Id: Iedfacd8c0834c9273a7e805658e82180f748f81b

diff --git a/android/sdremote/res/xml/preferences.xml b/android/sdremote/res/xml/preferences.xml
index b475ca6..e039995 100644
--- a/android/sdremote/res/xml/preferences.xml
+++ b/android/sdremote/res/xml/preferences.xml
@@ -1,7 +1,14 @@
 <?xml version="1.0" encoding="utf-8"?>
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
-    <SwitchPreference android:defaultValue="false" android:title="@string/options_autodecline"/>
-    <SwitchPreference android:defaultValue="false" android:title="@string/options_volumeswitching"/>
 
+    <!-- <SwitchPreference android:defaultValue="false" android:title="@string/options_autodecline" android:key="option_autodecline"/> -->
+    <SwitchPreference
+        android:defaultValue="false"
+        android:key="option_volumeswitching"
+        android:title="@string/options_volumeswitching" />
+
+    <Preference
+        android:key="option_switchcomputer"
+        android:title="@string/options_switchcomputer" />
 
 </PreferenceScreen>
\ 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 8cbfcfd..dbcc2e7 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
@@ -69,6 +69,28 @@ public class PresentationActivity extends Activity {
 		fragmentTransaction.commit();
 	}
 
+	@Override
+	public boolean dispatchKeyEvent(KeyEvent event) {
+		if (mPresentationFragment.isVisible() || mThumbnailFragment.isVisible()) {
+
+			int action = event.getAction();
+			int keyCode = event.getKeyCode();
+			switch (keyCode) {
+			case KeyEvent.KEYCODE_VOLUME_UP:
+				if (action == KeyEvent.ACTION_UP) {
+					mCommunicationService.getTransmitter().nextTransition();
+				}
+				return true;
+			case KeyEvent.KEYCODE_VOLUME_DOWN:
+				if (action == KeyEvent.ACTION_DOWN) {
+					mCommunicationService.getTransmitter().previousTransition();
+				}
+				return true;
+			}
+		}
+		return super.dispatchKeyEvent(event);
+	}
+
 	private ServiceConnection mConnection = new ServiceConnection() {
 		@Override
 		public void onServiceConnected(ComponentName aClassName,
commit 99b5672b44cd274e2cd3d303ce43bca571ecc902
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Sat Jul 28 13:48:57 2012 +0200

    Styled the options activity.
    
    Change-Id: Ideef94c978ae3bad536c9eb4ce740f985441cea1

diff --git a/android/sdremote/AndroidManifest.xml b/android/sdremote/AndroidManifest.xml
index 0f8b0fb..14f457b 100644
--- a/android/sdremote/AndroidManifest.xml
+++ b/android/sdremote/AndroidManifest.xml
@@ -11,9 +11,7 @@
         android:targetSdkVersion="14" />
 
     <application
-        android:icon="@drawable/ic_launcher"
         android:label="@string/app_name"
-        android:logo="@drawable/empty"
         android:theme="@style/Theme.ImpressRemote" >
         <activity
             android:name="TestClient"
@@ -34,6 +32,7 @@
         </activity>
         <activity
             android:name=".SettingsActivity"
+            android:icon="@drawable/icon_options"
             android:label="@string/options" >
         </activity>
     </application>
diff --git a/android/sdremote/res/drawable/icon_options.png b/android/sdremote/res/drawable/icon_options.png
new file mode 100644
index 0000000..ab79d13
Binary files /dev/null and b/android/sdremote/res/drawable/icon_options.png differ
diff --git a/android/sdremote/res/drawable/up_indicator_white.png b/android/sdremote/res/drawable/up_indicator_white.png
new file mode 100644
index 0000000..9a72a23
Binary files /dev/null and b/android/sdremote/res/drawable/up_indicator_white.png differ
diff --git a/android/sdremote/res/values/styles.xml b/android/sdremote/res/values/styles.xml
index 04143c4..8fa0c2d 100644
--- a/android/sdremote/res/values/styles.xml
+++ b/android/sdremote/res/values/styles.xml
@@ -11,8 +11,14 @@
     <color name="thumbnail_border">#B4B4B4</color>
     <color name="thumbnail_border_selected">#EE4400</color>
 
+    <style name="Theme.ImpressRemote.ActionBar.Title" parent="android:style/Widget.Holo.Light.ActionBar">
+        <item name="android:textColor">@color/white</item>
+        <item name="android:textSize">18dp</item>
+    </style>
+
     <style name="Theme.ImpressRemote.ActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
         <item name="android:background">@color/orange</item>
+        <item name="android:titleTextStyle">@style/Theme.ImpressRemote.ActionBar.Title</item>
     </style>
 
     <style name="Theme.ImpressRemote.ActionBarWidget" parent="android:style/Widget.Holo.Light">
@@ -35,11 +41,11 @@
     <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: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>
+         <item name="android:homeAsUpIndicator">@drawable/up_indicator_white</item>
     </style>
 
 </resources>
\ 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 8934520..8cbfcfd 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
@@ -167,10 +167,7 @@ public class PresentationActivity extends Activity {
 		public ActionBarManager() {
 
 			ActionBar aBar = getActionBar();
-			aBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
-			                ActionBar.DISPLAY_SHOW_CUSTOM
-			                                | ActionBar.DISPLAY_SHOW_TITLE
-			                                | ActionBar.DISPLAY_USE_LOGO);
+			aBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
 			aBar.setCustomView(R.layout.presentation_actionbar);
 
 			mThumbnailButton = (ToggleButton) aBar.getCustomView()
diff --git a/android/sdremote/src/org/libreoffice/impressremote/SettingsActivity.java b/android/sdremote/src/org/libreoffice/impressremote/SettingsActivity.java
index 6bdc9fc..d0119a0 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/SettingsActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/SettingsActivity.java
@@ -2,6 +2,7 @@ package org.libreoffice.impressremote;
 
 import android.app.Activity;
 import android.os.Bundle;
+import android.view.MenuItem;
 
 public class SettingsActivity extends Activity {
 
@@ -10,5 +11,17 @@ public class SettingsActivity extends Activity {
 		// TODO Auto-generated method stub
 		super.onCreate(savedInstanceState);
 		setContentView(R.layout.activity_settings);
+		getActionBar().setDisplayHomeAsUpEnabled(true);
+	}
+
+	@Override
+	public boolean onOptionsItemSelected(MenuItem item) {
+		switch (item.getItemId()) {
+		case android.R.id.home:
+			finish();
+			return true;
+		default:
+			return super.onOptionsItemSelected(item);
+		}
 	}
 }
commit a65eb4662c170d64924d909f87136d3a6a07856c
Author: Andrzej J.R. Hunt <andrzej at ahunt.org>
Date:   Sat Jul 28 13:02:13 2012 +0200

    Added options screen.
    
    Change-Id: Ifb7abc67383a72969e37d8e46a14fdaa76e47112

diff --git a/android/sdremote/AndroidManifest.xml b/android/sdremote/AndroidManifest.xml
index 4543b71..0f8b0fb 100644
--- a/android/sdremote/AndroidManifest.xml
+++ b/android/sdremote/AndroidManifest.xml
@@ -17,8 +17,7 @@
         android:theme="@style/Theme.ImpressRemote" >
         <activity
             android:name="TestClient"
-            android:label=""
-            >
+            android:label="" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
 
@@ -33,6 +32,10 @@
             android:name=".PresentationActivity"
             android:label="@string/title_activity_presentation" >
         </activity>
+        <activity
+            android:name=".SettingsActivity"
+            android:label="@string/options" >
+        </activity>
     </application>
 
 </manifest>
\ No newline at end of file
diff --git a/android/sdremote/res/layout/activity_settings.xml b/android/sdremote/res/layout/activity_settings.xml
new file mode 100644
index 0000000..be5e645
--- /dev/null
+++ b/android/sdremote/res/layout/activity_settings.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<fragment xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/settings_fragment"
+    android:name="org.libreoffice.impressremote.SettingsFragment"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent" />
diff --git a/android/sdremote/res/values/strings.xml b/android/sdremote/res/values/strings.xml
index 991d692..c3117cf 100644
--- a/android/sdremote/res/values/strings.xml
+++ b/android/sdremote/res/values/strings.xml
@@ -14,4 +14,7 @@
     <string name="clock_timer_restart">Restart</string>
     <string name="clock_timer_reset">Reset</string>
     <string name="clock_timer_resume">Resume</string>
+    <string name="options_autodecline">Auto-decline calls</string>
+    <string name="options_volumeswitching">Change slides using volume buttons</string>
+    <string name="options_switchcomputer">Switch computer</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 bb11845..04143c4 100644
--- a/android/sdremote/res/values/styles.xml
+++ b/android/sdremote/res/values/styles.xml
@@ -13,7 +13,6 @@
 
     <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/res/xml/preferences.xml b/android/sdremote/res/xml/preferences.xml
new file mode 100644
index 0000000..b475ca6
--- /dev/null
+++ b/android/sdremote/res/xml/preferences.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
+    <SwitchPreference android:defaultValue="false" android:title="@string/options_autodecline"/>
+    <SwitchPreference android:defaultValue="false" android:title="@string/options_volumeswitching"/>
+
+
+</PreferenceScreen>
\ 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 fb24076..8934520 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
@@ -25,6 +25,7 @@ import android.text.format.DateFormat;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
 import android.view.Menu;
+import android.view.MenuItem;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.View.OnClickListener;
@@ -68,13 +69,6 @@ public class PresentationActivity extends Activity {
 		fragmentTransaction.commit();
 	}
 
-	@Override
-	public boolean onCreateOptionsMenu(Menu menu) {
-		getMenuInflater().inflate(R.menu.actionbar_presentation, menu);
-		mActionBarManager = new ActionBarManager();
-		return true;
-	}
-
 	private ServiceConnection mConnection = new ServiceConnection() {
 		@Override
 		public void onServiceConnected(ComponentName aClassName,
@@ -106,6 +100,34 @@ public class PresentationActivity extends Activity {
 		}
 	}
 
+	// ---------------------------------------------- ACTION BAR ---------------
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu) {
+		getMenuInflater().inflate(R.menu.actionbar_presentation, menu);
+		mActionBarManager = new ActionBarManager();
+		return true;
+	}
+
+	@Override
+	public boolean onOptionsItemSelected(MenuItem item) {
+		Intent aIntent;
+		switch (item.getItemId()) {
+		case R.id.actionbar_presentation_submenu_options:
+			//			FragmentTransaction ft = getFragmentManager().beginTransaction();
+			//			ft.replace(R.id.presentation_innerFrame, new SettingsFragment());
+			//			ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+			//			ft.addToBackStack(null);
+			//			ft.commit();
+			aIntent = new Intent(this, SettingsActivity.class);
+			startActivity(aIntent);
+			return true;
+		case R.id.actionbar_presentation_submenu_blank:
+			return true;
+		default:
+			return super.onOptionsItemSelected(item);
+		}
+	}
+
 	private class ActionBarManager implements OnClickListener,
 	                FragmentManager.OnBackStackChangedListener,
 	                TextView.OnEditorActionListener {
@@ -113,6 +135,9 @@ public class PresentationActivity extends Activity {
 		private ToggleButton mTimeLabel;
 		private ToggleButton mThumbnailButton;
 
+		private View mDropdownOptions;
+		private View mDropdownBlank;
+
 		// ------- CLOCKBAR
 		private View mClockBar;
 		private ToggleButton mClockBar_clockButton;
@@ -142,6 +167,10 @@ public class PresentationActivity extends Activity {
 		public ActionBarManager() {
 
 			ActionBar aBar = getActionBar();
+			aBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
+			                ActionBar.DISPLAY_SHOW_CUSTOM
+			                                | ActionBar.DISPLAY_SHOW_TITLE
+			                                | ActionBar.DISPLAY_USE_LOGO);
 			aBar.setCustomView(R.layout.presentation_actionbar);
 
 			mThumbnailButton = (ToggleButton) aBar.getCustomView()
diff --git a/android/sdremote/src/org/libreoffice/impressremote/SettingsActivity.java b/android/sdremote/src/org/libreoffice/impressremote/SettingsActivity.java
new file mode 100644
index 0000000..6bdc9fc
--- /dev/null
+++ b/android/sdremote/src/org/libreoffice/impressremote/SettingsActivity.java
@@ -0,0 +1,14 @@
+package org.libreoffice.impressremote;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class SettingsActivity extends Activity {
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState) {
+		// TODO Auto-generated method stub
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_settings);
+	}
+}
diff --git a/android/sdremote/src/org/libreoffice/impressremote/SettingsFragment.java b/android/sdremote/src/org/libreoffice/impressremote/SettingsFragment.java
new file mode 100644
index 0000000..b6f02f6
--- /dev/null
+++ b/android/sdremote/src/org/libreoffice/impressremote/SettingsFragment.java
@@ -0,0 +1,13 @@
+package org.libreoffice.impressremote;
+
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
+
+public class SettingsFragment extends PreferenceFragment {
+	@Override
+	public void onCreate(Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+
+		addPreferencesFromResource(R.xml.preferences);
+	}
+}


More information about the Libreoffice-commits mailing list