[Libreoffice-commits] core.git: 4 commits - android/sdremote
Artur Dryomov
artur.dryomov at gmail.com
Sat Sep 14 09:39:16 PDT 2013
android/sdremote/res/drawable-nodpi/slide_unknown.png |binary
android/sdremote/res/layout/action_bar_computer_creation.xml | 4
android/sdremote/res/layout/activity_requirements.xml | 6 -
android/sdremote/res/layout/fragment_slides_pager.xml | 2
android/sdremote/src/org/libreoffice/impressremote/activity/ComputerConnectionActivity.java | 10 -
android/sdremote/src/org/libreoffice/impressremote/activity/ComputerCreationActivity.java | 10 +
android/sdremote/src/org/libreoffice/impressremote/activity/ComputersActivity.java | 4
android/sdremote/src/org/libreoffice/impressremote/activity/SettingsActivity.java | 2
android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java | 43 ++++---
android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServersFinder.java | 4
android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java | 27 ++---
android/sdremote/src/org/libreoffice/impressremote/communication/PairingProvider.java | 8 -
android/sdremote/src/org/libreoffice/impressremote/communication/Timer.java | 16 ++
android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesGridFragment.java | 2
android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java | 29 ++++-
android/sdremote/src/org/libreoffice/impressremote/util/FragmentOperator.java | 54 ----------
android/sdremote/src/org/libreoffice/impressremote/util/Fragments.java | 43 +++++++
android/sdremote/src/org/libreoffice/impressremote/util/Intents.java | 6 -
android/sdremote/src/org/libreoffice/impressremote/util/Preferences.java | 22 +---
android/sdremote/src/org/libreoffice/impressremote/util/SavedStates.java | 19 ++-
android/sdremote/src/org/libreoffice/impressremote/view/CapsTextView.java | 34 ++++++
21 files changed, 203 insertions(+), 142 deletions(-)
New commits:
commit b3e0c8081dc89228653d70e12ecfe1397c70fde5
Author: Artur Dryomov <artur.dryomov at gmail.com>
Date: Sat Sep 14 19:32:20 2013 +0300
Replace empty slide preview with solid grey background.
Change-Id: Ic6beec11b3d5bd86fa4722bd7bb8cb7cd69d8cf7
diff --git a/android/sdremote/res/drawable-nodpi/slide_unknown.png b/android/sdremote/res/drawable-nodpi/slide_unknown.png
index 57df42b..62d55e7 100644
Binary files a/android/sdremote/res/drawable-nodpi/slide_unknown.png and b/android/sdremote/res/drawable-nodpi/slide_unknown.png differ
commit 7dcbd06d018dd079878dec6318427aca36db0a0f
Author: Artur Dryomov <artur.dryomov at gmail.com>
Date: Sat Sep 14 19:18:24 2013 +0300
Add custom capitalized TextView.
To provide visual compatibility for 2.3 devices.
Change-Id: Ibdcc80a2f3d5a43dd8998153f2d872e564ec1c11
diff --git a/android/sdremote/res/layout/action_bar_computer_creation.xml b/android/sdremote/res/layout/action_bar_computer_creation.xml
index 5e6ea36..59e1495 100644
--- a/android/sdremote/res/layout/action_bar_computer_creation.xml
+++ b/android/sdremote/res/layout/action_bar_computer_creation.xml
@@ -11,7 +11,7 @@
android:layout_width="0dp"
android:layout_height="match_parent">
- <TextView
+ <org.libreoffice.impressremote.view.CapsTextView
style="@style/Widget.Sherlock.ActionBar.TabText"
android:text="@string/button_cancel"
android:drawableLeft="@drawable/ic_action_cancel"
@@ -38,7 +38,7 @@
android:layout_width="0dp"
android:layout_height="match_parent">
- <TextView
+ <org.libreoffice.impressremote.view.CapsTextView
style="@style/Widget.Sherlock.ActionBar.TabText"
android:text="@string/button_save"
android:drawableLeft="@drawable/ic_action_save"
diff --git a/android/sdremote/res/layout/activity_requirements.xml b/android/sdremote/res/layout/activity_requirements.xml
index 138ea56..dc48b7c 100644
--- a/android/sdremote/res/layout/activity_requirements.xml
+++ b/android/sdremote/res/layout/activity_requirements.xml
@@ -9,7 +9,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
- <TextView
+ <org.libreoffice.impressremote.view.CapsTextView
style="@style/SectionHeader"
android:text="@string/title_generic"/>
@@ -21,7 +21,7 @@
style="@style/SectionItem"
android:text="@string/requirements_libreoffice_general_enabled"/>
- <TextView
+ <org.libreoffice.impressremote.view.CapsTextView
style="@style/SectionHeader"
android:text="@string/title_wifi"/>
@@ -37,7 +37,7 @@
style="@style/SectionItem"
android:text="@string/requirements_network_ports"/>
- <TextView
+ <org.libreoffice.impressremote.view.CapsTextView
style="@style/SectionHeader"
android:text="@string/title_bluetooth"/>
diff --git a/android/sdremote/res/layout/fragment_slides_pager.xml b/android/sdremote/res/layout/fragment_slides_pager.xml
index 04a6294..8bf235c 100644
--- a/android/sdremote/res/layout/fragment_slides_pager.xml
+++ b/android/sdremote/res/layout/fragment_slides_pager.xml
@@ -22,7 +22,7 @@
android:layout_width="match_parent"
android:layout_height="0dp">
- <TextView
+ <org.libreoffice.impressremote.view.CapsTextView
style="@style/SectionHeader"
android:text="@string/header_notes"
android:paddingTop="@dimen/padding_header"/>
diff --git a/android/sdremote/src/org/libreoffice/impressremote/view/CapsTextView.java b/android/sdremote/src/org/libreoffice/impressremote/view/CapsTextView.java
new file mode 100644
index 0000000..84b632f
--- /dev/null
+++ b/android/sdremote/src/org/libreoffice/impressremote/view/CapsTextView.java
@@ -0,0 +1,34 @@
+/* -*- 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.view;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.TextView;
+
+public class CapsTextView extends TextView {
+ public CapsTextView(Context aContext) {
+ super(aContext);
+ }
+
+ public CapsTextView(Context aContext, AttributeSet aAttributeSet) {
+ super(aContext, aAttributeSet);
+ }
+
+ public CapsTextView(Context aContext, AttributeSet aAttributeSet, int aDefinedStyle) {
+ super(aContext, aAttributeSet, aDefinedStyle);
+ }
+
+ @Override
+ public void setText(CharSequence aText, BufferType aBufferType) {
+ super.setText(aText.toString().toUpperCase(), aBufferType);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 4c7ad3859a27ae5376a24dcfca291670b86e3367
Author: Artur Dryomov <artur.dryomov at gmail.com>
Date: Sat Sep 14 16:47:00 2013 +0300
Fix slide notes loading.
* Allow dynamic loading.
* Show notes only when they belong to the current slide.
Change-Id: I30dd73c9a1c9ac8533b830d908276aa6234aa7ce
diff --git a/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java b/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java
index 45fe40a..defd6a0 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java
@@ -115,6 +115,7 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi
mCommunicationService = aServiceBinder.getService();
startSlideShow();
+ resumeTimer();
}
private void startSlideShow() {
@@ -126,10 +127,20 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi
mCommunicationService.getCommandsTransmitter().startPresentation();
}
+ private void resumeTimer() {
+ if (!isServiceBound()) {
+ return;
+ }
+
+ mCommunicationService.getSlideShow().getTimer().resume();
+ }
+
@Override
protected void onStart() {
super.onStart();
+ resumeTimer();
+
registerIntentsReceiver();
}
@@ -242,13 +253,13 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi
aTimer.start();
}
- private void resumeTimer() {
- mCommunicationService.getSlideShow().getTimer().resume();
- }
-
private void changeTimer(int aMinutesLength) {
Timer aTimer = mCommunicationService.getSlideShow().getTimer();
+ if (aTimer.isTimeUp()) {
+ aTimer.reset();
+ }
+
aTimer.setMinutesLength(aMinutesLength);
}
@@ -429,7 +440,7 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi
DialogFragment aTimerDialog = buildTimerEditingDialog(aTimer);
aTimerDialog.show(getSupportFragmentManager(), TimerEditingDialog.TAG);
- aTimer.pause();
+ pauseTimer();
}
private DialogFragment buildTimerEditingDialog(Timer aTimer) {
@@ -505,15 +516,9 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi
return;
}
- stopTimer();
-
unbindService();
}
- private void stopTimer() {
- mCommunicationService.getSlideShow().getTimer().stop();
- }
-
private void unbindService() {
unbindService(this);
}
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
index cbeacd6..0db8b41 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
@@ -196,6 +196,7 @@ public class CommunicationService extends Service implements Runnable, MessagesL
@Override
public void onSlideShowFinish() {
+ mTimer.stop();
mSlideShow = new SlideShow(mTimer);
Intent aIntent = Intents.buildSlideShowStoppedIntent();
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/Timer.java b/android/sdremote/src/org/libreoffice/impressremote/communication/Timer.java
index 9efc42e..4e13910 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/Timer.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/Timer.java
@@ -66,16 +66,22 @@ public class Timer implements Runnable {
mPassedMinutes++;
}
+ public void stop() {
+ pause();
+ reset();
+ }
+
public void pause() {
- stop();
+ mTimerHandler.removeCallbacks(this);
}
- public void resume() {
- start();
+ public void reset() {
+ mTotalMinutes = 0;
+ mPassedMinutes = 0;
}
- public void stop() {
- mTimerHandler.removeCallbacks(this);
+ public void resume() {
+ start();
}
public boolean isTimeUp() {
diff --git a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java
index aba2e21..4692977 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java
@@ -144,13 +144,17 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn
return;
}
- if (areSlideNotesAvailable(aSlideIndex)) {
- showSlideNotes(aSlideIndex);
- scrollSlideNotes();
+ if (!isSlideVisible(aSlideIndex)) {
+ return;
}
- else {
+
+ if (!areSlideNotesAvailable(aSlideIndex)) {
hideSlideNotes();
+ return;
}
+
+ showSlideNotes(aSlideIndex);
+ scrollSlideNotes();
}
private boolean isSlideNotesLayoutAvailable() {
@@ -159,6 +163,10 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn
return aSlideNotesLayout != null;
}
+ private boolean isSlideVisible(int aSlideIndex) {
+ return aSlideIndex == getSlidesPager().getCurrentItem();
+ }
+
private boolean areSlideNotesAvailable(int aSlideIndex) {
String aSlideNotes = mCommunicationService.getSlideShow().getSlideNotes(aSlideIndex);
@@ -243,6 +251,14 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn
int aSlideIndex = aIntent.getIntExtra(Intents.Extras.SLIDE_INDEX, 0);
mSlidesPagerFragment.refreshSlide(aSlideIndex);
+ return;
+ }
+
+ if (Intents.Actions.SLIDE_NOTES.equals(aIntent.getAction())) {
+ int aSlideIndex = aIntent.getIntExtra(Intents.Extras.SLIDE_INDEX, 0);
+
+ mSlidesPagerFragment.setUpSlideNotes(aSlideIndex);
+ return;
}
}
}
@@ -253,6 +269,7 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn
aIntentFilter.addAction(Intents.Actions.SLIDE_SHOW_STOPPED);
aIntentFilter.addAction(Intents.Actions.SLIDE_CHANGED);
aIntentFilter.addAction(Intents.Actions.SLIDE_PREVIEW);
+ aIntentFilter.addAction(Intents.Actions.SLIDE_NOTES);
return aIntentFilter;
}
commit 2436d8c9bc296d64a98c6b1bcbecb66d42f15aab
Author: Artur Dryomov <artur.dryomov at gmail.com>
Date: Sat Sep 14 15:02:47 2013 +0300
Fix another code style issues.
Change-Id: Id76d17050b7fc2865a78b9a815a2f543e85e321f
diff --git a/android/sdremote/src/org/libreoffice/impressremote/activity/ComputerConnectionActivity.java b/android/sdremote/src/org/libreoffice/impressremote/activity/ComputerConnectionActivity.java
index fda1d96..f68c43c 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/activity/ComputerConnectionActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/activity/ComputerConnectionActivity.java
@@ -14,7 +14,7 @@ import android.support.v4.app.Fragment;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.MenuItem;
import org.libreoffice.impressremote.fragment.ComputerConnectionFragment;
-import org.libreoffice.impressremote.util.FragmentOperator;
+import org.libreoffice.impressremote.util.Fragments;
import org.libreoffice.impressremote.util.Intents;
import org.libreoffice.impressremote.communication.Server;
@@ -33,20 +33,20 @@ public class ComputerConnectionActivity extends SherlockFragmentActivity {
}
private void setUpTitle() {
- String aComputerName = extractReceivedComputer().getName();
+ String aComputerName = getComputer().getName();
getSupportActionBar().setSubtitle(aComputerName);
}
- private Server extractReceivedComputer() {
+ private Server getComputer() {
return getIntent().getParcelableExtra(Intents.Extras.SERVER);
}
private void setUpFragment() {
- Server aComputer = extractReceivedComputer();
+ Server aComputer = getComputer();
Fragment aFragment = ComputerConnectionFragment.newInstance(aComputer);
- FragmentOperator.addFragment(this, aFragment);
+ Fragments.Operator.add(this, aFragment);
}
@Override
diff --git a/android/sdremote/src/org/libreoffice/impressremote/activity/ComputerCreationActivity.java b/android/sdremote/src/org/libreoffice/impressremote/activity/ComputerCreationActivity.java
index 4e91251..0ccf0e9 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/activity/ComputerCreationActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/activity/ComputerCreationActivity.java
@@ -89,8 +89,7 @@ public class ComputerCreationActivity extends SherlockFragmentActivity implement
String aName = getText(getNameEdit());
if (!isIpAddressValid(aIpAddress)) {
- getIpAddressEdit().setError(getText(R.string.message_ip_address_validation));
- getIpAddressEdit().requestFocus();
+ setUpIpAddressErrorMessage();
return;
}
@@ -117,6 +116,13 @@ public class ComputerCreationActivity extends SherlockFragmentActivity implement
return Patterns.IP_ADDRESS.matcher(aIpAddress).matches();
}
+ private void setUpIpAddressErrorMessage() {
+ EditText aIpAddressEdit = getIpAddressEdit();
+
+ aIpAddressEdit.setError(getString(R.string.message_ip_address_validation));
+ aIpAddressEdit.requestFocus();
+ }
+
private void finish(String aIpAddress, String aName) {
Intent aIntent = Intents.buildComputerCreationResultIntent(aIpAddress, aName);
setResult(Activity.RESULT_OK, aIntent);
diff --git a/android/sdremote/src/org/libreoffice/impressremote/activity/ComputersActivity.java b/android/sdremote/src/org/libreoffice/impressremote/activity/ComputersActivity.java
index 954c9fc..7b085e7 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/activity/ComputersActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/activity/ComputersActivity.java
@@ -22,7 +22,7 @@ import com.actionbarsherlock.view.MenuItem;
import org.libreoffice.impressremote.adapter.ComputersPagerAdapter;
import org.libreoffice.impressremote.fragment.ComputersFragment;
import org.libreoffice.impressremote.util.BluetoothOperator;
-import org.libreoffice.impressremote.util.FragmentOperator;
+import org.libreoffice.impressremote.util.Fragments;
import org.libreoffice.impressremote.util.Intents;
import org.libreoffice.impressremote.R;
import org.libreoffice.impressremote.util.Preferences;
@@ -153,7 +153,7 @@ public class ComputersActivity extends SherlockFragmentActivity implements Actio
private void setUpComputersList() {
Fragment aComputersFragment = ComputersFragment.newInstance(ComputersFragment.Type.WIFI);
- FragmentOperator.addFragment(this, aComputersFragment);
+ Fragments.Operator.add(this, aComputersFragment);
}
@Override
diff --git a/android/sdremote/src/org/libreoffice/impressremote/activity/SettingsActivity.java b/android/sdremote/src/org/libreoffice/impressremote/activity/SettingsActivity.java
index ea1a9a5..00ae390 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/activity/SettingsActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/activity/SettingsActivity.java
@@ -32,6 +32,8 @@ public class SettingsActivity extends SherlockPreferenceActivity {
// This action is deprecated
// but we still need to target pre-Honeycomb devices.
+ // TODO: try to use a fragment depending on platform version
+
addPreferencesFromResource(R.xml.preferences);
}
diff --git a/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java b/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java
index 76ae2e7..45fe40a 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java
@@ -34,7 +34,7 @@ import org.libreoffice.impressremote.fragment.SlidesGridFragment;
import org.libreoffice.impressremote.fragment.SlidesPagerFragment;
import org.libreoffice.impressremote.fragment.TimerEditingDialog;
import org.libreoffice.impressremote.fragment.TimerSettingDialog;
-import org.libreoffice.impressremote.util.FragmentOperator;
+import org.libreoffice.impressremote.util.Fragments;
import org.libreoffice.impressremote.util.Intents;
import org.libreoffice.impressremote.util.Preferences;
import org.libreoffice.impressremote.util.SavedStates;
@@ -75,7 +75,7 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi
}
private void setUpFragment() {
- FragmentOperator.replaceFragmentAnimated(this, buildFragment());
+ Fragments.Operator.replaceAnimated(this, buildFragment());
}
private Fragment buildFragment() {
@@ -123,7 +123,7 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi
return;
}
- mCommunicationService.getTransmitter().startPresentation();
+ mCommunicationService.getCommandsTransmitter().startPresentation();
}
@Override
@@ -268,12 +268,12 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi
switch (aKeyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
if (!isLastSlideDisplayed()) {
- mCommunicationService.getTransmitter().performNextTransition();
+ mCommunicationService.getCommandsTransmitter().performNextTransition();
}
return true;
case KeyEvent.KEYCODE_VOLUME_DOWN:
- mCommunicationService.getTransmitter().performPreviousTransition();
+ mCommunicationService.getCommandsTransmitter().performPreviousTransition();
return true;
default:
@@ -446,11 +446,11 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi
}
private void resumeSlideShow() {
- mCommunicationService.getTransmitter().resumePresentation();
+ mCommunicationService.getCommandsTransmitter().resumePresentation();
}
private void pauseSlideShow() {
- mCommunicationService.getTransmitter().setUpBlankScreen();
+ mCommunicationService.getCommandsTransmitter().setUpBlankScreen();
}
private void setUpSlideShowPausedInformation() {
@@ -465,7 +465,7 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi
}
private void stopSlideShow() {
- mCommunicationService.getTransmitter().stopPresentation();
+ mCommunicationService.getCommandsTransmitter().stopPresentation();
finish();
}
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServersFinder.java b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServersFinder.java
index 2dbb6e6..4d7619b 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServersFinder.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/BluetoothServersFinder.java
@@ -102,8 +102,8 @@ class BluetoothServersFinder extends BroadcastReceiver implements ServersFinder,
return;
}
- Handler aHandler = new Handler();
- aHandler.postDelayed(this, TimeUnit.SECONDS.toMillis(SEARCH_DELAY_IN_SECONDS));
+ Handler aDiscoveryHandler = new Handler();
+ aDiscoveryHandler.postDelayed(this, TimeUnit.SECONDS.toMillis(SEARCH_DELAY_IN_SECONDS));
}
@Override
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
index ed2e5c2..cbeacd6 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java
@@ -111,6 +111,18 @@ public class CommunicationService extends Service implements Runnable, MessagesL
}
}
+ public void disconnectServer() {
+ if (!isServerConnectionAvailable()) {
+ return;
+ }
+
+ mServerConnection.close();
+ }
+
+ private boolean isServerConnectionAvailable() {
+ return mServerConnection != null;
+ }
+
private void connectServer() {
mServerConnection = buildServerConnection();
mServerConnection.open();
@@ -148,19 +160,7 @@ public class CommunicationService extends Service implements Runnable, MessagesL
LocalBroadcastManager.getInstance(this).sendBroadcast(aIntent);
}
- public void disconnectServer() {
- if (!isServerConnectionAvailable()) {
- return;
- }
-
- mServerConnection.close();
- }
-
- private boolean isServerConnectionAvailable() {
- return mServerConnection != null;
- }
-
- public CommandsTransmitter getTransmitter() {
+ public CommandsTransmitter getCommandsTransmitter() {
return mCommandsTransmitter;
}
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/PairingProvider.java b/android/sdremote/src/org/libreoffice/impressremote/communication/PairingProvider.java
index f91fbf7..f5f4fe4 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/communication/PairingProvider.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/communication/PairingProvider.java
@@ -8,10 +8,10 @@
*/
package org.libreoffice.impressremote.communication;
-import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.os.Build;
+import org.libreoffice.impressremote.util.BluetoothOperator;
import org.libreoffice.impressremote.util.Preferences;
final class PairingProvider {
@@ -58,15 +58,15 @@ final class PairingProvider {
}
private String getPairingDeviceName() {
- if (BluetoothAdapter.getDefaultAdapter() == null) {
+ if (!BluetoothOperator.isAvailable()) {
return Build.MODEL;
}
- if (BluetoothAdapter.getDefaultAdapter().getName() == null) {
+ if (BluetoothOperator.getAdapter().getName() == null) {
return Build.MODEL;
}
- return BluetoothAdapter.getDefaultAdapter().getName();
+ return BluetoothOperator.getAdapter().getName();
}
}
diff --git a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesGridFragment.java b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesGridFragment.java
index 1d32ed3..14e46e0 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesGridFragment.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesGridFragment.java
@@ -86,7 +86,7 @@ public class SlidesGridFragment extends SherlockFragment implements ServiceConne
@Override
public void onItemClick(AdapterView<?> aAdapterView, View aView, int aPosition, long aId) {
- mCommunicationService.getTransmitter().setCurrentSlide(aPosition);
+ mCommunicationService.getCommandsTransmitter().setCurrentSlide(aPosition);
}
@Override
diff --git a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java
index 346c79e..aba2e21 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java
@@ -111,7 +111,7 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn
}
private void showNextTransition() {
- mCommunicationService.getTransmitter().performNextTransition();
+ mCommunicationService.getCommandsTransmitter().performNextTransition();
}
private int getSlidesMargin() {
@@ -133,7 +133,7 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn
@Override
public void onPageSelected(int aPosition) {
if (mCommunicationService.getSlideShow().getCurrentSlideIndex() != aPosition) {
- mCommunicationService.getTransmitter().setCurrentSlide(aPosition);
+ mCommunicationService.getCommandsTransmitter().setCurrentSlide(aPosition);
}
setUpSlideNotes(aPosition);
diff --git a/android/sdremote/src/org/libreoffice/impressremote/util/FragmentOperator.java b/android/sdremote/src/org/libreoffice/impressremote/util/FragmentOperator.java
deleted file mode 100644
index af7e47c..0000000
--- a/android/sdremote/src/org/libreoffice/impressremote/util/FragmentOperator.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- 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.util;
-
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentActivity;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentTransaction;
-
-public final class FragmentOperator {
- private FragmentOperator() {
- }
-
- public static void addFragment(FragmentActivity aActivity, Fragment aFragment) {
- if (isFragmentAdded(aActivity)) {
- return;
- }
-
- FragmentTransaction aFragmentTransaction = beginFragmentTransaction(aActivity);
-
- aFragmentTransaction.add(android.R.id.content, aFragment);
-
- aFragmentTransaction.commit();
- }
-
- private static boolean isFragmentAdded(FragmentActivity aActivity) {
- FragmentManager aFragmentManager = aActivity.getSupportFragmentManager();
-
- return aFragmentManager.findFragmentById(android.R.id.content) != null;
- }
-
- private static FragmentTransaction beginFragmentTransaction(FragmentActivity aActivity) {
- FragmentManager aFragmentManager = aActivity.getSupportFragmentManager();
-
- return aFragmentManager.beginTransaction();
- }
-
- public static void replaceFragmentAnimated(FragmentActivity aActivity, Fragment aFragment) {
- FragmentTransaction aFragmentTransaction = beginFragmentTransaction(aActivity);
- aFragmentTransaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out);
-
- aFragmentTransaction.replace(android.R.id.content, aFragment);
-
- aFragmentTransaction.commit();
- }
-}
-
-/* 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 3b18058..fae8819 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/util/Fragments.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/util/Fragments.java
@@ -8,6 +8,11 @@
*/
package org.libreoffice.impressremote.util;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
+
public final class Fragments {
private Fragments() {
}
@@ -20,6 +25,44 @@ public final class Fragments {
public static final String MINUTES = "MINUTES";
public static final String TYPE = "TYPE";
}
+
+ public static final class Operator {
+ private Operator() {
+ }
+
+ public static void add(FragmentActivity aActivity, Fragment aFragment) {
+ if (isAdded(aActivity)) {
+ return;
+ }
+
+ FragmentTransaction aFragmentTransaction = beginTransaction(aActivity);
+
+ aFragmentTransaction.add(android.R.id.content, aFragment);
+
+ aFragmentTransaction.commit();
+ }
+
+ private static boolean isAdded(FragmentActivity aActivity) {
+ FragmentManager aFragmentManager = aActivity.getSupportFragmentManager();
+
+ return aFragmentManager.findFragmentById(android.R.id.content) != null;
+ }
+
+ private static FragmentTransaction beginTransaction(FragmentActivity aActivity) {
+ FragmentManager aFragmentManager = aActivity.getSupportFragmentManager();
+
+ return aFragmentManager.beginTransaction();
+ }
+
+ public static void replaceAnimated(FragmentActivity aActivity, Fragment aFragment) {
+ FragmentTransaction aFragmentTransaction = beginTransaction(aActivity);
+ aFragmentTransaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out);
+
+ aFragmentTransaction.replace(android.R.id.content, aFragment);
+
+ aFragmentTransaction.commit();
+ }
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/android/sdremote/src/org/libreoffice/impressremote/util/Intents.java b/android/sdremote/src/org/libreoffice/impressremote/util/Intents.java
index 20c56fb..a6ade2d 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/util/Intents.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/util/Intents.java
@@ -52,15 +52,13 @@ public final class Intents {
private Extras() {
}
+ public static final String MINUTES = "MINUTES";
public static final String PIN = "PIN";
+ public static final String SLIDE_INDEX = "SLIDE_INDEX";
public static final String SERVER = "SERVER";
public static final String SERVER_ADDRESS = "SERVER_ADDRESS";
public static final String SERVER_NAME = "SERVER_NAME";
-
- public static final String SLIDE_INDEX = "SLIDE_INDEX";
-
- public static final String MINUTES = "MINUTES";
}
public static final class RequestCodes {
diff --git a/android/sdremote/src/org/libreoffice/impressremote/util/Preferences.java b/android/sdremote/src/org/libreoffice/impressremote/util/Preferences.java
index 0a2141b..5a9b0c7 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/util/Preferences.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/util/Preferences.java
@@ -45,16 +45,20 @@ public final class Preferences {
private final SharedPreferences mPreferences;
- public static Preferences getAuthorizedServersInstance(Context aContext) {
- return new Preferences(aContext, Locations.AUTHORIZED_SERVERS);
+ private Preferences(Context context) {
+ mPreferences = PreferenceManager.getDefaultSharedPreferences(context);
}
private Preferences(Context aContext, String aLocation) {
- mPreferences = getPreferences(aContext, aLocation);
+ mPreferences = aContext.getSharedPreferences(aLocation, Context.MODE_PRIVATE);
}
- private SharedPreferences getPreferences(Context aContext, String aLocation) {
- return aContext.getSharedPreferences(aLocation, Context.MODE_PRIVATE);
+ public static Preferences getSettingsInstance(Context context) {
+ return new Preferences(context);
+ }
+
+ public static Preferences getAuthorizedServersInstance(Context aContext) {
+ return new Preferences(aContext, Locations.AUTHORIZED_SERVERS);
}
public static Preferences getSavedServersInstance(Context aContext) {
@@ -65,14 +69,6 @@ public final class Preferences {
return new Preferences(aContext, Locations.APPLICATION_STATES);
}
- public static Preferences getSettingsInstance(Context context) {
- return new Preferences(context);
- }
-
- private Preferences(Context context) {
- mPreferences = PreferenceManager.getDefaultSharedPreferences(context);
- }
-
public Map<String, ?> getAll() {
return mPreferences.getAll();
}
diff --git a/android/sdremote/src/org/libreoffice/impressremote/util/SavedStates.java b/android/sdremote/src/org/libreoffice/impressremote/util/SavedStates.java
index 0ec6b56..e3e37b2 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/util/SavedStates.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/util/SavedStates.java
@@ -1,3 +1,11 @@
+/* -*- 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.util;
public final class SavedStates {
@@ -8,13 +16,12 @@ 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";
public static final String ERROR_MESSAGE = "ERROR_MESSAGE";
-
+ public static final String LAYOUT_INDEX = "LAYOUT_INDEX";
public static final String MODE = "MODE";
+ public static final String PIN = "PIN";
+ public static final String PROGRESS_MESSAGE = "PROGRESS_MESSAGE";
}
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list