Settings: Add notification channel for SIM selection
Change-Id: I9318311fd6378a82050bb1604c29f0af2501c8b7
This commit is contained in:
@@ -6432,6 +6432,8 @@
|
|||||||
<string name="sim_calls_ask_first_prefs_title">Ask every time</string>
|
<string name="sim_calls_ask_first_prefs_title">Ask every time</string>
|
||||||
<!-- When a SIM preference hasn't been selected yet, this string is displayed as the pref summary until the user chooses a SIM subscription from the preference list [CHAR LIMIT=50] -->
|
<!-- When a SIM preference hasn't been selected yet, this string is displayed as the pref summary until the user chooses a SIM subscription from the preference list [CHAR LIMIT=50] -->
|
||||||
<string name="sim_selection_required_pref">Selection required</string>
|
<string name="sim_selection_required_pref">Selection required</string>
|
||||||
|
<!-- Title for SIM selection notification channel -->
|
||||||
|
<string name="sim_selection_channel_title">SIM selection</string>
|
||||||
|
|
||||||
<!--Dashboard strings-->
|
<!--Dashboard strings-->
|
||||||
<!-- Text to describe the dashboard fragment title [CHAR LIMIT=16] -->
|
<!-- Text to describe the dashboard fragment title [CHAR LIMIT=16] -->
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.sim;
|
package com.android.settings.sim;
|
||||||
|
|
||||||
|
import android.app.NotificationChannel;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
@@ -40,6 +41,9 @@ public class SimSelectNotification extends BroadcastReceiver {
|
|||||||
private static final String TAG = "SimSelectNotification";
|
private static final String TAG = "SimSelectNotification";
|
||||||
private static final int NOTIFICATION_ID = 1;
|
private static final int NOTIFICATION_ID = 1;
|
||||||
|
|
||||||
|
private static final String SIM_SELECT_NOTIFICATION_CHANNEL =
|
||||||
|
"sim_select_notification_channel";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
final TelephonyManager telephonyManager = (TelephonyManager)
|
final TelephonyManager telephonyManager = (TelephonyManager)
|
||||||
@@ -117,8 +121,14 @@ public class SimSelectNotification extends BroadcastReceiver {
|
|||||||
|
|
||||||
private void createNotification(Context context){
|
private void createNotification(Context context){
|
||||||
final Resources resources = context.getResources();
|
final Resources resources = context.getResources();
|
||||||
|
|
||||||
|
NotificationChannel notificationChannel = new NotificationChannel(
|
||||||
|
SIM_SELECT_NOTIFICATION_CHANNEL,
|
||||||
|
resources.getString(R.string.sim_selection_channel_title),
|
||||||
|
NotificationManager.IMPORTANCE_LOW);
|
||||||
|
|
||||||
NotificationCompat.Builder builder =
|
NotificationCompat.Builder builder =
|
||||||
new NotificationCompat.Builder(context)
|
new NotificationCompat.Builder(context, SIM_SELECT_NOTIFICATION_CHANNEL)
|
||||||
.setSmallIcon(R.drawable.ic_sim_card_alert_white_48dp)
|
.setSmallIcon(R.drawable.ic_sim_card_alert_white_48dp)
|
||||||
.setColor(context.getColor(R.color.sim_noitification))
|
.setColor(context.getColor(R.color.sim_noitification))
|
||||||
.setContentTitle(resources.getString(R.string.sim_notification_title))
|
.setContentTitle(resources.getString(R.string.sim_notification_title))
|
||||||
@@ -130,6 +140,7 @@ public class SimSelectNotification extends BroadcastReceiver {
|
|||||||
builder.setContentIntent(resultPendingIntent);
|
builder.setContentIntent(resultPendingIntent);
|
||||||
NotificationManager notificationManager =
|
NotificationManager notificationManager =
|
||||||
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
notificationManager.createNotificationChannel(notificationChannel);
|
||||||
notificationManager.notify(NOTIFICATION_ID, builder.build());
|
notificationManager.notify(NOTIFICATION_ID, builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user