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

This commit is contained in:
len 2016-11-19 14:46:49 +01:00
parent 1d014a5a94
commit 59c626b4a8
3 changed files with 22 additions and 12 deletions

View File

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

View File

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

View File

@ -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
}