|
|
@ -1,15 +1,36 @@ |
|
|
|
package io.legado.app.service |
|
|
|
package io.legado.app.service |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context |
|
|
|
import android.content.Intent |
|
|
|
import android.content.Intent |
|
|
|
import android.os.Build |
|
|
|
import android.os.Build |
|
|
|
import android.service.quicksettings.Tile |
|
|
|
import android.service.quicksettings.Tile |
|
|
|
import android.service.quicksettings.TileService |
|
|
|
import android.service.quicksettings.TileService |
|
|
|
import androidx.annotation.RequiresApi |
|
|
|
import androidx.annotation.RequiresApi |
|
|
|
import io.legado.app.constant.IntentAction |
|
|
|
import io.legado.app.constant.IntentAction |
|
|
|
|
|
|
|
import io.legado.app.utils.startService |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* web服务快捷开关 |
|
|
|
|
|
|
|
*/ |
|
|
|
@RequiresApi(Build.VERSION_CODES.N) |
|
|
|
@RequiresApi(Build.VERSION_CODES.N) |
|
|
|
class WebTileService : TileService() { |
|
|
|
class WebTileService : TileService() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun setState(context: Context, active: Boolean) { |
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
|
|
|
|
|
|
|
context.startService<WebTileService> { |
|
|
|
|
|
|
|
action = if (active) { |
|
|
|
|
|
|
|
IntentAction.start |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
IntentAction.stop |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { |
|
|
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { |
|
|
|
when (intent?.action) { |
|
|
|
when (intent?.action) { |
|
|
|
IntentAction.start -> { |
|
|
|
IntentAction.start -> { |
|
|
|