parent
b99df9aca7
commit
210e1bf51f
@ -0,0 +1,47 @@ |
||||
package io.legado.app.service |
||||
|
||||
import android.content.Intent |
||||
import android.os.Build |
||||
import android.service.quicksettings.Tile |
||||
import android.service.quicksettings.TileService |
||||
import androidx.annotation.RequiresApi |
||||
import io.legado.app.constant.IntentAction |
||||
|
||||
@RequiresApi(Build.VERSION_CODES.N) |
||||
class WebTileService : TileService() { |
||||
|
||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { |
||||
when (intent?.action) { |
||||
IntentAction.start -> { |
||||
qsTile.state = Tile.STATE_ACTIVE |
||||
qsTile.updateTile() |
||||
} |
||||
IntentAction.stop -> { |
||||
qsTile.state = Tile.STATE_INACTIVE |
||||
qsTile.updateTile() |
||||
} |
||||
} |
||||
return super.onStartCommand(intent, flags, startId) |
||||
} |
||||
|
||||
override fun onStartListening() { |
||||
super.onStartListening() |
||||
if (WebService.isRun) { |
||||
qsTile.state = Tile.STATE_ACTIVE |
||||
qsTile.updateTile() |
||||
} else { |
||||
qsTile.state = Tile.STATE_INACTIVE |
||||
qsTile.updateTile() |
||||
} |
||||
} |
||||
|
||||
override fun onClick() { |
||||
super.onClick() |
||||
if (WebService.isRun) { |
||||
WebService.stop(this) |
||||
} else { |
||||
WebService.start(this) |
||||
} |
||||
} |
||||
|
||||
} |
@ -1,17 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" |
||||
android:width="24dp" |
||||
android:height="24dp" |
||||
android:viewportWidth="24" |
||||
android:viewportHeight="24"> |
||||
|
||||
<path |
||||
android:fillColor="#FFFFFF" |
||||
android:pathData="M14.604,8.901H9.206c-1.046,0-1.898,0.909-1.898,2.025v8.885c0,1.117,0.853,2.024,1.898,2.024h5.397 c1.048,0,1.898-0.908,1.898-2.024v-8.885C16.502,9.81,15.651,8.901,14.604,8.901z M14.99,19.812c0,0.278-0.176,0.513-0.387,0.513 H9.206c-0.21,0-0.388-0.235-0.388-0.513v-8.885c0-0.278,0.178-0.513,0.388-0.513h5.397c0.211,0,0.387,0.235,0.387,0.513V19.812z" /> |
||||
<path |
||||
android:fillColor="#FFFFFF" |
||||
android:pathData="M11.997,1.836c-2.017,0-3.953,0.409-5.604,1.181c0,0,0,0-0.001,0C6.186,3.114,5.98,3.216,5.79,3.323 l0.739,1.318c0.158-0.089,0.33-0.174,0.502-0.253L6.93,4.169l0.102,0.218c1.453-0.68,3.17-1.039,4.966-1.04 c1.999,0,3.946,0.461,5.481,1.298l0.723-1.327C16.424,2.349,14.278,1.836,11.997,1.836z" /> |
||||
<path |
||||
android:fillColor="#FFFFFF" |
||||
android:pathData="M8.621,5.621l0.723,1.328C9.426,6.906,9.508,6.864,9.59,6.824c1.484-0.691,3.654-0.642,5.053,0.123 l0.727-1.327c-1.824-0.996-4.496-1.062-6.418-0.166l0.314,0.674l-0.32-0.671C8.838,5.508,8.729,5.563,8.621,5.621z" /> |
||||
</vector> |
Loading…
Reference in new issue