commit 6bff3434f8d4f9d26dcd27e74164bc57c9e73189 Author: bim dsnake@protonmail.com Date: Fri Apr 30 17:09:07 2021 -0400
Show both local port and "onion port" on hosted v2 and v3 onion services --- .../hiddenservices/adapters/OnionListAdapter.java | 6 +++- .../ui/v3onionservice/OnionV3ListAdapter.java | 10 +++++-- app/src/main/res/layout/layout_hs_list_item.xml | 32 ++++++++++++++++++---- 3 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/OnionListAdapter.java b/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/OnionListAdapter.java index e3983cfd..c925fb20 100644 --- a/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/OnionListAdapter.java +++ b/app/src/main/java/org/torproject/android/ui/hiddenservices/adapters/OnionListAdapter.java @@ -30,7 +30,11 @@ public class OnionListAdapter extends CursorAdapter { final String where = HSContentProvider.HiddenService._ID + "=" + id;
TextView port = view.findViewById(R.id.hs_port); - port.setText(cursor.getString(cursor.getColumnIndex(HSContentProvider.HiddenService.PORT))); + port.setText(String.format("%s\n%s", context.getString(R.string.local_port), + cursor.getString(cursor.getColumnIndex(HSContentProvider.HiddenService.PORT)))); + TextView onionPort = view.findViewById(R.id.onion_port); + onionPort.setText(String.format("%s\n%s", context.getString(R.string.onion_port), + cursor.getString(cursor.getColumnIndex(HSContentProvider.HiddenService.ONION_PORT)))); TextView name = view.findViewById(R.id.hs_name); name.setText(cursor.getString(cursor.getColumnIndex(HSContentProvider.HiddenService.NAME))); TextView domain = view.findViewById(R.id.hs_onion); diff --git a/app/src/main/java/org/torproject/android/ui/v3onionservice/OnionV3ListAdapter.java b/app/src/main/java/org/torproject/android/ui/v3onionservice/OnionV3ListAdapter.java index 6a858a9a..505675be 100644 --- a/app/src/main/java/org/torproject/android/ui/v3onionservice/OnionV3ListAdapter.java +++ b/app/src/main/java/org/torproject/android/ui/v3onionservice/OnionV3ListAdapter.java @@ -33,8 +33,14 @@ public class OnionV3ListAdapter extends CursorAdapter { public void bindView(View view, Context context, Cursor cursor) { int id = cursor.getInt(cursor.getColumnIndex(OnionServiceContentProvider.OnionService._ID)); final String where = OnionServiceContentProvider.OnionService._ID + "=" + id; - TextView port = view.findViewById(R.id.hs_port); - port.setText(cursor.getString(cursor.getColumnIndex(OnionServiceContentProvider.OnionService.PORT))); + TextView localPort = view.findViewById(R.id.hs_port); + localPort.setText(String.format("%s\n%s", context.getString(R.string.local_port), + cursor.getString(cursor.getColumnIndex(OnionServiceContentProvider.OnionService.PORT)))); + + TextView onionPort = view.findViewById(R.id.onion_port); + onionPort.setText(String.format("%s\n%s", context.getString(R.string.onion_port), + cursor.getString(cursor.getColumnIndex(OnionServiceContentProvider.OnionService.ONION_PORT)))); + TextView name = view.findViewById(R.id.hs_name); name.setText(cursor.getString(cursor.getColumnIndex(OnionServiceContentProvider.OnionService.NAME))); TextView domain = view.findViewById(R.id.hs_onion); diff --git a/app/src/main/res/layout/layout_hs_list_item.xml b/app/src/main/res/layout/layout_hs_list_item.xml index 54a95912..fa746409 100644 --- a/app/src/main/res/layout/layout_hs_list_item.xml +++ b/app/src/main/res/layout/layout_hs_list_item.xml @@ -1,18 +1,36 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingLeft="15dp" android:paddingRight="15dp">
- <TextView - android:id="@+id/hs_port" + <LinearLayout + android:gravity="center" android:layout_width="wrap_content" - android:layout_height="match_parent" + android:layout_height="wrap_content" android:paddingTop="10dp" android:paddingRight="10dp" - android:textSize="35sp" /> + android:orientation="vertical"> + + <TextView + android:id="@+id/hs_port" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:textSize="15sp" + tools:text="80" /> + + <TextView + tools:text="43" + android:textSize="15sp" + android:id="@+id/onion_port" + android:layout_width="wrap_content" + android:layout_height="wrap_content"/> + + + </LinearLayout>
<LinearLayout android:layout_width="0dp" @@ -26,7 +44,8 @@ android:layout_height="wrap_content" android:paddingLeft="10dp" android:paddingBottom="10dp" - android:textSize="24sp" /> + android:textSize="24sp" + tools:text="My Service" />
<TextView android:id="@+id/hs_onion" @@ -34,7 +53,8 @@ android:layout_height="wrap_content" android:paddingLeft="10dp" android:paddingBottom="10dp" - android:textSize="18sp" /> + android:textSize="18sp" + tools:text="abcdefg.onion" />
</LinearLayout>
tor-commits@lists.torproject.org