adding some Android 12 related preparations

This commit is contained in:
tibbi 2022-04-06 22:56:23 +02:00
parent aa8020b6b0
commit ac2e202f5c
11 changed files with 104 additions and 40 deletions

View file

@ -45,7 +45,9 @@
<activity
android:name=".activities.MainActivity"
android:exported="true"
android:launchMode="singleTask">
<meta-data
android:name="android.app.default_searchable"
android:resource="@xml/searchable" />
@ -83,8 +85,10 @@
<activity
android:name=".activities.WidgetMonthlyConfigureActivity"
android:exported="true"
android:screenOrientation="portrait"
android:theme="@style/MyWidgetConfigTheme">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
</intent-filter>
@ -92,6 +96,7 @@
<activity
android:name=".activities.WidgetListConfigureActivity"
android:exported="true"
android:screenOrientation="portrait"
android:theme="@style/MyWidgetConfigTheme">
<intent-filter>
@ -101,6 +106,7 @@
<activity
android:name=".activities.WidgetDateConfigureActivity"
android:exported="true"
android:screenOrientation="portrait"
android:theme="@style/MyWidgetConfigTheme">
<intent-filter>
@ -110,16 +116,19 @@
<activity
android:name="com.simplemobiletools.commons.activities.AboutActivity"
android:exported="false"
android:label="@string/about"
android:parentActivityName=".activities.MainActivity" />
<activity
android:name="com.simplemobiletools.commons.activities.CustomizationActivity"
android:exported="false"
android:label="@string/customize_colors"
android:parentActivityName=".activities.SettingsActivity" />
<activity
android:name=".activities.EventActivity"
android:exported="true"
android:label="@string/new_event"
android:launchMode="singleTask"
android:parentActivityName=".activities.MainActivity">
@ -143,12 +152,14 @@
<activity
android:name=".activities.TaskActivity"
android:exported="false"
android:label="@string/new_task"
android:launchMode="singleTask"
android:parentActivityName=".activities.MainActivity" />
<activity
android:name=".activities.SelectTimeZoneActivity"
android:exported="false"
android:parentActivityName=".activities.EventActivity">
<meta-data
android:name="android.app.default_searchable"
@ -161,20 +172,30 @@
<activity
android:name=".activities.SettingsActivity"
android:exported="true"
android:label="@string/settings"
android:parentActivityName=".activities.MainActivity" />
android:parentActivityName=".activities.MainActivity">
<intent-filter>
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".activities.ManageEventTypesActivity"
android:exported="false"
android:label="@string/event_types"
android:parentActivityName=".activities.SettingsActivity" />
<activity
android:name=".activities.SnoozeReminderActivity"
android:exported="false"
android:theme="@style/Theme.Transparent" />
<receiver
android:name=".helpers.MyWidgetMonthlyProvider"
android:exported="true"
android:icon="@drawable/img_widget_monthly_preview"
android:label="@string/widget_monthly">
<intent-filter>
@ -188,6 +209,7 @@
<receiver
android:name=".helpers.MyWidgetListProvider"
android:exported="true"
android:icon="@drawable/img_widget_list_preview"
android:label="@string/widget_list">
<intent-filter>
@ -201,6 +223,7 @@
<receiver
android:name=".helpers.MyWidgetDateProvider"
android:exported="true"
android:icon="@drawable/img_widget_date_preview"
android:label="@string/widget_todays_date">
<intent-filter>
@ -214,10 +237,12 @@
<service
android:name=".services.WidgetService"
android:exported="true"
android:permission="android.permission.BIND_REMOTEVIEWS" />
<service
android:name=".services.WidgetServiceEmpty"
android:exported="true"
android:permission="android.permission.BIND_REMOTEVIEWS" />
<service android:name=".services.SnoozeService" />
@ -227,11 +252,18 @@
android:exported="true"
android:permission="android.permission.BIND_JOB_SERVICE" />
<receiver android:name=".receivers.NotificationReceiver" />
<receiver
android:name=".receivers.NotificationReceiver"
android:exported="false" />
<receiver android:name=".receivers.CalDAVSyncReceiver" />
<receiver
android:name=".receivers.CalDAVSyncReceiver"
android:exported="false" />
<receiver
android:name=".receivers.BootCompletedReceiver"
android:exported="true">
<receiver android:name=".receivers.BootCompletedReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
@ -252,6 +284,7 @@
<activity-alias
android:name=".activities.SplashActivity.Red"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_red"
android:roundIcon="@mipmap/ic_launcher_red"
android:targetActivity=".activities.SplashActivity">
@ -265,6 +298,7 @@
<activity-alias
android:name=".activities.SplashActivity.Pink"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_pink"
android:roundIcon="@mipmap/ic_launcher_pink"
android:targetActivity=".activities.SplashActivity">
@ -278,6 +312,7 @@
<activity-alias
android:name=".activities.SplashActivity.Purple"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_purple"
android:roundIcon="@mipmap/ic_launcher_purple"
android:targetActivity=".activities.SplashActivity">
@ -291,6 +326,7 @@
<activity-alias
android:name=".activities.SplashActivity.Deep_purple"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_deep_purple"
android:roundIcon="@mipmap/ic_launcher_deep_purple"
android:targetActivity=".activities.SplashActivity">
@ -304,6 +340,7 @@
<activity-alias
android:name=".activities.SplashActivity.Indigo"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_indigo"
android:roundIcon="@mipmap/ic_launcher_indigo"
android:targetActivity=".activities.SplashActivity">
@ -317,6 +354,7 @@
<activity-alias
android:name=".activities.SplashActivity.Blue"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_blue"
android:roundIcon="@mipmap/ic_launcher_blue"
android:targetActivity=".activities.SplashActivity">
@ -330,6 +368,7 @@
<activity-alias
android:name=".activities.SplashActivity.Light_blue"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_light_blue"
android:roundIcon="@mipmap/ic_launcher_light_blue"
android:targetActivity=".activities.SplashActivity">
@ -343,6 +382,7 @@
<activity-alias
android:name=".activities.SplashActivity.Cyan"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_cyan"
android:roundIcon="@mipmap/ic_launcher_cyan"
android:targetActivity=".activities.SplashActivity">
@ -356,6 +396,7 @@
<activity-alias
android:name=".activities.SplashActivity.Teal"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_teal"
android:roundIcon="@mipmap/ic_launcher_teal"
android:targetActivity=".activities.SplashActivity">
@ -369,6 +410,7 @@
<activity-alias
android:name=".activities.SplashActivity.Green"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_green"
android:roundIcon="@mipmap/ic_launcher_green"
android:targetActivity=".activities.SplashActivity">
@ -382,6 +424,7 @@
<activity-alias
android:name=".activities.SplashActivity.Light_green"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_light_green"
android:roundIcon="@mipmap/ic_launcher_light_green"
android:targetActivity=".activities.SplashActivity">
@ -395,6 +438,7 @@
<activity-alias
android:name=".activities.SplashActivity.Lime"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_lime"
android:roundIcon="@mipmap/ic_launcher_lime"
android:targetActivity=".activities.SplashActivity">
@ -408,6 +452,7 @@
<activity-alias
android:name=".activities.SplashActivity.Yellow"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_yellow"
android:roundIcon="@mipmap/ic_launcher_yellow"
android:targetActivity=".activities.SplashActivity">
@ -421,6 +466,7 @@
<activity-alias
android:name=".activities.SplashActivity.Amber"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_amber"
android:roundIcon="@mipmap/ic_launcher_amber"
android:targetActivity=".activities.SplashActivity">
@ -434,6 +480,7 @@
<activity-alias
android:name=".activities.SplashActivity.Orange"
android:enabled="true"
android:exported="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher"
android:targetActivity=".activities.SplashActivity">
@ -446,6 +493,7 @@
<activity-alias
android:name=".activities.SplashActivity.Deep_orange"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_deep_orange"
android:roundIcon="@mipmap/ic_launcher_deep_orange"
android:targetActivity=".activities.SplashActivity">
@ -459,6 +507,7 @@
<activity-alias
android:name=".activities.SplashActivity.Brown"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_brown"
android:roundIcon="@mipmap/ic_launcher_brown"
android:targetActivity=".activities.SplashActivity">
@ -472,6 +521,7 @@
<activity-alias
android:name=".activities.SplashActivity.Blue_grey"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_blue_grey"
android:roundIcon="@mipmap/ic_launcher_blue_grey"
android:targetActivity=".activities.SplashActivity">
@ -485,6 +535,7 @@
<activity-alias
android:name=".activities.SplashActivity.Grey_black"
android:enabled="false"
android:exported="true"
android:icon="@mipmap/ic_launcher_grey_black"
android:roundIcon="@mipmap/ic_launcher_grey_black"
android:targetActivity=".activities.SplashActivity">

View file

@ -174,12 +174,12 @@ fun Context.getNotificationIntent(event: Event): PendingIntent {
val intent = Intent(this, NotificationReceiver::class.java)
intent.putExtra(EVENT_ID, event.id)
intent.putExtra(EVENT_OCCURRENCE_TS, event.startTS)
return PendingIntent.getBroadcast(this, event.id!!.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT)
return PendingIntent.getBroadcast(this, event.id!!.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
}
fun Context.cancelPendingIntent(id: Long) {
val intent = Intent(this, NotificationReceiver::class.java)
PendingIntent.getBroadcast(this, id.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT).cancel()
PendingIntent.getBroadcast(this, id.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE).cancel()
}
fun Context.getRepetitionText(seconds: Int) = when (seconds) {
@ -340,7 +340,7 @@ private fun getPendingIntent(context: Context, event: Event): PendingIntent {
val intent = Intent(context, EventActivity::class.java)
intent.putExtra(EVENT_ID, event.id)
intent.putExtra(EVENT_OCCURRENCE_TS, event.startTS)
return PendingIntent.getActivity(context, event.id!!.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT)
return PendingIntent.getActivity(context, event.id!!.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
}
private fun getSnoozePendingIntent(context: Context, event: Event): PendingIntent {
@ -348,9 +348,9 @@ private fun getSnoozePendingIntent(context: Context, event: Event): PendingInten
val intent = Intent(context, snoozeClass).setAction("Snooze")
intent.putExtra(EVENT_ID, event.id)
return if (context.config.useSameSnooze) {
PendingIntent.getService(context, event.id!!.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT)
PendingIntent.getService(context, event.id!!.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
} else {
PendingIntent.getActivity(context, event.id!!.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT)
PendingIntent.getActivity(context, event.id!!.toInt(), intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
}
}
@ -421,7 +421,12 @@ fun Context.recheckCalDAVCalendars(scheduleNextCalDAVSync: Boolean, callback: ()
fun Context.scheduleCalDAVSync(activate: Boolean) {
val syncIntent = Intent(applicationContext, CalDAVSyncReceiver::class.java)
val pendingIntent = PendingIntent.getBroadcast(applicationContext, SCHEDULE_CALDAV_REQUEST_CODE, syncIntent, PendingIntent.FLAG_UPDATE_CURRENT)
val pendingIntent = PendingIntent.getBroadcast(
applicationContext,
SCHEDULE_CALDAV_REQUEST_CODE,
syncIntent,
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
val alarm = getSystemService(Context.ALARM_SERVICE) as AlarmManager
alarm.cancel(pendingIntent)

View file

@ -39,7 +39,7 @@ class MyWidgetDateProvider : AppWidgetProvider() {
private fun setupAppOpenIntent(context: Context, views: RemoteViews) {
(context.getLaunchIntent() ?: Intent(context, SplashActivity::class.java)).apply {
val pendingIntent = PendingIntent.getActivity(context, OPEN_APP_INTENT_ID, this, PendingIntent.FLAG_UPDATE_CURRENT)
val pendingIntent = PendingIntent.getActivity(context, OPEN_APP_INTENT_ID, this, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
views.setOnClickPendingIntent(R.id.widget_date_holder, pendingIntent)
}
}

View file

@ -63,7 +63,8 @@ class MyWidgetListProvider : AppWidgetProvider() {
}
val startActivityIntent = context.getLaunchIntent() ?: Intent(context, SplashActivity::class.java)
val startActivityPendingIntent = PendingIntent.getActivity(context, 0, startActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT)
val startActivityPendingIntent =
PendingIntent.getActivity(context, 0, startActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
views.setPendingIntentTemplate(R.id.widget_event_list, startActivityPendingIntent)
views.setEmptyView(R.id.widget_event_list, R.id.widget_event_list_empty)
@ -78,7 +79,7 @@ class MyWidgetListProvider : AppWidgetProvider() {
private fun setupIntent(context: Context, views: RemoteViews, action: String, id: Int) {
Intent(context, MyWidgetListProvider::class.java).apply {
this.action = action
val pendingIntent = PendingIntent.getBroadcast(context, 0, this, 0)
val pendingIntent = PendingIntent.getBroadcast(context, 0, this, PendingIntent.FLAG_IMMUTABLE)
views.setOnClickPendingIntent(id, pendingIntent)
}
}

View file

@ -45,7 +45,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() {
private fun setupIntent(context: Context, views: RemoteViews, action: String, id: Int) {
Intent(context, MyWidgetMonthlyProvider::class.java).apply {
this.action = action
val pendingIntent = PendingIntent.getBroadcast(context, 0, this, 0)
val pendingIntent = PendingIntent.getBroadcast(context, 0, this, PendingIntent.FLAG_IMMUTABLE)
views.setOnClickPendingIntent(id, pendingIntent)
}
}
@ -54,7 +54,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() {
(context.getLaunchIntent() ?: Intent(context, SplashActivity::class.java)).apply {
putExtra(DAY_CODE, dayCode)
putExtra(VIEW_TO_OPEN, MONTHLY_VIEW)
val pendingIntent = PendingIntent.getActivity(context, Integer.parseInt(dayCode.substring(0, 6)), this, 0)
val pendingIntent = PendingIntent.getActivity(context, Integer.parseInt(dayCode.substring(0, 6)), this, PendingIntent.FLAG_IMMUTABLE)
views.setOnClickPendingIntent(id, pendingIntent)
}
}
@ -63,7 +63,7 @@ class MyWidgetMonthlyProvider : AppWidgetProvider() {
(context.getLaunchIntent() ?: Intent(context, SplashActivity::class.java)).apply {
putExtra(DAY_CODE, dayCode)
putExtra(VIEW_TO_OPEN, DAILY_VIEW)
val pendingIntent = PendingIntent.getActivity(context, Integer.parseInt(dayCode), this, 0)
val pendingIntent = PendingIntent.getActivity(context, Integer.parseInt(dayCode), this, PendingIntent.FLAG_IMMUTABLE)
views.setOnClickPendingIntent(id, pendingIntent)
}
}

View file

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/cab_share"
android:icon="@drawable/ic_share_vector"
android:title="@string/share"
app:showAsAction="ifRoom"/>
app:showAsAction="ifRoom" />
<item
android:id="@+id/cab_delete"
android:icon="@drawable/ic_delete_vector"
android:title="@string/delete"
app:showAsAction="ifRoom"/>
app:showAsAction="ifRoom" />
</menu>

View file

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/cab_share"
android:icon="@drawable/ic_share_vector"
android:title="@string/share"
app:showAsAction="ifRoom"/>
app:showAsAction="ifRoom" />
<item
android:id="@+id/cab_delete"
android:icon="@drawable/ic_delete_vector"
android:title="@string/delete"
app:showAsAction="ifRoom"/>
app:showAsAction="ifRoom" />
</menu>

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/cab_delete"
android:icon="@drawable/ic_delete_vector"
android:title="@string/delete"
app:showAsAction="ifRoom"/>
app:showAsAction="ifRoom" />
</menu>

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/add_event_type"
android:icon="@drawable/ic_plus_vector"
android:title="@string/add_new_type"
app:showAsAction="ifRoom"/>
app:showAsAction="ifRoom" />
</menu>

View file

@ -1,60 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/search"
android:icon="@drawable/ic_search_vector"
android:title="@string/search"
app:actionViewClass="androidx.appcompat.widget.SearchView"
app:showAsAction="collapseActionView|always"/>
app:showAsAction="collapseActionView|always" />
<item
android:id="@+id/go_to_today"
android:icon="@drawable/ic_today_vector"
android:title="@string/go_to_today"
app:showAsAction="always"/>
app:showAsAction="always" />
<item
android:id="@+id/change_view"
android:icon="@drawable/ic_change_view_vector"
android:title="@string/change_view"
app:showAsAction="always"/>
app:showAsAction="always" />
<item
android:id="@+id/filter"
android:icon="@drawable/ic_filter_vector"
android:title="@string/filter_events_by_type"
app:showAsAction="ifRoom"/>
app:showAsAction="ifRoom" />
<item
android:id="@+id/refresh_caldav_calendars"
android:icon="@drawable/ic_repeat_vector"
android:title="@string/refresh_caldav_calendars"
app:showAsAction="ifRoom"/>
app:showAsAction="ifRoom" />
<item
android:id="@+id/go_to_date"
android:showAsAction="never"
android:title="@string/go_to_date"
app:showAsAction="never"/>
app:showAsAction="never" />
<item
android:id="@+id/print"
android:showAsAction="never"
android:title="@string/print"
app:showAsAction="never"/>
app:showAsAction="never" />
<item
android:id="@+id/add_holidays"
android:showAsAction="never"
android:title="@string/add_holidays"
app:showAsAction="never"/>
app:showAsAction="never" />
<item
android:id="@+id/add_birthdays"
android:showAsAction="never"
android:title="@string/add_birthdays"
app:showAsAction="never"/>
app:showAsAction="never" />
<item
android:id="@+id/add_anniversaries"
android:showAsAction="never"
android:title="@string/add_anniversaries"
app:showAsAction="never"/>
app:showAsAction="never" />
<item
android:id="@+id/import_events"
android:showAsAction="never"
android:title="@string/import_events_from_ics"
app:showAsAction="never"/>
app:showAsAction="never" />
<item
android:id="@+id/export_events"
android:showAsAction="never"
android:title="@string/export_events_to_ics"
app:showAsAction="never"/>
app:showAsAction="never" />
<item
android:id="@+id/settings"
android:icon="@drawable/ic_settings_cog_vector"

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/search"
android:icon="@drawable/ic_search_vector"