Commit 5a848548 authored by Mygod's avatar Mygod

Refine layout using GridView

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