Commit 1f695b9c authored by Max Lv's avatar Max Lv

refine the action button style

parent aedb5811
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
android:layout_marginBottom="@dimen/fab_margin_bottom"> android:layout_marginBottom="@dimen/fab_margin_bottom">
<android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:backgroundTint="@color/material_green_600" app:backgroundTint="@color/material_blue_grey_700"
android:src="@drawable/ic_cloud_off" android:src="@drawable/ic_cloud_off"
app:pressedTranslationZ="6dp" app:borderWidth="0dp" /> app:pressedTranslationZ="6dp" app:borderWidth="0dp" />
</com.github.jorgecastilloprz.FABProgressCircle> </com.github.jorgecastilloprz.FABProgressCircle>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" <android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="?attr/actionBarSize" android:layout_width="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?attr/colorPrimary" android:elevation="4dp" android:layout_height="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" android:layout_width="match_parent"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:id="@+id/toolbar" /> android:background="?attr/colorPrimary"
\ No newline at end of file android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:titleTextAppearance="@style/Toolbar.TitleText"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:id="@+id/toolbar" />
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
<resources> <resources>
<style name="Toolbar.TitleText" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
<item name="android:textSize">24sp</item>
</style>
<style name="Theme.Material" parent="Theme.AppCompat.Light.NoActionBar"> <style name="Theme.Material" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:alertDialogTheme">@style/Theme.Material.Dialog.Alert</item> <item name="android:alertDialogTheme">@style/Theme.Material.Dialog.Alert</item>
<item name="android:dialogTheme">@style/Theme.Material.Dialog</item> <item name="android:dialogTheme">@style/Theme.Material.Dialog</item>
......
...@@ -51,6 +51,7 @@ import android.graphics.{Bitmap, Color, Typeface} ...@@ -51,6 +51,7 @@ import android.graphics.{Bitmap, Color, Typeface}
import android.net.{Uri, VpnService} import android.net.{Uri, VpnService}
import android.os._ import android.os._
import android.preference.{Preference, PreferenceManager, SwitchPreference} import android.preference.{Preference, PreferenceManager, SwitchPreference}
import android.support.v4.content.ContextCompat
import android.support.design.widget.{FloatingActionButton, Snackbar} import android.support.design.widget.{FloatingActionButton, Snackbar}
import android.support.v7.app.AppCompatActivity import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.Toolbar import android.support.v7.widget.Toolbar
...@@ -214,13 +215,7 @@ class Shadowsocks ...@@ -214,13 +215,7 @@ class Shadowsocks
} }
// Update the UI // Update the UI
if (fab != null) fab.setEnabled(true) if (fab != null) fab.setEnabled(true)
if (State.isAvailable(bgService.getState)) { stateUpdate()
setPreferenceEnabled(enabled = true)
} else {
changeSwitch(checked = true)
setPreferenceEnabled(enabled = false)
}
state = bgService.getState
if (!status.getBoolean(getVersionName, false)) { if (!status.getBoolean(getVersionName, false)) {
status.edit.putBoolean(getVersionName, true).apply() status.edit.putBoolean(getVersionName, true).apply()
...@@ -249,8 +244,9 @@ class Shadowsocks ...@@ -249,8 +244,9 @@ class Shadowsocks
private lazy val listView = new ListView(this) private lazy val listView = new ListView(this)
private lazy val profileManager = private lazy val profileManager =
new ProfileManager(settings, getApplication.asInstanceOf[ShadowsocksApplication].dbHelper) new ProfileManager(settings, getApplication.asInstanceOf[ShadowsocksApplication].dbHelper)
private lazy val application = getApplication.asInstanceOf[ShadowsocksApplication] private lazy val application = getApplication.asInstanceOf[ShadowsocksApplication]
private lazy val greyTint = ContextCompat.getColorStateList(this, R.color.material_blue_grey_700)
private lazy val greenTint = ContextCompat.getColorStateList(this, R.color.material_green_600)
var handler = new Handler() var handler = new Handler()
...@@ -778,25 +774,33 @@ class Shadowsocks ...@@ -778,25 +774,33 @@ class Shadowsocks
prepared = false prepared = false
} }
protected override def onResume() { private def stateUpdate() {
super.onResume()
if (bgService != null) { if (bgService != null) {
bgService.getState match { bgService.getState match {
case State.CONNECTING => case State.CONNECTING =>
fab.setBackgroundTintList(greyTint);
fabProgressCircle.show() fabProgressCircle.show()
changeSwitch(checked = true) changeSwitch(checked = true)
case State.CONNECTED => case State.CONNECTED =>
fab.setBackgroundTintList(greenTint);
fabProgressCircle.hide() fabProgressCircle.hide()
changeSwitch(checked = true) changeSwitch(checked = true)
case State.STOPPING => case State.STOPPING =>
fab.setBackgroundTintList(greyTint);
fabProgressCircle.show() fabProgressCircle.show()
changeSwitch(checked = false) changeSwitch(checked = false)
case _ => case _ =>
fab.setBackgroundTintList(greyTint);
fabProgressCircle.hide() fabProgressCircle.hide()
changeSwitch(checked = false) changeSwitch(checked = false)
} }
state = bgService.getState state = bgService.getState
} }
}
protected override def onResume() {
super.onResume()
stateUpdate()
ConfigUtils.refresh(this) ConfigUtils.refresh(this)
// Check if profile list changed // Check if profile list changed
...@@ -1022,11 +1026,13 @@ class Shadowsocks ...@@ -1022,11 +1026,13 @@ class Shadowsocks
handler.post(() => if (state != s) { handler.post(() => if (state != s) {
s match { s match {
case State.CONNECTING => case State.CONNECTING =>
fab.setBackgroundTintList(greyTint);
fab.setImageResource(R.drawable.ic_cloud_queue) fab.setImageResource(R.drawable.ic_cloud_queue)
fab.setEnabled(false) fab.setEnabled(false)
fabProgressCircle.show() fabProgressCircle.show()
setPreferenceEnabled(enabled = false) setPreferenceEnabled(enabled = false)
case State.CONNECTED => case State.CONNECTED =>
fab.setBackgroundTintList(greenTint);
if (state == State.CONNECTING) { if (state == State.CONNECTING) {
fabProgressCircle.beginFinalAnimation() fabProgressCircle.beginFinalAnimation()
} else { } else {
...@@ -1036,6 +1042,7 @@ class Shadowsocks ...@@ -1036,6 +1042,7 @@ class Shadowsocks
changeSwitch(checked = true) changeSwitch(checked = true)
setPreferenceEnabled(enabled = false) setPreferenceEnabled(enabled = false)
case State.STOPPED => case State.STOPPED =>
fab.setBackgroundTintList(greyTint);
handler.postDelayed(() => fabProgressCircle.hide(), 1000) handler.postDelayed(() => fabProgressCircle.hide(), 1000)
fab.setEnabled(true) fab.setEnabled(true)
changeSwitch(checked = false) changeSwitch(checked = false)
...@@ -1043,6 +1050,7 @@ class Shadowsocks ...@@ -1043,6 +1050,7 @@ class Shadowsocks
getString(R.string.vpn_error).formatLocal(Locale.ENGLISH, m), Snackbar.LENGTH_LONG).show getString(R.string.vpn_error).formatLocal(Locale.ENGLISH, m), Snackbar.LENGTH_LONG).show
setPreferenceEnabled(enabled = true) setPreferenceEnabled(enabled = true)
case State.STOPPING => case State.STOPPING =>
fab.setBackgroundTintList(greyTint);
fab.setImageResource(R.drawable.ic_cloud_queue) fab.setImageResource(R.drawable.ic_cloud_queue)
fab.setEnabled(false) fab.setEnabled(false)
fabProgressCircle.show() fabProgressCircle.show()
......
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