Browse Source

Add an extension function to limit the number of characters in a string. Dependency updates

len 8 years ago
parent
commit
59c626b4a8

+ 3 - 3
app/build.gradle

@@ -114,7 +114,7 @@ dependencies {
     compile 'com.android.support:multidex:1.0.1'
 
     // Job scheduling
-    compile 'com.evernote:android-job:1.1.2'
+    compile 'com.evernote:android-job:1.1.3'
     compile 'com.google.android.gms:play-services-gcm:9.8.0'
 
     // ReactiveX
@@ -140,7 +140,7 @@ dependencies {
     compile 'com.github.bmoliveira:snake-yaml:v1.18-android'
 
     // JavaScript engine
-    compile 'com.squareup.duktape:duktape-android:1.0.0'
+    compile 'com.squareup.duktape:duktape-android:1.1.0'
 
     // Disk cache
     compile 'com.jakewharton:disklrucache:2.0.2'
@@ -200,7 +200,7 @@ dependencies {
 }
 
 buildscript {
-    ext.kotlin_version = '1.0.5'
+    ext.kotlin_version = '1.0.5-2'
     repositories {
         mavenCentral()
     }

+ 6 - 9
app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt

@@ -20,10 +20,7 @@ import eu.kanade.tachiyomi.data.preference.getOrDefault
 import eu.kanade.tachiyomi.data.source.SourceManager
 import eu.kanade.tachiyomi.data.source.online.OnlineSource
 import eu.kanade.tachiyomi.ui.main.MainActivity
-import eu.kanade.tachiyomi.util.AndroidComponentUtil
-import eu.kanade.tachiyomi.util.notification
-import eu.kanade.tachiyomi.util.notificationManager
-import eu.kanade.tachiyomi.util.syncChaptersWithSource
+import eu.kanade.tachiyomi.util.*
 import rx.Observable
 import rx.Subscription
 import rx.schedulers.Schedulers
@@ -330,7 +327,7 @@ class LibraryUpdateService : Service() {
                 append(getString(R.string.notification_new_chapters))
                 for (manga in updates) {
                     append("\n")
-                    append(manga.title)
+                    append(manga.title.chop(30))
                 }
             }
             if (!failedUpdates.isEmpty()) {
@@ -338,7 +335,7 @@ class LibraryUpdateService : Service() {
                 append(getString(R.string.notification_manga_update_failed))
                 for (manga in failedUpdates) {
                     append("\n")
-                    append(manga.title)
+                    append(manga.title.chop(30))
                 }
             }
             toString()
@@ -370,7 +367,7 @@ class LibraryUpdateService : Service() {
      * @param body the body of the notification.
      */
     private fun showNotification(title: String, body: String) {
-        notificationManager.notify(notificationId, notification() {
+        notificationManager.notify(notificationId, notification {
             setSmallIcon(R.drawable.ic_refresh_white_24dp_img)
             setLargeIcon(notificationBitmap)
             setContentTitle(title)
@@ -386,7 +383,7 @@ class LibraryUpdateService : Service() {
      * @param total the total progress.
      */
     private fun showProgressNotification(manga: Manga, current: Int, total: Int, cancelIntent: PendingIntent) {
-        notificationManager.notify(notificationId, notification() {
+        notificationManager.notify(notificationId, notification {
             setSmallIcon(R.drawable.ic_refresh_white_24dp_img)
             setLargeIcon(notificationBitmap)
             setContentTitle(manga.title)
@@ -407,7 +404,7 @@ class LibraryUpdateService : Service() {
         val title = getString(R.string.notification_update_completed)
         val body = getUpdatedMangasBody(updates, failed)
 
-        notificationManager.notify(notificationId, notification() {
+        notificationManager.notify(notificationId, notification {
             setSmallIcon(R.drawable.ic_refresh_white_24dp_img)
             setLargeIcon(notificationBitmap)
             setContentTitle(title)

+ 13 - 0
app/src/main/java/eu/kanade/tachiyomi/util/StringExtensions.kt

@@ -0,0 +1,13 @@
+package eu.kanade.tachiyomi.util
+
+/**
+ * Replaces the given string to have at most [count] characters using [replacement] at its end.
+ * If [replacement] is longer than [count] an exception will be thrown when `length > count`.
+ */
+fun String.chop(count: Int, replacement: String = "..."): String {
+    return if (length > count)
+        take(count - replacement.length) + replacement
+    else
+        this
+
+}