From ff802c08b5d45779fb8a361be4704c2f04bb8d4a Mon Sep 17 00:00:00 2001 From: Artur Dryomov Date: Mon, 9 Sep 2013 01:28:32 +0300 Subject: [PATCH] Add ability to pause and resume a slide show. Change-Id: I5c93cc0b2ad1aa68529ae1e278bd2cb7ad54359d --- android/sdremote/AndroidManifest.xml | 10 +-- .../res/drawable-hdpi/ic_action_resume.png | Bin 0 -> 1410 bytes .../res/drawable-mdpi/ic_action_resume.png | Bin 0 -> 1248 bytes .../res/drawable-xhdpi/ic_action_resume.png | Bin 0 -> 1620 bytes .../res/layout/fragment_empty_slide.xml | 23 ++++++ .../res/menu/menu_action_bar_slide_show.xml | 11 +++ android/sdremote/res/values/colors.xml | 1 + android/sdremote/res/values/dimens.xml | 1 + android/sdremote/res/values/strings.xml | 6 +- .../activity/SlideShowActivity.java | 75 +++++++++++++++--- .../fragment/EmptySlideFragment.java | 30 +++++++ .../fragment/SlidesPagerFragment.java | 4 + 12 files changed, 142 insertions(+), 19 deletions(-) create mode 100755 android/sdremote/res/drawable-hdpi/ic_action_resume.png create mode 100755 android/sdremote/res/drawable-mdpi/ic_action_resume.png create mode 100755 android/sdremote/res/drawable-xhdpi/ic_action_resume.png create mode 100644 android/sdremote/res/layout/fragment_empty_slide.xml create mode 100644 android/sdremote/src/org/libreoffice/impressremote/fragment/EmptySlideFragment.java diff --git a/android/sdremote/AndroidManifest.xml b/android/sdremote/AndroidManifest.xml index 6d7064d87a5b..714b05fd2cbd 100644 --- a/android/sdremote/AndroidManifest.xml +++ b/android/sdremote/AndroidManifest.xml @@ -37,17 +37,17 @@ - - - + + + diff --git a/android/sdremote/res/drawable-hdpi/ic_action_resume.png b/android/sdremote/res/drawable-hdpi/ic_action_resume.png new file mode 100755 index 0000000000000000000000000000000000000000..df8a2ca28e1e3978a59dbe9cf415a59429357084 GIT binary patch literal 1410 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTC$r9IylHmNblJdl&R0hYC{G?O` z&)mfH)S%SF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dZnv1@ zG!Lpb1-Dx)aO%|uIz}H9wMbD769T3m5EGtofgE_!Pt60S_ab1z_LS;2W?*0p@^oU1PZ9MzCuS-Z@1@eQA(D8tnc61wVVaLqcBX29V# zIWsfCC{pB#;hbN;Y=1mG{NVSVChH#?3JPqh|LrZGSga@d$!j@N{9T4gOd3khts8O< z?X^rPXb9`z;YkuzpTR45fIZHj&o?BH>tajpOh?&liEZx)I}SJ}I5=yUdI zwcx(@vCZ>MBKP9@Zw9BTD$?TGZ|G+IGUZf=3##35+)i(c`JQwIC;NGYYfAs7gf=z( zd%E<}-7T*g=REtzXT4)%)}bwz{w}bZpZ#W!zhlhvxU=Q4`JVk@$q@kz*H;xE&f-7v zoz3Lf+=R;*m_w)X*Ww_78!_em8^&}%-Jpxqbc)I$z JtaD0e0syqNvA+NS literal 0 HcmV?d00001 diff --git a/android/sdremote/res/drawable-xhdpi/ic_action_resume.png b/android/sdremote/res/drawable-xhdpi/ic_action_resume.png new file mode 100755 index 0000000000000000000000000000000000000000..51124993df109972aa504c796b17e788a3ed0efd GIT binary patch literal 1620 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+m{l@EB1$5BeXNr6bM+EIYV;~{3xK*A7;Nk-3KEmEQ%e+* zQqwc@Y?a>c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxKsVXI%uvD1M9IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD$Tv3bSNU;+l1ennz|zM-B0$V)JVzP|XC=H|jx7ncO3BHWAB;NpiyW)Z+ZoqGVvir744~DzI`cN=+=uFAB-e&w+(vKt_H^esM;Afr4|esh**NZ(?$0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cmV?d00001 diff --git a/android/sdremote/res/layout/fragment_empty_slide.xml b/android/sdremote/res/layout/fragment_empty_slide.xml new file mode 100644 index 000000000000..5e01fe3bc242 --- /dev/null +++ b/android/sdremote/res/layout/fragment_empty_slide.xml @@ -0,0 +1,23 @@ + + + + + + + + + + diff --git a/android/sdremote/res/menu/menu_action_bar_slide_show.xml b/android/sdremote/res/menu/menu_action_bar_slide_show.xml index eaa2b3d0ea3c..457e6bcfcb88 100644 --- a/android/sdremote/res/menu/menu_action_bar_slide_show.xml +++ b/android/sdremote/res/menu/menu_action_bar_slide_show.xml @@ -19,6 +19,17 @@ android:icon="@drawable/ic_action_timer" android:showAsAction="ifRoom"/> + + + + #55ffffff @color/background_action_bar #7f000000 + @android:color/black #65000000 #35000000 diff --git a/android/sdremote/res/values/dimens.xml b/android/sdremote/res/values/dimens.xml index 05c730363378..9b1e885533f7 100644 --- a/android/sdremote/res/values/dimens.xml +++ b/android/sdremote/res/values/dimens.xml @@ -14,6 +14,7 @@ 8dp 16dp 8dp + 16dp 8dp 40dp diff --git a/android/sdremote/res/values/strings.xml b/android/sdremote/res/values/strings.xml index 02e2cde11066..9fd81f9cd67b 100644 --- a/android/sdremote/res/values/strings.xml +++ b/android/sdremote/res/values/strings.xml @@ -12,7 +12,7 @@ Requirements Connection Creation - Slide Show + Slide show Timer Open source licenses @@ -25,6 +25,8 @@ Slides pager Timer Stop slide show + Pause slide show + Resume slide show Cancel Save @@ -40,6 +42,7 @@ Time is up! Make sure LibreOffice is running on a computer on the same WiFi network. Make sure LibreOffice is running on a computer with Bluetooth enabled. + Paused IP address Name (optional) @@ -54,6 +57,7 @@ Slide preview Slide preview + Empty slide Volume keys actions Switch slides and activate animations using volume keys diff --git a/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java b/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java index a29d817cd405..19b7dbbbf1d2 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java +++ b/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java @@ -29,6 +29,7 @@ import org.libreoffice.impressremote.R; import org.libreoffice.impressremote.communication.CommunicationService; import org.libreoffice.impressremote.communication.SlideShow; import org.libreoffice.impressremote.communication.Timer; +import org.libreoffice.impressremote.fragment.EmptySlideFragment; import org.libreoffice.impressremote.fragment.SlidesGridFragment; import org.libreoffice.impressremote.fragment.SlidesPagerFragment; import org.libreoffice.impressremote.fragment.TimerEditingDialog; @@ -40,7 +41,7 @@ import org.libreoffice.impressremote.util.SavedStates; public class SlideShowActivity extends SherlockFragmentActivity implements ServiceConnection { private static enum Mode { - PAGER, GRID + PAGER, GRID, EMPTY } private Mode mMode; @@ -85,6 +86,9 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi case GRID: return SlidesGridFragment.newInstance(); + case EMPTY: + return EmptySlideFragment.newInstance(); + default: return SlidesPagerFragment.newInstance(); } @@ -314,16 +318,26 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi public boolean onPrepareOptionsMenu(Menu aMenu) { MenuItem aSlidesPagerMenuItem = aMenu.findItem(R.id.menu_slides_pager); MenuItem aSlidesGridMenuItem = aMenu.findItem(R.id.menu_slides_grid); + MenuItem aSlideShowResumeMenuItem = aMenu.findItem(R.id.menu_resume_slide_show); switch (mMode) { case PAGER: + setMenuItemsVisibility(aMenu, true); aSlidesPagerMenuItem.setVisible(false); aSlidesGridMenuItem.setVisible(true); + aSlideShowResumeMenuItem.setVisible(false); break; case GRID: + setMenuItemsVisibility(aMenu, true); aSlidesPagerMenuItem.setVisible(true); aSlidesGridMenuItem.setVisible(false); + aSlideShowResumeMenuItem.setVisible(false); + break; + + case EMPTY: + setMenuItemsVisibility(aMenu, false); + aSlideShowResumeMenuItem.setVisible(true); break; default: @@ -333,38 +347,47 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi return super.onPrepareOptionsMenu(aMenu); } + private void setMenuItemsVisibility(Menu aMenu, boolean aAreItemsVisible) { + for (int aItemIndex = 0; aItemIndex < aMenu.size(); aItemIndex++) { + aMenu.getItem(aItemIndex).setVisible(aAreItemsVisible); + } + } + @Override public boolean onOptionsItemSelected(MenuItem aMenuItem) { switch (aMenuItem.getItemId()) { case android.R.id.home: navigateUp(); - return true; case R.id.menu_slides_grid: - mMode = Mode.GRID; - - setUpFragment(); - refreshActionBarMenu(); - + changeMode(Mode.GRID); return true; case R.id.menu_slides_pager: - mMode = Mode.PAGER; - - setUpFragment(); - refreshActionBarMenu(); - + changeMode(Mode.PAGER); return true; case R.id.menu_timer: callTimer(); + return true; + case R.id.menu_resume_slide_show: + changeMode(Mode.PAGER); + setUpSlideShowInformation(); + resumeSlideShow(); + resumeTimer(); + return true; + + case R.id.menu_pause_slide_show: + changeMode(Mode.EMPTY); + setUpSlideShowPausedInformation(); + pauseSlideShow(); + pauseTimer(); return true; case R.id.menu_stop_slide_show: stopSlideShow(); - return true; default: @@ -376,6 +399,13 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi finish(); } + private void changeMode(Mode aMode) { + mMode = aMode; + + setUpFragment(); + refreshActionBarMenu(); + } + private void refreshActionBarMenu() { supportInvalidateOptionsMenu(); } @@ -410,6 +440,25 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi aTimerDialog.show(getSupportFragmentManager(), TimerSettingDialog.TAG); } + private void resumeSlideShow() { + mCommunicationService.getTransmitter().resumePresentation(); + } + + private void pauseSlideShow() { + mCommunicationService.getTransmitter().setUpBlankScreen(); + } + + private void setUpSlideShowPausedInformation() { + ActionBar aActionBar = getSupportActionBar(); + + aActionBar.setTitle(R.string.title_slide_show); + aActionBar.setSubtitle(R.string.message_paused); + } + + private void pauseTimer() { + mCommunicationService.getSlideShow().getTimer().pause(); + } + private void stopSlideShow() { mCommunicationService.getTransmitter().stopPresentation(); diff --git a/android/sdremote/src/org/libreoffice/impressremote/fragment/EmptySlideFragment.java b/android/sdremote/src/org/libreoffice/impressremote/fragment/EmptySlideFragment.java new file mode 100644 index 000000000000..014ad7fb9a70 --- /dev/null +++ b/android/sdremote/src/org/libreoffice/impressremote/fragment/EmptySlideFragment.java @@ -0,0 +1,30 @@ +/* -*- Mode: Java; 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.fragment; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.actionbarsherlock.app.SherlockFragment; +import org.libreoffice.impressremote.R; + +public class EmptySlideFragment extends SherlockFragment { + public static EmptySlideFragment newInstance() { + return new EmptySlideFragment(); + } + + @Override + public View onCreateView(LayoutInflater aInflater, ViewGroup aContainer, Bundle aSavedInstance) { + return aInflater.inflate(R.layout.fragment_empty_slide, aContainer, false); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java index ae53035d054f..e3c921076d39 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java @@ -69,6 +69,10 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn } private void setUpSlidesPager() { + if (!isServiceBound()) { + return; + } + if (!isAdded()) { return; }