Commit 25b6a307 authored by Mygod's avatar Mygod

Layout bugfixes

parent 5217b1d1
...@@ -48,22 +48,18 @@ ...@@ -48,22 +48,18 @@
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:id="@+id/details"> android:id="@+id/details">
<TextView android:id="@+id/address" <TextView android:id="@+id/address"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical|start" android:gravity="top"
android:gravity="center_vertical|start"
android:layout_weight="1" android:layout_weight="1"
android:maxLines="1" android:maxLines="2"
android:ellipsize="end" android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/> android:textColor="?android:attr/textColorSecondary"/>
<TextView android:id="@+id/traffic" <TextView android:id="@+id/traffic"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end" android:gravity="top"
android:gravity="center_vertical|end"
android:layout_weight="1"
android:maxLines="1"
android:ellipsize="end" android:ellipsize="end"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/> android:textColor="?android:attr/textColorSecondary"/>
......
...@@ -20,8 +20,9 @@ ...@@ -20,8 +20,9 @@
package com.github.shadowsocks package com.github.shadowsocks
import java.util.GregorianCalendar
import android.content._ import android.content._
import android.graphics.Typeface
import android.os.{Build, Bundle, Handler, UserManager} import android.os.{Build, Bundle, Handler, UserManager}
import android.support.v4.content.LocalBroadcastManager import android.support.v4.content.LocalBroadcastManager
import android.support.v7.widget.RecyclerView.ViewHolder import android.support.v7.widget.RecyclerView.ViewHolder
...@@ -31,17 +32,14 @@ import android.support.v7.widget.helper.ItemTouchHelper ...@@ -31,17 +32,14 @@ import android.support.v7.widget.helper.ItemTouchHelper
import android.support.v7.widget.helper.ItemTouchHelper.SimpleCallback import android.support.v7.widget.helper.ItemTouchHelper.SimpleCallback
import android.view._ import android.view._
import android.widget.{TextView, Toast} import android.widget.{TextView, Toast}
import com.github.shadowsocks.ShadowsocksApplication.app import com.github.shadowsocks.ShadowsocksApplication.app
import com.github.shadowsocks.database.Profile import com.github.shadowsocks.database.Profile
import com.github.shadowsocks.utils._ import com.github.shadowsocks.utils._
import com.github.shadowsocks.widget.UndoSnackbarManager import com.github.shadowsocks.widget.UndoSnackbarManager
import com.google.android.gms.ads.{AdRequest, AdSize, NativeExpressAdView} import com.google.android.gms.ads.{AdRequest, NativeExpressAdView}
import java.util.GregorianCalendar
import scala.util.Random
import scala.collection.mutable.ArrayBuffer import scala.collection.mutable.ArrayBuffer
import scala.util.Random
final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListener { final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListener {
private final class ProfileViewHolder(val view: View) extends RecyclerView.ViewHolder(view) private final class ProfileViewHolder(val view: View) extends RecyclerView.ViewHolder(view)
...@@ -49,9 +47,9 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene ...@@ -49,9 +47,9 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
var item: Profile = _ var item: Profile = _
private val text1 = itemView.findViewById(R.id.title).asInstanceOf[TextView] private val title = itemView.findViewById(R.id.title).asInstanceOf[TextView]
private val text2 = itemView.findViewById(R.id.address).asInstanceOf[TextView] private val address = itemView.findViewById(R.id.address).asInstanceOf[TextView]
private val text3 = itemView.findViewById(R.id.traffic).asInstanceOf[TextView] private val traffic = itemView.findViewById(R.id.traffic).asInstanceOf[TextView]
private val indicator = itemView.findViewById(R.id.indicator).asInstanceOf[ViewGroup] private val indicator = itemView.findViewById(R.id.indicator).asInstanceOf[ViewGroup]
itemView.setOnClickListener(this) itemView.setOnClickListener(this)
...@@ -73,15 +71,18 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene ...@@ -73,15 +71,18 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
val tx = item.tx + txTotal val tx = item.tx + txTotal
val rx = item.rx + rxTotal val rx = item.rx + rxTotal
var title = if (isDemoMode) "Profile #" + item.id else item.name var title = if (isDemoMode) "Profile #" + item.id else item.name
val address = (if (item.host.contains(":")) "[%s]:%d" else "%s:%d").format(item.host, item.remotePort) var address = (if (item.host.contains(":")) "[%s]:%d" else "%s:%d").format(item.host, item.remotePort)
if (title == null || title.isEmpty) title = address if ((title == null || title.isEmpty) && address.nonEmpty) {
title = address
address = ""
}
val traffic = getString(R.string.stat_profiles, val traffic = getString(R.string.stat_profiles,
TrafficMonitor.formatTraffic(tx), TrafficMonitor.formatTraffic(rx)) TrafficMonitor.formatTraffic(tx), TrafficMonitor.formatTraffic(rx))
handler.post(() => { handler.post(() => {
text1.setText(title) this.title.setText(title)
text2.setText(address) this.address.setText(address)
text3.setText(traffic) this.traffic.setText(traffic)
}) })
} }
...@@ -90,11 +91,9 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene ...@@ -90,11 +91,9 @@ final class ProfilesFragment extends ToolbarFragment with OnMenuItemClickListene
updateText() updateText()
if (item.id == app.profileId) { if (item.id == app.profileId) {
// text1.setTypeface(null, Typeface.BOLD)
indicator.setBackgroundResource(R.drawable.background_selected) indicator.setBackgroundResource(R.drawable.background_selected)
selectedItem = this selectedItem = this
} else { } else {
// text1.setTypeface(null, Typeface.NORMAL)
indicator.setBackgroundResource(R.drawable.background_selectable) indicator.setBackgroundResource(R.drawable.background_selectable)
if (selectedItem eq this) selectedItem = null if (selectedItem eq this) selectedItem = null
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment