Commit 7d78ab9b authored by Ricki Hirner's avatar Ricki Hirner

Version bump to 1.5.3; notification improvements; Android 8 compatibility

parent c9cd4ed5
Pipeline #14435598 passed with stage
in 1 minute and 1 second
......@@ -19,8 +19,8 @@ android {
minSdkVersion 19
targetSdkVersion 27
versionCode 16
versionName "1.5.2"
versionCode 17
versionName "1.5.3"
}
buildTypes {
release {
......
......@@ -15,7 +15,6 @@ import android.content.*
import android.content.pm.PackageManager
import android.os.Bundle
import android.support.v4.app.NotificationCompat
import android.support.v4.app.NotificationManagerCompat
import android.support.v4.content.ContextCompat
import android.util.Base64
import android.util.Log
......@@ -26,6 +25,7 @@ import at.bitfire.icsdroid.db.CalendarCredentials
import at.bitfire.icsdroid.db.LocalCalendar
import at.bitfire.icsdroid.db.LocalEvent
import at.bitfire.icsdroid.ui.CalendarListActivity
import at.bitfire.icsdroid.ui.NotificationUtils
import java.io.IOException
import java.io.InputStreamReader
import java.net.HttpURLConnection
......@@ -71,9 +71,9 @@ class SyncAdapter(
}
override fun onSecurityException(account: Account?, extras: Bundle?, authority: String?, syncResult: SyncResult?) {
val nm = NotificationManagerCompat.from(context)
val notification = NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.ic_perm_settings_white)
val nm = NotificationUtils.createChannels(context)
val notification = NotificationCompat.Builder(context, NotificationUtils.CHANNEL_SYNC)
.setSmallIcon(R.drawable.ic_sync_problem_white)
.setContentTitle(context.getString(R.string.sync_permission_required))
.setContentText(context.getString(R.string.sync_permission_required_sync_calendar))
.setCategory(NotificationCompat.CATEGORY_ERROR)
......@@ -115,6 +115,10 @@ class SyncAdapter(
return
}
// dismiss old notifications
val notificationManager = NotificationUtils.createChannels(context)
notificationManager.cancel(calendar.id.toString(), 0)
var conn: URLConnection? = null
var certManager: CustomCertManager? = null
......@@ -215,13 +219,13 @@ class SyncAdapter(
} catch(e: IOException) {
Log.e(Constants.TAG, "Couldn't read calendar", e)
errorMessage = e.localizedMessage
errorMessage = errorMessage ?: e.localizedMessage
synchronized(syncResult) {
syncResult.stats.numIoExceptions++
}
} catch(e: Exception) {
Log.e(Constants.TAG, "Couldn't process calendar", e)
errorMessage = e.localizedMessage
errorMessage = errorMessage ?: e.localizedMessage
synchronized(syncResult) {
syncResult.stats.numParseExceptions++
}
......@@ -233,9 +237,8 @@ class SyncAdapter(
}
errorMessage?.let { msg ->
val nm = NotificationManagerCompat.from(context)
val notification = NotificationCompat.Builder(context)
.setSmallIcon(R.mipmap.ic_launcher)
val notification = NotificationCompat.Builder(context, NotificationUtils.CHANNEL_SYNC)
.setSmallIcon(R.drawable.ic_sync_problem_white)
.setCategory(NotificationCompat.CATEGORY_ERROR)
.setGroup("ICSdroid")
.setContentTitle(context.getString(R.string.sync_error_title))
......@@ -246,7 +249,7 @@ class SyncAdapter(
.setWhen(System.currentTimeMillis())
.setOnlyAlertOnce(true)
calendar.color?.let { notification.color = it }
nm.notify(0, notification.build())
notificationManager.notify(calendar.id.toString(), 0, notification.build())
calendar.updateStatusError(msg)
}
......
/*
* Copyright (c) Ricki Hirner (bitfire web engineering).
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*/
package at.bitfire.icsdroid.ui
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.os.Build
import at.bitfire.icsdroid.R
object NotificationUtils {
val CHANNEL_SYNC = "sync"
fun createChannels(context: Context): NotificationManager {
val nm = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
if (Build.VERSION.SDK_INT >= 26) {
nm.createNotificationChannel(NotificationChannel(CHANNEL_SYNC,
context.getString(R.string.notification_channel_sync_problem), NotificationManager.IMPORTANCE_LOW))
}
return nm
}
}
\ No newline at end of file
......@@ -13,5 +13,5 @@
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M18.99,11.5c0.34,0 0.67,0.03 1,0.07L20,0 0,20h11.56c-0.04,-0.33 -0.07,-0.66 -0.07,-1 0,-4.14 3.36,-7.5 7.5,-7.5zM22.7,19.49c0.02,-0.16 0.04,-0.32 0.04,-0.49 0,-0.17 -0.01,-0.33 -0.04,-0.49l1.06,-0.83c0.09,-0.08 0.12,-0.21 0.06,-0.32l-1,-1.73c-0.06,-0.11 -0.19,-0.15 -0.31,-0.11l-1.24,0.5c-0.26,-0.2 -0.54,-0.37 -0.85,-0.49l-0.19,-1.32c-0.01,-0.12 -0.12,-0.21 -0.24,-0.21h-2c-0.12,0 -0.23,0.09 -0.25,0.21l-0.19,1.32c-0.3,0.13 -0.59,0.29 -0.85,0.49l-1.24,-0.5c-0.11,-0.04 -0.24,0 -0.31,0.11l-1,1.73c-0.06,0.11 -0.04,0.24 0.06,0.32l1.06,0.83c-0.02,0.16 -0.03,0.32 -0.03,0.49 0,0.17 0.01,0.33 0.03,0.49l-1.06,0.83c-0.09,0.08 -0.12,0.21 -0.06,0.32l1,1.73c0.06,0.11 0.19,0.15 0.31,0.11l1.24,-0.5c0.26,0.2 0.54,0.37 0.85,0.49l0.19,1.32c0.02,0.12 0.12,0.21 0.25,0.21h2c0.12,0 0.23,-0.09 0.25,-0.21l0.19,-1.32c0.3,-0.13 0.59,-0.29 0.84,-0.49l1.25,0.5c0.11,0.04 0.24,0 0.31,-0.11l1,-1.73c0.06,-0.11 0.03,-0.24 -0.06,-0.32l-1.07,-0.83zM18.99,20.5c-0.83,0 -1.5,-0.67 -1.5,-1.5s0.67,-1.5 1.5,-1.5 1.5,0.67 1.5,1.5 -0.67,1.5 -1.5,1.5z"/>
android:pathData="M3,12c0,2.21 0.91,4.2 2.36,5.64L3,20h6v-6l-2.24,2.24C5.68,15.15 5,13.66 5,12c0,-2.61 1.67,-4.83 4,-5.65L9,4.26C5.55,5.15 3,8.27 3,12zM11,17h2v-2h-2v2zM21,4h-6v6l2.24,-2.24C18.32,8.85 19,10.34 19,12c0,2.61 -1.67,4.83 -4,5.65v2.09c3.45,-0.89 6,-4.01 6,-7.74 0,-2.21 -0.91,-4.2 -2.36,-5.64L21,4zM11,13h2L13,7h-2v6z"/>
</vector>
<?xml version='1.0' encoding='UTF-8'?>
<resources>
<string name="app_name">ICSdroid</string>
<string name="notification_channel_sync_problem">Sync-Probleme</string>
<string name="action_next">Weiter</string>
<string name="calendar_list_empty_info">Noch kein Webcal-Abo! Mit + oder durch Öffnen eines Webcal-fähigen URLs hinzufügen.</string>
<string name="calendar_list_info">Über ICSdroid</string>
......
......@@ -13,6 +13,7 @@
<resources>
<string name="app_name">ICSdroid</string>
<string name="notification_channel_sync_problem">Sync problems</string>
<string name="action_next">Next</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