remove unneeded notification channel

This commit is contained in:
Conny Duck 2018-05-08 22:35:25 +02:00
parent 2dcbce3fbc
commit 33c59cf578
2 changed files with 9 additions and 5 deletions

View File

@ -33,8 +33,8 @@ class SplashActivity : AppCompatActivity(), Injectable {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
/** delete old notification channels that were in use in Tusky 1.4 */
NotificationHelper.deleteLegacyNotificationChannels(this)
/** delete old notification channels */
NotificationHelper.deleteLegacyNotificationChannels(this, accountManager)
/** Determine whether the user is currently logged in, and if so go ahead and load the
* timeline. Otherwise, start the activity_login screen. */

View File

@ -37,7 +37,6 @@ import android.util.Log;
import com.keylesspalace.tusky.MainActivity;
import com.keylesspalace.tusky.R;
import com.keylesspalace.tusky.TuskyApplication;
import com.keylesspalace.tusky.ViewThreadActivity;
import com.keylesspalace.tusky.db.AccountEntity;
import com.keylesspalace.tusky.db.AccountManager;
import com.keylesspalace.tusky.entity.Notification;
@ -371,17 +370,22 @@ public class NotificationHelper {
}
}
public static void deleteLegacyNotificationChannels(Context context) {
// delete the notification channels that where used before the multi account mode was introduced to avoid confusion
public static void deleteLegacyNotificationChannels(Context context, AccountManager accountManager) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
// used until Tusky 1.4
//noinspection ConstantConditions
notificationManager.deleteNotificationChannel(CHANNEL_MENTION);
notificationManager.deleteNotificationChannel(CHANNEL_FAVOURITE);
notificationManager.deleteNotificationChannel(CHANNEL_BOOST);
notificationManager.deleteNotificationChannel(CHANNEL_FOLLOW);
// used until Tusky 1.7
for(AccountEntity account: accountManager.getAllAccountsOrderedByActive()) {
notificationManager.deleteNotificationChannel(CHANNEL_FAVOURITE+" "+account.getIdentifier());
}
}
}