diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c7278a60..08782a1ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +### 1.7.11 (Aug 10, 2019) + +* Fix bug that produced corrupted CSV files in some countries + +### 1.7.10 (June 15, 2019) + +* Fix bug that prevented some devices from showing notifications. +* Update targetSdk to Android Pie (API level 28) + ### 1.7.8 (April 21, 2018) * Add support for adaptive icons (Oreo) diff --git a/android/gradle.properties b/android/gradle.properties index d559eb682..49afd37ce 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ -VERSION_CODE = 35 -VERSION_NAME = 1.7.8 +VERSION_CODE = 39 +VERSION_NAME = 1.8.0 MIN_SDK_VERSION = 19 TARGET_SDK_VERSION = 29 diff --git a/android/uhabits-android/src/main/AndroidManifest.xml b/android/uhabits-android/src/main/AndroidManifest.xml index 87472fbb4..2f371d686 100644 --- a/android/uhabits-android/src/main/AndroidManifest.xml +++ b/android/uhabits-android/src/main/AndroidManifest.xml @@ -19,9 +19,7 @@ --> + xmlns:android="http://schemas.android.com/apk/res/android"> diff --git a/android/uhabits-android/src/main/java/org/isoron/uhabits/notifications/AndroidNotificationTray.kt b/android/uhabits-android/src/main/java/org/isoron/uhabits/notifications/AndroidNotificationTray.kt index 468fa678c..c588acddd 100644 --- a/android/uhabits-android/src/main/java/org/isoron/uhabits/notifications/AndroidNotificationTray.kt +++ b/android/uhabits-android/src/main/java/org/isoron/uhabits/notifications/AndroidNotificationTray.kt @@ -28,6 +28,7 @@ import android.os.Build.VERSION.* import android.support.annotation.* import android.support.v4.app.* import android.support.v4.app.NotificationCompat.* +import android.util.* import org.isoron.androidbase.* import org.isoron.uhabits.R import org.isoron.uhabits.core.* @@ -71,14 +72,23 @@ class AndroidNotificationTray notificationManager.notify(Int.MAX_VALUE, summary) val notification = buildNotification(habit, reminderTime, timestamp) createAndroidNotificationChannel(context) - notificationManager.notify(notificationId, notification) + try { + notificationManager.notify(notificationId, notification) + } catch (e: RuntimeException) { + // Some Xiaomi phones produce a RuntimeException if custom notification sounds are used. + Log.i("AndroidNotificationTray", "Failed to show notification. Retrying without sound.") + val n = buildNotification(habit, reminderTime, timestamp, disableSound = true) + notificationManager.notify(notificationId, n) + + } active.add(notificationId) } @NonNull fun buildNotification(@NonNull habit: Habit, @NonNull reminderTime: Long, - @NonNull timestamp: Timestamp) : Notification + @NonNull timestamp: Timestamp, + disableSound: Boolean = false) : Notification { val addRepetitionAction = Action( @@ -109,12 +119,15 @@ class AndroidNotificationTray .setDeleteIntent(pendingIntents.dismissNotification(habit)) .addAction(addRepetitionAction) .addAction(removeRepetitionAction) - .setSound(ringtoneManager.getURI()) + .setSound(null) .setWhen(reminderTime) .setShowWhen(true) .setOngoing(preferences.shouldMakeNotificationsSticky()) .setGroup("default") + if (!disableSound) + builder.setSound(ringtoneManager.getURI()) + if (preferences.shouldMakeNotificationsLed()) builder.setLights(Color.RED, 1000, 1000) diff --git a/android/uhabits-core/src/main/java/org/isoron/uhabits/core/io/HabitsCSVExporter.java b/android/uhabits-core/src/main/java/org/isoron/uhabits/core/io/HabitsCSVExporter.java index e8a8f3769..cebf85b21 100644 --- a/android/uhabits-core/src/main/java/org/isoron/uhabits/core/io/HabitsCSVExporter.java +++ b/android/uhabits-core/src/main/java/org/isoron/uhabits/core/io/HabitsCSVExporter.java @@ -119,7 +119,7 @@ public class HabitsCSVExporter { String sane = sanitizeFilename(h.getName()); String habitDirName = - String.format("%03d %s", allHabits.indexOf(h) + 1, sane); + String.format(Locale.US, "%03d %s", allHabits.indexOf(h) + 1, sane); habitDirName = habitDirName.trim() + "/"; new File(exportDirName + habitDirName).mkdirs(); @@ -202,7 +202,7 @@ public class HabitsCSVExporter checksWriter.write(String.valueOf(checkmarks.get(j)[i])); checksWriter.write(DELIMITER); String score = - String.format("%.4f", ((float) scores.get(j)[i])); + String.format(Locale.US, "%.4f", ((float) scores.get(j)[i])); scoresWriter.write(score); scoresWriter.write(DELIMITER); } diff --git a/android/uhabits-core/src/main/java/org/isoron/uhabits/core/models/ScoreList.java b/android/uhabits-core/src/main/java/org/isoron/uhabits/core/models/ScoreList.java index b3ba68370..49c1c36fb 100644 --- a/android/uhabits-core/src/main/java/org/isoron/uhabits/core/models/ScoreList.java +++ b/android/uhabits-core/src/main/java/org/isoron/uhabits/core/models/ScoreList.java @@ -172,7 +172,7 @@ public abstract class ScoreList implements Iterable for (Score s : this) { String timestamp = dateFormat.format(s.getTimestamp().getUnixTime()); - String score = String.format((Locale)null, "%.4f", s.getValue()); + String score = String.format(Locale.US, "%.4f", s.getValue()); out.write(String.format("%s,%s\n", timestamp, score)); } }