From 7c0ddee3f8d8e2d4f95e77fe67613c82dbd172bd Mon Sep 17 00:00:00 2001 From: "Andrzej J.R. Hunt" Date: Wed, 25 Jul 2012 14:28:59 +0200 Subject: First piece of ActionBar implemented. Change-Id: I3b0a920da177ef4f11347fa50ddc3a44597b6824 --- android/sdremote/AndroidManifest.xml | 11 +-- android/sdremote/res/drawable/empty.png | Bin 0 -> 107 bytes android/sdremote/res/drawable/icon_thumbs.png | Bin 0 -> 175 bytes .../sdremote/res/layout/fragment_presentation.xml | 5 ++ .../sdremote/res/layout/presentation_actionbar.xml | 22 ++++++ .../sdremote/res/menu/actionbar_presentation.xml | 20 ++--- android/sdremote/res/values/strings.xml | 2 +- android/sdremote/res/values/styles.xml | 27 ++++++- .../impressremote/ActionBarManager.java | 69 ---------------- .../impressremote/PresentationActivity.java | 88 ++++++++++++++++++++- .../impressremote/PresentationFragment.java | 38 ++------- .../org/libreoffice/impressremote/TestClient.java | 1 + 12 files changed, 162 insertions(+), 121 deletions(-) create mode 100644 android/sdremote/res/drawable/empty.png create mode 100644 android/sdremote/res/drawable/icon_thumbs.png create mode 100644 android/sdremote/res/layout/presentation_actionbar.xml delete mode 100644 android/sdremote/src/org/libreoffice/impressremote/ActionBarManager.java (limited to 'android/sdremote') 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 @@ + android:label="" + > @@ -27,16 +29,9 @@ - - - - - - - diff --git a/android/sdremote/res/drawable/empty.png b/android/sdremote/res/drawable/empty.png new file mode 100644 index 000000000000..8705a3df4191 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 000000000000..ae10accd7ef6 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 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" /> + + + + + + + + \ 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 @@ - - - - - - - + + - - + + - \ 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 @@ Handle to resize view. Blank Screen Options - HH:mm + hh:mm h:m:ss \ 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 @@ - + #EE4400 + #303030 + #FFFFFF #E8E9E8 3 @@ -13,8 +15,31 @@ @color/orange + + + + + + + \ 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 -- cgit