summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
Diffstat (limited to 'android')
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/fragment/ComputerConnectionFragment.java26
1 files changed, 24 insertions, 2 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputerConnectionFragment.java b/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputerConnectionFragment.java
index ee9c75b4ed4c..c70599e3957b 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputerConnectionFragment.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputerConnectionFragment.java
@@ -82,8 +82,7 @@ public class ComputerConnectionFragment extends SherlockFragment implements Serv
}
private void bindService() {
- Intent aServiceIntent = new Intent(getActivity(), CommunicationService.class);
-
+ Intent aServiceIntent = Intents.buildCommunicationServiceIntent(getActivity());
getActivity().bindService(aServiceIntent, this, Context.BIND_AUTO_CREATE);
}
@@ -140,18 +139,21 @@ public class ComputerConnectionFragment extends SherlockFragment implements Serv
String aPin = aIntent.getStringExtra(Intents.Extras.PIN);
mComputerConnectionFragment.setUpPinValidationInstructions(aPin);
+ mComputerConnectionFragment.refreshActionBarMenu();
return;
}
if (Intents.Actions.PAIRING_SUCCESSFUL.equals(aIntent.getAction())) {
mComputerConnectionFragment.setUpPresentation();
+ mComputerConnectionFragment.refreshActionBarMenu();
return;
}
if (Intents.Actions.CONNECTION_FAILED.equals(aIntent.getAction())) {
mComputerConnectionFragment.setUpErrorMessage();
+ mComputerConnectionFragment.refreshActionBarMenu();
}
}
}
@@ -219,17 +221,37 @@ public class ComputerConnectionFragment extends SherlockFragment implements Serv
aViewAnimator.setDisplayedChild(aViewAnimator.indexOfChild(aMessageLayout));
}
+ private void refreshActionBarMenu() {
+ getSherlockActivity().supportInvalidateOptionsMenu();
+ }
+
@Override
public void onCreateOptionsMenu(Menu aMenu, MenuInflater aMenuInflater) {
+ if (!shouldActionBarMenuBeDisplayed()) {
+ aMenu.clear();
+ return;
+ }
+
aMenuInflater.inflate(R.menu.menu_action_bar_computer_connection, aMenu);
}
+ private boolean shouldActionBarMenuBeDisplayed() {
+ if (getView() == null) {
+ return false;
+ }
+
+ ViewAnimator aViewAnimator = (ViewAnimator) getView().findViewById(R.id.view_animator);
+
+ return aViewAnimator.getCurrentView().getId() == R.id.layout_error_message;
+ }
+
@Override
public boolean onOptionsItemSelected(MenuItem aMenuItem) {
switch (aMenuItem.getItemId()) {
case R.id.menu_reconnect:
showProgressBar();
connectToComputer();
+ refreshActionBarMenu();
return true;
default: