Loading app/src/main/AndroidManifest.xml +13 −2 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ android:theme="@style/SplashTheme"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> Loading Loading @@ -83,5 +84,15 @@ android:name="android.appwidget.provider" android:resource="@xml/widget_info"/> </receiver> <service android:name=".helpers.MyTileService" android:label="@string/app_launcher_name" android:icon="@drawable/img_widget_preview" android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"> <intent-filter> <action android:name="android.service.quicksettings.action.QS_TILE" /> </intent-filter> </service> </application> </manifest> app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyTileService.kt 0 → 100644 +33 −0 Original line number Diff line number Diff line package com.simplemobiletools.flashlight.helpers import android.os.Build import android.service.quicksettings.Tile import android.service.quicksettings.TileService import android.support.annotation.RequiresApi @RequiresApi(Build.VERSION_CODES.N) class MyTileService : TileService() { override fun onClick() { MyCameraImpl.newInstance(this).toggleFlashlight() updateTile() } override fun onTileRemoved() { if (MyCameraImpl.isFlashlightOn) MyCameraImpl.newInstance(this).toggleFlashlight() } override fun onStartListening() { updateTile() } override fun onTileAdded() { updateTile() } private fun updateTile() { qsTile.state = if (MyCameraImpl.isFlashlightOn) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE qsTile.updateTile() } } Loading
app/src/main/AndroidManifest.xml +13 −2 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ android:theme="@style/SplashTheme"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> Loading Loading @@ -83,5 +84,15 @@ android:name="android.appwidget.provider" android:resource="@xml/widget_info"/> </receiver> <service android:name=".helpers.MyTileService" android:label="@string/app_launcher_name" android:icon="@drawable/img_widget_preview" android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"> <intent-filter> <action android:name="android.service.quicksettings.action.QS_TILE" /> </intent-filter> </service> </application> </manifest>
app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyTileService.kt 0 → 100644 +33 −0 Original line number Diff line number Diff line package com.simplemobiletools.flashlight.helpers import android.os.Build import android.service.quicksettings.Tile import android.service.quicksettings.TileService import android.support.annotation.RequiresApi @RequiresApi(Build.VERSION_CODES.N) class MyTileService : TileService() { override fun onClick() { MyCameraImpl.newInstance(this).toggleFlashlight() updateTile() } override fun onTileRemoved() { if (MyCameraImpl.isFlashlightOn) MyCameraImpl.newInstance(this).toggleFlashlight() } override fun onStartListening() { updateTile() } override fun onTileAdded() { updateTile() } private fun updateTile() { qsTile.state = if (MyCameraImpl.isFlashlightOn) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE qsTile.updateTile() } }