mirror of
https://github.com/SimpleMobileTools/Simple-Flashlight.git
synced 2025-02-17 04:10:46 +01:00
Merge pull request #41 from chrjsorg/feature/chrjsorg/quicksettings-tile
Quicksettings Tile
This commit is contained in:
commit
c34b5e9954
@ -28,9 +28,10 @@
|
||||
android:name=".activities.SplashActivity"
|
||||
android:theme="@style/SplashTheme">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
@ -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>
|
||||
|
@ -0,0 +1,33 @@
|
||||
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…
x
Reference in New Issue
Block a user