diff options
author | Artur Dryomov <artur.dryomov@gmail.com> | 2013-07-14 22:01:38 +0300 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2013-07-25 18:01:55 +0100 |
commit | 1b085b8f7337f78248c24701c2ab61772e3ceaf3 (patch) | |
tree | e704f044bede5d1c70b8de1c9e221587318cbe13 /android | |
parent | 5f6eb2d86da300416be13e63a7d3e863e32338d4 (diff) |
Add adding and removing computers.
Change-Id: I52166bbe848e1b877a91d8ad83859e9f6345c3aa
Diffstat (limited to 'android')
24 files changed, 428 insertions, 2 deletions
diff --git a/android/sdremote/AndroidManifest.xml b/android/sdremote/AndroidManifest.xml index e8225a33cc3c..72d692b0eb6d 100644 --- a/android/sdremote/AndroidManifest.xml +++ b/android/sdremote/AndroidManifest.xml @@ -37,6 +37,12 @@ </activity> <activity + android:name=".ComputerCreationActivity" + android:label="Creation" + android:theme="@style/Theme.ImpressRemote.ComputerCreation"> + </activity> + + <activity android:name=".SelectorActivity" android:label="@string/selector_choose_a_computer" android:uiOptions="splitActionBarWhenNarrow"> diff --git a/android/sdremote/res/drawable-hdpi/ic_action_add_computer.png b/android/sdremote/res/drawable-hdpi/ic_action_add_computer.png Binary files differnew file mode 100755 index 000000000000..ad8ada6bdfa0 --- /dev/null +++ b/android/sdremote/res/drawable-hdpi/ic_action_add_computer.png diff --git a/android/sdremote/res/drawable-hdpi/ic_action_cancel.png b/android/sdremote/res/drawable-hdpi/ic_action_cancel.png Binary files differnew file mode 100755 index 000000000000..094eea589246 --- /dev/null +++ b/android/sdremote/res/drawable-hdpi/ic_action_cancel.png diff --git a/android/sdremote/res/drawable-hdpi/ic_action_save.png b/android/sdremote/res/drawable-hdpi/ic_action_save.png Binary files differnew file mode 100755 index 000000000000..53cf6877eb72 --- /dev/null +++ b/android/sdremote/res/drawable-hdpi/ic_action_save.png diff --git a/android/sdremote/res/drawable-mdpi/ic_action_add_computer.png b/android/sdremote/res/drawable-mdpi/ic_action_add_computer.png Binary files differnew file mode 100755 index 000000000000..4d5d484b3997 --- /dev/null +++ b/android/sdremote/res/drawable-mdpi/ic_action_add_computer.png diff --git a/android/sdremote/res/drawable-mdpi/ic_action_cancel.png b/android/sdremote/res/drawable-mdpi/ic_action_cancel.png Binary files differnew file mode 100755 index 000000000000..3336760d5f3e --- /dev/null +++ b/android/sdremote/res/drawable-mdpi/ic_action_cancel.png diff --git a/android/sdremote/res/drawable-mdpi/ic_action_save.png b/android/sdremote/res/drawable-mdpi/ic_action_save.png Binary files differnew file mode 100755 index 000000000000..35cda8e11213 --- /dev/null +++ b/android/sdremote/res/drawable-mdpi/ic_action_save.png diff --git a/android/sdremote/res/drawable-xhdpi/ic_action_add_computer.png b/android/sdremote/res/drawable-xhdpi/ic_action_add_computer.png Binary files differnew file mode 100755 index 000000000000..23b9a1c18577 --- /dev/null +++ b/android/sdremote/res/drawable-xhdpi/ic_action_add_computer.png diff --git a/android/sdremote/res/drawable-xhdpi/ic_action_cancel.png b/android/sdremote/res/drawable-xhdpi/ic_action_cancel.png Binary files differnew file mode 100755 index 000000000000..f391760ef134 --- /dev/null +++ b/android/sdremote/res/drawable-xhdpi/ic_action_cancel.png diff --git a/android/sdremote/res/drawable-xhdpi/ic_action_save.png b/android/sdremote/res/drawable-xhdpi/ic_action_save.png Binary files differnew file mode 100755 index 000000000000..b52dc37012a3 --- /dev/null +++ b/android/sdremote/res/drawable-xhdpi/ic_action_save.png diff --git a/android/sdremote/res/layout-v11/action_bar_computer_creation.xml b/android/sdremote/res/layout-v11/action_bar_computer_creation.xml new file mode 100644 index 000000000000..0c7c5c8ea777 --- /dev/null +++ b/android/sdremote/res/layout-v11/action_bar_computer_creation.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="horizontal" + android:divider="?android:attr/dividerVertical" + android:showDividers="middle" + android:dividerPadding="@dimen/padding_horizontal_action_bar_divider" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <FrameLayout + android:id="@+id/button_cancel" + style="?android:actionButtonStyle" + android:layout_weight="1" + android:layout_width="0dp" + android:layout_height="match_parent"> + + <TextView + style="?android:actionBarTabTextStyle" + android:text="@string/button_cancel" + android:drawableLeft="@drawable/ic_action_cancel" + android:drawablePadding="@dimen/padding_action_bar_button_drawable" + android:paddingRight="@dimen/padding_horizontal_action_bar_button" + android:gravity="center_vertical" + android:layout_gravity="center" + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> + + </FrameLayout> + + <FrameLayout + android:id="@+id/button_save" + style="?android:actionButtonStyle" + android:layout_weight="1" + android:layout_width="0dp" + android:layout_height="match_parent"> + + <TextView + style="?android:actionBarTabTextStyle" + android:text="@string/button_save" + android:drawableLeft="@drawable/ic_action_save" + android:drawablePadding="@dimen/padding_action_bar_button_drawable" + android:paddingRight="@dimen/padding_horizontal_action_bar_button" + android:gravity="center_vertical" + android:layout_gravity="center" + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> + + </FrameLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/android/sdremote/res/layout/action_bar_computer_creation.xml b/android/sdremote/res/layout/action_bar_computer_creation.xml new file mode 100644 index 000000000000..5e6ea3696fb6 --- /dev/null +++ b/android/sdremote/res/layout/action_bar_computer_creation.xml @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="horizontal" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <FrameLayout + android:id="@+id/button_cancel" + style="@style/Widget.Sherlock.ActionButton" + android:layout_weight="1" + android:layout_width="0dp" + android:layout_height="match_parent"> + + <TextView + style="@style/Widget.Sherlock.ActionBar.TabText" + android:text="@string/button_cancel" + android:drawableLeft="@drawable/ic_action_cancel" + android:drawablePadding="@dimen/padding_action_bar_button_drawable" + android:paddingRight="@dimen/padding_horizontal_action_bar_button" + android:gravity="center_vertical" + android:layout_gravity="center" + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> + + </FrameLayout> + + <View + android:layout_width="@dimen/width_action_bar_divider" + android:layout_height="match_parent" + android:layout_marginTop="@dimen/margin_vertical_action_bar_divider" + android:layout_marginBottom="@dimen/margin_vertical_action_bar_divider" + android:background="@color/background_action_bar_divider"/> + + <FrameLayout + android:id="@+id/button_save" + style="@style/Widget.Sherlock.ActionButton" + android:layout_weight="1" + android:layout_width="0dp" + android:layout_height="match_parent"> + + <TextView + style="@style/Widget.Sherlock.ActionBar.TabText" + android:text="@string/button_save" + android:drawableLeft="@drawable/ic_action_save" + android:drawablePadding="@dimen/padding_action_bar_button_drawable" + android:paddingRight="@dimen/padding_horizontal_action_bar_button" + android:gravity="center_vertical" + android:layout_gravity="center" + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> + + </FrameLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/android/sdremote/res/layout/activity_computer_creation.xml b/android/sdremote/res/layout/activity_computer_creation.xml new file mode 100644 index 000000000000..be1f31395436 --- /dev/null +++ b/android/sdremote/res/layout/activity_computer_creation.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:padding="@dimen/padding_creation_layout" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <EditText + android:id="@+id/edit_ip_address" + android:singleLine="true" + android:inputType="text" + android:hint="@string/hint_ip_address" + android:layout_width="match_parent" + android:layout_height="wrap_content"/> + + <EditText + android:id="@+id/edit_name" + android:singleLine="true" + android:inputType="text" + android:hint="@string/hint_name" + android:paddingTop="@dimen/padding_vertical_edit" + android:layout_width="match_parent" + android:layout_height="wrap_content"/> + +</LinearLayout>
\ No newline at end of file diff --git a/android/sdremote/res/menu/menu_action_bar_computers.xml b/android/sdremote/res/menu/menu_action_bar_computers.xml index ee7cfb8c1ef2..7835fa986feb 100644 --- a/android/sdremote/res/menu/menu_action_bar_computers.xml +++ b/android/sdremote/res/menu/menu_action_bar_computers.xml @@ -2,6 +2,12 @@ <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item + android:id="@+id/menu_add_computer" + android:title="@string/menu_add_computer" + android:icon="@drawable/ic_action_add_computer" + android:showAsAction="always"/> + + <item android:id="@+id/menu_licenses" android:title="@string/menu_licenses" android:showAsAction="never"/> diff --git a/android/sdremote/res/menu/menu_context_computers.xml b/android/sdremote/res/menu/menu_context_computers.xml new file mode 100644 index 000000000000..d2490c0de3b1 --- /dev/null +++ b/android/sdremote/res/menu/menu_context_computers.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + + <item + android:id="@+id/menu_remove_computer" + android:title="@string/menu_remove_computer"/> + +</menu>
\ No newline at end of file diff --git a/android/sdremote/res/values/colors.xml b/android/sdremote/res/values/colors.xml index 5cbe66a6b3ed..f15f73bd3826 100644 --- a/android/sdremote/res/values/colors.xml +++ b/android/sdremote/res/values/colors.xml @@ -3,6 +3,8 @@ <color name="background_action_bar">#e46f1f</color> + <color name="background_action_bar_divider">#55ffffff</color> + <color name="orange">#EE4400</color> <color name="grey">#303030</color> <color name="white">#FFFFFF</color> diff --git a/android/sdremote/res/values/dimens.xml b/android/sdremote/res/values/dimens.xml index 4af04087d552..694e02e64eee 100644 --- a/android/sdremote/res/values/dimens.xml +++ b/android/sdremote/res/values/dimens.xml @@ -1,11 +1,21 @@ <?xml version="1.0" encoding="utf-8"?> <resources> + <dimen name="padding_action_bar_button_drawable">8dp</dimen> + <dimen name="padding_creation_layout">16dp</dimen> + <dimen name="padding_horizontal_list_item">8dp</dimen> <dimen name="padding_horizontal_connection_layout">40dp</dimen> + <dimen name="padding_horizontal_action_bar_button">20dp</dimen> + <dimen name="padding_horizontal_action_bar_divider">12dp</dimen> <dimen name="padding_vertical_pin">10dp</dimen> <dimen name="padding_vertical_error_message">10dp</dimen> + <dimen name="padding_vertical_edit">8dp</dimen> + + <dimen name="margin_vertical_action_bar_divider">12dp</dimen> + + <dimen name="width_action_bar_divider">0.5dp</dimen> <dimen name="text_size_list_item">18sp</dimen> <dimen name="text_size_pin">35sp</dimen> diff --git a/android/sdremote/res/values/strings.xml b/android/sdremote/res/values/strings.xml index ab3a73b184d5..4e7502dfd3a2 100644 --- a/android/sdremote/res/values/strings.xml +++ b/android/sdremote/res/values/strings.xml @@ -73,11 +73,21 @@ <string name="menu_licenses">Open source licenses</string> <string name="menu_reconnect">Reconnect</string> + <string name="menu_add_computer">Add computer</string> + <string name="menu_remove_computer">Remove</string> + + <string name="button_cancel">Cancel</string> + <string name="button_save">Save</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> <string name="message_impress_remote_enabling">Make sure you enabled remote control. Go to “Tools → Options → LibreOffice Impress → General” in LibreOffice Impress.</string> <string name="message_impress_wifi_enabling">You should enable experimental features at “Tools → Options → LibreOffice → Advanced” as well.</string> <string name="message_impress_pairing_check">If you have Bluetooth pairing issues check instructions related to your desktop OS.</string> + <string name="message_ip_address_validation">You should type a valid IP address.</string> + <string name="message_name_validation">Name should not be empty.</string> + + <string name="hint_ip_address">IP address</string> + <string name="hint_name">Name</string> </resources> diff --git a/android/sdremote/res/values/themes.xml b/android/sdremote/res/values/themes.xml index 2dcde14acfcf..21f5be187576 100644 --- a/android/sdremote/res/values/themes.xml +++ b/android/sdremote/res/values/themes.xml @@ -37,6 +37,16 @@ <item name="displayOptions">showTitle|showHome|useLogo</item> </style> + <style name="Theme.ImpressRemote.ComputerCreation" parent="Theme.ImpressRemote"> + <item name="android:actionBarStyle">@style/Theme.ImpressRemote.ComputerCreation.ActionBar</item> + <item name="actionBarStyle">@style/Theme.ImpressRemote.ComputerCreation.ActionBar</item> + </style> + + <style name="Theme.ImpressRemote.ComputerCreation.ActionBar" parent="Theme.ImpressRemote.ActionBar"> + <item name="android:displayOptions">showCustom</item> + <item name="displayOptions">showCustom</item> + </style> + <style name="Theme.ImpressRemote.ActionBarWidget" parent="android:style/Widget.Holo.Light"> <item name="android:background">@color/orange</item> <item name="android:textColor">@color/white</item> diff --git a/android/sdremote/src/org/libreoffice/impressremote/ComputerCreationActivity.java b/android/sdremote/src/org/libreoffice/impressremote/ComputerCreationActivity.java new file mode 100644 index 000000000000..4311ff285a78 --- /dev/null +++ b/android/sdremote/src/org/libreoffice/impressremote/ComputerCreationActivity.java @@ -0,0 +1,118 @@ +package org.libreoffice.impressremote; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.text.TextUtils; +import android.util.Patterns; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.EditText; + +import com.actionbarsherlock.app.ActionBar; +import com.actionbarsherlock.app.SherlockFragmentActivity; + +public class ComputerCreationActivity extends SherlockFragmentActivity implements View.OnClickListener { + @Override + protected void onCreate(Bundle aSavedInstanceState) { + super.onCreate(aSavedInstanceState); + setContentView(R.layout.activity_computer_creation); + + setUpActionBar(); + } + + private void setUpActionBar() { + View aView = buildCustomActionBarView(); + ActionBar.LayoutParams aLayoutParams = buildCustomActionBarLayoutParams(); + + getSupportActionBar().setCustomView(aView, aLayoutParams); + + getCancelButton().setOnClickListener(this); + getSaveButton().setOnClickListener(this); + } + + private View buildCustomActionBarView() { + Context aContext = getSupportActionBar().getThemedContext(); + LayoutInflater aInflater = (LayoutInflater) aContext.getSystemService( + LAYOUT_INFLATER_SERVICE); + + return aInflater.inflate(R.layout.action_bar_computer_creation, null); + } + + private ActionBar.LayoutParams buildCustomActionBarLayoutParams() { + return new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.MATCH_PARENT); + } + + private View getCancelButton() { + return getSupportActionBar().getCustomView().findViewById(R.id.button_cancel); + } + + private View getSaveButton() { + return getSupportActionBar().getCustomView().findViewById(R.id.button_save); + } + + @Override + public void onClick(View aView) { + if (aView.equals(getCancelButton())) { + cancelCreation(); + + return; + } + + + if (aView.equals(getSaveButton())) { + saveServer(); + } + } + + private void cancelCreation() { + finish(); + } + + private void saveServer() { + String aIpAddress = getText(getIpAddressEdit()); + String aName = getText(getNameEdit()); + + if (!isIpAddressValid(aIpAddress)) { + getIpAddressEdit().setError(getText(R.string.message_ip_address_validation)); + } + + if (TextUtils.isEmpty(aName)) { + getNameEdit().setError(getText(R.string.message_name_validation)); + } + + if (isServerInformationValid(aIpAddress, aName)) { + finish(aIpAddress, aName); + } + } + + private String getText(EditText aEdit) { + return aEdit.getText().toString().trim(); + } + + private EditText getIpAddressEdit() { + return (EditText) findViewById(R.id.edit_ip_address); + } + + private EditText getNameEdit() { + return (EditText) findViewById(R.id.edit_name); + } + + private boolean isServerInformationValid(String aIpAddress, String aName) { + return isIpAddressValid(aIpAddress) && !TextUtils.isEmpty(aName); + } + + private boolean isIpAddressValid(String aIpAddress) { + return Patterns.IP_ADDRESS.matcher(aIpAddress).matches(); + } + + private void finish(String aIpAddress, String aName) { + Intent aIntent = Intents.buildComputerCreationResultIntent(aIpAddress, aName); + setResult(Activity.RESULT_OK, aIntent); + + finish(); + } +} diff --git a/android/sdremote/src/org/libreoffice/impressremote/ComputersActivity.java b/android/sdremote/src/org/libreoffice/impressremote/ComputersActivity.java index 0a5ea2f689a7..c337c9410b8c 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/ComputersActivity.java +++ b/android/sdremote/src/org/libreoffice/impressremote/ComputersActivity.java @@ -75,7 +75,7 @@ public class ComputersActivity extends SherlockFragmentActivity { } private void callLicensesActivity() { - Intent aIntent = new Intent(this, LicensesActivity.class); + Intent aIntent = Intents.buildLicensesIntent(this); startActivity(aIntent); } } diff --git a/android/sdremote/src/org/libreoffice/impressremote/ComputersFragment.java b/android/sdremote/src/org/libreoffice/impressremote/ComputersFragment.java index ba17da2f8602..2c294a591393 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/ComputersFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/ComputersFragment.java @@ -11,6 +11,7 @@ package org.libreoffice.impressremote; import java.util.ArrayList; import java.util.List; +import android.app.Activity; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.Context; @@ -20,10 +21,14 @@ import android.content.ServiceConnection; import android.os.Bundle; import android.os.IBinder; import android.support.v4.content.LocalBroadcastManager; +import android.view.ContextMenu; import android.view.View; +import android.widget.AdapterView; import android.widget.ListView; import com.actionbarsherlock.app.SherlockListFragment; +import com.actionbarsherlock.internal.view.menu.ActionMenu; +import com.actionbarsherlock.view.MenuItem; import org.libreoffice.impressremote.communication.CommunicationService; import org.libreoffice.impressremote.communication.Server; @@ -58,6 +63,12 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo super.onCreate(savedInstanceState); mType = (Type) getArguments().getSerializable("TYPE"); + + setUpActionBar(); + } + + private void setUpActionBar() { + setHasOptionsMenu(true); } @Override @@ -227,6 +238,87 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo Intent aIntent = Intents.buildComputerConnectionIntent(getActivity(), aComputer); startActivity(aIntent); } + + @Override + public void onStart() { + super.onStart(); + + setUpContextMenu(); + } + + private void setUpContextMenu() { + registerForContextMenu(getListView()); + } + + @Override + public void onCreateContextMenu(ContextMenu aMenu, View aView, ContextMenu.ContextMenuInfo aMenuInfo) { + super.onCreateContextMenu(aMenu, aView, aMenuInfo); + + getActivity().getMenuInflater().inflate(R.menu.menu_context_computers, aMenu); + } + + @Override + public boolean onContextItemSelected(android.view.MenuItem aMenuItem) { + int aComputerPosition = getListItemPosition(aMenuItem); + Server aComputer = getComputersAdapter().getItem(aComputerPosition); + + removeComputer(aComputer); + + return true; + } + + private int getListItemPosition(android.view.MenuItem aMenuItem) { + AdapterView.AdapterContextMenuInfo aMenuItemInfo = (AdapterView.AdapterContextMenuInfo) aMenuItem.getMenuInfo(); + + return aMenuItemInfo.position; + } + + private void removeComputer(Server aComputer) { + mCommunicationService.removeServer(aComputer); + + Intent aIntent = Intents.buildServersListChangedIntent(); + LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(aIntent); + } + + @Override + public boolean onOptionsItemSelected(MenuItem aMenuItem) { + switch (aMenuItem.getItemId()) { + case R.id.menu_add_computer: + callComputerCreationActivity(); + return true; + + default: + return super.onOptionsItemSelected(aMenuItem); + } + } + + private void callComputerCreationActivity() { + Intent aIntent = new Intent(getActivity(), ComputerCreationActivity.class); + startActivityForResult(aIntent, Intents.RequestCodes.CREATE_SERVER); + } + + @Override + public void onActivityResult(int aRequestCode, int aResultCode, Intent aIntent) { + if (aRequestCode != Intents.RequestCodes.CREATE_SERVER) { + return; + } + + if (aResultCode != Activity.RESULT_OK) { + return; + } + + String aServerAddress = aIntent.getStringExtra(Intents.Extras.SERVER_ADDRESS); + String aServerName = aIntent.getStringExtra(Intents.Extras.SERVER_NAME); + + addServer(aServerAddress, aServerName); + } + + private void addServer(String aAddress, String aName) { + mCommunicationService.addServer(aAddress, aName); + + Intent aIntent = Intents.buildServersListChangedIntent(); + LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(aIntent); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/android/sdremote/src/org/libreoffice/impressremote/Intents.java b/android/sdremote/src/org/libreoffice/impressremote/Intents.java index cbb2b112d581..93d71cb1c5c0 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/Intents.java +++ b/android/sdremote/src/org/libreoffice/impressremote/Intents.java @@ -36,10 +36,19 @@ public final class Intents { public static final String PIN = "PIN"; 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 class RequestCodes { + private RequestCodes() { + } + + public static final int CREATE_SERVER = 1; + } + public static Intent buildServersListChangedIntent() { return new Intent(Actions.SERVERS_LIST_CHANGED); } @@ -94,4 +103,20 @@ public final class Intents { return aIntent; } + + public static Intent buildComputerCreationIntent(Context aContext) { + return new Intent(aContext, ComputerCreationActivity.class); + } + + public static Intent buildComputerCreationResultIntent(String aAddress, String aName) { + Intent aIntent = new Intent(); + aIntent.putExtra(Extras.SERVER_ADDRESS, aAddress); + aIntent.putExtra(Extras.SERVER_NAME, aName); + + return aIntent; + } + + public static Intent buildLicensesIntent(Context aContext) { + return new Intent(aContext, LicensesActivity.class); + } } diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/ServersManager.java b/android/sdremote/src/org/libreoffice/impressremote/communication/ServersManager.java index 22148f78c341..967ef9d28962 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/ServersManager.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/ServersManager.java @@ -86,7 +86,7 @@ public class ServersManager { } public void removeServer(Server aServer) { - if (getManualAddedTcpServers().contains(aServer)) { + if (getServersAddresses(getManualAddedTcpServers()).contains(aServer.getAddress())) { removeManualAddedServer(aServer); return; @@ -95,6 +95,16 @@ public class ServersManager { blacklistServer(aServer); } + private List<String> getServersAddresses(List<Server> aServers) { + List<String> aServersAddresses = new ArrayList<String>(); + + for (Server aServer : aServers) { + aServersAddresses.add(aServer.getAddress()); + } + + return aServersAddresses; + } + private void removeManualAddedServer(Server aServer) { Preferences.remove(mContext, Preferences.Locations.STORED_SERVERS, aServer.getAddress()); |