summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2012-07-25 14:28:59 +0200
committerMichael Meeks <michael.meeks@suse.com>2012-08-06 10:23:01 +0100
commit7c0ddee3f8d8e2d4f95e77fe67613c82dbd172bd (patch)
tree7c28c0f94ff9bf577401aed9ae5ec71bce2d478a /android
parent71a2d202a049d2ed383b1b363055aace0c21bc93 (diff)
First piece of ActionBar implemented.
Change-Id: I3b0a920da177ef4f11347fa50ddc3a44597b6824
Diffstat (limited to 'android')
-rw-r--r--android/sdremote/AndroidManifest.xml11
-rw-r--r--android/sdremote/res/drawable/empty.pngbin0 -> 107 bytes
-rw-r--r--android/sdremote/res/drawable/icon_thumbs.pngbin0 -> 175 bytes
-rw-r--r--android/sdremote/res/layout/fragment_presentation.xml5
-rw-r--r--android/sdremote/res/layout/presentation_actionbar.xml22
-rw-r--r--android/sdremote/res/menu/actionbar_presentation.xml20
-rw-r--r--android/sdremote/res/values/strings.xml2
-rw-r--r--android/sdremote/res/values/styles.xml27
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/ActionBarManager.java69
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java88
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/PresentationFragment.java38
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/TestClient.java1
12 files changed, 162 insertions, 121 deletions
diff --git a/android/sdremote/AndroidManifest.xml b/android/sdremote/AndroidManifest.xml
index 689e0ecfe9ee..4543b718569a 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 000000000000..8705a3df4191
--- /dev/null
+++ b/android/sdremote/res/drawable/empty.png
Binary files differ
diff --git a/android/sdremote/res/drawable/icon_thumbs.png b/android/sdremote/res/drawable/icon_thumbs.png
new file mode 100644
index 000000000000..ae10accd7ef6
--- /dev/null
+++ b/android/sdremote/res/drawable/icon_thumbs.png
Binary files differ
diff --git a/android/sdremote/res/layout/fragment_presentation.xml b/android/sdremote/res/layout/fragment_presentation.xml
index 2d17759a3c72..2b58bde0768c 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 000000000000..01f0d51d830d
--- /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 020fae1d49d5..03524efbac28 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 c677dcb5623f..7c9dae3e4441 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 fdc39269b828..04143c4958ef 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 33ea95cc04fa..000000000000
--- 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 05c5c4a627b7..8b6d75f6d1d5 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 aec285bf819e..78625398bcae 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 5620c5b400b9..501cf978e727 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