commit 8494cfb63327bd27e9c31b155dfb2c14e3f5658f Author: arrase arrase@gmail.com Date: Sun Nov 20 03:20:14 2016 +0100
actions dialog --- .../android/ui/hs/HiddenServicesActivity.java | 17 +++---- .../android/ui/hs/dialogs/HSActionsDialog.java | 56 ++++++++++++++++++++++ .../android/ui/hs/dialogs/HSDataDialog.java | 10 ++-- app/src/main/res/layout/layout_hs_actions.xml | 30 ++++++++++++ app/src/main/res/layout/layout_hs_data_dialog.xml | 2 +- app/src/main/res/values/strings.xml | 6 ++- 6 files changed, 103 insertions(+), 18 deletions(-)
diff --git a/app/src/main/java/org/torproject/android/ui/hs/HiddenServicesActivity.java b/app/src/main/java/org/torproject/android/ui/hs/HiddenServicesActivity.java index a2c9280..576f083 100644 --- a/app/src/main/java/org/torproject/android/ui/hs/HiddenServicesActivity.java +++ b/app/src/main/java/org/torproject/android/ui/hs/HiddenServicesActivity.java @@ -2,17 +2,21 @@ package org.torproject.android.ui.hs;
import android.content.ContentResolver; +import android.content.DialogInterface; import android.database.ContentObserver; import android.os.Bundle; import android.os.Handler; import android.support.design.widget.FloatingActionButton; +import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.AdapterView; import android.widget.ListView; +import android.widget.TextView;
import org.torproject.android.R; import org.torproject.android.ui.hs.adapters.OnionListAdapter; +import org.torproject.android.ui.hs.dialogs.HSActionsDialog; import org.torproject.android.ui.hs.dialogs.HSDataDialog; import org.torproject.android.ui.hs.providers.HSContentProvider;
@@ -69,19 +73,12 @@ public class HiddenServicesActivity extends AppCompatActivity { ListView onion_list = (ListView) findViewById(R.id.onion_list); onion_list.setAdapter(mAdapter);
- onion_list.setOnItemClickListener(new AdapterView.OnItemClickListener(){ + onion_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { - - } - }); - - onion_list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener(){ - - @Override - public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { - return false; + HSActionsDialog dialog = new HSActionsDialog(); + dialog.show(getSupportFragmentManager(), "HSActionsDialog"); } }); } diff --git a/app/src/main/java/org/torproject/android/ui/hs/dialogs/HSActionsDialog.java b/app/src/main/java/org/torproject/android/ui/hs/dialogs/HSActionsDialog.java new file mode 100644 index 0000000..8c5ca48 --- /dev/null +++ b/app/src/main/java/org/torproject/android/ui/hs/dialogs/HSActionsDialog.java @@ -0,0 +1,56 @@ +package org.torproject.android.ui.hs.dialogs; + + +import android.app.Dialog; +import android.os.Bundle; +import android.support.annotation.NonNull; +import android.support.v4.app.DialogFragment; +import android.support.v7.app.AlertDialog; +import android.view.View; +import android.widget.Button; + +import org.torproject.android.R; + +public class HSActionsDialog extends DialogFragment { + + @NonNull + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) { + + final View dialog_view = getActivity().getLayoutInflater().inflate(R.layout.layout_hs_actions, null); + final AlertDialog actionDialog = new AlertDialog.Builder(getActivity()) + .setView(dialog_view) + .setTitle(R.string.hidden_services) + .create(); + + Button save = (Button) dialog_view.findViewById(R.id.btn_hs_backup); + save.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + actionDialog.dismiss(); + } + }); + + Button cancel = (Button) dialog_view.findViewById(R.id.btn_hs_clipboard); + cancel.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + actionDialog.dismiss(); + } + }); + + Button delete = (Button) dialog_view.findViewById(R.id.btn_hs_delete); + delete.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + actionDialog.dismiss(); + } + }); + + Button btn_cancel = (Button) dialog_view.findViewById(R.id.btn_hs_cancel); + btn_cancel.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + actionDialog.dismiss(); + } + }); + + return actionDialog; + } +} diff --git a/app/src/main/java/org/torproject/android/ui/hs/dialogs/HSDataDialog.java b/app/src/main/java/org/torproject/android/ui/hs/dialogs/HSDataDialog.java index 67c3691..98a9d3f 100644 --- a/app/src/main/java/org/torproject/android/ui/hs/dialogs/HSDataDialog.java +++ b/app/src/main/java/org/torproject/android/ui/hs/dialogs/HSDataDialog.java @@ -25,9 +25,9 @@ public class HSDataDialog extends DialogFragment { final View dialog_view = getActivity().getLayoutInflater().inflate(R.layout.layout_hs_data_dialog, null);
// Use the Builder class for convenient dialog construction - final AlertDialog serverDataDialog = new AlertDialog.Builder(getActivity()) + final AlertDialog serviceDataDialog = new AlertDialog.Builder(getActivity()) .setView(dialog_view) - .setTitle(R.string.hs_dialog_title) + .setTitle(R.string.hidden_services) .create();
// Buttons action @@ -44,7 +44,7 @@ public class HSDataDialog extends DialogFragment {
if (checkInput(localPort,onionPort)) { saveData(serverName, localPort,onionPort); - serverDataDialog.dismiss(); + serviceDataDialog.dismiss(); } } }); @@ -52,11 +52,11 @@ public class HSDataDialog extends DialogFragment { Button cancel = (Button) dialog_view.findViewById(R.id.HSDialogCancel); cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { - serverDataDialog.cancel(); + serviceDataDialog.cancel(); } });
- return serverDataDialog; + return serviceDataDialog; }
private boolean checkInput(Integer local, Integer remote){ diff --git a/app/src/main/res/layout/layout_hs_actions.xml b/app/src/main/res/layout/layout_hs_actions.xml new file mode 100644 index 0000000..64bda7d --- /dev/null +++ b/app/src/main/res/layout/layout_hs_actions.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" android:layout_width="match_parent" + android:layout_height="match_parent"> + + <Button + android:text="@string/copy_address_to_clipboard" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:id="@+id/btn_hs_clipboard" /> + + <Button + android:text="@string/backup_service" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:id="@+id/btn_hs_backup" /> + + <Button + android:text="@string/delete_service" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:id="@+id/btn_hs_delete" /> + + <Button + android:text="@string/btn_cancel" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:id="@+id/btn_hs_cancel" /> + +</LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/layout/layout_hs_data_dialog.xml b/app/src/main/res/layout/layout_hs_data_dialog.xml index 7379f45..d791b1b 100644 --- a/app/src/main/res/layout/layout_hs_data_dialog.xml +++ b/app/src/main/res/layout/layout_hs_data_dialog.xml @@ -59,7 +59,7 @@ android:layout_height="match_parent">
<Button - android:text="@string/cancel" + android:text="@string/btn_cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/HSDialogCancel" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ea01787..6ed7777 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -330,13 +330,15 @@ <string name="note_only_standard_tor_bridges_work_on_intel_x86_atom_devices">NOTE: Only standard Tor bridges work on Intel X86/ATOM devices</string>
<string name="vpn_default_world">World (Location)</string> + <string name="hidden_services">Hidden Services</string> <string name="title_activity_hidden_services">Hidden Services</string> <string name="save">Save</string> - <string name="cancel">Cancel</string> - <string name="hs_dialog_title">Hidden Service</string> <string name="ports">Ports</string> <string name="local_port">Local Port</string> <string name="onion_port">Onion Port</string> <string name="name">Name</string> <string name="invalid_port">Invalid Port</string> + <string name="copy_address_to_clipboard">Copy address to clipboard</string> + <string name="backup_service">Backup Service</string> + <string name="delete_service">Delete Service</string> </resources>