Fix icons for notifications
This commit is contained in:
parent
fd83fef528
commit
6092161df0
|
@ -33,10 +33,10 @@ class AlarmService : Service(), OnPreparedListener {
|
||||||
val pendingStop =
|
val pendingStop =
|
||||||
PendingIntent.getBroadcast(context, 0, stopBroadcast, PendingIntent.FLAG_IMMUTABLE)
|
PendingIntent.getBroadcast(context, 0, stopBroadcast, PendingIntent.FLAG_IMMUTABLE)
|
||||||
return NotificationCompat.Builder(context, MainActivity.CHANNEL_ID_PENDING)
|
return NotificationCompat.Builder(context, MainActivity.CHANNEL_ID_PENDING)
|
||||||
.setSmallIcon(R.drawable.ic_baseline_hourglass_bottom_24).setContentTitle("Resting")
|
.setSmallIcon(R.drawable.baseline_hourglass_bottom_24).setContentTitle("Resting")
|
||||||
.setContentIntent(pendingContent)
|
.setContentIntent(pendingContent)
|
||||||
.addAction(R.drawable.ic_baseline_stop_24, "Stop", pendingStop)
|
.addAction(R.drawable.launch_background, "Stop", pendingStop)
|
||||||
.addAction(R.drawable.ic_baseline_stop_24, "Add 1 min", pendingAdd)
|
.addAction(R.drawable.launch_background, "Add 1 min", pendingAdd)
|
||||||
.setDeleteIntent(pendingStop)
|
.setDeleteIntent(pendingStop)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ import io.flutter.embedding.engine.FlutterEngine
|
||||||
import io.flutter.plugin.common.MethodChannel
|
import io.flutter.plugin.common.MethodChannel
|
||||||
import kotlin.math.floor
|
import kotlin.math.floor
|
||||||
|
|
||||||
class MainActivity : FlutterActivity() {
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
|
class MainActivity : FlutterActivity() {
|
||||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||||
super.configureFlutterEngine(flutterEngine)
|
super.configureFlutterEngine(flutterEngine)
|
||||||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, FLUTTER_CHANNEL).setMethodCallHandler {
|
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, FLUTTER_CHANNEL).setMethodCallHandler {
|
||||||
|
@ -38,7 +38,6 @@ class MainActivity : FlutterActivity() {
|
||||||
private var running = false
|
private var running = false
|
||||||
|
|
||||||
private val stopReceiver = object : BroadcastReceiver() {
|
private val stopReceiver = object : BroadcastReceiver() {
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
|
||||||
override fun onReceive(context: Context?, intent: Intent?) {
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
Log.d("MainActivity", "Received stop broadcast intent")
|
Log.d("MainActivity", "Received stop broadcast intent")
|
||||||
stop()
|
stop()
|
||||||
|
@ -46,7 +45,6 @@ class MainActivity : FlutterActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private val addReceiver = object : BroadcastReceiver() {
|
private val addReceiver = object : BroadcastReceiver() {
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
|
||||||
override fun onReceive(context: Context?, intent: Intent?) {
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
add()
|
add()
|
||||||
}
|
}
|
||||||
|
@ -55,7 +53,6 @@ class MainActivity : FlutterActivity() {
|
||||||
init {
|
init {
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
|
||||||
fun add() {
|
fun add() {
|
||||||
Log.d("MainActivity", "Add 1 min to alarm.")
|
Log.d("MainActivity", "Add 1 min to alarm.")
|
||||||
countdownTimer?.cancel()
|
countdownTimer?.cancel()
|
||||||
|
@ -69,7 +66,6 @@ class MainActivity : FlutterActivity() {
|
||||||
context.stopService(intent)
|
context.stopService(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
|
||||||
fun stop() {
|
fun stop() {
|
||||||
Log.d("MainActivity", "Stop alarm.")
|
Log.d("MainActivity", "Stop alarm.")
|
||||||
countdownTimer?.cancel()
|
countdownTimer?.cancel()
|
||||||
|
@ -81,7 +77,6 @@ class MainActivity : FlutterActivity() {
|
||||||
manager.cancel(NOTIFICATION_ID_PENDING)
|
manager.cancel(NOTIFICATION_ID_PENDING)
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
|
||||||
fun timer(milliseconds: Int) {
|
fun timer(milliseconds: Int) {
|
||||||
context.registerReceiver(stopReceiver, IntentFilter(STOP_BROADCAST))
|
context.registerReceiver(stopReceiver, IntentFilter(STOP_BROADCAST))
|
||||||
context.registerReceiver(addReceiver, IntentFilter(ADD_BROADCAST))
|
context.registerReceiver(addReceiver, IntentFilter(ADD_BROADCAST))
|
||||||
|
@ -96,7 +91,6 @@ class MainActivity : FlutterActivity() {
|
||||||
running = true
|
running = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
|
||||||
private fun getTimer(
|
private fun getTimer(
|
||||||
endMs: Int,
|
endMs: Int,
|
||||||
): CountDownTimer {
|
): CountDownTimer {
|
||||||
|
@ -125,7 +119,6 @@ class MainActivity : FlutterActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnspecifiedImmutableFlag")
|
@SuppressLint("UnspecifiedImmutableFlag")
|
||||||
@RequiresApi(Build.VERSION_CODES.M)
|
|
||||||
private fun getBuilder(): NotificationCompat.Builder {
|
private fun getBuilder(): NotificationCompat.Builder {
|
||||||
val contentIntent = Intent(context, MainActivity::class.java)
|
val contentIntent = Intent(context, MainActivity::class.java)
|
||||||
val pendingContent =
|
val pendingContent =
|
||||||
|
@ -140,14 +133,13 @@ class MainActivity : FlutterActivity() {
|
||||||
val pendingStop =
|
val pendingStop =
|
||||||
PendingIntent.getBroadcast(context, 0, stopBroadcast, PendingIntent.FLAG_IMMUTABLE)
|
PendingIntent.getBroadcast(context, 0, stopBroadcast, PendingIntent.FLAG_IMMUTABLE)
|
||||||
return NotificationCompat.Builder(context, CHANNEL_ID_PENDING)
|
return NotificationCompat.Builder(context, CHANNEL_ID_PENDING)
|
||||||
.setSmallIcon(R.drawable.ic_baseline_hourglass_bottom_24).setContentTitle("Resting")
|
.setSmallIcon(R.drawable.baseline_hourglass_bottom_24).setContentTitle("Resting")
|
||||||
.setContentIntent(pendingContent)
|
.setContentIntent(pendingContent)
|
||||||
.addAction(R.drawable.ic_baseline_stop_24, "Stop", pendingStop)
|
.addAction(R.drawable.baseline_hourglass_bottom_24, "Stop", pendingStop)
|
||||||
.addAction(R.drawable.ic_baseline_stop_24, "Add 1 min", pendingAdd)
|
.addAction(R.drawable.baseline_hourglass_bottom_24, "Add 1 min", pendingAdd)
|
||||||
.setDeleteIntent(pendingStop)
|
.setDeleteIntent(pendingStop)
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
|
||||||
private fun getManager(): NotificationManager {
|
private fun getManager(): NotificationManager {
|
||||||
val notificationManager = context.getSystemService(
|
val notificationManager = context.getSystemService(
|
||||||
NotificationManager::class.java
|
NotificationManager::class.java
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<vector android:height="24dp" android:tint="#000000"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M18,22l-0.01,-6L14,12l3.99,-4.01L18,2H6v6l4,4l-4,3.99V22H18zM8,7.5V4h8v3.5l-4,4L8,7.5z"/>
|
||||||
|
</vector>
|
Loading…
Reference in New Issue
Block a user