Loading AndroidManifest.xml +9 −0 Original line number Diff line number Diff line Loading @@ -332,6 +332,15 @@ android:name=".quickcontact.QuickContactBroadcastReceiver" android:exported="false"/> <!-- Responsible for creating notification channels when boot is completed or when app is re-installed --> <receiver android:name=".interactions.OnBootOrUpgradeReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.MY_PACKAGE_REPLACED" /> </intent-filter> </receiver> <activity-alias android:name="ContactShortcut" android:icon="@drawable/logo_quick_contacts_color_44in48dp" Loading res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -1583,4 +1583,7 @@ <!-- The notification title shown while SIM contacts are being imported [CHAR LIMIT=40] --> <string name="importing_sim_in_progress_title">Importing SIM</string> <!-- Text shown when viewing channel settings for default Contacts notifications [CHAR LIMIT=50] --> <string name="contacts_default_notification_channel">Notifications</string> </resources> src/com/android/contacts/SimImportService.java +4 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import com.android.contacts.database.SimContactDao; import com.android.contacts.model.SimCard; import com.android.contacts.model.SimContact; import com.android.contacts.model.account.AccountWithDataSet; import com.android.contacts.util.ContactsNotificationChannelsUtil; import com.android.contactsbind.FeedbackHelper; import java.util.ArrayList; Loading Loading @@ -189,6 +190,7 @@ public class SimImportService extends Service { final Intent intent = new Intent(this, PeopleActivity.class); final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setOngoing(false) .setChannel(ContactsNotificationChannelsUtil.DEFAULT_CHANNEL) .setAutoCancel(true) .setContentTitle(this.getString(R.string.importing_sim_finished_title)) .setColor(this.getResources().getColor(R.color.dialtacts_theme_color)) Loading @@ -201,6 +203,7 @@ public class SimImportService extends Service { final Intent intent = new Intent(this, PeopleActivity.class); final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setOngoing(false) .setChannel(ContactsNotificationChannelsUtil.DEFAULT_CHANNEL) .setAutoCancel(true) .setContentTitle(this.getString(R.string.importing_sim_failed_title)) .setContentText(this.getString(R.string.importing_sim_failed_message)) Loading @@ -214,6 +217,7 @@ public class SimImportService extends Service { final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); final String description = getString(R.string.importing_sim_in_progress_title); builder.setOngoing(true) .setChannel(ContactsNotificationChannelsUtil.DEFAULT_CHANNEL) .setProgress(/* current */ 0, /* max */ 100, /* indeterminate */ true) .setContentTitle(description) .setColor(this.getResources().getColor(R.color.dialtacts_theme_color)) Loading src/com/android/contacts/interactions/OnBootOrUpgradeReceiver.java 0 → 100644 +35 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.contacts.interactions; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import com.android.contacts.util.ContactsNotificationChannelsUtil; public class OnBootOrUpgradeReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (Intent.ACTION_BOOT_COMPLETED.equals(action) || Intent.ACTION_MY_PACKAGE_REPLACED.equals(action)) { ContactsNotificationChannelsUtil.createDefaultChannel(context); } } } src/com/android/contacts/util/ContactsNotificationChannelsUtil.java 0 → 100644 +44 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.contacts.util; import android.annotation.TargetApi; import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.Context; import android.os.Build; import android.support.v4.os.BuildCompat; import com.android.contacts.R; @TargetApi(Build.VERSION_CODES.O) public class ContactsNotificationChannelsUtil { public static String DEFAULT_CHANNEL = "DEFAULT_CHANNEL"; private ContactsNotificationChannelsUtil() {} public static void createDefaultChannel(Context context) { if (!BuildCompat.isAtLeastO()) { return; } final NotificationManager nm = context.getSystemService(NotificationManager.class); final NotificationChannel channel = new NotificationChannel(DEFAULT_CHANNEL, context.getString(R.string.contacts_default_notification_channel), NotificationManager.IMPORTANCE_DEFAULT); nm.createNotificationChannel(channel); } } Loading
AndroidManifest.xml +9 −0 Original line number Diff line number Diff line Loading @@ -332,6 +332,15 @@ android:name=".quickcontact.QuickContactBroadcastReceiver" android:exported="false"/> <!-- Responsible for creating notification channels when boot is completed or when app is re-installed --> <receiver android:name=".interactions.OnBootOrUpgradeReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.MY_PACKAGE_REPLACED" /> </intent-filter> </receiver> <activity-alias android:name="ContactShortcut" android:icon="@drawable/logo_quick_contacts_color_44in48dp" Loading
res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -1583,4 +1583,7 @@ <!-- The notification title shown while SIM contacts are being imported [CHAR LIMIT=40] --> <string name="importing_sim_in_progress_title">Importing SIM</string> <!-- Text shown when viewing channel settings for default Contacts notifications [CHAR LIMIT=50] --> <string name="contacts_default_notification_channel">Notifications</string> </resources>
src/com/android/contacts/SimImportService.java +4 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ import com.android.contacts.database.SimContactDao; import com.android.contacts.model.SimCard; import com.android.contacts.model.SimContact; import com.android.contacts.model.account.AccountWithDataSet; import com.android.contacts.util.ContactsNotificationChannelsUtil; import com.android.contactsbind.FeedbackHelper; import java.util.ArrayList; Loading Loading @@ -189,6 +190,7 @@ public class SimImportService extends Service { final Intent intent = new Intent(this, PeopleActivity.class); final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setOngoing(false) .setChannel(ContactsNotificationChannelsUtil.DEFAULT_CHANNEL) .setAutoCancel(true) .setContentTitle(this.getString(R.string.importing_sim_finished_title)) .setColor(this.getResources().getColor(R.color.dialtacts_theme_color)) Loading @@ -201,6 +203,7 @@ public class SimImportService extends Service { final Intent intent = new Intent(this, PeopleActivity.class); final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setOngoing(false) .setChannel(ContactsNotificationChannelsUtil.DEFAULT_CHANNEL) .setAutoCancel(true) .setContentTitle(this.getString(R.string.importing_sim_failed_title)) .setContentText(this.getString(R.string.importing_sim_failed_message)) Loading @@ -214,6 +217,7 @@ public class SimImportService extends Service { final NotificationCompat.Builder builder = new NotificationCompat.Builder(this); final String description = getString(R.string.importing_sim_in_progress_title); builder.setOngoing(true) .setChannel(ContactsNotificationChannelsUtil.DEFAULT_CHANNEL) .setProgress(/* current */ 0, /* max */ 100, /* indeterminate */ true) .setContentTitle(description) .setColor(this.getResources().getColor(R.color.dialtacts_theme_color)) Loading
src/com/android/contacts/interactions/OnBootOrUpgradeReceiver.java 0 → 100644 +35 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.contacts.interactions; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import com.android.contacts.util.ContactsNotificationChannelsUtil; public class OnBootOrUpgradeReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (Intent.ACTION_BOOT_COMPLETED.equals(action) || Intent.ACTION_MY_PACKAGE_REPLACED.equals(action)) { ContactsNotificationChannelsUtil.createDefaultChannel(context); } } }
src/com/android/contacts/util/ContactsNotificationChannelsUtil.java 0 → 100644 +44 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.contacts.util; import android.annotation.TargetApi; import android.app.NotificationChannel; import android.app.NotificationManager; import android.content.Context; import android.os.Build; import android.support.v4.os.BuildCompat; import com.android.contacts.R; @TargetApi(Build.VERSION_CODES.O) public class ContactsNotificationChannelsUtil { public static String DEFAULT_CHANNEL = "DEFAULT_CHANNEL"; private ContactsNotificationChannelsUtil() {} public static void createDefaultChannel(Context context) { if (!BuildCompat.isAtLeastO()) { return; } final NotificationManager nm = context.getSystemService(NotificationManager.class); final NotificationChannel channel = new NotificationChannel(DEFAULT_CHANNEL, context.getString(R.string.contacts_default_notification_channel), NotificationManager.IMPORTANCE_DEFAULT); nm.createNotificationChannel(channel); } }