summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorArtur Dryomov <artur.dryomov@gmail.com>2013-07-21 03:59:00 +0300
committerMichael Meeks <michael.meeks@suse.com>2013-07-25 18:01:59 +0100
commitf01c976a1def48a11e95e36b747f55dfbc8647c8 (patch)
tree66c6a52bf705763422d4392a9846b480fc94ad77 /android
parent001552cc8a01ddc724856a905017937e735eee73 (diff)
Improve the ComputerConnectionFragment.
Show reconnection action bar button only when it is necessary, i. e. when there is a connection error. Change-Id: Iecb86f7a1bf0b094f2fffbe12c03bea474774417
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: