Skip to content

Commit 25a7229

Browse files
authored
Merge pull request #175 from KryptKode/feat/bright-display-tile
Add Bright Display settings tile
2 parents a8584c1 + 28bda12 commit 25a7229

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<activity
6464
android:name=".activities.BrightDisplayActivity"
6565
android:exported="false"
66+
android:launchMode="singleInstance"
6667
android:label="@string/bright_display"
6768
android:theme="@style/FullScreenTheme" />
6869

@@ -131,7 +132,7 @@
131132
</receiver>
132133

133134
<service
134-
android:name=".helpers.MyTileService"
135+
android:name=".helpers.FlashlightTileService"
135136
android:exported="true"
136137
android:icon="@drawable/img_torch_widget_preview"
137138
android:label="@string/app_launcher_name"
@@ -141,6 +142,17 @@
141142
</intent-filter>
142143
</service>
143144

145+
<service
146+
android:name=".helpers.BrightDisplayTileService"
147+
android:exported="true"
148+
android:icon="@drawable/img_bright_display_widget_preview"
149+
android:label="@string/bright_display"
150+
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
151+
<intent-filter>
152+
<action android:name="android.service.quicksettings.action.QS_TILE" />
153+
</intent-filter>
154+
</service>
155+
144156
<activity-alias
145157
android:name=".activities.SplashActivity.Red"
146158
android:enabled="false"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.simplemobiletools.flashlight.helpers
2+
3+
import android.annotation.TargetApi
4+
import android.content.Intent
5+
import android.os.Build
6+
import android.service.quicksettings.TileService
7+
import com.simplemobiletools.flashlight.activities.BrightDisplayActivity
8+
9+
@TargetApi(Build.VERSION_CODES.N)
10+
class BrightDisplayTileService : TileService() {
11+
12+
override fun onClick() {
13+
val intent = Intent(applicationContext, BrightDisplayActivity::class.java)
14+
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
15+
startActivityAndCollapse(intent)
16+
}
17+
}

app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/MyTileService.kt renamed to app/src/main/kotlin/com/simplemobiletools/flashlight/helpers/FlashlightTileService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import android.service.quicksettings.Tile
66
import android.service.quicksettings.TileService
77

88
@TargetApi(Build.VERSION_CODES.N)
9-
class MyTileService : TileService() {
9+
class FlashlightTileService : TileService() {
1010

1111
override fun onClick() {
1212
MyCameraImpl.newInstance(this).toggleFlashlight()

0 commit comments

Comments
 (0)