[tor-commits] [orbot/master] switch to listview

n8fr8 at torproject.org n8fr8 at torproject.org
Thu Mar 2 04:10:20 UTC 2017


commit c232e1c92ed6324ab9bbf3f5bd37d771838d4412
Author: arrase <arrase at gmail.com>
Date:   Sun Nov 20 01:52:23 2016 +0100

    switch to listview
---
 app/build.gradle                                   |   1 -
 .../android/ui/hs/HiddenServicesActivity.java      |  83 ++++++------
 .../ui/hs/adapters/CursorRecyclerViewAdapter.java  | 144 ---------------------
 .../android/ui/hs/adapters/HSAdapter.java          |  55 --------
 .../android/ui/hs/adapters/OnionListAdapter.java   |  36 ++++++
 .../android/ui/hs/dialogs/HSDataDialog.java        |   5 +-
 .../main/res/layout/activity_hidden_services.xml   |  34 -----
 .../main/res/layout/content_hidden_services.xml    |  22 ----
 app/src/main/res/layout/dialog_hs_data.xml         |  79 -----------
 app/src/main/res/layout/layout_hs_data_dialog.xml  |  79 +++++++++++
 app/src/main/res/layout/layout_hs_list_item.xml    |  20 +++
 app/src/main/res/layout/layout_hs_list_view.xml    |  22 ++++
 app/src/main/res/layout/onion_item.xml             |  33 -----
 13 files changed, 205 insertions(+), 408 deletions(-)

diff --git a/app/build.gradle b/app/build.gradle
index 66d1225..cc364c7 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -31,5 +31,4 @@ dependencies {
     compile 'com.android.support:support-v4:23.4.0'
     compile 'com.android.support:appcompat-v7:23.4.0'
     compile 'com.android.support:design:23.4.0'
-    compile 'com.android.support:cardview-v7:23.4.0'
 }
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 da556da..a2c9280 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
@@ -1,38 +1,49 @@
 package org.torproject.android.ui.hs;
 
+
 import android.content.ContentResolver;
 import android.database.ContentObserver;
 import android.os.Bundle;
 import android.os.Handler;
 import android.support.design.widget.FloatingActionButton;
 import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.Toolbar;
 import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ListView;
 
 import org.torproject.android.R;
-import org.torproject.android.ui.hs.adapters.HSAdapter;
+import org.torproject.android.ui.hs.adapters.OnionListAdapter;
 import org.torproject.android.ui.hs.dialogs.HSDataDialog;
 import org.torproject.android.ui.hs.providers.HSContentProvider;
 
 public class HiddenServicesActivity extends AppCompatActivity {
-    private HSAdapter mHiddenServices;
     private ContentResolver mCR;
-    private HSObserver mHSObserver;
+    private OnionListAdapter mAdapter;
+
     private String[] mProjection = new String[]{
             HSContentProvider.HiddenService._ID,
             HSContentProvider.HiddenService.NAME,
-            HSContentProvider.HiddenService.DOMAIN,
-            HSContentProvider.HiddenService.ONION_PORT,
-            HSContentProvider.HiddenService.PORT};
+            HSContentProvider.HiddenService.DOMAIN};
+
+    class HSObserver extends ContentObserver {
+        HSObserver(Handler handler) {
+            super(handler);
+        }
+
+        @Override
+        public void onChange(boolean selfChange) {
+            mAdapter.changeCursor(mCR.query(
+                    HSContentProvider.CONTENT_URI, mProjection, null, null, null
+            ));
+        }
+    }
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_hidden_services);
-        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
-        setSupportActionBar(toolbar);
+        setContentView(R.layout.layout_hs_list_view);
+
+        mCR = getContentResolver();
 
         FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
         fab.setOnClickListener(new View.OnClickListener() {
@@ -43,35 +54,35 @@ public class HiddenServicesActivity extends AppCompatActivity {
             }
         });
 
-        mCR = getContentResolver();
-        // View adapter
-        mHiddenServices = new HSAdapter(
-                mCR.query(
+        mAdapter = new OnionListAdapter(
+                this,
+                getContentResolver().query(
                         HSContentProvider.CONTENT_URI, mProjection, null, null, null
-                ));
+                ),
+                0
+        );
 
-        mHSObserver = new HSObserver(new Handler());
-        mCR.registerContentObserver(HSContentProvider.CONTENT_URI, true, mHSObserver);
+        mCR.registerContentObserver(
+                HSContentProvider.CONTENT_URI, true, new HSObserver(new Handler())
+        );
 
-        // Fill view
-        RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.onion_list);
-        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
-        mRecyclerView.setAdapter(mHiddenServices);
-    }
+        ListView onion_list = (ListView) findViewById(R.id.onion_list);
+        onion_list.setAdapter(mAdapter);
 
-    class HSObserver extends ContentObserver {
-        public HSObserver(Handler handler) {
-            super(handler);
-        }
+        onion_list.setOnItemClickListener(new AdapterView.OnItemClickListener(){
 
-        @Override
-        public void onChange(boolean selfChange) {
-            // New data
-            mHiddenServices.changeCursor(mCR.query(
-                    HSContentProvider.CONTENT_URI, mProjection, null, null, null
-            ));
-        }
+            @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;
+            }
+        });
+    }
 }
diff --git a/app/src/main/java/org/torproject/android/ui/hs/adapters/CursorRecyclerViewAdapter.java b/app/src/main/java/org/torproject/android/ui/hs/adapters/CursorRecyclerViewAdapter.java
deleted file mode 100644
index 9798413..0000000
--- a/app/src/main/java/org/torproject/android/ui/hs/adapters/CursorRecyclerViewAdapter.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package org.torproject.android.ui.hs.adapters;
-
-/*
- * Copyright (C) 2014 skyfish.jy at gmail.com
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-import android.database.Cursor;
-import android.database.DataSetObserver;
-import android.support.v7.widget.RecyclerView;
-
-/**
- * Created by skyfishjy on 10/31/14.
- */
-
-public abstract class CursorRecyclerViewAdapter<VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<VH> {
-
-    private Cursor mCursor;
-
-    private boolean mDataValid;
-
-    private int mRowIdColumn;
-
-    private DataSetObserver mDataSetObserver;
-
-    public CursorRecyclerViewAdapter(Cursor cursor) {
-        mCursor = cursor;
-        mDataValid = cursor != null;
-        mRowIdColumn = mDataValid ? mCursor.getColumnIndex("_id") : -1;
-        mDataSetObserver = new NotifyingDataSetObserver();
-        if (mCursor != null) {
-            mCursor.registerDataSetObserver(mDataSetObserver);
-        }
-    }
-
-    @Override
-    public int getItemCount() {
-        if (mDataValid && mCursor != null) {
-            return mCursor.getCount();
-        }
-        return 0;
-    }
-
-    @Override
-    public long getItemId(int position) {
-        if (mDataValid && mCursor != null && mCursor.moveToPosition(position)) {
-            return mCursor.getLong(mRowIdColumn);
-        }
-        return 0;
-    }
-
-    @Override
-    public void setHasStableIds(boolean hasStableIds) {
-        super.setHasStableIds(true);
-    }
-
-    public abstract void onBindViewHolder(VH viewHolder, Cursor cursor);
-
-    @Override
-    public void onBindViewHolder(VH viewHolder, int position) {
-        if (!mDataValid) {
-            throw new IllegalStateException("this should only be called when the cursor is valid");
-        }
-        if (!mCursor.moveToPosition(position)) {
-            throw new IllegalStateException("couldn't move cursor to position " + position);
-        }
-        onBindViewHolder(viewHolder, mCursor);
-    }
-
-    /**
-     * Change the underlying cursor to a new cursor. If there is an existing cursor it will be
-     * closed.
-     */
-    public void changeCursor(Cursor cursor) {
-        Cursor old = swapCursor(cursor);
-        if (old != null) {
-            old.close();
-        }
-    }
-
-    public void closeCursor() {
-        mCursor.unregisterDataSetObserver(mDataSetObserver);
-        mCursor.close();
-    }
-
-    /**
-     * Swap in a new Cursor, returning the old Cursor.  Unlike
-     * {@link #changeCursor(Cursor)}, the returned old Cursor is <em>not</em>
-     * closed.
-     */
-    private Cursor swapCursor(Cursor newCursor) {
-        if (newCursor == mCursor) {
-            return null;
-        }
-        final Cursor oldCursor = mCursor;
-        if (oldCursor != null && mDataSetObserver != null) {
-            oldCursor.unregisterDataSetObserver(mDataSetObserver);
-        }
-        mCursor = newCursor;
-        if (mCursor != null) {
-            if (mDataSetObserver != null) {
-                mCursor.registerDataSetObserver(mDataSetObserver);
-            }
-            mRowIdColumn = newCursor.getColumnIndexOrThrow("_id");
-            mDataValid = true;
-            notifyDataSetChanged();
-        } else {
-            mRowIdColumn = -1;
-            mDataValid = false;
-            notifyDataSetChanged();
-            //There is no notifyDataSetInvalidated() method in RecyclerView.Adapter
-        }
-        return oldCursor;
-    }
-
-    private class NotifyingDataSetObserver extends DataSetObserver {
-        @Override
-        public void onChanged() {
-            super.onChanged();
-            mDataValid = true;
-            notifyDataSetChanged();
-        }
-
-        @Override
-        public void onInvalidated() {
-            super.onInvalidated();
-            mDataValid = false;
-            notifyDataSetChanged();
-            //There is no notifyDataSetInvalidated() method in RecyclerView.Adapter
-        }
-    }
-}
\ No newline at end of file
diff --git a/app/src/main/java/org/torproject/android/ui/hs/adapters/HSAdapter.java b/app/src/main/java/org/torproject/android/ui/hs/adapters/HSAdapter.java
deleted file mode 100644
index 92189ad..0000000
--- a/app/src/main/java/org/torproject/android/ui/hs/adapters/HSAdapter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.torproject.android.ui.hs.adapters;
-
-import android.database.Cursor;
-import android.support.v7.widget.RecyclerView;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import org.torproject.android.R;
-import org.torproject.android.ui.hs.providers.HSContentProvider;
-
-public class HSAdapter extends CursorRecyclerViewAdapter<HSAdapter.ViewHolder> {
-
-    public HSAdapter(Cursor cursor) {
-        super(cursor);
-    }
-
-    @Override
-    public HSAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
-        View v = LayoutInflater.from(parent.getContext())
-                .inflate(R.layout.onion_item, parent, false);
-
-        ViewHolder vh = new ViewHolder(v);
-
-        return vh;
-    }
-
-    @Override
-    public void onBindViewHolder(ViewHolder viewHolder, Cursor cursor) {
-        viewHolder.id = cursor.getInt(cursor.getColumnIndex(HSContentProvider.HiddenService._ID));
-
-        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()+ " -> " +onion_port.toString());
-
-        viewHolder.domain.setText(
-                cursor.getString(cursor.getColumnIndex(HSContentProvider.HiddenService.DOMAIN))
-        );
-    }
-
-    class ViewHolder extends RecyclerView.ViewHolder {
-        TextView name;
-        TextView domain;
-        Integer id;
-
-        ViewHolder(View itemView) {
-            super(itemView);
-            name = (TextView) itemView.findViewById(R.id.hs_name);
-            domain = (TextView) itemView.findViewById(R.id.hs_onion);
-        }
-    }
-}
diff --git a/app/src/main/java/org/torproject/android/ui/hs/adapters/OnionListAdapter.java b/app/src/main/java/org/torproject/android/ui/hs/adapters/OnionListAdapter.java
new file mode 100644
index 0000000..5275730
--- /dev/null
+++ b/app/src/main/java/org/torproject/android/ui/hs/adapters/OnionListAdapter.java
@@ -0,0 +1,36 @@
+package org.torproject.android.ui.hs.adapters;
+
+import android.content.Context;
+import android.database.Cursor;
+import android.support.v4.widget.CursorAdapter;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import org.torproject.android.R;
+import org.torproject.android.ui.hs.providers.HSContentProvider;
+
+public class OnionListAdapter extends CursorAdapter {
+    private LayoutInflater cursorInflater;
+
+    public OnionListAdapter(Context context, Cursor c, int flags) {
+        super(context, c, flags);
+
+        cursorInflater = (LayoutInflater) context.getSystemService(
+                Context.LAYOUT_INFLATER_SERVICE);
+    }
+
+    @Override
+    public void bindView(View view, Context context, Cursor cursor) {
+        TextView name = (TextView) view.findViewById(R.id.hs_name);
+        name.setText(cursor.getString(cursor.getColumnIndex(HSContentProvider.HiddenService.NAME)));
+        TextView domain = (TextView) view.findViewById(R.id.hs_onion);
+        domain.setText(cursor.getString(cursor.getColumnIndex(HSContentProvider.HiddenService.DOMAIN)));
+    }
+
+    @Override
+    public View newView(Context context, Cursor cursor, ViewGroup parent) {
+        return cursorInflater.inflate(R.layout.layout_hs_list_item, parent, false);
+    }
+}
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 fb62cb7..67c3691 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
@@ -5,14 +5,11 @@ import android.app.Dialog;
 import android.content.ContentResolver;
 import android.content.ContentValues;
 import android.os.Bundle;
-import android.support.annotation.BoolRes;
 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;
-import android.widget.CheckBox;
 import android.widget.EditText;
 import android.widget.Toast;
 
@@ -25,7 +22,7 @@ public class HSDataDialog extends DialogFragment {
     @Override
     public Dialog onCreateDialog(Bundle savedInstanceState) {
         // Get the layout
-        final View dialog_view = getActivity().getLayoutInflater().inflate(R.layout.dialog_hs_data, null);
+        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())
diff --git a/app/src/main/res/layout/activity_hidden_services.xml b/app/src/main/res/layout/activity_hidden_services.xml
deleted file mode 100644
index a2e8663..0000000
--- a/app/src/main/res/layout/activity_hidden_services.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:fitsSystemWindows="true"
-    tools:context="org.torproject.android.ui.hs.HiddenServicesActivity">
-
-    <android.support.design.widget.AppBarLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:theme="@style/DefaultTheme.AppBarOverlay">
-
-        <android.support.v7.widget.Toolbar
-            android:id="@+id/toolbar"
-            android:layout_width="match_parent"
-            android:layout_height="?attr/actionBarSize"
-            android:background="?attr/colorPrimary"
-            app:popupTheme="@style/DefaultTheme.PopupOverlay" />
-
-    </android.support.design.widget.AppBarLayout>
-
-    <include layout="@layout/content_hidden_services" />
-
-    <android.support.design.widget.FloatingActionButton
-        android:id="@+id/fab"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_gravity="bottom|end"
-        android:layout_margin="@dimen/fab_margin"
-        app:srcCompat="@android:drawable/stat_notify_more" />
-
-</android.support.design.widget.CoordinatorLayout>
diff --git a/app/src/main/res/layout/content_hidden_services.xml b/app/src/main/res/layout/content_hidden_services.xml
deleted file mode 100644
index 39588f9..0000000
--- a/app/src/main/res/layout/content_hidden_services.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:id="@+id/content_hidden_services"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:paddingBottom="@dimen/activity_vertical_margin"
-    android:paddingLeft="10dp"
-    android:paddingRight="10dp"
-    android:paddingTop="@dimen/activity_vertical_margin"
-    app:layout_behavior="@string/appbar_scrolling_view_behavior"
-    tools:context="org.torproject.android.ui.hs.HiddenServicesActivity"
-    tools:showIn="@layout/activity_hidden_services">
-
-    <android.support.v7.widget.RecyclerView
-        android:id="@+id/onion_list"
-        android:scrollbars="vertical"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"/>
-
-</RelativeLayout>
diff --git a/app/src/main/res/layout/dialog_hs_data.xml b/app/src/main/res/layout/dialog_hs_data.xml
deleted file mode 100644
index 7379f45..0000000
--- a/app/src/main/res/layout/dialog_hs_data.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-<?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="wrap_content"
-    android:paddingLeft="5dp"
-    android:paddingRight="5dp"
-    android:paddingTop="5dp"
-    android:paddingBottom="5dp">
-
-    <TextView
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:id="@+id/HSNameLabel"
-        android:text="@string/name"
-        android:textAppearance="@style/TextAppearance.AppCompat.Widget.PopupMenu.Small"
-        android:paddingLeft="5dp" />
-
-    <EditText
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:inputType="text"
-        android:ems="10"
-        android:id="@+id/hsName" />
-
-    <TextView
-        android:text="@string/local_port"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:id="@+id/HSLocalPortLabel"
-        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/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
-        android:orientation="horizontal"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent">
-
-        <Button
-            android:text="@string/cancel"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:id="@+id/HSDialogCancel"
-            android:layout_weight="1"
-            style="@style/Widget.AppCompat.Button.Borderless.Colored" />
-
-        <Button
-            android:text="@string/save"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:id="@+id/HSDialogSave"
-            android:layout_weight="1"
-            style="@style/Widget.AppCompat.Button.Borderless.Colored" />
-
-    </LinearLayout>
-
-</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
new file mode 100644
index 0000000..7379f45
--- /dev/null
+++ b/app/src/main/res/layout/layout_hs_data_dialog.xml
@@ -0,0 +1,79 @@
+<?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="wrap_content"
+    android:paddingLeft="5dp"
+    android:paddingRight="5dp"
+    android:paddingTop="5dp"
+    android:paddingBottom="5dp">
+
+    <TextView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:id="@+id/HSNameLabel"
+        android:text="@string/name"
+        android:textAppearance="@style/TextAppearance.AppCompat.Widget.PopupMenu.Small"
+        android:paddingLeft="5dp" />
+
+    <EditText
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:inputType="text"
+        android:ems="10"
+        android:id="@+id/hsName" />
+
+    <TextView
+        android:text="@string/local_port"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:id="@+id/HSLocalPortLabel"
+        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/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
+        android:orientation="horizontal"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+        <Button
+            android:text="@string/cancel"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:id="@+id/HSDialogCancel"
+            android:layout_weight="1"
+            style="@style/Widget.AppCompat.Button.Borderless.Colored" />
+
+        <Button
+            android:text="@string/save"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:id="@+id/HSDialogSave"
+            android:layout_weight="1"
+            style="@style/Widget.AppCompat.Button.Borderless.Colored" />
+
+    </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/layout_hs_list_item.xml b/app/src/main/res/layout/layout_hs_list_item.xml
new file mode 100644
index 0000000..539de8f
--- /dev/null
+++ b/app/src/main/res/layout/layout_hs_list_item.xml
@@ -0,0 +1,20 @@
+<?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="match_parent"
+    android:orientation="vertical">
+
+    <TextView
+        android:id="@+id/hs_name"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:textSize="24sp" />
+
+    <TextView
+        android:id="@+id/hs_onion"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:textSize="18sp" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/layout_hs_list_view.xml b/app/src/main/res/layout/layout_hs_list_view.xml
new file mode 100644
index 0000000..551d4e6
--- /dev/null
+++ b/app/src/main/res/layout/layout_hs_list_view.xml
@@ -0,0 +1,22 @@
+<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/main_content"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <ListView
+        android:id="@+id/onion_list"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" />
+
+    <android.support.design.widget.FloatingActionButton
+        android:id="@+id/fab"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="bottom|end"
+        android:layout_margin="16dp"
+        android:src="@android:drawable/stat_notify_more"
+        app:layout_anchor="@id/onion_list"
+        app:layout_anchorGravity="bottom|right|end" />
+
+</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/onion_item.xml b/app/src/main/res/layout/onion_item.xml
deleted file mode 100644
index 12fbf1d..0000000
--- a/app/src/main/res/layout/onion_item.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:padding="5dp">
-
-    <android.support.v7.widget.CardView
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content">
-
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="vertical"
-            android:padding="5dp">
-
-            <TextView
-                android:id="@+id/hs_name"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:textSize="24sp"
-                android:paddingLeft="5dp" />
-
-            <TextView
-                android:id="@+id/hs_onion"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:textSize="18sp"
-                android:paddingLeft="5dp" />
-        </LinearLayout>
-    </android.support.v7.widget.CardView>
-</LinearLayout>
\ No newline at end of file





More information about the tor-commits mailing list