From 3d45fa8038429fe8e98bc0d9314f9e395aaf710a Mon Sep 17 00:00:00 2001 From: takahirom Date: Sun, 8 Apr 2018 14:15:37 +0900 Subject: [PATCH] Introduce hyperion --- app/build.gradle.kts | 15 +++++++ .../presentation/DebotObserver.kt | 44 ------------------- .../confsched2018/presentation/DebugApp.kt | 26 ++++++++++- build.gradle.kts | 2 + buildSrc/src/main/kotlin/Depends.kt | 12 +++++ buildSrc/src/main/kotlin/Versions.kt | 1 + 6 files changed, 55 insertions(+), 45 deletions(-) delete mode 100644 app/src/debug/java/io/github/droidkaigi/confsched2018/presentation/DebotObserver.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index ff437463..ef43b4cd 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -190,6 +190,21 @@ dependencies { //==================== Debug ==================== debugImplementation(Depends.Stetho.core) debugImplementation(Depends.Stetho.okhttp3) + listOf(Depends.Hyperion.core, + Depends.Hyperion.measurement, + Depends.Hyperion.attr, + Depends.Hyperion.disk, + Depends.Hyperion.recorder, + Depends.Hyperion.phoenix, + Depends.Hyperion.crash, + Depends.Hyperion.preferences, + Depends.Hyperion.simpleItem + ).forEach { + debugImplementation(it) { + exclude(group = "com.android.support") + exclude(group = "com.google.dagger") + } + } implementation(Depends.crashlytics) { isTransitive = true diff --git a/app/src/debug/java/io/github/droidkaigi/confsched2018/presentation/DebotObserver.kt b/app/src/debug/java/io/github/droidkaigi/confsched2018/presentation/DebotObserver.kt deleted file mode 100644 index 87c63983..00000000 --- a/app/src/debug/java/io/github/droidkaigi/confsched2018/presentation/DebotObserver.kt +++ /dev/null @@ -1,44 +0,0 @@ -package io.github.droidkaigi.confsched2018.presentation - -import android.app.Activity -import android.app.Application -import android.os.Bundle -import android.support.v4.app.FragmentActivity -import com.tomoima.debot.Debot - -class DebotObserver : Application.ActivityLifecycleCallbacks { - - val debot: Debot by lazy { - Debot.getInstance() - } - - override fun onActivityCreated(activity: Activity?, savedInstanceState: Bundle?) { - if (activity !is Activity) return - debot.allowShake(activity.applicationContext) - } - - override fun onActivityStarted(activity: Activity?) { - // no-op - } - - override fun onActivityResumed(activity: Activity?) { - if (activity !is FragmentActivity) return - debot.startSensor(activity) - } - - override fun onActivityPaused(activity: Activity?) { - debot.stopSensor() - } - - override fun onActivityStopped(activity: Activity?) { - // no-op - } - - override fun onActivitySaveInstanceState(activity: Activity?, outState: Bundle?) { - // no-op - } - - override fun onActivityDestroyed(activity: Activity?) { - // no-op - } -} diff --git a/app/src/debug/java/io/github/droidkaigi/confsched2018/presentation/DebugApp.kt b/app/src/debug/java/io/github/droidkaigi/confsched2018/presentation/DebugApp.kt index bfe1b54b..25cdb695 100644 --- a/app/src/debug/java/io/github/droidkaigi/confsched2018/presentation/DebugApp.kt +++ b/app/src/debug/java/io/github/droidkaigi/confsched2018/presentation/DebugApp.kt @@ -1,9 +1,16 @@ package io.github.droidkaigi.confsched2018.presentation +import android.content.Context +import android.content.ContextWrapper +import android.support.v4.app.FragmentActivity import com.facebook.stetho.Stetho +import com.github.takahirom.hyperion.plugin.simpleitem.SimpleItem +import com.github.takahirom.hyperion.plugin.simpleitem.SimpleItemHyperionPlugin import com.squareup.leakcanary.LeakCanary +import com.tomoima.debot.Debot import com.tomoima.debot.DebotConfigurator import com.tomoima.debot.DebotStrategyBuilder +import io.github.droidkaigi.confsched2018.R import timber.log.Timber class DebugApp : App() { @@ -14,6 +21,24 @@ class DebugApp : App() { setupLeakCanary() setupStetho() setupDebot() + setupHyperion() + } + + private fun setupHyperion() { + val item = SimpleItem.Builder("Depot menu") + .image(R.drawable.ic_notification) + .clickListener { view -> + fun unwrapFragmentActivity(context: Context): FragmentActivity? { + if (context is FragmentActivity) return context + val baseContext = (context as? ContextWrapper)?.baseContext ?: return null + return unwrapFragmentActivity(baseContext) + } + + val activity: FragmentActivity? = unwrapFragmentActivity(view.context) + ?: return@clickListener + Debot.getInstance().showDebugMenu(activity) + }.build() + SimpleItemHyperionPlugin.addItem(item) } private fun setupTimber() { @@ -34,6 +59,5 @@ class DebugApp : App() { .build() DebotConfigurator.configureWithCustomizedMenu(builder.strategyList) - registerActivityLifecycleCallbacks(DebotObserver()) } } diff --git a/build.gradle.kts b/build.gradle.kts index 911fbc9c..c97fca12 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,6 +9,8 @@ allprojects { jcenter() maven(url="https://plugins.gradle.org/m2/") maven(url="https://maven.fabric.io/public") + maven(url = "https://maven.fabric.io/public") + maven(url = "https://jitpack.io") } } diff --git a/buildSrc/src/main/kotlin/Depends.kt b/buildSrc/src/main/kotlin/Depends.kt index fe2bdaa3..f9e398cd 100644 --- a/buildSrc/src/main/kotlin/Depends.kt +++ b/buildSrc/src/main/kotlin/Depends.kt @@ -103,6 +103,18 @@ object Depends { val okhttp3 = "com.facebook.stetho:stetho-okhttp3:${Versions.stetho}" } + object Hyperion { + val core = "com.willowtreeapps.hyperion:hyperion-core:${Versions.hyperion}" + val measurement = "com.willowtreeapps.hyperion:hyperion-measurement:${Versions.hyperion}" + val attr = "com.willowtreeapps.hyperion:hyperion-attr:${Versions.hyperion}" + val disk = "com.willowtreeapps.hyperion:hyperion-disk:${Versions.hyperion}" + val recorder = "com.willowtreeapps.hyperion:hyperion-recorder:${Versions.hyperion}" + val phoenix = "com.willowtreeapps.hyperion:hyperion-phoenix:${Versions.hyperion}" + val crash = "com.willowtreeapps.hyperion:hyperion-crash:${Versions.hyperion}" + val preferences = "com.willowtreeapps.hyperion:hyperion-shared-preferences:${Versions.hyperion}" + val simpleItem = "com.github.takahirom:Hyperion-Simple-Item:0.3.0" + } + val crashlytics = "com.crashlytics.sdk.android:crashlytics:2.8.0@aar" val timber = "com.jakewharton.timber:timber:4.6.0" val leakcanary = "com.squareup.leakcanary:leakcanary-android:1.5.4" diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 4930f29a..d13c8055 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -21,6 +21,7 @@ object Versions { const val glide = "4.5.0" const val groupie = "2.0.3" const val stetho = "1.5.0" + const val hyperion = "0.9.21" const val debot = "2.0.3" const val ossLicenses = "0.9.1" const val deploygate = "1.1.4"