Update UI for onion port
This commit is contained in:
parent
b10387bb07
commit
e776e12492
|
@ -573,15 +573,18 @@ public class OrbotMainActivity extends AppCompatActivity
|
|||
HSContentProvider.HiddenService.NAME,
|
||||
HSContentProvider.HiddenService.DOMAIN,
|
||||
HSContentProvider.HiddenService.PORT,
|
||||
HSContentProvider.HiddenService.REMOTE_PORT};
|
||||
HSContentProvider.HiddenService.ONION_PORT};
|
||||
|
||||
if(hsName == null)
|
||||
hsName = "hs"+hsPort;
|
||||
|
||||
if(hsRemotePort == -1)
|
||||
hsRemotePort = hsPort;
|
||||
|
||||
ContentValues fields = new ContentValues();
|
||||
fields.put("name", hsName);
|
||||
fields.put("port", hsPort);
|
||||
fields.put("remote_port", hsRemotePort);
|
||||
fields.put("onion_port", hsRemotePort);
|
||||
|
||||
ContentResolver cr = getContentResolver();
|
||||
Cursor row = cr.query(HSContentProvider.CONTENT_URI, mProjection, "port="+hsPort, null, null);
|
||||
|
@ -623,7 +626,7 @@ public class OrbotMainActivity extends AppCompatActivity
|
|||
if (action.equals(INTENT_ACTION_REQUEST_HIDDEN_SERVICE))
|
||||
{
|
||||
final int hiddenServicePort = getIntent().getIntExtra("hs_port", -1);
|
||||
final int hiddenServiceRemotePort = getIntent().getIntExtra("hs_remote_port", -1);
|
||||
final int hiddenServiceRemotePort = getIntent().getIntExtra("hs_onion_port", -1);
|
||||
final String hiddenServiceName = getIntent().getStringExtra("hs_name");
|
||||
final boolean getHiddenServiceKey = getIntent().getBooleanExtra("hs_get_key",false);
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ public class HiddenServicesActivity extends AppCompatActivity {
|
|||
HSContentProvider.HiddenService._ID,
|
||||
HSContentProvider.HiddenService.NAME,
|
||||
HSContentProvider.HiddenService.DOMAIN,
|
||||
HSContentProvider.HiddenService.ONION_PORT,
|
||||
HSContentProvider.HiddenService.PORT};
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,8 +32,9 @@ public class HSAdapter extends CursorRecyclerViewAdapter<HSAdapter.ViewHolder> {
|
|||
|
||||
String name_string = cursor.getString(cursor.getColumnIndex(HSContentProvider.HiddenService.NAME));
|
||||
Integer port = cursor.getInt(cursor.getColumnIndex(HSContentProvider.HiddenService.PORT));
|
||||
Integer onion_port = cursor.getInt(cursor.getColumnIndex(HSContentProvider.HiddenService.ONION_PORT));
|
||||
|
||||
viewHolder.name.setText(name_string + ": " + port.toString());
|
||||
viewHolder.name.setText(name_string + ": " + port.toString()+ " -> " +onion_port.toString());
|
||||
|
||||
viewHolder.domain.setText(
|
||||
cursor.getString(cursor.getColumnIndex(HSContentProvider.HiddenService.DOMAIN))
|
||||
|
|
|
@ -15,7 +15,7 @@ public class HSDatabase extends SQLiteOpenHelper {
|
|||
"_id INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
"name TEXT, " +
|
||||
"domain TEXT, " +
|
||||
"remote_port INTEGER, " +
|
||||
"onion_port INTEGER, " +
|
||||
"port INTEGER);";
|
||||
|
||||
public HSDatabase(Context context) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.content.ContentValues;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.ShareCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
@ -35,12 +36,15 @@ public class HSDataDialog extends DialogFragment {
|
|||
save.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
String serverName = ((EditText) dialog_view.findViewById(R.id.hsName)).getText().toString();
|
||||
Integer serverPort = Integer.parseInt(
|
||||
((EditText) dialog_view.findViewById(R.id.serverPort)).getText().toString()
|
||||
Integer localPort = Integer.parseInt(
|
||||
((EditText) dialog_view.findViewById(R.id.hsLocalPort)).getText().toString()
|
||||
);
|
||||
Integer onionPort = Integer.parseInt(
|
||||
((EditText) dialog_view.findViewById(R.id.hsOnionPort)).getText().toString()
|
||||
);
|
||||
|
||||
if (checkInput(serverPort)) {
|
||||
saveData(serverName, serverPort);
|
||||
if (checkInput(localPort,onionPort)) {
|
||||
saveData(serverName, localPort,onionPort);
|
||||
serverDataDialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
@ -56,11 +60,11 @@ public class HSDataDialog extends DialogFragment {
|
|||
return serverDataDialog;
|
||||
}
|
||||
|
||||
private boolean checkInput(Integer port) {
|
||||
private boolean checkInput(Integer local, Integer remote){
|
||||
boolean is_ok = true;
|
||||
Integer error_msg = 0;
|
||||
|
||||
if (port <= 1 || port > 65535) {
|
||||
if ((local <= 1 || local > 65535) || (remote <= 1 || remote > 65535)) {
|
||||
error_msg = R.string.invalid_port;
|
||||
is_ok = false;
|
||||
}
|
||||
|
@ -72,10 +76,11 @@ public class HSDataDialog extends DialogFragment {
|
|||
return is_ok;
|
||||
}
|
||||
|
||||
private void saveData(String name, Integer port) {
|
||||
private void saveData(String name, Integer local, Integer remote) {
|
||||
ContentValues fields = new ContentValues();
|
||||
fields.put("name", name);
|
||||
fields.put("port", port);
|
||||
fields.put("port", local);
|
||||
fields.put("onion_port", remote);
|
||||
|
||||
ContentResolver cr = getContext().getContentResolver();
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ public class HSContentProvider extends ContentProvider {
|
|||
//Nombres de columnas
|
||||
public static final String NAME = "name";
|
||||
public static final String PORT = "port";
|
||||
public static final String REMOTE_PORT = "remote_port";
|
||||
public static final String ONION_PORT = "onion_port";
|
||||
public static final String DOMAIN = "domain";
|
||||
|
||||
private HiddenService() {
|
||||
|
|
|
@ -24,10 +24,10 @@
|
|||
android:id="@+id/hsName" />
|
||||
|
||||
<TextView
|
||||
android:text="@string/port"
|
||||
android:text="@string/local_port"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/HSPortLabel"
|
||||
android:id="@+id/HSLocalPortLabel"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Widget.PopupMenu.Small"
|
||||
android:paddingLeft="5dp" />
|
||||
|
||||
|
@ -35,7 +35,22 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:id="@+id/serverPort"
|
||||
android:id="@+id/hsLocalPort"
|
||||
android:inputType="number" />
|
||||
|
||||
<TextView
|
||||
android:text="@string/onion_port"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/HSOnionPortLabel"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Widget.PopupMenu.Small"
|
||||
android:paddingLeft="5dp" />
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:id="@+id/hsOnionPort"
|
||||
android:inputType="number" />
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -334,7 +334,9 @@
|
|||
<string name="save">Save</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="hs_dialog_title">Hidden Service</string>
|
||||
<string name="port">Port</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>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue