diff --git a/src/main/res/drawable/background_selectable.xml b/src/main/res/drawable/background_selectable.xml new file mode 100644 index 00000000..1d2a6c4b --- /dev/null +++ b/src/main/res/drawable/background_selectable.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/main/res/drawable/background_selected.xml b/src/main/res/drawable/background_selected.xml new file mode 100644 index 00000000..01e1208e --- /dev/null +++ b/src/main/res/drawable/background_selected.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/main/res/layout/layout_main.xml b/src/main/res/layout/layout_main.xml index 957f7fde..c72faecd 100644 --- a/src/main/res/layout/layout_main.xml +++ b/src/main/res/layout/layout_main.xml @@ -20,22 +20,6 @@ android:orientation="vertical" android:nextFocusRight="@+id/fab" android:layout_alignParentBottom="true"> - - - - + + + + + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:focusable="true" + android:nextFocusRight="@+id/edit" + android:background="?android:attr/selectableItemBackground" + android:layout_marginTop="8dp" + android:layout_marginStart="8dp" + android:layout_marginEnd="8dp"> + android:layout_height="wrap_content" + android:orientation="vertical" + android:padding="8dp" + android:id="@+id/indicator" + android:background="@drawable/background_selectable"> + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:id="@+id/container"> + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:layout_weight="1" + android:textAppearance="?android:attr/textAppearanceLarge" + android:textColor="?android:attr/textColorPrimary" + android:gravity="center_vertical" + android:maxLines="2" + android:ellipsize="end"/> + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:layout_gravity="top" + app:srcCompat="@drawable/ic_image_edit" + android:background="?attr/selectableItemBackgroundBorderless" + android:contentDescription="Edit" + android:focusable="true" + android:nextFocusLeft="@+id/container"/> + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textColor="?android:attr/textColorSecondary"/> diff --git a/src/main/scala/com/github/shadowsocks/ProfilesFragment.scala b/src/main/scala/com/github/shadowsocks/ProfilesFragment.scala index 1c2440e0..9aa7c36f 100644 --- a/src/main/scala/com/github/shadowsocks/ProfilesFragment.scala +++ b/src/main/scala/com/github/shadowsocks/ProfilesFragment.scala @@ -45,6 +45,7 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene var item: Profile = _ private val text1 = itemView.findViewById(android.R.id.text1).asInstanceOf[TextView] private val text2 = itemView.findViewById(android.R.id.text2).asInstanceOf[TextView] + private val indicator = itemView.findViewById(R.id.indicator).asInstanceOf[ViewGroup] itemView.setOnClickListener(this) { @@ -65,15 +66,14 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene val builder = new StringBuilder() val address = (if (item.host.contains(":")) "[%s]:%d" else "%s:%d").format(item.host, item.remotePort) if (title == null || title.isEmpty) title = address else builder.append(address) - if (tx != 0 || rx != 0) { + // if (tx != 0 || rx != 0) { if (builder.nonEmpty) builder.append('\n') builder.append(getString(R.string.stat_profiles, TrafficMonitor.formatTraffic(tx), TrafficMonitor.formatTraffic(rx))) - } + // } handler.post(() => { text1.setText(title) text2.setText(builder) - text2.setVisibility(if (builder.isEmpty) View.GONE else View.VISIBLE) }) } @@ -81,10 +81,12 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene this.item = item updateText() if (item.id == app.profileId) { - text1.setTypeface(null, Typeface.BOLD) + // text1.setTypeface(null, Typeface.BOLD) + indicator.setBackgroundResource(R.drawable.background_selected) selectedItem = this } else { - text1.setTypeface(null, Typeface.NORMAL) + // text1.setTypeface(null, Typeface.NORMAL) + indicator.setBackgroundResource(R.drawable.background_selectable) if (selectedItem eq this) selectedItem = null } }