actions dialog

This commit is contained in:
arrase 2016-11-20 03:20:14 +01:00
parent c232e1c92e
commit 8494cfb633
6 changed files with 103 additions and 18 deletions

View File

@ -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");
}
});
}

View File

@ -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;
}
}

View File

@ -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){

View File

@ -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>

View File

@ -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"

View File

@ -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>