Commit 1cefa88b authored by Ricki Hirner's avatar Ricki Hirner

Notifications: fix crashes (for Android 4.4 and when wrong CardDAV password occurs)

parent be4a650d
......@@ -63,7 +63,8 @@
<activity
android:name=".ui.AppSettingsActivity"
android:label="@string/app_settings"
android:parentActivityName=".ui.AccountsActivity"/>
android:parentActivityName=".ui.AccountsActivity"
android:exported="true"/>
<activity
android:name=".ui.setup.LoginActivity"
......
......@@ -84,6 +84,7 @@ object Logger : SharedPreferences.OnSharedPreferenceChangeListener {
val prefIntent = Intent(context, AppSettingsActivity::class.java)
prefIntent.putExtra(AppSettingsActivity.EXTRA_SCROLL_TO, LOG_TO_FILE)
prefIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
builder .setContentText(logDir.path)
.setCategory(NotificationCompat.CATEGORY_STATUS)
......@@ -100,10 +101,11 @@ object Logger : SharedPreferences.OnSharedPreferenceChangeListener {
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "DAVx⁵ logs")
shareIntent.putExtra(Intent.EXTRA_STREAM, logFileUri)
shareIntent.type = "text/plain"
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
val shareAction = NotificationCompat.Action.Builder(R.drawable.ic_share_action,
context.getString(R.string.logging_notification_share_log),
PendingIntent.getActivity(context, 0, shareIntent, PendingIntent.FLAG_UPDATE_CURRENT))
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_ACTIVITY_NEW_TASK)
val chooserIntent = Intent.createChooser(shareIntent, null)
val shareAction = NotificationCompat.Action.Builder(R.drawable.ic_share_action_notification,
context.getString(R.string.logging_notification_send_log),
PendingIntent.getActivity(context, 0, chooserIntent, PendingIntent.FLAG_UPDATE_CURRENT))
builder.addAction(shareAction.build())
} catch(e: IOException) {
log.log(Level.SEVERE, "Couldn't create log file", e)
......
......@@ -653,7 +653,11 @@ abstract class SyncManager<ResourceType: LocalResource<*>, out CollectionType: L
var viewItemAction: NotificationCompat.Action? = null
if (e is UnauthorizedException) {
contentIntent = Intent(context, AccountSettingsActivity::class.java)
contentIntent.putExtra(AccountSettingsActivity.EXTRA_ACCOUNT, account)
contentIntent.putExtra(AccountSettingsActivity.EXTRA_ACCOUNT,
if (authority == ContactsContract.AUTHORITY)
mainAccount
else
account)
} else {
contentIntent = Intent(context, DebugInfoActivity::class.java)
contentIntent.putExtra(DebugInfoActivity.KEY_THROWABLE, e)
......
......@@ -17,7 +17,6 @@ import androidx.preference.SwitchPreferenceCompat
import at.bitfire.cert4android.CustomCertManager
import at.bitfire.davdroid.BuildConfig
import at.bitfire.davdroid.R
import at.bitfire.davdroid.log.Logger
import at.bitfire.davdroid.settings.Settings
import com.google.android.material.snackbar.Snackbar
import java.net.URI
......@@ -68,7 +67,9 @@ class AppSettingsActivity: AppCompatActivity() {
false
}
arguments?.getString(EXTRA_SCROLL_TO)?.let { scrollToPreference(it) }
arguments?.getString(EXTRA_SCROLL_TO)?.let { key ->
scrollToPreference(key)
}
}
private fun loadSettings() {
......
......@@ -95,15 +95,14 @@ class DebugInfoActivity: AppCompatActivity(), LoaderManager.LoaderCallbacks<Stri
writer.close()
builder.setStream(FileProvider.getUriForFile(this, getString(R.string.authority_debug_provider), reportFile))
builder.intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_ACTIVITY_NEW_TASK)
} catch(e: IOException) {
// creating an attachment failed, so send it inline
val text = "Couldn't create debug info file: " + Log.getStackTraceString(e) + "\n\n$it"
builder.setText(text)
}
val sendIntent = builder.intent
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
startActivity(Intent.createChooser(sendIntent, null))
builder.startChooser()
}
}
......
......@@ -60,7 +60,7 @@
<string name="logging_couldnt_create_file">Couldn\'t create log file</string>
<string name="logging_notification_title">DAVx⁵ logging</string>
<string name="logging_notification_text">Now logging all DAVx⁵ activities</string>
<string name="logging_notification_share_log">Share log</string>
<string name="logging_notification_send_log">Send log</string>
<!-- AccountsActivity -->
<string name="navigation_drawer_open">Open navigation drawer</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment