android/sdremote/AndroidManifest.xml | 10 android/sdremote/res/drawable-hdpi/ic_action_resume.png |binary android/sdremote/res/drawable-mdpi/ic_action_resume.png |binary android/sdremote/res/drawable-xhdpi/ic_action_resume.png |binary android/sdremote/res/layout-land/fragment_empty_slide.xml | 8 android/sdremote/res/layout-land/fragment_slides_pager.xml | 9 android/sdremote/res/layout/fragment_empty_slide.xml | 23 android/sdremote/res/layout/fragment_slides_pager.xml | 75 +-- android/sdremote/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 | 7 android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java | 75 ++- android/sdremote/src/org/libreoffice/impressremote/adapter/SlidesPagerAdapter.java | 10 android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java | 47 + android/sdremote/src/org/libreoffice/impressremote/fragment/ComputersFragment.java | 247 +++++----- android/sdremote/src/org/libreoffice/impressremote/fragment/EmptySlideFragment.java | 30 + android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java | 71 ++ android/sdremote/src/org/libreoffice/impressremote/util/BluetoothOperator.java | 40 + android/sdremote/src/org/libreoffice/impressremote/util/Fragments.java | 2 android/sdremote/src/org/libreoffice/impressremote/util/SavedStates.java | 2 21 files changed, 470 insertions(+), 199 deletions(-)
New commits: commit 06b632f0d367178b7266e50c6f140ef36984733f Author: Artur Dryomov <artur.dryo...@gmail.com> Date: Wed Sep 11 01:17:51 2013 +0300 Fix notes jumps. * Remove empty spaces not reset while changing text via TextSwitcher. * Scroll notes to the top on changes because outer ScrollView remembers current position not respecting TextSwitcher state of course. Change-Id: I3e9ba458e4ce6b13e5b02675ca28d6c7c5829f00 diff --git a/android/sdremote/res/layout/fragment_slides_pager.xml b/android/sdremote/res/layout/fragment_slides_pager.xml index d572db0..04a6294 100644 --- a/android/sdremote/res/layout/fragment_slides_pager.xml +++ b/android/sdremote/res/layout/fragment_slides_pager.xml @@ -28,6 +28,7 @@ android:paddingTop="@dimen/padding_header"/> <ScrollView + android:id="@+id/scroll_notes" android:layout_width="wrap_content" android:layout_height="wrap_content"> @@ -35,6 +36,7 @@ android:id="@+id/text_switcher_notes" android:inAnimation="@android:anim/fade_in" android:outAnimation="@android:anim/fade_out" + android:measureAllChildren="false" android:paddingTop="@dimen/padding_slide_notes" android:paddingLeft="@dimen/padding_slide_notes" android:paddingRight="@dimen/padding_slide_notes" diff --git a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java index aa86de0..29de294 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java @@ -24,6 +24,7 @@ import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ScrollView; import android.widget.TextSwitcher; import com.actionbarsherlock.app.SherlockFragment; @@ -143,6 +144,7 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn if (areSlideNotesAvailable(aSlideIndex)) { showSlideNotes(aSlideIndex); + scrollSlideNotes(); } else { hideSlideNotes(); @@ -172,6 +174,12 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn return (TextSwitcher) getView().findViewById(R.id.text_switcher_notes); } + private void scrollSlideNotes() { + ScrollView aSlideNotesScroll = (ScrollView) getView().findViewById(R.id.scroll_notes); + + aSlideNotesScroll.scrollTo(0, 0); + } + private void hideSlideNotes() { TextSwitcher aSlideNotesSwitcher = getSlideNotesSwitcher(); commit 5dd70c5c9b3e8cc7313285c2eae31b8d4f7a8d60 Author: Artur Dryomov <artur.dryo...@gmail.com> Date: Tue Sep 10 22:40:41 2013 +0300 Add ability to change transactions via clicking a slide. Change-Id: Ifc9344c53492a053b15bc0f005e881bc09077473 diff --git a/android/sdremote/src/org/libreoffice/impressremote/adapter/SlidesPagerAdapter.java b/android/sdremote/src/org/libreoffice/impressremote/adapter/SlidesPagerAdapter.java index be6f84f..328dc97 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/adapter/SlidesPagerAdapter.java +++ b/android/sdremote/src/org/libreoffice/impressremote/adapter/SlidesPagerAdapter.java @@ -25,11 +25,15 @@ public class SlidesPagerAdapter extends PagerAdapter { private final SlideShow mSlideShow; - public SlidesPagerAdapter(Context aContext, SlideShow aSlideShow) { + private final View.OnClickListener mSlideClickListener; + + public SlidesPagerAdapter(Context aContext, SlideShow aSlideShow, View.OnClickListener aSlideClickListener) { mLayoutInflater = LayoutInflater.from(aContext); mImageLoader = new ImageLoader(aContext.getResources(), R.drawable.slide_unknown); mSlideShow = aSlideShow; + + mSlideClickListener = aSlideClickListener; } @Override @@ -48,6 +52,10 @@ public class SlidesPagerAdapter extends PagerAdapter { setUpUnknownSlidePreview(aSlideView); } + // ViewPager itself cannot handle click events, + // so we need to use hacks. Android is good. + aSlideView.setOnClickListener(mSlideClickListener); + aViewGroup.addView(aSlideView); return aSlideView; diff --git a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java index f12b3d8..aa86de0 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java @@ -33,7 +33,7 @@ import org.libreoffice.impressremote.R; import org.libreoffice.impressremote.adapter.SlidesPagerAdapter; import org.libreoffice.impressremote.communication.CommunicationService; -public class SlidesPagerFragment extends SherlockFragment implements ServiceConnection, ViewPager.OnPageChangeListener { +public class SlidesPagerFragment extends SherlockFragment implements ServiceConnection, ViewPager.OnPageChangeListener, View.OnClickListener { private CommunicationService mCommunicationService; private BroadcastReceiver mIntentsReceiver; @@ -92,7 +92,25 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn private PagerAdapter buildSlidesAdapter() { SlideShow aSlideShow = mCommunicationService.getSlideShow(); - return new SlidesPagerAdapter(getActivity(), aSlideShow); + return new SlidesPagerAdapter(getActivity(), aSlideShow, this); + } + + @Override + public void onClick(View aView) { + if (!isLastSlideDisplayed()) { + showNextTransition(); + } + } + + private boolean isLastSlideDisplayed() { + int aCurrentSlideIndex = mCommunicationService.getSlideShow().getHumanCurrentSlideIndex(); + int aSlidesCount = mCommunicationService.getSlideShow().getSlidesCount(); + + return aCurrentSlideIndex == aSlidesCount; + } + + private void showNextTransition() { + mCommunicationService.getTransmitter().performNextTransition(); } private int getSlidesMargin() { commit ca5c6e9696048fca9cafba632b574ca4c351b4dd Author: Artur Dryomov <artur.dryo...@gmail.com> Date: Tue Sep 10 22:03:12 2013 +0300 Add saving progress message state between orientation changes. Change-Id: Ic74810e90ca882f734ae7d1fab4b250908ae9c49 diff --git a/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputersFragment.java b/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputersFragment.java index d249588..0c70f52 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputersFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputersFragment.java @@ -23,6 +23,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.support.v4.content.LocalBroadcastManager; +import android.text.TextUtils; import android.view.ContextMenu; import android.view.LayoutInflater; import android.view.View; @@ -42,6 +43,7 @@ import org.libreoffice.impressremote.util.Intents; import org.libreoffice.impressremote.R; import org.libreoffice.impressremote.communication.CommunicationService; import org.libreoffice.impressremote.communication.Server; +import org.libreoffice.impressremote.util.SavedStates; public class ComputersFragment extends SherlockListFragment implements ServiceConnection, Runnable { private static final int SHOWING_PROGRESS_MESSAGE_DELAY_IN_SECONDS = 10; @@ -90,6 +92,25 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo } @Override + public void onViewStateRestored(Bundle aSavedInstanceState) { + super.onViewStateRestored(aSavedInstanceState); + + if (aSavedInstanceState == null) { + return; + } + + loadProgressMessage(aSavedInstanceState); + } + + private void loadProgressMessage(Bundle aSavedInstanceState) { + boolean aProgressMessageDisplayed = aSavedInstanceState.getBoolean(SavedStates.Keys.PROGRESS_MESSAGE); + + if (aProgressMessageDisplayed) { + showProgressMessage(); + } + } + + @Override public void onActivityCreated(Bundle aSavedInstanceState) { super.onActivityCreated(aSavedInstanceState); @@ -435,6 +456,19 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo } @Override + public void onSaveInstanceState(Bundle aOutState) { + super.onSaveInstanceState(aOutState); + + saveProgressMessage(aOutState); + } + + private void saveProgressMessage(Bundle aOutState) { + boolean aProgressMessageDisplayed = !TextUtils.isEmpty(getProgressMessageView().getText().toString()); + + aOutState.putBoolean(SavedStates.Keys.PROGRESS_MESSAGE, aProgressMessageDisplayed); + } + + @Override public void onDestroy() { super.onDestroy(); diff --git a/android/sdremote/src/org/libreoffice/impressremote/util/SavedStates.java b/android/sdremote/src/org/libreoffice/impressremote/util/SavedStates.java index c9339c8..0ec6b56 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/util/SavedStates.java +++ b/android/sdremote/src/org/libreoffice/impressremote/util/SavedStates.java @@ -8,6 +8,8 @@ public final class SavedStates { private Keys() { } + public static final String PROGRESS_MESSAGE = "PROGRESS_MESSAGE"; + public static final String LAYOUT_INDEX = "LAYOUT_INDEX"; public static final String PIN = "PIN"; commit e9d61192574ea7de22beed2644868bfba319ff91 Author: Artur Dryomov <artur.dryo...@gmail.com> Date: Tue Sep 10 21:08:50 2013 +0300 Remove notes from the landscape layout. Ignoring tablets at moment. Change-Id: Ie2ac0840cea994e942b2f7e1a7d4a2e73ebd12de diff --git a/android/sdremote/res/layout-land/fragment_empty_slide.xml b/android/sdremote/res/layout-land/fragment_empty_slide.xml new file mode 100644 index 0000000..37a733d --- /dev/null +++ b/android/sdremote/res/layout-land/fragment_empty_slide.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<ImageView xmlns:android="http://schemas.android.com/apk/res/android" + android:src="@color/background_slide_empty" + android:contentDescription="@string/description_empty_slide" + android:layout_gravity="center" + android:padding="@dimen/padding_empty_slide_layout" + android:layout_width="match_parent" + android:layout_height="match_parent"/> \ No newline at end of file diff --git a/android/sdremote/res/layout-land/fragment_slides_pager.xml b/android/sdremote/res/layout-land/fragment_slides_pager.xml new file mode 100644 index 0000000..c539b852 --- /dev/null +++ b/android/sdremote/res/layout-land/fragment_slides_pager.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<android.support.v4.view.ViewPager + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/pager_slides" + android:layout_gravity="center" + android:paddingTop="@dimen/padding_slides_pager" + android:paddingBottom="@dimen/padding_slides_pager" + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> \ No newline at end of file diff --git a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java index f8769f3..f12b3d8 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java @@ -119,6 +119,10 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn } private void setUpSlideNotes(int aSlideIndex) { + if (!isSlideNotesLayoutAvailable()) { + return; + } + if (areSlideNotesAvailable(aSlideIndex)) { showSlideNotes(aSlideIndex); } @@ -127,6 +131,12 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn } } + private boolean isSlideNotesLayoutAvailable() { + ViewGroup aSlideNotesLayout = (ViewGroup) getView().findViewById(R.id.layout_notes); + + return aSlideNotesLayout != null; + } + private boolean areSlideNotesAvailable(int aSlideIndex) { String aSlideNotes = mCommunicationService.getSlideShow().getSlideNotes(aSlideIndex); commit 54433a11e711a440f698c94edcd22379222db1ce Author: Artur Dryomov <artur.dryo...@gmail.com> Date: Tue Sep 10 12:24:19 2013 +0300 Remove hiding notes section when there are no notes. Show warning instead. This change should help avoiding users confusing when they see half of the screen empty without any reason. Change-Id: Ic229e80fc56a9ad8a419dc19b0784213b1fe3a68 diff --git a/android/sdremote/res/layout/fragment_slides_pager.xml b/android/sdremote/res/layout/fragment_slides_pager.xml index 18308a2..d572db0 100644 --- a/android/sdremote/res/layout/fragment_slides_pager.xml +++ b/android/sdremote/res/layout/fragment_slides_pager.xml @@ -13,59 +13,46 @@ android:layout_width="match_parent" android:layout_height="0dp"/> - <ViewAnimator - android:id="@+id/view_animator" - android:inAnimation="@android:anim/fade_in" - android:outAnimation="@android:anim/fade_out" + <LinearLayout + android:id="@+id/layout_notes" + android:orientation="vertical" + android:paddingLeft="@dimen/padding_slides_pager" + android:paddingRight="@dimen/padding_slides_pager" android:layout_weight="3" android:layout_width="match_parent" android:layout_height="0dp"> - <View - android:id="@+id/view_empty" - android:layout_width="match_parent" - android:layout_height="match_parent"/> - - <LinearLayout - android:id="@+id/layout_notes" - android:orientation="vertical" - android:paddingLeft="@dimen/padding_slides_pager" - android:paddingRight="@dimen/padding_slides_pager" - android:layout_width="match_parent" - android:layout_height="match_parent"> - - <TextView - style="@style/SectionHeader" - android:text="@string/header_notes" - android:paddingTop="@dimen/padding_header"/> - - <ScrollView - android:layout_width="wrap_content" + <TextView + style="@style/SectionHeader" + android:text="@string/header_notes" + android:paddingTop="@dimen/padding_header"/> + + <ScrollView + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + + <TextSwitcher + android:id="@+id/text_switcher_notes" + android:inAnimation="@android:anim/fade_in" + android:outAnimation="@android:anim/fade_out" + android:paddingTop="@dimen/padding_slide_notes" + android:paddingLeft="@dimen/padding_slide_notes" + android:paddingRight="@dimen/padding_slide_notes" + android:layout_width="match_parent" android:layout_height="wrap_content"> - <TextSwitcher - android:id="@+id/text_switcher_notes" - android:inAnimation="@android:anim/fade_in" - android:outAnimation="@android:anim/fade_out" - android:paddingTop="@dimen/padding_slide_notes" - android:paddingLeft="@dimen/padding_slide_notes" - android:paddingRight="@dimen/padding_slide_notes" + <TextView android:layout_width="match_parent" - android:layout_height="wrap_content"> + android:layout_height="wrap_content"/> - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content"/> - <TextView - android:layout_width="match_parent" - android:layout_height="wrap_content"/> - - </TextSwitcher> + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content"/> - </ScrollView> + </TextSwitcher> - </LinearLayout> + </ScrollView> - </ViewAnimator> + </LinearLayout> </LinearLayout> diff --git a/android/sdremote/res/values/strings.xml b/android/sdremote/res/values/strings.xml index 9fd81f9..0eefa95 100644 --- a/android/sdremote/res/values/strings.xml +++ b/android/sdremote/res/values/strings.xml @@ -43,6 +43,7 @@ <string name="message_search_wifi">Make sure LibreOffice is running on a computer on the same WiFi network.</string> <string name="message_search_bluetooth">Make sure LibreOffice is running on a computer with Bluetooth enabled.</string> <string name="message_paused">Paused</string> + <string name="message_notes_empty">Nothing here.</string> <string name="hint_ip_address">IP address</string> <string name="hint_name">Name (optional)</string> diff --git a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java index e3c9210..f8769f3 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java @@ -21,12 +21,10 @@ import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.text.Html; import android.text.TextUtils; -import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextSwitcher; -import android.widget.ViewAnimator; import com.actionbarsherlock.app.SherlockFragment; import org.libreoffice.impressremote.communication.SlideShow; @@ -84,6 +82,7 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn aSlidesPager.setOnPageChangeListener(this); setUpCurrentSlide(); + setUpCurrentSlideNotes(); } private ViewPager getSlidesPager() { @@ -106,6 +105,12 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn getSlidesPager().setCurrentItem(aSlideShow.getCurrentSlideIndex()); } + private void setUpCurrentSlideNotes() { + SlideShow aSlideShow = mCommunicationService.getSlideShow(); + + setUpSlideNotes(aSlideShow.getCurrentSlideIndex()); + } + @Override public void onPageSelected(int aPosition) { mCommunicationService.getTransmitter().setCurrentSlide(aPosition); @@ -129,28 +134,20 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn } private void showSlideNotes(int aSlideIndex) { - ViewAnimator aViewAnimator = (ViewAnimator) getView().findViewById(R.id.view_animator); - ViewGroup aNotesLayout = (ViewGroup) getView().findViewById(R.id.layout_notes); - - if (aViewAnimator.getDisplayedChild() != aViewAnimator.indexOfChild(aNotesLayout)) { - aViewAnimator.setDisplayedChild(aViewAnimator.indexOfChild(aNotesLayout)); - } + TextSwitcher aSlideNotesSwitcher = getSlideNotesSwitcher(); + String aSlideNotes = mCommunicationService.getSlideShow().getSlideNotes(aSlideIndex); - setSlideNotes(aSlideIndex); + aSlideNotesSwitcher.setText(Html.fromHtml(aSlideNotes)); } - private void setSlideNotes(int aSlideIndex) { - TextSwitcher aSlideNotesTextSwitcher = (TextSwitcher) getView().findViewById(R.id.text_switcher_notes); - String aSlideNotes = mCommunicationService.getSlideShow().getSlideNotes(aSlideIndex); - - aSlideNotesTextSwitcher.setText(Html.fromHtml(aSlideNotes)); + private TextSwitcher getSlideNotesSwitcher() { + return (TextSwitcher) getView().findViewById(R.id.text_switcher_notes); } private void hideSlideNotes() { - ViewAnimator aViewAnimator = (ViewAnimator) getView().findViewById(R.id.view_animator); - View aEmptyView = getView().findViewById(R.id.view_empty); + TextSwitcher aSlideNotesSwitcher = getSlideNotesSwitcher(); - aViewAnimator.setDisplayedChild(aViewAnimator.indexOfChild(aEmptyView)); + aSlideNotesSwitcher.setText(getString(R.string.message_notes_empty)); } @Override commit 2dfaabc1bab1cf20110e984010c96a5b94973db8 Author: Artur Dryomov <artur.dryo...@gmail.com> Date: Mon Sep 9 11:12:55 2013 +0300 Fix null pointer exception for devices without Bluetooth. Change-Id: If44089824fe48b302f6e75ccbbfb3a6843016723 diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java index f2ead28..d7915c3 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java @@ -302,6 +302,10 @@ public class CommunicationService extends Service implements Runnable, MessagesL } private void restoreBluetoothState() { + if (!BluetoothOperator.isStateValid(mBluetoothState)) { + return; + } + if (mBluetoothState.wasBluetoothEnabled()) { return; } diff --git a/android/sdremote/src/org/libreoffice/impressremote/util/BluetoothOperator.java b/android/sdremote/src/org/libreoffice/impressremote/util/BluetoothOperator.java index 4be74e1..56b05aa 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/util/BluetoothOperator.java +++ b/android/sdremote/src/org/libreoffice/impressremote/util/BluetoothOperator.java @@ -39,9 +39,17 @@ public final class BluetoothOperator { } public static State getState() { + if (!isAvailable()) { + return null; + } + return new State(getAdapter().isEnabled()); } + public static boolean isStateValid(State aState) { + return aState != null; + } + public static void enable() { if (!isAvailable()) { return; commit ff802c08b5d45779fb8a361be4704c2f04bb8d4a Author: Artur Dryomov <artur.dryo...@gmail.com> Date: Mon Sep 9 01:28:32 2013 +0300 Add ability to pause and resume a slide show. Change-Id: I5c93cc0b2ad1aa68529ae1e278bd2cb7ad54359d diff --git a/android/sdremote/AndroidManifest.xml b/android/sdremote/AndroidManifest.xml index 6d7064d..714b05f 100644 --- a/android/sdremote/AndroidManifest.xml +++ b/android/sdremote/AndroidManifest.xml @@ -38,17 +38,17 @@ </activity> <activity - android:name=".activity.ComputerConnectionActivity" - android:label="@string/title_connection"> - </activity> - - <activity android:name=".activity.ComputerCreationActivity" android:label="@string/title_creation" android:theme="@style/Theme.ImpressRemote.ComputerCreation"> </activity> <activity + android:name=".activity.ComputerConnectionActivity" + android:label="@string/title_connection"> + </activity> + + <activity android:name=".activity.SlideShowActivity" android:label="@string/title_slide_show"> </activity> 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 0000000..df8a2ca Binary files /dev/null and b/android/sdremote/res/drawable-hdpi/ic_action_resume.png differ diff --git a/android/sdremote/res/drawable-mdpi/ic_action_resume.png b/android/sdremote/res/drawable-mdpi/ic_action_resume.png new file mode 100755 index 0000000..6a40cd5 Binary files /dev/null and b/android/sdremote/res/drawable-mdpi/ic_action_resume.png differ 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 0000000..5112499 Binary files /dev/null and b/android/sdremote/res/drawable-xhdpi/ic_action_resume.png differ 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 0000000..5e01fe3 --- /dev/null +++ b/android/sdremote/res/layout/fragment_empty_slide.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:gravity="center" + android:padding="@dimen/padding_empty_slide_layout" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <ImageView + android:src="@color/background_slide_empty" + android:contentDescription="@string/description_empty_slide" + android:layout_weight="4" + android:layout_width="match_parent" + android:layout_height="0dp"/> + + + <View + android:layout_weight="3" + android:layout_width="match_parent" + android:layout_height="0dp"/> + +</LinearLayout> + 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 eaa2b3d..457e6bc 100644 --- a/android/sdremote/res/menu/menu_action_bar_slide_show.xml +++ b/android/sdremote/res/menu/menu_action_bar_slide_show.xml @@ -20,6 +20,17 @@ android:showAsAction="ifRoom"/> <item + android:id="@+id/menu_resume_slide_show" + android:title="@string/menu_resume_slide_show" + android:icon="@drawable/ic_action_resume" + android:showAsAction="always"/> + + <item + android:id="@+id/menu_pause_slide_show" + android:title="@string/menu_pause_slide_show" + android:showAsAction="never"/> + + <item android:id="@+id/menu_stop_slide_show" android:title="@string/menu_stop_slide_show" android:showAsAction="never"/> diff --git a/android/sdremote/res/values/colors.xml b/android/sdremote/res/values/colors.xml index f43e8f1..049c9b5 100644 --- a/android/sdremote/res/values/colors.xml +++ b/android/sdremote/res/values/colors.xml @@ -5,6 +5,7 @@ <color name="background_action_bar_divider">#55ffffff</color> <color name="background_header">@color/background_action_bar</color> <color name="background_slide_index">#7f000000</color> + <color name="background_slide_empty">@android:color/black</color> <color name="stroke_grid_slide">#65000000</color> <color name="stroke_pager_slide">#35000000</color> diff --git a/android/sdremote/res/values/dimens.xml b/android/sdremote/res/values/dimens.xml index 05c7303..9b1e885 100644 --- a/android/sdremote/res/values/dimens.xml +++ b/android/sdremote/res/values/dimens.xml @@ -14,6 +14,7 @@ <dimen name="padding_slide_notes">8dp</dimen> <dimen name="padding_help">16dp</dimen> <dimen name="padding_section_item">8dp</dimen> + <dimen name="padding_empty_slide_layout">16dp</dimen> <dimen name="padding_horizontal_list_item">8dp</dimen> <dimen name="padding_horizontal_connection_layout">40dp</dimen> diff --git a/android/sdremote/res/values/strings.xml b/android/sdremote/res/values/strings.xml index 02e2cde..9fd81f9 100644 --- a/android/sdremote/res/values/strings.xml +++ b/android/sdremote/res/values/strings.xml @@ -12,7 +12,7 @@ <string name="title_requirements">Requirements</string> <string name="title_connection">Connection</string> <string name="title_creation">Creation</string> - <string name="title_slide_show">Slide Show</string> + <string name="title_slide_show">Slide show</string> <string name="title_timer">Timer</string> <string name="menu_licenses">Open source licenses</string> @@ -25,6 +25,8 @@ <string name="menu_slides_pager">Slides pager</string> <string name="menu_timer">Timer</string> <string name="menu_stop_slide_show">Stop slide show</string> + <string name="menu_pause_slide_show">Pause slide show</string> + <string name="menu_resume_slide_show">Resume slide show</string> <string name="button_cancel">Cancel</string> <string name="button_save">Save</string> @@ -40,6 +42,7 @@ <string name="message_time_is_up">Time is up!</string> <string name="message_search_wifi">Make sure LibreOffice is running on a computer on the same WiFi network.</string> <string name="message_search_bluetooth">Make sure LibreOffice is running on a computer with Bluetooth enabled.</string> + <string name="message_paused">Paused</string> <string name="hint_ip_address">IP address</string> <string name="hint_name">Name (optional)</string> @@ -54,6 +57,7 @@ <string name="description_pager_slide">Slide preview</string> <string name="description_grid_slide">Slide preview</string> + <string name="description_empty_slide">Empty slide</string> <string name="preferences_volume_keys_actions_title">Volume keys actions</string> <string name="preferences_volume_keys_actions_summary">Switch slides and activate animations using volume keys</string> diff --git a/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java b/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java index a29d817..19b7dbb 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 0000000..014ad7f --- /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 ae53035..e3c9210 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; } commit 21e5de7d5630605735f4572369e37d7bab0a5522 Author: Artur Dryomov <artur.dryo...@gmail.com> Date: Sun Sep 8 16:20:04 2013 +0300 Fix servers search behaviour. * Start search and stop it during the lifecycle. Before this change searching was a constant process draining battery. * Enable and disable Bluetooth according to the service lifecycle. This should help to avoid race conditions and disable or enable Bluetooth better way. Change-Id: I02ef1bb67d9fb6fd56d0aff0a176cdb41284a49f diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java index e6dd88a..f2ead28 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java @@ -43,7 +43,7 @@ public class CommunicationService extends Service implements Runnable, MessagesL private MessagesReceiver mMessagesReceiver; private CommandsTransmitter mCommandsTransmitter; - private boolean mBluetoothWasEnabled; + private BluetoothOperator.State mBluetoothState; private Timer mTimer; private SlideShow mSlideShow; @@ -61,7 +61,8 @@ public class CommunicationService extends Service implements Runnable, MessagesL mServersManager = new ServersManager(this); - mBluetoothWasEnabled = false; + saveBluetoothState(); + enableBluetooth(); mTimer = new Timer(this); mSlideShow = new SlideShow(mTimer); @@ -76,6 +77,14 @@ public class CommunicationService extends Service implements Runnable, MessagesL } } + private void saveBluetoothState() { + mBluetoothState = BluetoothOperator.getState(); + } + + private void enableBluetooth() { + BluetoothOperator.enable(); + } + @Override public IBinder onBind(Intent intent) { return mBinder; @@ -164,28 +173,14 @@ public class CommunicationService extends Service implements Runnable, MessagesL LocalBroadcastManager.getInstance(this).sendBroadcast(aIntent); } - public void startSearch() { + public void startServersSearch() { mState = State.SEARCHING; - if (BluetoothOperator.isAvailable()) { - mBluetoothWasEnabled = BluetoothOperator.getAdapter().isEnabled(); - - if (!BluetoothOperator.getAdapter().isEnabled()) { - BluetoothOperator.getAdapter().enable(); - } - } - mServersManager.startServersSearch(); } - public void stopSearch() { + public void stopServersSearch() { mServersManager.stopServersSearch(); - - if (BluetoothOperator.isAvailable()) { - if (!mBluetoothWasEnabled) { - BluetoothOperator.getAdapter().disable(); - } - } } public List<Server> getServers() { @@ -298,11 +293,21 @@ public class CommunicationService extends Service implements Runnable, MessagesL @Override public void onDestroy() { - stopSearch(); + stopServersSearch(); + + restoreBluetoothState(); mThread.interrupt(); mThread = null; } + + private void restoreBluetoothState() { + if (mBluetoothState.wasBluetoothEnabled()) { + return; + } + + BluetoothOperator.disable(); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputersFragment.java b/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputersFragment.java index b6d2b95..d249588 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputersFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputersFragment.java @@ -37,6 +37,7 @@ import android.widget.ViewAnimator; import com.actionbarsherlock.app.SherlockListFragment; import com.actionbarsherlock.view.MenuItem; import org.libreoffice.impressremote.adapter.ComputersAdapter; +import org.libreoffice.impressremote.util.Fragments; import org.libreoffice.impressremote.util.Intents; import org.libreoffice.impressremote.R; import org.libreoffice.impressremote.communication.CommunicationService; @@ -65,21 +66,16 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo private static Bundle buildArguments(Type aType) { Bundle aArguments = new Bundle(); - aArguments.putSerializable("TYPE", aType); + aArguments.putSerializable(Fragments.Arguments.TYPE, aType); return aArguments; } @Override - public View onCreateView(LayoutInflater aInflater, ViewGroup aContainer, Bundle aSavedInstanceState) { - return aInflater.inflate(R.layout.fragment_computers_list, aContainer, false); - } - - @Override public void onCreate(Bundle aSavedInstanceState) { super.onCreate(aSavedInstanceState); - mType = (Type) getArguments().getSerializable("TYPE"); + mType = (Type) getArguments().getSerializable(Fragments.Arguments.TYPE); setUpActionBar(); } @@ -89,6 +85,11 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo } @Override + public View onCreateView(LayoutInflater aInflater, ViewGroup aContainer, Bundle aSavedInstanceState) { + return aInflater.inflate(R.layout.fragment_computers_list, aContainer, false); + } + + @Override public void onActivityCreated(Bundle aSavedInstanceState) { super.onActivityCreated(aSavedInstanceState); @@ -105,11 +106,22 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo CommunicationService.CBinder aServiceBinder = (CommunicationService.CBinder) aBinder; mCommunicationService = aServiceBinder.getService(); - mCommunicationService.startSearch(); - + startComputersSearch(); loadComputers(); } + private void startComputersSearch() { + if (!isServiceBound()) { + return; + } + + mCommunicationService.startServersSearch(); + } + + private boolean isServiceBound() { + return mCommunicationService != null; + } + private void loadComputers() { if (!isServiceBound()) { return; @@ -127,20 +139,46 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo } } - private boolean isServiceBound() { - return mCommunicationService != null; + private List<Server> getComputers() { + List<Server> aComputers = new ArrayList<Server>(); + + for (Server aComputer : mCommunicationService.getServers()) { + if (isComputerSupportsRequiredType(aComputer)) { + aComputers.add(aComputer); + } + } + + return aComputers; + } + + private boolean isComputerSupportsRequiredType(Server aComputer) { + switch (mType) { + case WIFI: + return aComputer.getProtocol() == Server.Protocol.TCP; + + case BLUETOOTH: + return aComputer.getProtocol() == Server.Protocol.BLUETOOTH; + + default: + return false; + } } private void hideComputersList() { + showView(getProgressBarLayout()); + } + + private void showView(View aView) { ViewAnimator aViewAnimator = getViewAnimator(); - int aProgressBarLayoutIndex = aViewAnimator.indexOfChild(getProgressBarLayout()); + int aViewIndex = aViewAnimator.indexOfChild(aView); + int aCurrentViewIndex = aViewAnimator.getDisplayedChild(); - if (aViewAnimator.getDisplayedChild() == aProgressBarLayoutIndex) { + if (aViewIndex == aCurrentViewIndex) { return; } - aViewAnimator.setDisplayedChild(aProgressBarLayoutIndex); + aViewAnimator.setDisplayedChild(aViewIndex); } private ViewAnimator getViewAnimator() { @@ -201,15 +239,12 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo setListAdapter(null); } - private ListView getComputesList() { - return (ListView) getView().findViewById(android.R.id.list); - } - private void showComputersList() { - ViewAnimator aViewAnimator = getViewAnimator(); - ListView aComputersList= getComputesList(); + showView(getComputersList()); + } - aViewAnimator.setDisplayedChild(aViewAnimator.indexOfChild(aComputersList)); + private ListView getComputersList() { + return (ListView) getView().findViewById(android.R.id.list); } private void setUpComputersAdapter() { @@ -233,57 +268,14 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo getComputersAdapter().add(getComputers()); } - private List<Server> getComputers() { - List<Server> aComputers = new ArrayList<Server>(); - - for (Server aServer : mCommunicationService.getServers()) { - if (isComputerSupportsRequiredType(aServer)) { - aComputers.add(aServer); - } - } - - return aComputers; - } - - private boolean isComputerSupportsRequiredType(Server aServer) { - switch (mType) { - case WIFI: - return aServer.getProtocol() == Server.Protocol.TCP; - - case BLUETOOTH: - return aServer.getProtocol() == Server.Protocol.BLUETOOTH; - - default: - return false; - } - } - - @Override - public void onDestroy() { - super.onDestroy(); - - unbindService(); - } - - private void unbindService() { - if (!isServiceBound()) { - return; - } - - getActivity().unbindService(this); - } - - @Override - public void onServiceDisconnected(ComponentName aComponentName) { - mCommunicationService = null; - } - @Override - public void onResume() { - super.onResume(); + public void onStart() { + super.onStart(); registerIntentsReceiver(); + setUpContextMenu(); + startComputersSearch(); loadComputers(); } @@ -322,37 +314,6 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo return LocalBroadcastManager.getInstance(aContext); } - @Override - public void onPause() { - super.onPause(); - - unregisterIntentsReceiver(); - } - - private void unregisterIntentsReceiver() { - try { - getBroadcastManager().unregisterReceiver(mIntentsReceiver); - } catch (IllegalArgumentException e) { - // Receiver not registered. - // Fixed in Honeycomb: Androidâs issue #6191. - } - } - - @Override - public void onListItemClick(ListView aListView, View aView, int aPosition, long aId) { - Server aComputer = getComputersAdapter().getItem(aPosition); - - Intent aIntent = Intents.buildComputerConnectionIntent(getActivity(), aComputer); - startActivity(aIntent); - } - - @Override - public void onStart() { - super.onStart(); - - setUpContextMenu(); - } - private void setUpContextMenu() { registerForContextMenu(getListView()); } @@ -438,6 +399,60 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo Intent aIntent = Intents.buildServersListChangedIntent(); LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(aIntent); } + + @Override + public void onListItemClick(ListView aListView, View aView, int aPosition, long aId) { + Server aComputer = getComputersAdapter().getItem(aPosition); + + Intent aIntent = Intents.buildComputerConnectionIntent(getActivity(), aComputer); + startActivity(aIntent); + } + + @Override + public void onStop() { + super.onStop(); + + stopComputersSearch(); + + unregisterIntentsReceiver(); + } + + private void unregisterIntentsReceiver() { + try { + getBroadcastManager().unregisterReceiver(mIntentsReceiver); + } catch (IllegalArgumentException e) { + // Receiver not registered. + // Fixed in Honeycomb: Androidâs issue #6191. + } + } + + private void stopComputersSearch() { + if (!isServiceBound()) { + return; + } + + mCommunicationService.stopServersSearch(); + } + + @Override + public void onDestroy() { + super.onDestroy(); + + unbindService(); + } + + private void unbindService() { + if (!isServiceBound()) { + return; + } + + getActivity().unbindService(this); + } + + @Override + public void onServiceDisconnected(ComponentName aComponentName) { + mCommunicationService = null; + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/android/sdremote/src/org/libreoffice/impressremote/util/BluetoothOperator.java b/android/sdremote/src/org/libreoffice/impressremote/util/BluetoothOperator.java index a531d86..4be74e1 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/util/BluetoothOperator.java +++ b/android/sdremote/src/org/libreoffice/impressremote/util/BluetoothOperator.java @@ -11,6 +11,18 @@ package org.libreoffice.impressremote.util; import android.bluetooth.BluetoothAdapter; public final class BluetoothOperator { + public static final class State { + private final boolean mWasBluetoothEnabled; + + private State(boolean aIsBluetoothEnabled) { + mWasBluetoothEnabled = aIsBluetoothEnabled; + } + + public boolean wasBluetoothEnabled() { + return mWasBluetoothEnabled; + } + } + private BluetoothOperator() { } @@ -25,6 +37,26 @@ public final class BluetoothOperator { return BluetoothAdapter.getDefaultAdapter(); } + + public static State getState() { + return new State(getAdapter().isEnabled()); + } + + public static void enable() { + if (!isAvailable()) { + return; + } + + getAdapter().enable(); + } + + public static void disable() { + if (!isAvailable()) { + return; + } + + getAdapter().disable(); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/android/sdremote/src/org/libreoffice/impressremote/util/Fragments.java b/android/sdremote/src/org/libreoffice/impressremote/util/Fragments.java index 89752bf..3b18058 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/util/Fragments.java +++ b/android/sdremote/src/org/libreoffice/impressremote/util/Fragments.java @@ -17,8 +17,8 @@ public final class Fragments { } public static final String COMPUTER = "COMPUTER"; - public static final String MINUTES = "MINUTES"; + public static final String TYPE = "TYPE"; } }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits