@@ -2,6 +2,7 @@ package id.psw.floatstat
22
33import android.annotation.SuppressLint
44import android.app.*
5+ import android.content.Context
56import android.content.Intent
67import android.content.res.Configuration
78import android.graphics.*
@@ -37,6 +38,15 @@ class FloatWindowService : Service() {
3738 const val ACTION_CLOSE = " id.psw.temperamon.action.CLOSE"
3839 const val ACTION_EXPAND = " id.psw.temperamon.action.EXPAND"
3940 private const val allowEditor: Boolean = true
41+
42+ fun startServiceS (ctx : Context ){
43+ val i = Intent (ctx, FloatWindowService ::class .java)
44+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
45+ ctx.startForegroundService(i)
46+ }else {
47+ ctx.startService(i)
48+ }
49+ }
4050 }
4151
4252 private var vMainView : StatusView ? = null
@@ -138,19 +148,19 @@ class FloatWindowService : Service() {
138148 val notifFlag = if (sdkAtLeast(Build .VERSION_CODES .M )) PendingIntent .FLAG_IMMUTABLE or PendingIntent .FLAG_UPDATE_CURRENT else 0
139149
140150 val notif = NotificationCompat .Builder (this , NOTIF_ID )
141- .setContentTitle(" Floating Stats is running " )
142- .setContentText(" Expand this notification to control the floating widget " )
151+ .setContentTitle(getString( R .string.float_stat_notif_title) )
152+ .setContentText(getString( R .string.float_stat_notif_desc) )
143153 .setSmallIcon(R .drawable.ic_main_notification)
144154 .setSilent(true )
145155 .setContentIntent(PendingIntent .getService(this , INT_ACTION_EXPAND ,
146156 Intent (ACTION_EXPAND ), notifFlag))
147- .addAction(android.R .drawable.ic_menu_view, " Show/Hide " ,
157+ .addAction(android.R .drawable.ic_menu_view, getString( R .string.float_stat_notif_visibility) ,
148158 PendingIntent .getService(this , INT_ACTION_VISIBILITY ,
149159 Intent (ACTION_VISIBILITY ), notifFlag))
150- .addAction(android.R .drawable.ic_menu_edit, " Edit " ,
160+ .addAction(android.R .drawable.ic_menu_edit, getString( R .string.float_stat_notif_edit) ,
151161 PendingIntent .getService(this , INT_ACTION_EDIT ,
152162 Intent (ACTION_EDIT ), notifFlag))
153- .addAction(android.R .drawable.ic_menu_close_clear_cancel, " Close " ,
163+ .addAction(android.R .drawable.ic_menu_close_clear_cancel, getString( R .string.float_stat_notif_close) ,
154164 PendingIntent .getService(this , INT_ACTION_CLOSE ,
155165 Intent (ACTION_CLOSE ), notifFlag))
156166 .build()
@@ -236,19 +246,25 @@ class FloatWindowService : Service() {
236246 setOnClickListener { btn ->
237247 PopupMenu (context, this ).apply {
238248 menuInflater.inflate(R .menu.selector_menu, menu)
249+ menu.findItem(R .id.plugin_selector_bootstart).isChecked = app.startOnBoot
250+
239251 setOnMenuItemClickListener {
240252 when (it.itemId){
241253 R .id.plugin_selector_donate -> { app().openDonateUri() }
242254 R .id.plugin_selector_refresh -> {
243255 editWindow?.cancel()
244256 app().refreshPluginList()
245- Toast .makeText(app, " Updating Data and Plugin List, The data selector list will re-open after 1 second, " , Toast .LENGTH_LONG ).show()
257+ Toast .makeText(app, context.getString( R .string.plugin_selector_updating_warning) , Toast .LENGTH_LONG ).show()
246258 Timer (" UpdateWait" , false ).schedule(1000 ){
247259 wHandler.post {
248260 openEditWindow()
249261 }
250262 }
251263 }
264+ R .id.plugin_selector_bootstart -> {
265+ app.startOnBoot = ! app.startOnBoot
266+ app.savePreferences()
267+ }
252268 }
253269 true
254270 }
0 commit comments