diff --git a/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt b/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt index 70d91f9a..7cdeb622 100644 --- a/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt +++ b/app/src/main/java/io/github/wulkanowy/WulkanowyApp.kt @@ -1,6 +1,5 @@ package io.github.wulkanowy -import android.annotation.SuppressLint import android.app.Application import android.util.Log.DEBUG import android.util.Log.INFO @@ -40,7 +39,6 @@ class WulkanowyApp : Application(), Configuration.Provider { @Inject lateinit var analyticsHelper: AnalyticsHelper - @SuppressLint("UnsafeOptInUsageWarning") override fun onCreate() { super.onCreate() initializeAppLanguage() diff --git a/app/src/main/java/io/github/wulkanowy/services/alarm/TimetableNotificationReceiver.kt b/app/src/main/java/io/github/wulkanowy/services/alarm/TimetableNotificationReceiver.kt index 2ca5f05b..b388d2ac 100644 --- a/app/src/main/java/io/github/wulkanowy/services/alarm/TimetableNotificationReceiver.kt +++ b/app/src/main/java/io/github/wulkanowy/services/alarm/TimetableNotificationReceiver.kt @@ -138,7 +138,7 @@ class TimetableNotificationReceiver : HiltBroadcastReceiver() { PendingIntent.getActivity( context, NOTIFICATION_ID, - SplashActivity.getStartIntent(context, Destination.Timetable(), true), + SplashActivity.getStartIntent(context, Destination.Timetable()), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntentCompat.FLAG_IMMUTABLE ) ) diff --git a/app/src/main/java/io/github/wulkanowy/services/shortcuts/ShortcutsHelper.kt b/app/src/main/java/io/github/wulkanowy/services/shortcuts/ShortcutsHelper.kt index bb09434b..4ad9ac12 100644 --- a/app/src/main/java/io/github/wulkanowy/services/shortcuts/ShortcutsHelper.kt +++ b/app/src/main/java/io/github/wulkanowy/services/shortcuts/ShortcutsHelper.kt @@ -35,7 +35,7 @@ class ShortcutsHelper @Inject constructor(@ApplicationContext private val contex .setShortLabel(context.getString(R.string.grade_title)) .setLongLabel(context.getString(R.string.grade_title)) .setIcon(IconCompat.createWithResource(context, R.drawable.ic_shortcut_grade)) - .setIntent(SplashActivity.getStartIntent(context, startNewTask = true) + .setIntent(SplashActivity.getStartIntent(context) .apply { action = Intent.ACTION_VIEW putExtra(EXTRA_SHORTCUT_DESTINATION_ID, "grade") @@ -47,7 +47,7 @@ class ShortcutsHelper @Inject constructor(@ApplicationContext private val contex .setShortLabel(context.getString(R.string.attendance_title)) .setLongLabel(context.getString(R.string.attendance_title)) .setIcon(IconCompat.createWithResource(context, R.drawable.ic_shortcut_attendance)) - .setIntent(SplashActivity.getStartIntent(context, startNewTask = true) + .setIntent(SplashActivity.getStartIntent(context) .apply { action = Intent.ACTION_VIEW putExtra(EXTRA_SHORTCUT_DESTINATION_ID, "attendance") @@ -59,7 +59,7 @@ class ShortcutsHelper @Inject constructor(@ApplicationContext private val contex .setShortLabel(context.getString(R.string.exam_title)) .setLongLabel(context.getString(R.string.exam_title)) .setIcon(IconCompat.createWithResource(context, R.drawable.ic_shortcut_exam)) - .setIntent(SplashActivity.getStartIntent(context, startNewTask = true) + .setIntent(SplashActivity.getStartIntent(context) .apply { action = Intent.ACTION_VIEW putExtra(EXTRA_SHORTCUT_DESTINATION_ID, "exam") @@ -71,7 +71,7 @@ class ShortcutsHelper @Inject constructor(@ApplicationContext private val contex .setShortLabel(context.getString(R.string.timetable_title)) .setLongLabel(context.getString(R.string.timetable_title)) .setIcon(IconCompat.createWithResource(context, R.drawable.ic_shortcut_timetable)) - .setIntent(SplashActivity.getStartIntent(context, startNewTask = true) + .setIntent(SplashActivity.getStartIntent(context) .apply { action = Intent.ACTION_VIEW putExtra(EXTRA_SHORTCUT_DESTINATION_ID, "timetable") diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/ChangeTimetableNotification.kt b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/ChangeTimetableNotification.kt index f8860b7f..7bfef96a 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/ChangeTimetableNotification.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/ChangeTimetableNotification.kt @@ -34,8 +34,7 @@ class ChangeTimetableNotification @Inject constructor( content = it, intentToStart = SplashActivity.getStartIntent( context = context, - destination = Destination.Timetable(date), - startNewTask = true + destination = Destination.Timetable(date) ) ) } @@ -54,7 +53,7 @@ class ChangeTimetableNotification @Inject constructor( changedLessons.size, changedLessons.size ), - intentToStart = SplashActivity.getStartIntent(context, Destination.Timetable(), true), + intentToStart = SplashActivity.getStartIntent(context, Destination.Timetable()), type = NotificationType.CHANGE_TIMETABLE ) diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewAttendanceNotification.kt b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewAttendanceNotification.kt index 3792725c..c78dcd05 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewAttendanceNotification.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewAttendanceNotification.kt @@ -31,7 +31,7 @@ class NewAttendanceNotification @Inject constructor( NotificationData( title = context.getPlural(R.plurals.attendance_notify_new_items_title, 1), content = it, - intentToStart = SplashActivity.getStartIntent(context, Destination.Attendance, true) + intentToStart = SplashActivity.getStartIntent(context, Destination.Attendance) ) } @@ -46,7 +46,7 @@ class NewAttendanceNotification @Inject constructor( notificationDataList.size, notificationDataList.size ), - intentToStart = SplashActivity.getStartIntent(context, Destination.Attendance, true), + intentToStart = SplashActivity.getStartIntent(context, Destination.Attendance), type = NotificationType.NEW_ATTENDANCE ) diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewConferenceNotification.kt b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewConferenceNotification.kt index 4ec359b0..8ef14788 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewConferenceNotification.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewConferenceNotification.kt @@ -31,7 +31,7 @@ class NewConferenceNotification @Inject constructor( NotificationData( title = context.getPlural(R.plurals.conference_notify_new_item_title, 1), content = it, - intentToStart = SplashActivity.getStartIntent(context, Destination.Conference, true) + intentToStart = SplashActivity.getStartIntent(context, Destination.Conference) ) } @@ -43,7 +43,7 @@ class NewConferenceNotification @Inject constructor( lines.size, lines.size ), - intentToStart = SplashActivity.getStartIntent(context, Destination.Conference, true), + intentToStart = SplashActivity.getStartIntent(context, Destination.Conference), type = NotificationType.NEW_CONFERENCE ) diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewExamNotification.kt b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewExamNotification.kt index feb7c320..b3cf04c4 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewExamNotification.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewExamNotification.kt @@ -31,7 +31,7 @@ class NewExamNotification @Inject constructor( NotificationData( title = context.getPlural(R.plurals.exam_notify_new_item_title, 1), content = it, - intentToStart = SplashActivity.getStartIntent(context, Destination.Exam, true), + intentToStart = SplashActivity.getStartIntent(context, Destination.Exam), ) } @@ -43,7 +43,7 @@ class NewExamNotification @Inject constructor( lines.size, lines.size ), - intentToStart = SplashActivity.getStartIntent(context, Destination.Exam, true), + intentToStart = SplashActivity.getStartIntent(context, Destination.Exam), type = NotificationType.NEW_EXAM ) diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewGradeNotification.kt b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewGradeNotification.kt index 425a57fc..39ecbe33 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewGradeNotification.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewGradeNotification.kt @@ -23,7 +23,7 @@ class NewGradeNotification @Inject constructor( NotificationData( title = context.getPlural(R.plurals.grade_new_items, 1), content = "${it.subject}: ${it.entry}", - intentToStart = SplashActivity.getStartIntent(context, Destination.Grade, true), + intentToStart = SplashActivity.getStartIntent(context, Destination.Grade), ) } @@ -31,7 +31,7 @@ class NewGradeNotification @Inject constructor( notificationDataList = notificationDataList, title = context.getPlural(R.plurals.grade_new_items, items.size), content = context.getPlural(R.plurals.grade_notify_new_items, items.size, items.size), - intentToStart = SplashActivity.getStartIntent(context, Destination.Grade, true), + intentToStart = SplashActivity.getStartIntent(context, Destination.Grade), type = NotificationType.NEW_GRADE_DETAILS ) @@ -43,7 +43,7 @@ class NewGradeNotification @Inject constructor( NotificationData( title = context.getPlural(R.plurals.grade_new_items_predicted, 1), content = "${it.subject}: ${it.predictedGrade}", - intentToStart = SplashActivity.getStartIntent(context, Destination.Grade, true), + intentToStart = SplashActivity.getStartIntent(context, Destination.Grade), ) } @@ -55,7 +55,7 @@ class NewGradeNotification @Inject constructor( items.size, items.size ), - intentToStart = SplashActivity.getStartIntent(context, Destination.Grade, true), + intentToStart = SplashActivity.getStartIntent(context, Destination.Grade), type = NotificationType.NEW_GRADE_PREDICTED ) @@ -67,7 +67,7 @@ class NewGradeNotification @Inject constructor( NotificationData( title = context.getPlural(R.plurals.grade_new_items_final, 1), content = "${it.subject}: ${it.finalGrade}", - intentToStart = SplashActivity.getStartIntent(context, Destination.Grade, true), + intentToStart = SplashActivity.getStartIntent(context, Destination.Grade), ) } @@ -79,7 +79,7 @@ class NewGradeNotification @Inject constructor( items.size, items.size ), - intentToStart = SplashActivity.getStartIntent(context, Destination.Grade, true), + intentToStart = SplashActivity.getStartIntent(context, Destination.Grade), type = NotificationType.NEW_GRADE_FINAL ) diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewHomeworkNotification.kt b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewHomeworkNotification.kt index fcaed10f..ff32aa66 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewHomeworkNotification.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewHomeworkNotification.kt @@ -31,7 +31,7 @@ class NewHomeworkNotification @Inject constructor( NotificationData( title = context.getPlural(R.plurals.homework_notify_new_item_title, 1), content = it, - intentToStart = SplashActivity.getStartIntent(context, Destination.Homework, true), + intentToStart = SplashActivity.getStartIntent(context, Destination.Homework), ) } @@ -42,7 +42,7 @@ class NewHomeworkNotification @Inject constructor( lines.size, lines.size ), - intentToStart = SplashActivity.getStartIntent(context, Destination.Homework, true), + intentToStart = SplashActivity.getStartIntent(context, Destination.Homework), type = NotificationType.NEW_HOMEWORK, notificationDataList = notificationDataList ) diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewLuckyNumberNotification.kt b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewLuckyNumberNotification.kt index ab2c1ca7..5c36a06c 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewLuckyNumberNotification.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewLuckyNumberNotification.kt @@ -22,7 +22,7 @@ class NewLuckyNumberNotification @Inject constructor( R.string.lucky_number_notify_new_item, item.luckyNumber.toString() ), - intentToStart = SplashActivity.getStartIntent(context, Destination.LuckyNumber, true) + intentToStart = SplashActivity.getStartIntent(context, Destination.LuckyNumber) ) appNotificationManager.sendSingleNotification( diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewMessageNotification.kt b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewMessageNotification.kt index 1a06cf6f..b98d3466 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewMessageNotification.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewMessageNotification.kt @@ -22,7 +22,7 @@ class NewMessageNotification @Inject constructor( NotificationData( title = context.getPlural(R.plurals.message_new_items, 1), content = "${it.sender}: ${it.subject}", - intentToStart = SplashActivity.getStartIntent(context, Destination.Message, true), + intentToStart = SplashActivity.getStartIntent(context, Destination.Message), ) } @@ -30,7 +30,7 @@ class NewMessageNotification @Inject constructor( notificationDataList = notificationDataList, title = context.getPlural(R.plurals.message_new_items, items.size), content = context.getPlural(R.plurals.message_notify_new_items, items.size, items.size), - intentToStart = SplashActivity.getStartIntent(context, Destination.Message, true), + intentToStart = SplashActivity.getStartIntent(context, Destination.Message), type = NotificationType.NEW_MESSAGE ) diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewNoteNotification.kt b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewNoteNotification.kt index 533d7f38..65520e01 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewNoteNotification.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewNoteNotification.kt @@ -29,13 +29,13 @@ class NewNoteNotification @Inject constructor( NotificationData( title = context.getPlural(titleRes, 1), content = "${it.teacher}: ${it.category}", - intentToStart = SplashActivity.getStartIntent(context, Destination.Note, true), + intentToStart = SplashActivity.getStartIntent(context, Destination.Note), ) } val groupNotificationData = GroupNotificationData( notificationDataList = notificationDataList, - intentToStart = SplashActivity.getStartIntent(context, Destination.Note, true), + intentToStart = SplashActivity.getStartIntent(context, Destination.Note), title = context.getPlural(R.plurals.note_new_items, items.size), content = context.getPlural(R.plurals.note_notify_new_items, items.size, items.size), type = NotificationType.NEW_NOTE diff --git a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewSchoolAnnouncementNotification.kt b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewSchoolAnnouncementNotification.kt index 1efe13ae..6b839d29 100644 --- a/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewSchoolAnnouncementNotification.kt +++ b/app/src/main/java/io/github/wulkanowy/services/sync/notifications/NewSchoolAnnouncementNotification.kt @@ -22,8 +22,7 @@ class NewSchoolAnnouncementNotification @Inject constructor( NotificationData( intentToStart = SplashActivity.getStartIntent( context = context, - destination = Destination.SchoolAnnouncement, - startNewTask = true + destination = Destination.SchoolAnnouncement ), title = context.getPlural( R.plurals.school_announcement_notify_new_item_title, @@ -36,8 +35,7 @@ class NewSchoolAnnouncementNotification @Inject constructor( type = NotificationType.NEW_ANNOUNCEMENT, intentToStart = SplashActivity.getStartIntent( context = context, - destination = Destination.SchoolAnnouncement, - startNewTask = true + destination = Destination.SchoolAnnouncement ), title = context.getPlural( R.plurals.school_announcement_notify_new_item_title, diff --git a/app/src/main/java/io/github/wulkanowy/ui/base/BasePresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/base/BasePresenter.kt index 40d54860..5cd5d010 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/base/BasePresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/base/BasePresenter.kt @@ -20,7 +20,7 @@ open class BasePresenter( ) { private val job = SupervisorJob() - protected val presenterScope = CoroutineScope(job + Dispatchers.Main.immediate) + protected val presenterScope = CoroutineScope(job + Dispatchers.Main) private val childrenJobs = mutableMapOf() diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/luckynumberwidget/LuckyNumberWidgetProvider.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/luckynumberwidget/LuckyNumberWidgetProvider.kt index 9ef41068..2b2d18fa 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/luckynumberwidget/LuckyNumberWidgetProvider.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/luckynumberwidget/LuckyNumberWidgetProvider.kt @@ -62,7 +62,7 @@ class LuckyNumberWidgetProvider : AppWidgetProvider() { val appIntent = PendingIntent.getActivity( context, LUCKY_NUMBER_PENDING_INTENT_ID, - SplashActivity.getStartIntent(context, Destination.LuckyNumber, true), + SplashActivity.getStartIntent(context, Destination.LuckyNumber), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntentCompat.FLAG_IMMUTABLE ) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt index d0c3b9a4..d81abe34 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/main/MainActivity.kt @@ -1,6 +1,5 @@ package io.github.wulkanowy.ui.modules.main -import android.annotation.SuppressLint import android.content.Context import android.content.Intent import android.os.Build.VERSION_CODES.P @@ -88,7 +87,6 @@ class MainActivity : BaseActivity(), MainVie private var savedInstanceState: Bundle? = null - @SuppressLint("NewApi") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(ActivityMainBinding.inflate(layoutInflater).apply { binding = this }.root) @@ -97,7 +95,8 @@ class MainActivity : BaseActivity(), MainVie messageContainer = binding.mainMessageContainer updateHelper.messageContainer = binding.mainFragmentContainer - val destination = intent.getSerializableExtra(EXTRA_START_DESTINATION) as Destination? + val destination = (intent.getSerializableExtra(EXTRA_START_DESTINATION) as Destination?) + ?.takeIf { savedInstanceState == null } presenter.onAttachView(this, destination) updateHelper.checkAndInstallUpdates(this) @@ -143,6 +142,7 @@ class MainActivity : BaseActivity(), MainVie initialize(startMenuIndex, savedInstanceState) } + savedInstanceState = null } private fun initializeToolbar() { @@ -292,6 +292,5 @@ class MainActivity : BaseActivity(), MainVie override fun onSaveInstanceState(outState: Bundle) { super.onSaveInstanceState(outState) navController.onSaveInstanceState(outState) - intent.removeExtra(EXTRA_START_DESTINATION) } } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashActivity.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashActivity.kt index b27f06ef..5c152455 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashActivity.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/splash/SplashActivity.kt @@ -33,17 +33,11 @@ class SplashActivity : BaseActivity(), SplashView private const val EXTRA_EXTERNAL_URL = "external_url" - fun getStartIntent( - context: Context, - destination: Destination? = null, - startNewTask: Boolean = false - ) = Intent(context, SplashActivity::class.java).apply { - putExtra(EXTRA_START_DESTINATION, destination) - - if (startNewTask) { + fun getStartIntent(context: Context, destination: Destination? = null) = + Intent(context, SplashActivity::class.java).apply { + putExtra(EXTRA_START_DESTINATION, destination) flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK } - } } override fun onCreate(savedInstanceState: Bundle?) { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/timetablewidget/TimetableWidgetProvider.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/timetablewidget/TimetableWidgetProvider.kt index 2c8c5a67..0f069116 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/timetablewidget/TimetableWidgetProvider.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/timetablewidget/TimetableWidgetProvider.kt @@ -179,7 +179,7 @@ class TimetableWidgetProvider : HiltBroadcastReceiver() { val appIntent = PendingIntent.getActivity( context, TIMETABLE_PENDING_INTENT_ID, - SplashActivity.getStartIntent(context, Destination.Timetable(), true), + SplashActivity.getStartIntent(context, Destination.Timetable()), PendingIntent.FLAG_UPDATE_CURRENT or PendingIntentCompat.FLAG_IMMUTABLE )