diff options
author | Arne Schwabe <arne@rfc2549.org> | 2014-11-17 14:08:24 +0100 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2014-11-17 14:08:24 +0100 |
commit | 72126eb563b222483864b51838ee664c1974bd83 (patch) | |
tree | fa5a978246a9d2b88e4df484388789d45a446f81 /main/src | |
parent | c67a5e6a846fa55b94cecacf08c489bbbaa7576c (diff) |
Implement deletion of remotes
--HG--
extra : rebase_source : 7acb74bd77bff57b6f29ff020fa668966086cafa
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java | 37 | ||||
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/fragments/Settings_Connections.java | 7 | ||||
-rw-r--r-- | main/src/main/res/drawable-hdpi/ic_delete_grey600_24dp.png | bin | 0 -> 248 bytes | |||
-rw-r--r-- | main/src/main/res/drawable-mdpi/ic_delete_grey600_24dp.png | bin | 0 -> 199 bytes | |||
-rw-r--r-- | main/src/main/res/drawable-xhdpi/ic_delete_grey600_24dp.png | bin | 0 -> 271 bytes | |||
-rw-r--r-- | main/src/main/res/drawable-xxhdpi/ic_delete_grey600_24dp.png | bin | 0 -> 341 bytes | |||
-rw-r--r-- | main/src/main/res/drawable-xxxhdpi/ic_delete_grey600_24dp.png | bin | 0 -> 402 bytes | |||
-rw-r--r-- | main/src/main/res/drawable/bg_rect_round.xml | 12 | ||||
-rw-r--r-- | main/src/main/res/layout/server_card.xml | 20 | ||||
-rw-r--r-- | main/src/main/res/values-v21/refs.xml | 2 | ||||
-rw-r--r-- | main/src/main/res/values/refs.xml | 1 | ||||
-rwxr-xr-x | main/src/main/res/values/strings.xml | 3 |
12 files changed, 70 insertions, 12 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java b/main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java index 05adef0d..9fd7c04f 100644 --- a/main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java +++ b/main/src/main/java/de/blinkt/openvpn/fragments/ConnectionsAdapter.java @@ -5,17 +5,20 @@ package de.blinkt.openvpn.fragments; +import android.app.AlertDialog; import android.content.Context; +import android.content.DialogInterface; import android.support.v7.widget.RecyclerView; import android.text.Editable; import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.BaseAdapter; +import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.EditText; +import android.widget.ImageButton; import android.widget.RadioGroup; import android.widget.Switch; import android.widget.TextView; @@ -52,6 +55,7 @@ public class ConnectionsAdapter extends RecyclerView.Adapter<ConnectionsAdapter. private final EditText mCustomOptionText; private final CheckBox mCustomOptionCB; private final View mCustomOptionsLayout; + private final ImageButton mDeleteButton; public ConnectionsHolder(View card) { super(card); @@ -63,6 +67,7 @@ public class ConnectionsAdapter extends RecyclerView.Adapter<ConnectionsAdapter. mCustomOptionText = (EditText) card.findViewById(R.id.customoptions); mProtoGroup = (RadioGroup) card.findViewById(R.id.udptcpradiogroup); mCustomOptionsLayout = card.findViewById(R.id.custom_options_layout); + mDeleteButton = (ImageButton) card.findViewById(R.id.remove_connection); } } @@ -116,6 +121,25 @@ public class ConnectionsAdapter extends RecyclerView.Adapter<ConnectionsAdapter. } }); + cH.mDeleteButton.setOnClickListener( + new View.OnClickListener() { + @Override + public void onClick(View v) { + AlertDialog.Builder ab = new AlertDialog.Builder(mContext); + ab.setTitle(R.string.query_delete_remote); + ab.setPositiveButton(R.string.keep, null); + ab.setNegativeButton(R.string.delete, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + removeRemote(i); + notifyItemRemoved(i); + } + }); + ab.create().show(); + } + } + ); + cH.mServerNameView.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { @@ -154,6 +178,15 @@ public class ConnectionsAdapter extends RecyclerView.Adapter<ConnectionsAdapter. } + private void removeRemote(int idx) { + Connection[] mConnections2 = Arrays.copyOf(mConnections, mConnections.length-1); + for (int i=idx+1;i<mConnections.length;i++){ + mConnections2[i-1]=mConnections[i]; + } + mConnections = mConnections2; + displayWarningifNoneEnabled(); + } + @Override public int getItemCount() { return mConnections.length; @@ -173,7 +206,7 @@ public class ConnectionsAdapter extends RecyclerView.Adapter<ConnectionsAdapter. mConnections = Arrays.copyOf(mConnections, mConnections.length+1); mConnections[mConnections.length-1] = new Connection(); notifyItemInserted(mConnections.length-1); - + displayWarningifNoneEnabled(); } public void saveProfile() { diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Connections.java b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Connections.java index db620c52..67b49e87 100644 --- a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Connections.java +++ b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Connections.java @@ -60,7 +60,7 @@ public class Settings_Connections extends Fragment implements View.OnClickListen public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.connections, container, false); - + mWarning = (TextView) v.findViewById(R.id.noserver_active_warning); mRecyclerView = (RecyclerView) v.findViewById(R.id.connection_recycler_view); int dpwidth = (int) (container.getWidth()/getResources().getDisplayMetrics().density); @@ -74,7 +74,6 @@ public class Settings_Connections extends Fragment implements View.OnClickListen mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(),LinearLayoutManager.VERTICAL,false)); mRecyclerView.setAdapter(mConnectionsAdapter); - mConnectionsAdapter.displayWarningifNoneEnabled(); ImageButton fab_button = (ImageButton) v.findViewById(R.id.add_new_remote); if(fab_button!=null) @@ -83,7 +82,9 @@ public class Settings_Connections extends Fragment implements View.OnClickListen mUseRandomRemote = (CheckBox) v.findViewById(R.id.remote_random); mUseRandomRemote.setChecked(mProfile.mRemoteRandom); - mWarning = (TextView) v.findViewById(R.id.noserver_active_warning); + + mConnectionsAdapter.displayWarningifNoneEnabled(); + return v; } diff --git a/main/src/main/res/drawable-hdpi/ic_delete_grey600_24dp.png b/main/src/main/res/drawable-hdpi/ic_delete_grey600_24dp.png Binary files differnew file mode 100644 index 00000000..b72a9f3c --- /dev/null +++ b/main/src/main/res/drawable-hdpi/ic_delete_grey600_24dp.png diff --git a/main/src/main/res/drawable-mdpi/ic_delete_grey600_24dp.png b/main/src/main/res/drawable-mdpi/ic_delete_grey600_24dp.png Binary files differnew file mode 100644 index 00000000..e757fdb0 --- /dev/null +++ b/main/src/main/res/drawable-mdpi/ic_delete_grey600_24dp.png diff --git a/main/src/main/res/drawable-xhdpi/ic_delete_grey600_24dp.png b/main/src/main/res/drawable-xhdpi/ic_delete_grey600_24dp.png Binary files differnew file mode 100644 index 00000000..c6bb43e8 --- /dev/null +++ b/main/src/main/res/drawable-xhdpi/ic_delete_grey600_24dp.png diff --git a/main/src/main/res/drawable-xxhdpi/ic_delete_grey600_24dp.png b/main/src/main/res/drawable-xxhdpi/ic_delete_grey600_24dp.png Binary files differnew file mode 100644 index 00000000..4886ab1e --- /dev/null +++ b/main/src/main/res/drawable-xxhdpi/ic_delete_grey600_24dp.png diff --git a/main/src/main/res/drawable-xxxhdpi/ic_delete_grey600_24dp.png b/main/src/main/res/drawable-xxxhdpi/ic_delete_grey600_24dp.png Binary files differnew file mode 100644 index 00000000..e4e21812 --- /dev/null +++ b/main/src/main/res/drawable-xxxhdpi/ic_delete_grey600_24dp.png diff --git a/main/src/main/res/drawable/bg_rect_round.xml b/main/src/main/res/drawable/bg_rect_round.xml new file mode 100644 index 00000000..0eab3696 --- /dev/null +++ b/main/src/main/res/drawable/bg_rect_round.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (c) 2012-2014 Arne Schwabe + ~ Distributed under the GNU GPL v2. For full terms see the file doc/LICENSE.txt + --> + +<shape xmlns:android="http://schemas.android.com/apk/res/android"> + <solid android:color="@android:color/background_light" /> + + <corners android:radius="10dp" /> + +</shape>
\ No newline at end of file diff --git a/main/src/main/res/layout/server_card.xml b/main/src/main/res/layout/server_card.xml index 96971d33..20b7e0d5 100644 --- a/main/src/main/res/layout/server_card.xml +++ b/main/src/main/res/layout/server_card.xml @@ -106,8 +106,7 @@ android:layout_height="wrap_content" android:text="TCP" /> </RadioGroup> - - <!-- <TextView + <!-- <TextView android:paddingTop="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" @@ -187,15 +186,22 @@ android:layout_below="@+id/portnumber" android:layout_alignRight="@+id/portnumber" android:layout_alignEnd="@+id/portnumber" /> + <ImageButton + android:layout_margin="12dp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="12dp" + android:layout_alignRight="@+id/portnumber" + android:layout_alignEnd="@+id/portnumber" + android:layout_below="@id/remoteSwitch" + android:background="@drawable/ic_menu_delete_grey" + android:id="@+id/remove_connection" /> + </RelativeLayout> </android.support.v7.widget.CardView> - <ImageButton - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:id="@+id/imageButton" - android:layout_gravity="right|top" /> + </FrameLayout>
\ No newline at end of file diff --git a/main/src/main/res/values-v21/refs.xml b/main/src/main/res/values-v21/refs.xml index 76b5c20f..70918ab9 100644 --- a/main/src/main/res/values-v21/refs.xml +++ b/main/src/main/res/values-v21/refs.xml @@ -10,6 +10,8 @@ <drawable name="ic_menu_save">@drawable/ic_check_white_24dp</drawable> <drawable name="ic_menu_view">@drawable/ic_filter_list_white_24dp</drawable> <drawable name="ic_menu_delete">@drawable/ic_delete_white_24dp</drawable> + <drawable name="ic_menu_delete_grey">@drawable/ic_delete_grey600_24dp</drawable> + <drawable name="ic_menu_edit">@drawable/ic_edit_white_24dp</drawable> <drawable name="ic_menu_import">@drawable/ic_archive_white_24dp</drawable> <drawable name="vpn_item_edit">@drawable/ic_edit_grey600_24dp</drawable> diff --git a/main/src/main/res/values/refs.xml b/main/src/main/res/values/refs.xml index 4944a992..937b5110 100644 --- a/main/src/main/res/values/refs.xml +++ b/main/src/main/res/values/refs.xml @@ -17,5 +17,6 @@ <drawable name="ic_dialog_alert">@android:drawable/ic_dialog_alert</drawable> <drawable name="ic_menu_add_grey">@android:drawable/ic_menu_add</drawable> <drawable name="ic_menu_import_grey">@drawable/ic_menu_archive</drawable> + <drawable name="ic_menu_delete_grey">@android:drawable/ic_menu_delete</drawable> </resources>
\ No newline at end of file diff --git a/main/src/main/res/values/strings.xml b/main/src/main/res/values/strings.xml index 4a76ac70..648779fe 100755 --- a/main/src/main/res/values/strings.xml +++ b/main/src/main/res/values/strings.xml @@ -336,5 +336,8 @@ <string name="app_no_longer_exists">Package %s is no longer installed, removing it from app allow/disallow list</string> <string name="vpn_disallow_radio">VPN is used for all apps but exclude selected</string> <string name="vpn_allow_radio">VPN is used for only for selected apps</string> + <string name="query_delete_remote">Remove remote server entry?</string> + <string name="keep">Keep</string> + <string name="delete">Delete</string> </resources> |