Skip to content

Instantly share code, notes, and snippets.

@koral-- koral--/build.gradle
Last active Apr 6, 2017

Embed
What would you like to do?
import com.android.ddmlib.AndroidDebugBridge
import com.android.ddmlib.IDevice
import com.android.ddmlib.NullOutputReceiver
import java.util.concurrent.TimeUnit
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
apply plugin: 'com.android.application'
android {
buildToolsVersion '25.0.1'
compileSdkVersion 25
}
IDevice.metaClass.setZeroScale {
delegate.executeShellCommand("settings put global ${it}_scale 0", NullOutputReceiver.receiver, 1, TimeUnit.SECONDS)
}
task('connectedDisableAnimations') {
AndroidDebugBridge.initIfNeeded(false)
def bridge = AndroidDebugBridge.createBridge(android.adbExecutable.path, false)
doLast {
bridge.devices.each {
it.setZeroScale 'window_animation'
it.setZeroScale 'transition_animation'
it.setZeroScale 'animator_duration'
}
}
}
import com.android.ddmlib.AndroidDebugBridge
import com.android.ddmlib.IDevice
import com.android.ddmlib.NullOutputReceiver
import java.util.concurrent.TimeUnit
import com.android.build.gradle.AppExtension
import com.android.build.gradle.AppPlugin
import org.gradle.api.Project
import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper
buildscript {
repositories {
jcenter()
gradleScriptKotlin()
}
dependencies {
classpath("com.android.tools.build:gradle:2.2.2")
classpath(kotlinModule("gradle-plugin"))
}
}
apply {
plugin<AppPlugin>()
plugin<KotlinAndroidPluginWrapper>()
}
android {
buildToolsVersion("25.0.1")
compileSdkVersion(25)
}
fun Project.android(setup: AppExtension.() -> Unit) = the<AppExtension>().setup()
fun IDevice.setZeroScale(prefix: String) {
executeShellCommand("settings put global ${prefix}_scale 0", NullOutputReceiver.getReceiver(), 1, TimeUnit.SECONDS)
}
task("connectedSetup") {
AndroidDebugBridge.initIfNeeded(false)
val bridge = AndroidDebugBridge.createBridge(the<AppExtension>().adbExecutable.path, false)
doLast {
bridge.devices.forEach {
it.setZeroScale("window_animation")
it.setZeroScale("transition_animation")
it.setZeroScale("animator_duration")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.