diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java index 4c7bb4f0a..f4a35c904 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/BTService.java @@ -577,14 +577,15 @@ public class BTService extends XWService { PendingIntent stopPI = PendingIntent.getBroadcast(this, 0, stopIntent, 0); - m_notification = - new NotificationCompat.Builder( this, Utils.getChannelId(this) ) + String channelID = Channels.getChannelID( this, Channels.ID.FOREGROUND ); + NotificationCompat.Builder builder = + new NotificationCompat.Builder( this, channelID ) .setSmallIcon( R.drawable.notify_btservice ) .setContentText( getString(R.string.bkng_notify_text) ) .setContentIntent( pendIntent ) .addAction( R.drawable.notify_btservice, - getString(R.string.bkng_stop_text), stopPI ) - .build(); + getString(R.string.bkng_stop_text), stopPI ); + m_notification = builder.build(); } Log.d( TAG, "calling service.startForeground()" ); diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java index 848da6f3f..9e6ec2df2 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/Utils.java @@ -83,8 +83,6 @@ public class Utils { private static final String TAG = Utils.class.getSimpleName(); public static final int TURN_COLOR = 0x7F00FF00; - private static final String _CHANNEL_ID = BuildConfig.APPLICATION_ID + "_channel_id"; - private static final String DB_PATH = "XW_GAMES"; private static final String HIDDEN_PREFS = "xwprefs_hidden"; private static final String FIRST_VERSION_KEY = "FIRST_VERSION_KEY"; @@ -258,8 +256,9 @@ public class Utils { defaults |= Notification.DEFAULT_VIBRATE; } + String channelID = Channels.getChannelID( context, Channels.ID.GAME_EVENT ); Notification notification = - new NotificationCompat.Builder( context, getChannelId(context) ) + new NotificationCompat.Builder( context, channelID ) .setContentIntent( pi ) .setSmallIcon( R.drawable.notify ) //.setTicker(body) @@ -620,27 +619,4 @@ public class Utils { } } } - - private static boolean sChannelMade = false; - static String getChannelId( Context context ) - { - if ( !sChannelMade ) { - sChannelMade = true; - if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ) { - NotificationManager notMgr = (NotificationManager) - context.getSystemService( Context.NOTIFICATION_SERVICE ); - - String channelDescription = "XWORDS Default Channel"; - NotificationChannel channel = notMgr.getNotificationChannel( _CHANNEL_ID ); - if ( channel == null ) { - channel = new NotificationChannel( _CHANNEL_ID, channelDescription, - NotificationManager.IMPORTANCE_LOW ); - // channel.setLightColor(Color.GREEN); - channel.enableVibration( true ); - notMgr.createNotificationChannel( channel ); - } - } - } - return _CHANNEL_ID; - } } diff --git a/xwords4/android/app/src/main/res/values/strings.xml b/xwords4/android/app/src/main/res/values/strings.xml index c7b7660ae..bd57ba9d4 100644 --- a/xwords4/android/app/src/main/res/values/strings.xml +++ b/xwords4/android/app/src/main/res/values/strings.xml @@ -2727,4 +2727,8 @@ Android Permissions Permission not granted + + Ready-for-bluetooth + + In-game events