|
|
@ -1,7 +1,16 @@
|
|
|
|
package com.todoroo.astrid.service;
|
|
|
|
package com.todoroo.astrid.service;
|
|
|
|
|
|
|
|
|
|
|
|
import static com.google.common.base.Strings.isNullOrEmpty;
|
|
|
|
import static com.google.common.base.Strings.isNullOrEmpty;
|
|
|
|
|
|
|
|
import static com.todoroo.andlib.utility.AndroidUtilities.atLeastOreo;
|
|
|
|
|
|
|
|
import static org.tasks.notifications.NotificationManager.NOTIFICATION_CHANNEL_DEFAULT;
|
|
|
|
|
|
|
|
import static org.tasks.notifications.NotificationManager.NOTIFICATION_CHANNEL_MISCELLANEOUS;
|
|
|
|
|
|
|
|
import static org.tasks.notifications.NotificationManager.NOTIFICATION_CHANNEL_TASKER;
|
|
|
|
|
|
|
|
import static org.tasks.notifications.NotificationManager.NOTIFICATION_CHANNEL_TIMERS;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.annotation.TargetApi;
|
|
|
|
|
|
|
|
import android.app.NotificationChannel;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
|
|
|
import android.os.Build;
|
|
|
|
import android.os.Environment;
|
|
|
|
import android.os.Environment;
|
|
|
|
import com.google.common.base.Strings;
|
|
|
|
import com.google.common.base.Strings;
|
|
|
|
import com.google.common.collect.ImmutableList;
|
|
|
|
import com.google.common.collect.ImmutableList;
|
|
|
@ -30,6 +39,7 @@ import org.tasks.data.TaskAttachment;
|
|
|
|
import org.tasks.data.TaskAttachmentDao;
|
|
|
|
import org.tasks.data.TaskAttachmentDao;
|
|
|
|
import org.tasks.data.UserActivity;
|
|
|
|
import org.tasks.data.UserActivity;
|
|
|
|
import org.tasks.data.UserActivityDao;
|
|
|
|
import org.tasks.data.UserActivityDao;
|
|
|
|
|
|
|
|
import org.tasks.injection.ForApplication;
|
|
|
|
import org.tasks.preferences.DefaultFilterProvider;
|
|
|
|
import org.tasks.preferences.DefaultFilterProvider;
|
|
|
|
import org.tasks.preferences.Preferences;
|
|
|
|
import org.tasks.preferences.Preferences;
|
|
|
|
|
|
|
|
|
|
|
@ -41,7 +51,6 @@ public class Upgrader {
|
|
|
|
private static final int V6_0_beta_1 = 522;
|
|
|
|
private static final int V6_0_beta_1 = 522;
|
|
|
|
private static final int V6_0_beta_2 = 523;
|
|
|
|
private static final int V6_0_beta_2 = 523;
|
|
|
|
private static final int V6_4 = 546;
|
|
|
|
private static final int V6_4 = 546;
|
|
|
|
|
|
|
|
|
|
|
|
private final Preferences preferences;
|
|
|
|
private final Preferences preferences;
|
|
|
|
private final Tracker tracker;
|
|
|
|
private final Tracker tracker;
|
|
|
|
private final TagDataDao tagDataDao;
|
|
|
|
private final TagDataDao tagDataDao;
|
|
|
@ -53,9 +62,11 @@ public class Upgrader {
|
|
|
|
private final GoogleTaskListDao googleTaskListDao;
|
|
|
|
private final GoogleTaskListDao googleTaskListDao;
|
|
|
|
private final UserActivityDao userActivityDao;
|
|
|
|
private final UserActivityDao userActivityDao;
|
|
|
|
private final TaskAttachmentDao taskAttachmentDao;
|
|
|
|
private final TaskAttachmentDao taskAttachmentDao;
|
|
|
|
|
|
|
|
private Context context;
|
|
|
|
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
@Inject
|
|
|
|
public Upgrader(
|
|
|
|
public Upgrader(
|
|
|
|
|
|
|
|
@ForApplication Context context,
|
|
|
|
Preferences preferences,
|
|
|
|
Preferences preferences,
|
|
|
|
Tracker tracker,
|
|
|
|
Tracker tracker,
|
|
|
|
TagDataDao tagDataDao,
|
|
|
|
TagDataDao tagDataDao,
|
|
|
@ -67,6 +78,7 @@ public class Upgrader {
|
|
|
|
GoogleTaskListDao googleTaskListDao,
|
|
|
|
GoogleTaskListDao googleTaskListDao,
|
|
|
|
UserActivityDao userActivityDao,
|
|
|
|
UserActivityDao userActivityDao,
|
|
|
|
TaskAttachmentDao taskAttachmentDao) {
|
|
|
|
TaskAttachmentDao taskAttachmentDao) {
|
|
|
|
|
|
|
|
this.context = context;
|
|
|
|
this.preferences = preferences;
|
|
|
|
this.preferences = preferences;
|
|
|
|
this.tracker = tracker;
|
|
|
|
this.tracker = tracker;
|
|
|
|
this.tagDataDao = tagDataDao;
|
|
|
|
this.tagDataDao = tagDataDao;
|
|
|
@ -103,12 +115,47 @@ public class Upgrader {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tracker.reportEvent(Tracking.Events.UPGRADE, Integer.toString(from));
|
|
|
|
tracker.reportEvent(Tracking.Events.UPGRADE, Integer.toString(from));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
createNotificationChannels();
|
|
|
|
preferences.setCurrentVersion(to);
|
|
|
|
preferences.setCurrentVersion(to);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
localBroadcastManager.broadcastRefresh();
|
|
|
|
localBroadcastManager.broadcastRefresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void createNotificationChannels() {
|
|
|
|
|
|
|
|
if (atLeastOreo()) {
|
|
|
|
|
|
|
|
android.app.NotificationManager notificationManager =
|
|
|
|
|
|
|
|
(android.app.NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
|
|
|
|
|
|
notificationManager.createNotificationChannel(
|
|
|
|
|
|
|
|
createNotificationChannel(NOTIFICATION_CHANNEL_DEFAULT, R.string.notifications, true));
|
|
|
|
|
|
|
|
notificationManager.createNotificationChannel(
|
|
|
|
|
|
|
|
createNotificationChannel(NOTIFICATION_CHANNEL_TASKER, R.string.tasker_locale, true));
|
|
|
|
|
|
|
|
notificationManager.createNotificationChannel(
|
|
|
|
|
|
|
|
createNotificationChannel(
|
|
|
|
|
|
|
|
NOTIFICATION_CHANNEL_TIMERS, R.string.TEA_timer_controls, true));
|
|
|
|
|
|
|
|
notificationManager.createNotificationChannel(
|
|
|
|
|
|
|
|
createNotificationChannel(
|
|
|
|
|
|
|
|
NOTIFICATION_CHANNEL_MISCELLANEOUS, R.string.miscellaneous, false));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@TargetApi(Build.VERSION_CODES.O)
|
|
|
|
|
|
|
|
private NotificationChannel createNotificationChannel(
|
|
|
|
|
|
|
|
String channelId, int nameResId, boolean alert) {
|
|
|
|
|
|
|
|
String channelName = context.getString(nameResId);
|
|
|
|
|
|
|
|
int importance =
|
|
|
|
|
|
|
|
alert
|
|
|
|
|
|
|
|
? android.app.NotificationManager.IMPORTANCE_HIGH
|
|
|
|
|
|
|
|
: android.app.NotificationManager.IMPORTANCE_LOW;
|
|
|
|
|
|
|
|
NotificationChannel notificationChannel =
|
|
|
|
|
|
|
|
new NotificationChannel(channelId, channelName, importance);
|
|
|
|
|
|
|
|
notificationChannel.enableLights(alert);
|
|
|
|
|
|
|
|
notificationChannel.enableVibration(alert);
|
|
|
|
|
|
|
|
notificationChannel.setBypassDnd(alert);
|
|
|
|
|
|
|
|
notificationChannel.setShowBadge(alert);
|
|
|
|
|
|
|
|
return notificationChannel;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void performMarshmallowMigration() {
|
|
|
|
private void performMarshmallowMigration() {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// preserve pre-marshmallow default backup location
|
|
|
|
// preserve pre-marshmallow default backup location
|
|
|
|