Commit 5a848548 authored by Mygod's avatar Mygod

Refine layout using GridView

parent 0cf15857
......@@ -37,6 +37,7 @@ libraryDependencies ++= Seq(
"com.google.android.gms" % "play-services-ads" % "8.4.0",
"com.google.android.gms" % "play-services-analytics" % "8.4.0",
"com.android.support" % "design" % "23.1.1",
"com.android.support" % "gridlayout-v7" % "23.1.1",
"com.github.jorgecastilloprz" % "fabprogresscircle" % "1.01",
"com.j256.ormlite" % "ormlite-core" % "4.48",
"com.j256.ormlite" % "ormlite-android" % "4.48",
......
......@@ -30,92 +30,95 @@
android:gravity="end" />
</LinearLayout>
<TableLayout
android:stretchColumns="2"
android:layout_width="wrap_content"
<android.support.v7.widget.GridLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
app:columnCount="4"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_column="0"
app:layout_column="0"
style="@style/TextAppearance.AppCompat.Body2"
android:ellipsize="marquee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="24dp"
android:layout_marginEnd="24dp"
android:gravity="end"
android:text="@string/sent" />
<TextView
android:layout_column="1"
app:layout_column="1"
android:id="@+id/tx"
android:textSize="14sp"
android:textColor="?android:attr/textColorSecondary"
android:ellipsize="marquee"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="end" />
app:layout_columnWeight="1"
app:layout_gravity="fill_horizontal" />
<TextView
android:layout_column="2"
app:layout_column="2"
android:textSize="14sp"
android:textColor="?android:attr/textColorSecondary"
android:ellipsize="marquee"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:text="▲" />
<TextView
android:layout_column="3"
app:layout_column="3"
android:id="@+id/txRate"
android:textSize="14sp"
android:textColor="?android:attr/textColorSecondary"
android:ellipsize="marquee"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_columnWeight="1"
app:layout_gravity="fill_horizontal"
android:gravity="end" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_column="0"
app:layout_row="1"
app:layout_column="0"
style="@style/TextAppearance.AppCompat.Body2"
android:ellipsize="marquee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="24dp"
android:layout_marginEnd="24dp"
android:gravity="end"
android:text="@string/received"/>
<TextView
android:layout_column="1"
app:layout_row="1"
app:layout_column="1"
android:id="@+id/rx"
android:textSize="14sp"
android:textColor="?android:attr/textColorSecondary"
android:ellipsize="marquee"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="end" />
app:layout_columnWeight="1"
app:layout_gravity="fill_horizontal" />
<TextView
android:layout_column="2"
app:layout_row="1"
app:layout_column="2"
android:textSize="14sp"
android:textColor="?android:attr/textColorSecondary"
android:ellipsize="marquee"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end"
android:text="▼" />
<TextView
android:layout_column="3"
app:layout_row="1"
app:layout_column="3"
android:id="@+id/rxRate"
android:textSize="14sp"
android:textColor="?android:attr/textColorSecondary"
android:ellipsize="marquee"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_columnWeight="1"
app:layout_gravity="fill_horizontal"
android:gravity="end" />
</TableRow>
</TableLayout>
</android.support.v7.widget.GridLayout>
</LinearLayout>
......@@ -169,12 +169,12 @@ class Shadowsocks
def updateTraffic(): Unit = if (trafficCache == null) callback.trafficUpdated(0, 0, 0, 0) else {
if (connectionTestResult == null) connectionTestResult = getString(R.string.connection_test_pending)
if (preferences.natSwitch.isChecked) {
preferences.stat.setSummary("")
preferences.stat.setSummary(null)
} else {
if (connectionTestSuccess) {
preferences.stat.setSummary(connectionTestResult)
} else {
preferences.stat.setSummary(getString(R.string.connection_test_fail))
preferences.stat.setSummary(R.string.connection_test_fail)
Snackbar.make(findViewById(android.R.id.content), connectionTestResult, Snackbar.LENGTH_LONG).show
}
}
......
......@@ -78,7 +78,7 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
addPreferencesFromResource(R.xml.pref_all)
getPreferenceManager.getSharedPreferences.registerOnSharedPreferenceChangeListener(this)
stat= findPreference(Key.stat)
stat = findPreference(Key.stat)
stat.setOnPreferenceClickListener(_ => {
val id = synchronized {
testCount += 1
......@@ -97,7 +97,7 @@ class ShadowsocksSettings extends PreferenceFragment with OnSharedPreferenceChan
conn.setUseCaches(false)
if (testCount == id) {
var result: String = null
var success: Boolean = true
var success = true
try {
val start = currentTimeMillis
conn.getInputStream
......
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