diff --git a/src/main/res/layout/layout_main.xml b/src/main/res/layout/layout_main.xml
index b8039e6b..7cbd6231 100644
--- a/src/main/res/layout/layout_main.xml
+++ b/src/main/res/layout/layout_main.xml
@@ -27,9 +27,10 @@
android:paddingEnd="72dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
-
+
-
+
diff --git a/src/main/res/layout/layout_profiles_item.xml b/src/main/res/layout/layout_profiles_item.xml
index 5ce26fd1..4ece9771 100644
--- a/src/main/res/layout/layout_profiles_item.xml
+++ b/src/main/res/layout/layout_profiles_item.xml
@@ -1,77 +1,82 @@
-
-
+
+
-
+
-
-
+
+
+
+
+
+ android:layout_marginStart="8dp"
+ android:layout_marginTop="4dp"
+ android:id="@+id/details">
+
+
+
-
-
-
-
-
-
+
+
diff --git a/src/main/res/values/attrs.xml b/src/main/res/values/attrs.xml
index fc9b5af9..0671660e 100644
--- a/src/main/res/values/attrs.xml
+++ b/src/main/res/values/attrs.xml
@@ -1,5 +1,9 @@
+
+
+
+
diff --git a/src/main/scala/com/github/shadowsocks/ProfilesFragment.scala b/src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
index ff7bf926..d04ab1f8 100644
--- a/src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
+++ b/src/main/scala/com/github/shadowsocks/ProfilesFragment.scala
@@ -25,7 +25,7 @@ import java.util.GregorianCalendar
import android.content._
import android.os.{Bundle, Handler}
import android.support.v4.content.LocalBroadcastManager
-import android.support.v7.widget.{DefaultItemAnimator, LinearLayoutManager, RecyclerView, Toolbar}
+import android.support.v7.widget._
import android.support.v7.widget.RecyclerView.ViewHolder
import android.support.v7.widget.helper.ItemTouchHelper
import android.support.v7.widget.helper.ItemTouchHelper.SimpleCallback
diff --git a/src/main/scala/com/github/shadowsocks/widget/BoundedCardView.scala b/src/main/scala/com/github/shadowsocks/widget/BoundedCardView.scala
new file mode 100644
index 00000000..62a96382
--- /dev/null
+++ b/src/main/scala/com/github/shadowsocks/widget/BoundedCardView.scala
@@ -0,0 +1,12 @@
+package com.github.shadowsocks.widget
+
+import android.content.Context
+import android.support.v7.widget.CardView
+import android.util.AttributeSet
+
+/**
+ * @author Mygod
+ */
+class BoundedCardView(context: Context, attrs: AttributeSet) extends CardView(context, attrs) with BoundedView {
+ initAttrs(context, attrs)
+}
diff --git a/src/main/scala/com/github/shadowsocks/widget/BoundedGridLayout.scala b/src/main/scala/com/github/shadowsocks/widget/BoundedGridLayout.scala
new file mode 100644
index 00000000..a7a2a171
--- /dev/null
+++ b/src/main/scala/com/github/shadowsocks/widget/BoundedGridLayout.scala
@@ -0,0 +1,12 @@
+package com.github.shadowsocks.widget
+
+import android.content.Context
+import android.support.v7.widget.GridLayout
+import android.util.AttributeSet
+
+/**
+ * @author Mygod
+ */
+class BoundedGridLayout(context: Context, attrs: AttributeSet) extends GridLayout(context, attrs) with BoundedView {
+ initAttrs(context, attrs)
+}
diff --git a/src/main/scala/com/github/shadowsocks/widget/BoundedView.scala b/src/main/scala/com/github/shadowsocks/widget/BoundedView.scala
new file mode 100644
index 00000000..c9a3c3a9
--- /dev/null
+++ b/src/main/scala/com/github/shadowsocks/widget/BoundedView.scala
@@ -0,0 +1,32 @@
+package com.github.shadowsocks.widget
+
+import android.content.Context
+import android.util.AttributeSet
+import android.view.View
+import android.view.View.MeasureSpec
+import com.github.shadowsocks.R
+
+/**
+ * Based on: http://stackoverflow.com/a/6212120/2245107
+ *
+ * @author Mygod
+ */
+trait BoundedView extends View {
+ private var boundedWidth: Int = _
+ private var boundedHeight: Int = _
+
+ protected def initAttrs(context: Context, attrs: AttributeSet) {
+ val arr = context.obtainStyledAttributes(attrs, R.styleable.BoundedView)
+ boundedWidth = arr.getDimensionPixelSize(R.styleable.BoundedView_bounded_width, 0)
+ boundedHeight = arr.getDimensionPixelSize(R.styleable.BoundedView_bounded_height, 0)
+ arr.recycle()
+ }
+
+ override def onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int): Unit = super.onMeasure(
+ if (boundedWidth > 0 && boundedWidth < MeasureSpec.getSize(widthMeasureSpec))
+ MeasureSpec.makeMeasureSpec(boundedWidth, MeasureSpec.getMode(widthMeasureSpec))
+ else widthMeasureSpec,
+ if (boundedHeight > 0 && boundedHeight < MeasureSpec.getSize(heightMeasureSpec))
+ MeasureSpec.makeMeasureSpec(boundedHeight, MeasureSpec.getMode(heightMeasureSpec))
+ else heightMeasureSpec)
+}