diff options
author | Artur Dryomov <artur.dryomov@gmail.com> | 2013-07-12 02:01:40 +0300 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2013-07-25 18:01:53 +0100 |
commit | 1990f88aa6394d26d4fde08ff47055e9b1d9ce59 (patch) | |
tree | 98c4a5a7ae3700ae16120fea731e9366380361fe /android | |
parent | Fix search state declaration at the CommunicationService. (diff) | |
download | core-1990f88aa6394d26d4fde08ff47055e9b1d9ce59.tar.gz core-1990f88aa6394d26d4fde08ff47055e9b1d9ce59.zip |
Add action bar button for reconnection.
Change-Id: I8729dcd2b179b7301ae85528a615195e907cf443
Diffstat (limited to 'android')
-rwxr-xr-x | android/sdremote/res/drawable-hdpi/ic_action_reconnect.png | bin | 0 -> 3138 bytes | |||
-rwxr-xr-x | android/sdremote/res/drawable-mdpi/ic_action_reconnect.png | bin | 0 -> 3033 bytes | |||
-rwxr-xr-x | android/sdremote/res/drawable-xhdpi/ic_action_reconnect.png | bin | 0 -> 3219 bytes | |||
-rw-r--r-- | android/sdremote/res/layout/fragment_computer_connection.xml | 2 | ||||
-rw-r--r-- | android/sdremote/res/menu/menu_action_bar_computer_connection.xml | 10 | ||||
-rw-r--r-- | android/sdremote/res/values/strings.xml | 1 | ||||
-rw-r--r-- | android/sdremote/src/org/libreoffice/impressremote/ComputerConnectionFragment.java | 43 |
7 files changed, 55 insertions, 1 deletions
diff --git a/android/sdremote/res/drawable-hdpi/ic_action_reconnect.png b/android/sdremote/res/drawable-hdpi/ic_action_reconnect.png Binary files differnew file mode 100755 index 000000000000..bb9d855f7769 --- /dev/null +++ b/android/sdremote/res/drawable-hdpi/ic_action_reconnect.png diff --git a/android/sdremote/res/drawable-mdpi/ic_action_reconnect.png b/android/sdremote/res/drawable-mdpi/ic_action_reconnect.png Binary files differnew file mode 100755 index 000000000000..bd611e8e24d2 --- /dev/null +++ b/android/sdremote/res/drawable-mdpi/ic_action_reconnect.png diff --git a/android/sdremote/res/drawable-xhdpi/ic_action_reconnect.png b/android/sdremote/res/drawable-xhdpi/ic_action_reconnect.png Binary files differnew file mode 100755 index 000000000000..a7fdc0dfcb1d --- /dev/null +++ b/android/sdremote/res/drawable-xhdpi/ic_action_reconnect.png diff --git a/android/sdremote/res/layout/fragment_computer_connection.xml b/android/sdremote/res/layout/fragment_computer_connection.xml index 7b004569bfaa..6ad129044918 100644 --- a/android/sdremote/res/layout/fragment_computer_connection.xml +++ b/android/sdremote/res/layout/fragment_computer_connection.xml @@ -7,7 +7,7 @@ android:layout_height="match_parent"> <ProgressBar - android:id="@android:id/progress" + android:id="@+id/progress_bar" style="?android:progressBarStyleLarge" android:layout_gravity="center" android:layout_width="wrap_content" diff --git a/android/sdremote/res/menu/menu_action_bar_computer_connection.xml b/android/sdremote/res/menu/menu_action_bar_computer_connection.xml new file mode 100644 index 000000000000..ca8714d8a842 --- /dev/null +++ b/android/sdremote/res/menu/menu_action_bar_computer_connection.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + + <item + android:id="@+id/menu_reconnect" + android:title="@string/menu_reconnect" + android:icon="@drawable/ic_action_reconnect" + android:showAsAction="always"/> + +</menu>
\ No newline at end of file diff --git a/android/sdremote/res/values/strings.xml b/android/sdremote/res/values/strings.xml index ceffa3eeb620..ab3a73b184d5 100644 --- a/android/sdremote/res/values/strings.xml +++ b/android/sdremote/res/values/strings.xml @@ -72,6 +72,7 @@ <string name="title_connection">Connection</string> <string name="menu_licenses">Open source licenses</string> + <string name="menu_reconnect">Reconnect</string> <string name="message_impress_pin_validation">Go to “Slide Show → Impress Remote” in LibreOffice Impress and enter the code.</string> <string name="message_connection_failed_title">Connection failed</string> diff --git a/android/sdremote/src/org/libreoffice/impressremote/ComputerConnectionFragment.java b/android/sdremote/src/org/libreoffice/impressremote/ComputerConnectionFragment.java index 186e20ec7c76..fd97bed6c9ba 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/ComputerConnectionFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/ComputerConnectionFragment.java @@ -13,10 +13,14 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; +import android.widget.ProgressBar; import android.widget.TextView; import android.widget.ViewAnimator; import com.actionbarsherlock.app.SherlockFragment; +import com.actionbarsherlock.view.Menu; +import com.actionbarsherlock.view.MenuInflater; +import com.actionbarsherlock.view.MenuItem; import org.libreoffice.impressremote.communication.CommunicationService; import org.libreoffice.impressremote.communication.Server; @@ -47,6 +51,12 @@ public class ComputerConnectionFragment extends SherlockFragment implements Serv super.onCreate(aSavedInstance); mComputer = getArguments().getParcelable("COMPUTER"); + + setUpActionBarMenu(); + } + + private void setUpActionBarMenu() { + setHasOptionsMenu(true); } @Override @@ -73,6 +83,14 @@ public class ComputerConnectionFragment extends SherlockFragment implements Serv mCommunicationService = aServiceBinder.getService(); + connectToComputer(); + } + + private void connectToComputer() { + if (!isServiceBound()) { + return; + } + mCommunicationService.connectTo(mComputer); } @@ -189,6 +207,31 @@ public class ComputerConnectionFragment extends SherlockFragment implements Serv } @Override + public void onCreateOptionsMenu(Menu aMenu, MenuInflater aMenuInflater) { + aMenuInflater.inflate(R.menu.menu_action_bar_computer_connection, aMenu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem aMenuItem) { + switch (aMenuItem.getItemId()) { + case R.id.menu_reconnect: + showProgressBar(); + connectToComputer(); + return true; + + default: + return super.onOptionsItemSelected(aMenuItem); + } + } + + private void showProgressBar() { + ViewAnimator aViewAnimator = (ViewAnimator) getView().findViewById(R.id.view_animator); + ProgressBar aProgressBar = (ProgressBar) getView().findViewById(R.id.progress_bar); + + aViewAnimator.setDisplayedChild(aViewAnimator.indexOfChild(aProgressBar)); + } + + @Override public void onPause() { super.onPause(); |