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