Change tile to a quick switch
This commit is contained in:
@@ -128,7 +128,7 @@
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<service android:name=".ShadowsocksTileService" android:label="@string/app_name"
|
||||
<service android:name=".ShadowsocksTileService" android:label="@string/quick_toggle"
|
||||
android:icon="@drawable/ic_start_connected"
|
||||
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
|
||||
<intent-filter>
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="quick_toggle">Переключение</string>
|
||||
|
||||
<!-- global/misc category -->
|
||||
<string name="misc_cat">Разное</string>
|
||||
<string name="profile">Профиль</string>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">影梭</string>
|
||||
<string name="quick_toggle">开关</string>
|
||||
|
||||
<string name="misc_cat">其他</string>
|
||||
<string name="proxy_cat">服务器设置</string>
|
||||
<string name="profile_name">配置名称</string>
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Shadowsocks</string>
|
||||
<string name="quick_toggle">開關</string>
|
||||
|
||||
<string name="misc_cat">其他</string>
|
||||
<string name="proxy_cat">伺服器設定</string>
|
||||
<string name="profile_name">設定檔名稱</string>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Shadowsocks</string>
|
||||
<string name="quick_toggle">Toggle</string>
|
||||
|
||||
<!-- global/misc category -->
|
||||
<string name="misc_cat">Misc</string>
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.github.shadowsocks
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Icon
|
||||
import android.service.quicksettings.{Tile, TileService}
|
||||
import com.github.shadowsocks.aidl.IShadowsocksServiceCallback
|
||||
import com.github.shadowsocks.utils.State
|
||||
import com.github.shadowsocks.utils.{State, Utils}
|
||||
import com.github.shadowsocks.ShadowsocksApplication.app
|
||||
|
||||
/**
|
||||
@@ -48,10 +47,14 @@ final class ShadowsocksTileService extends TileService with ServiceBoundContext
|
||||
|
||||
override def onStopListening {
|
||||
super.onStopListening
|
||||
detachService // just in case the user switches to NAT mode
|
||||
detachService // just in case the user switches to NAT mode, also saves battery
|
||||
}
|
||||
|
||||
override def onClick = if (isLocked) unlockAndRun(configure) else configure()
|
||||
override def onClick = if (isLocked) unlockAndRun(toggle) else toggle()
|
||||
|
||||
private def configure() = startActivityAndCollapse(new Intent(this, classOf[Shadowsocks]))
|
||||
private def toggle() = bgService.getState match {
|
||||
case State.STOPPED => Utils.startSsService(this)
|
||||
case State.CONNECTED => Utils.stopSsService(this)
|
||||
case _ => // ignore
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user