Skip to content
This repository has been archived by the owner on May 8, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1135 from 47deg/javi-1133-upgrade-libraries
Browse files Browse the repository at this point in the history
Upgrade libraries
  • Loading branch information
Javi Pacheco authored Nov 24, 2016
2 parents f435321 + 0914834 commit de2a73c
Show file tree
Hide file tree
Showing 21 changed files with 70 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
sudo: false
language: scala
jdk:
- oraclejdk8
scala:
- 2.11.7
addons:
Expand Down
2 changes: 1 addition & 1 deletion modules/api/build.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
platformTarget in Android := "android-23"
platformTarget in Android := "android-24"
2 changes: 1 addition & 1 deletion modules/app/build.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
platformTarget in Android := "android-23"
platformTarget in Android := "android-24"
8 changes: 4 additions & 4 deletions modules/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@
<string name="wizard_new_conf_desc_step_5">Remember, you can create and configure the Collections and Moments in the launcher. Enjoy 9Cards!</string>

<!-- Wizard Inline -->
<string name="wizard_inline_message_app_drawer">Hi, Its %1$s from the 9 Cards team! I\'d like to tell you something cool about the App Drawer.</string> <!-- Pending review language -->
<string name="wizard_inline_message_collections">Hi, Its %1$s from the 9 Cards team! I\'d like to tell you something cool about the Collections.</string> <!-- Pending review language -->
<string name="wizard_inline_message_profile">Hi, Its %1$s from the 9 Cards team! I\'d like to tell you something cool about the Profile.</string> <!-- Pending review language -->
<string name="wizard_inline_message_launcher">Hi, Its %1$s from the 9 Cards team! I\'d like to tell you something cool about the Launcher.</string> <!-- Pending review language -->
<string name="wizard_inline_message_app_drawer">Hi, Its %1$s from the 9 Cards team! Let me tell you about the App Drawer.</string> <!-- Pending review language -->
<string name="wizard_inline_message_collections">Hi, Its %1$s from the 9 Cards team! Check out the cool features in Collections.</string> <!-- Pending review language -->
<string name="wizard_inline_message_profile">Hi, Its %1$s from the 9 Cards team! Want to learn more about the Profile.</string> <!-- Pending review language -->
<string name="wizard_inline_message_launcher">Hi, Its %1$s from the 9 Cards team! I\'d like to show you some cool things about the Launcher.</string> <!-- Pending review language -->
<string name="wizard_inline_show">Let\'s go!</string>

<string name="wizard_inline_got_it">Got it!</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MomentBroadcastReceiver
def verifyConnectionStatus(maybeNetworkInfo: Option[android.net.NetworkInfo]): Unit =
maybeNetworkInfo foreach { networkInfo =>
if (networkInfo.getType == ConnectivityManager.TYPE_WIFI) {
connectionStatusTaskRef := connectionStatusChangedJobs.connectionStatusChanged().resolveAsyncDelayed(5.seconds)
connectionStatusTaskRef := connectionStatusChangedJobs.connectionStatusChanged().resolveAutoCancelableAsyncDelayed(5.seconds)
}
}

Expand All @@ -43,7 +43,7 @@ class MomentBroadcastReceiver
}

maybeService foreach { service =>
fenceStatusRef := service.resolveAsyncDelayed(500.millis)
fenceStatusRef := service.resolveAutoCancelableAsyncDelayed(500.millis)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ trait SharedCollectionItem

background.getPaint.setColor(theme.getRandomIndexColor)
val apps = collection.resolvedPackages
android.util.Log.d("9cards", s"${collection.name} -- apps: ${apps.map(_.title).mkString(",")}")
(icon <~ ivSrc(collection.getIconCollectionDetail)) ~
(appsIcons <~
vgRemoveAllViews <~
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,24 @@ object TaskServiceOps {
}
}

def resolveAutoCancelableAsyncDelayed[E >: Throwable](
finiteDuration: FiniteDuration,
onResult: A => Unit = a => (),
onException: E => Unit = (e: Throwable) => ()
): Cancelable = {
Task.defer(t.value).executeWithOptions(_.enableAutoCancelableRunLoops).delayExecution(finiteDuration).runAsync { result =>
result match {
case Failure(ex) =>
printErrorTaskMessage("=> EXCEPTION Disjunction <=", ex)
onException(ex)
case Success(Right(value)) => onResult(value)
case Success(Left(ex)) =>
printErrorTaskMessage(s"=> EXCEPTION Left) <=", ex)
onException(ex)
}
}
}

def resolveAsyncService[E >: Throwable](
onResult: (A) => TaskService[A] = a => TaskService(Task(Either.right(a))),
onException: (E) => TaskService[A] = (e: NineCardException) => TaskService(Task(Either.left(e)))): Cancelable = {
Expand All @@ -70,6 +88,22 @@ object TaskServiceOps {
}
}

def resolveAutoCancelableAsyncService[E >: Throwable](
onResult: (A) => TaskService[A] = a => TaskService(Task(Either.right(a))),
onException: (E) => TaskService[A] = (e: NineCardException) => TaskService(Task(Either.left(e)))): Cancelable = {
Task.defer(t.value).executeWithOptions(_.enableAutoCancelableRunLoops).runAsync { result =>
result match {
case Failure(ex) =>
printErrorTaskMessage("=> EXCEPTION Disjunction <=", ex)
onException(ex).value.runAsync
case Success(Right(response)) => onResult(response).value.coeval
case Success(Left(ex)) =>
printErrorTaskMessage(s"=> EXCEPTION Left) <=", ex)
onException(ex).value.runAsync
}
}
}

def resolve[E >: Throwable](
onResult: A => Unit = a => (),
onException: E => Unit = (e: Throwable) => ()): Unit = {
Expand Down Expand Up @@ -97,6 +131,9 @@ object TaskServiceOps {
def resolveAsyncServiceOr[E >: Throwable](exception: (E) => TaskService[A]): Cancelable =
resolveAsyncService(onException = exception)

def resolveAutoCancelableAsyncServiceOr[E >: Throwable](exception: (E) => TaskService[A]): Cancelable =
resolveAutoCancelableAsyncService(onException = exception)

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.animation.{Animator, AnimatorListenerAdapter, ValueAnimator}
import android.graphics.Paint.Style
import android.graphics._
import android.graphics.drawable.{Animatable, Drawable}
import android.support.v4.content.ContextCompat
import android.view.animation.DecelerateInterpolator
import cards.nine.app.ui.components.drawables.IconTypes._
import macroid.ContextWrapper
Expand Down Expand Up @@ -99,7 +100,6 @@ case class PathMorphDrawable(
currentIcon.foreach(drawIcon(canvas, _))
}


override def setColorFilter(cf: ColorFilter): Unit = iconPaint.setColorFilter(cf)

override def setAlpha(alpha: Int): Unit = iconPaint.setAlpha(alpha)
Expand Down Expand Up @@ -131,7 +131,7 @@ case class PathMorphDrawable(
}

def setColorResource(color: Int): Unit = {
iconPaint.setColor(context.application.getResources.getColor(color))
iconPaint.setColor(ContextCompat.getColor(context.application, color))
invalidateSelf()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ class PublicCollectionsFragment(implicit launcherJobs: LauncherJobs)
}

override def loadPublicCollectionsByTypeSharedCollection(typeSharedCollection: TypeSharedCollection): Unit =
serialCancelableTaskRef := collectionJobs.loadPublicCollectionsByTypeSharedCollection(typeSharedCollection).resolveAsyncServiceOr(onError)
serialCancelableTaskRef := collectionJobs.loadPublicCollectionsByTypeSharedCollection(typeSharedCollection).resolveAutoCancelableAsyncServiceOr(onError)

override def loadPublicCollectionsByCategory(category: NineCardsCategory): Unit =
serialCancelableTaskRef := collectionJobs.loadPublicCollectionsByCategory(category).resolveAsyncServiceOr(onError)
serialCancelableTaskRef := collectionJobs.loadPublicCollectionsByCategory(category).resolveAutoCancelableAsyncServiceOr(onError)

override def loadPublicCollections(): Unit =
serialCancelableTaskRef := collectionJobs.loadPublicCollections().resolveAsyncServiceOr(onError)
serialCancelableTaskRef := collectionJobs.loadPublicCollections().resolveAutoCancelableAsyncServiceOr(onError)

override def onAddCollection(sharedCollection: SharedCollection): Unit =
(for {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ class ProfileActivity
tab match {
case AccountsTab =>
serialCancelableTaskRef := withError(jobs.loadUserAccounts())
.resolveAsyncServiceOr(_ => jobs.profileUiActions.showEmptyAccountsContent(error = true))
.resolveAutoCancelableAsyncServiceOr(_ => jobs.profileUiActions.showEmptyAccountsContent(error = true))
case PublicationsTab =>
serialCancelableTaskRef := withError(jobs.loadPublications())
.resolveAsyncServiceOr(onException(jobs.profileUiActions.showEmptyPublicationsContent(error = true)))
.resolveAutoCancelableAsyncServiceOr(onException(jobs.profileUiActions.showEmptyPublicationsContent(error = true)))
case SubscriptionsTab =>
serialCancelableTaskRef := withError(jobs.loadSubscriptions())
.resolveAsyncServiceOr(onException(jobs.profileUiActions.showEmptySubscriptionsContent(error = true)))
.resolveAutoCancelableAsyncServiceOr(onException(jobs.profileUiActions.showEmptySubscriptionsContent(error = true)))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class WizardUiActions(dom: WizardDOM, listener: WizardUiListener)(implicit val c
case Some(p) if p.nonEmpty => listener.onClickSelectV1DeviceButton(p)
case _ => listener.onClickSelectDeviceButton(None)
}
case _ => listener.onClickSelectDeviceButton(None)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/commons/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
android.Plugin.androidBuild

platformTarget in Android := "android-23"
platformTarget in Android := "android-24"
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
package cards.nine.commons

import cats.data.EitherT
import cats.{Functor, Monad}
import monix.eval.Task
import cats.syntax.either._
import monix.cats.MonixToCatsConversions
import monix.eval.Task

import scala.language.{higherKinds, implicitConversions}

package object services {

object TaskService {

implicit val taskFunctor = new Functor[Task] {
override def map[A, B](fa: Task[A])(f: (A) => B): Task[B] = fa.map(f)
}

implicit val taskMonad = new Monad[Task] {
override def flatMap[A, B](fa: Task[A])(f: (A) => Task[B]): Task[B] = fa.flatMap(f)
override def pure[A](x: A): Task[A] = Task(x)
override def tailRecM[A, B](a: A)(f: (A) => Task[Either[A, B]]): Task[B] = defaultTailRecM(a)(f)
}
object TaskService extends MonixToCatsConversions {

trait NineCardException extends RuntimeException {
def message: String
Expand Down
2 changes: 1 addition & 1 deletion modules/process/build.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
platformTarget in Android := "android-23"
platformTarget in Android := "android-24"
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class UserProcessImpl(
androidId <- persistenceServices.getAndroidId
_ <- apiServices.updateInstallation(deviceToken)(RequestConfig(apiKey, sessionToken, androidId))
} yield ()).resolve[UserException]
case _ => TaskService(Task(Right(0)))
case _ => TaskService.right(0)
}

private[this] def findUserById(id: Int): TaskService[User] =
Expand Down
2 changes: 1 addition & 1 deletion modules/repository/build.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
platformTarget in Android := "android-23"
platformTarget in Android := "android-24"
2 changes: 1 addition & 1 deletion modules/services/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
android.Plugin.androidBuild

platformTarget in Android := "android-23"
platformTarget in Android := "android-24"
1 change: 1 addition & 0 deletions project/Libraries.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ object Libraries {
object monix {
lazy val monixTypes = "io.monix" %% "monix-types" % Versions.monixV
lazy val monixEval = "io.monix" %% "monix-eval" % Versions.monixV
lazy val monixCats = "io.monix" %% "monix-cats" % Versions.monixV
}

object android {
Expand Down
2 changes: 1 addition & 1 deletion project/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ object Settings extends SiteKeys {
organizationName := "47deg",
scalaVersion := Versions.scalaV,
resolvers ++= commonResolvers,
libraryDependencies ++= Seq(cats, monixTypes, monixEval)
libraryDependencies ++= Seq(cats, monixTypes, monixEval, monixCats)
)

lazy val duplicatedFiles = Set(
Expand Down
6 changes: 3 additions & 3 deletions project/Versions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object Versions {
val crashlyticsV = "2.5.2"
val jodaTimeV = "2.9.2"
val gfcTimeUUIDV = "0.0.6"
val monixV = "2.0.0"
val catsV = "0.7.2"
val flowUpV= "0.1.6"
val monixV = "2.1.1"
val catsV = "0.8.1"
val flowUpV= "0.1.8"
}
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
addSbtPlugin("org.brianmckenna" % "sbt-wartremover" % "0.13")

addSbtPlugin("org.scala-android" % "sbt-android" % "1.6.9")
addSbtPlugin("org.scala-android" % "sbt-android" % "1.7.1")

resolvers += Resolver.url("scoverage-bintray", url("https://dl.bintray.com/sksamuel/sbt-plugins/"))(Resolver.ivyStylePatterns)

Expand Down

0 comments on commit de2a73c

Please sign in to comment.