Repository: PSPDFKit-labs/QuickDemo Branch: master Commit: 8fda952e4019 Files: 35 Total size: 78.6 KB Directory structure: gitextract_g_ka2lrf/ ├── .gitignore ├── LICENSE ├── README.md ├── app/ │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src/ │ ├── androidTest/ │ │ └── java/ │ │ └── com/ │ │ └── pspdfkit/ │ │ └── labs/ │ │ └── quickdemo/ │ │ └── ExampleInstrumentedTest.kt │ ├── main/ │ │ ├── AndroidManifest.xml │ │ ├── assets/ │ │ │ └── setup-guide.html │ │ ├── kotlin/ │ │ │ └── com/ │ │ │ └── pspdfkit/ │ │ │ └── labs/ │ │ │ └── quickdemo/ │ │ │ ├── DemoMode.kt │ │ │ ├── Utils.kt │ │ │ ├── activity/ │ │ │ │ ├── ConfigurationActivity.kt │ │ │ │ └── SetupGuideActivity.kt │ │ │ └── service/ │ │ │ └── DemoModeTileService.kt │ │ └── res/ │ │ ├── drawable/ │ │ │ ├── ic_configuration_activity.xml │ │ │ ├── ic_demo_mode.xml │ │ │ └── ic_launcher.xml │ │ ├── layout/ │ │ │ └── activity_setup_guide.xml │ │ ├── values/ │ │ │ ├── array.xml │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ ├── values-w820dp/ │ │ │ └── dimens.xml │ │ └── xml/ │ │ └── demo_mode_preferences.xml │ └── test/ │ └── java/ │ └── com/ │ └── pspdfkit/ │ └── labs/ │ └── quickdemo/ │ └── ExampleUnitTest.kt ├── build.gradle ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── settings.gradle ├── setup-guide.md └── setup.sh ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ # Built application files *.apk *.ap_ # Files for the ART/Dalvik VM *.dex # Java class files *.class # Generated files bin/ gen/ out/ # Gradle files .gradle/ build/ # Local configuration file (sdk path, etc) local.properties # Proguard folder generated by Eclipse proguard/ # Log Files *.log # Android Studio Navigation editor temp files .navigation/ # Android Studio captures folder captures/ # Intellij *.iml .idea # Keystore files *.jks # External native build folder generated in Android Studio 2.2 and later .externalNativeBuild ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2016-2019 PSPDFKit Labs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # QuickDemo _QuickDemo_ is a Nougat 7.0 [quick settings tile](https://developer.android.com/about/versions/nougat/android-7.0.html#tile_api) for fast access to the Marshmallow 6.0 [System UI demo mode](https://android.googlesource.com/platform/frameworks/base/+/android-6.0.0_r1/packages/SystemUI/docs/demo_mode.md). The app also provides a configuration activity for customizing available demo mode settings. Release blog post: https://pspdfkit.com/blog/2016/clean-statusbar-with-systemui-and-quickdemo/ ![QuickDemo in action](showcase.gif) ## Requirements * Android SDK (API 25) * Android Studio 2.2+ * `adb` (for installing the app and granting the required permissions) * Android emulator or devices running Marshmallow (API 23+) ## Building To build and run the app, you can open the project with Android Studio and press `Run`. Alternatively you can install the app from the command line. ```bash git clone git@github.com:PSPDFKit-labs/QuickDemo.git cd QuickDemo/ ./gradlew installDebug ``` You can also run the [`setup.sh`](https://github.com/PSPDFKit-labs/QuickDemo/blob/master/setup.sh) script, wich will check for ANDROID_HOME, clone the project, and use Gradle to install and setup the tool. The script will also remove files of the project after installation. ## Setup ### With Gradle If you cloned the project, you can run `setupDemoMode` gradle task to do the setup. This can be done either by finding and selecting `setupDemoMode` in `Gradle` window in Android Studio, or by running the following: ```bash ./gradlew setupDemoMode ``` ### Manually via adb 1. When launching the app for the first time you need to grant the `android.permission.DUMP` permission, which is required to control the System UI demo mode. You need to do this using `adb`. ```bash adb shell pm grant com.pspdfkit.labs.quickdemo android.permission.DUMP ``` 2. Since the System UI tuner (and its demo mode) is an experimental Android feature, you need to activate it globally. ```bash adb shell settings put global sysui_demo_allowed 1 ``` ## Usage 1. The app comes with a quick settings tile which you can use to quickly toggle the demo mode. 1. Completely open the status bar drawer, expanding all quick setting tiles. 2. Press the edit button on top of the drawer, to show the quick setting tiles picker. 3. Drag the QuickDemo tile to your desired position. 4. Exit edit mode, and tap the tile. 2. You can launch QuickDemo activity to configure all displayed icons of the demo mode. 1. You can find the activity in your app launcher. ## Feedback and contribution Since this project is open source, feel free to use it, give feedback, or contribute in any way you find suitable. ## About This project is maintained and funded by [PSPDFKit](https://pspdfkit.com/). See [our other open source projects](https://github.com/PSPDFKit-labs), read [our blog](https://pspdfkit.com/blog/) or say hello on Twitter ([@PSPDFKit](https://twitter.com/pspdfkit)). ================================================ FILE: app/.gitignore ================================================ /build ================================================ FILE: app/build.gradle ================================================ /* * Copyright (c) 2016-2019 PSPDFKit GmbH. All rights reserved. * * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT. * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES. * This notice may not be removed from this file */ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'android-command' android { compileSdkVersion 28 defaultConfig { applicationId "com.pspdfkit.labs.quickdemo" minSdkVersion 23 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets { main.java.srcDirs += 'src/main/kotlin' } } dependencies { androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', { exclude group: 'com.android.support', module: 'support-annotations' }) implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'io.reactivex.rxjava2:rxjava:2.2.4' implementation 'io.reactivex.rxjava2:rxandroid:2.1.0' testImplementation 'junit:junit:4.12' } task setupDemoMode(type: com.novoda.gradle.command.AdbTask) { description 'Demo Mode initial setup' doLast { runCommand(['shell', 'settings', 'put', 'global', 'sysui_demo_allowed', '1']) runCommand(['shell', 'pm', 'grant', 'com.pspdfkit.labs.quickdemo', 'android.permission.DUMP']) } } ================================================ FILE: app/proguard-rules.pro ================================================ # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified # in /Users/david/Library/Android/sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles # directive in build.gradle. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html # Add any project specific keep options here: # If your project uses WebView with JS, uncomment the following # and specify the fully qualified class name to the JavaScript interface # class: #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} ================================================ FILE: app/src/androidTest/java/com/pspdfkit/labs/quickdemo/ExampleInstrumentedTest.kt ================================================ /* * Copyright (c) 2016-2019 PSPDFKit GmbH. All rights reserved. * * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT. * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES. * This notice may not be removed from this file */ package com.pspdfkit.labs.quickdemo import androidx.test.InstrumentationRegistry import androidx.test.runner.AndroidJUnit4 import org.junit.Assert.assertEquals import org.junit.Test import org.junit.runner.RunWith /** * Instrumentation test, which will execute on an Android device. * @see [Testing documentation](http://d.android.com/tools/testing) */ @RunWith(AndroidJUnit4::class) class ExampleInstrumentedTest { @Test @Throws(Exception::class) fun useAppContext() { // Context of the app under test. val appContext = InstrumentationRegistry.getTargetContext() assertEquals("com.pspdfkit.demoqstile", appContext.packageName) } } ================================================ FILE: app/src/main/AndroidManifest.xml ================================================ ================================================ FILE: app/src/main/assets/setup-guide.html ================================================ setup-guide

QuickDemo is a tool for Android developers. If you don't know what this application is for, do not use it!

Setup

To enable QuickDemo you need to do two things.

  1. Enable the System UI demo mode on your phone.
  2. Grant the android.permission.DUMP to the QuickDemo app. This permissions is protected and can't be requested at runtime.

This can be achieved by running the following gradle task.

./gradlew setupDemoMode

If you don't have the project. Both steps can be performed manually from command line via adb.

# Ensure demo mode is activated.
adb shell settings put global sysui_demo_allowed 1

# Grant required permissions.
adb shell pm grant com.pspdfkit.labs.quickdemo android.permission.DUMP

Please note: The permissions is granted until you revoke it or uninstall the app.

================================================ FILE: app/src/main/kotlin/com/pspdfkit/labs/quickdemo/DemoMode.kt ================================================ /* * Copyright (c) 2016-2019 PSPDFKit GmbH. All rights reserved. * * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT. * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES. * This notice may not be removed from this file */ package com.pspdfkit.labs.quickdemo import android.content.Context import android.content.Intent import android.content.SharedPreferences import android.content.pm.PackageManager import android.preference.PreferenceManager import android.provider.Settings import androidx.core.content.ContextCompat import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty class DemoMode private constructor(context: Context) { private val applicationContext: Context = context.applicationContext private val sharedPreferences: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context) private val demoModeProperties = mutableSetOf>() companion object { private var singleton: DemoMode? = null /** Returns the demo mode singleton */ fun get(context: Context): DemoMode { var demoMode = singleton if (demoMode == null) { demoMode = DemoMode(context) singleton = demoMode } return demoMode } const val DEFAULT_MOBILE_DATATYPE = "hidden" const val DEFAULT_MOBILE_LEVEL = 4 const val DEFAULT_WIFI_LEVEL = 4 const val DEFAULT_NETWORK_NUM_OF_SIMS = 1 const val DEFAULT_STATUS_BAR_MODE = "transparent" const val DEFAULT_BATTERY_LEVEL = 100 const val DEFAULT_STATUS_HIDDEN = "hidden" } /** Returns `true` if the required permissions to send out demo mode broadcasts are available, or `false` if they need to be requested first. */ val requiredPermissionsGranted: Boolean get() = ContextCompat.checkSelfPermission(applicationContext, "android.permission.DUMP") == PackageManager.PERMISSION_GRANTED /** Returns `true` if the demo mode has been activated in system UI. **/ val demoModeAllowed: Boolean get() = Settings.Global.getInt(applicationContext.contentResolver, "sysui_demo_allowed", 0) == 1 /** * Enables or disables the demo mode. If this is set to `false`, no other demo mode settings will have effect. */ var enabled: Boolean get() = sharedPreferences.getBoolean("demoEnabled", false) set(value) { sharedPreferences.edit().putBoolean("demoEnabled", value).commit() if (value) { sendDemoCommand("enter") for (property in demoModeProperties) { property.issueDemoModeCommand() } } else { sendDemoCommand("exit") } } /** * If set to `true`, all notifications get hidden. */ var hideNotifications by booleanPreference("hideNotifications", true) { value -> if (enabled) sendDemoCommand("notifications", "visible" to !value) } /** * Sets the time in the format of `hhmm`. */ var time by stringPreference("time", "0700") { value -> if (enabled) sendDemoCommand("clock", "hhmm" to value) } /** * Can be set to any of `opaque`, `translucent`, `semi-transparent`, `transparent`, or `warning`. */ var statusBarMode by stringPreference("statusBarMode", DEFAULT_STATUS_BAR_MODE) { value -> if (enabled) sendDemoCommand("bars", "mode" to value) } /** * Configure the network display (Wi-Fi, mobile, airplane, etc.). */ val network = Network() inner class Network { /** * Enables or disables airplane mode. Disabled by default. */ var showAirplane by booleanPreference("networkShowAirplane", false) { value -> if (enabled) sendDemoCommand("network", "airplane" to if (value) "show" else "hide") } /** * Enables or disables full network connectivity mode. Enabled by default. */ var fullConnectivity by booleanPreference("networkFullConnectivity", true) { value -> if (enabled) sendDemoCommand("network", "fully" to value) } /** * Shows or hides the Wi-Fi icon. Hidden by default. */ var showWifi by booleanPreference("networkShowWifi", false) { value -> if (enabled) sendDemoCommand("network", "wifi" to if (value) "show" else "hide") } /** * Sets the Wi-Fi connection level. Can be an integer from `0` (no reception) to `4` (full reception). Defaults to `4`. */ var wifiLevel by intPreference("networkWifiLevel", DEFAULT_WIFI_LEVEL) { value -> if (enabled && showWifi) sendDemoCommand("network", "wifi" to "show", "level" to value) } /** * Shows or hides the mobile network icon. Shown by default. */ var mobileShown by booleanPreference("networkMobileShown", true) { value -> if (enabled) sendDemoCommand("network", "mobile" to if (value) "show" else "hide") } /** * Sets the mobile network level. Can be an integer from `0` (no reception) to `4` (full reception). Defaults to `4`. */ var mobileLevel by intPreference("networkMobileLevel", DEFAULT_MOBILE_LEVEL) { value -> if (enabled && mobileShown) sendDemoCommand("network", "mobile" to "show", "level" to value) } /** * Sets the mobile network connection type. Can be any of `1x`, `3g`, `4g`, `e`, `g`, `h`, `lte`, `roam`, or any other value to hide. Defaults to `lte`. */ var mobileDatatype by stringPreference("networkMobileDatatype", DEFAULT_MOBILE_DATATYPE) { value -> if (enabled && mobileShown) sendDemoCommand("network", "mobile" to "show", "datatype" to value) } /** * Sets mobile signal icon to carrier network change UX when disconnected. Disabled by default. */ var showCarrierNetworkChange by booleanPreference("networkCarrierNetworkChange", false) { value -> if (enabled) sendDemoCommand("network", "carriernetworkchange" to if (value) "show" else "hide") } /** * Sets the number of used SIMs. Can be an integer from `1` to `8`. Defaults to `1`. */ var numberOfSims by intPreference("networkNumberOfSims", DEFAULT_NETWORK_NUM_OF_SIMS) { value -> if (enabled) sendDemoCommand("network", "sims" to value) } /** * Show or hide the "no SIM" icon. Hidden by default. */ var showNoSim by booleanPreference("networkShowNoSim", false) { value -> if (enabled) sendDemoCommand("network", "nosim" to if (value) "show" else "hide") } } /** * Configure the status icons (alarm, volume, bluetooth, etc.) */ val status = Status() inner class Status { /** * Sets the volume icon. Can be any of `silent`, `vibrate`, or any other value to hide the icon. Hidden by default. */ var volume by stringPreference("statusVolume", DEFAULT_STATUS_HIDDEN) { value -> if (enabled) sendDemoCommand("status", "volume" to value) } /** * Sets the bluetooth icon. Can be any of `connected`, `disconnected`, `hidden`. Hidden by default. */ var bluetooth by stringPreference("statusBluetooth", DEFAULT_STATUS_HIDDEN, { value -> if (enabled) sendDemoCommand("status", "bluetooth" to value) }) /** * Shows or hides the icon in the location slot. Hidden by default. */ var showLocation by booleanPreference("statusLocation", false) { value -> if (enabled) sendDemoCommand("status", "location" to if (value) "show" else "hide") } /** * Shows or hides the alarm clock icon. Hidden by default. */ var showAlarm by booleanPreference("statusAlarm", false) { value -> if (enabled) sendDemoCommand("status", "alarm" to if (value) "show" else "hide") } /** * Shows or hides the sync icon. Hidden by default. */ var showSync by booleanPreference("statusSync", false) { value -> if (enabled) sendDemoCommand("status", "sync" to if (value) "show" else "hide") } /** * Shows or hides the TTY icon. Hidden by default. */ var showTty by booleanPreference("statusTty", false) { value -> if (enabled) sendDemoCommand("status", "tty" to if (value) "show" else "hide") } /** * Shows or hides the CDMA ERI icon. Hidden by default. */ var showEri by booleanPreference("statusEri", false) { value -> if (enabled) sendDemoCommand("status", "eri" to if (value) "show" else "hide") } /** * Shows or hides the mute icon. Hidden by default. */ var showMute by booleanPreference("statusMute", false) { value -> if (enabled) sendDemoCommand("status", "mute" to if (value) "show" else "hide") } /** * Shows or hides the speakerphone icon. Hidden by default. */ var showSpeakerphone by booleanPreference("statusSpeakerphone", false) { value -> if (enabled) sendDemoCommand("status", "speakerphone" to if (value) "show" else "hide") } } /** * Configure the battery display. */ val battery = Battery() inner class Battery() { /** * Sets the shown battery level. Can be an integer from `0` (depleted) to `100` (fully charged). Defaults to `100`. */ var level by intPreference("batteryLevel", DEFAULT_BATTERY_LEVEL) { value -> if (enabled) sendDemoCommand("battery", "level" to value) } /** * Enables or disables the battery being shown as being plugged in and charging. Defaults to `false`. */ var plugged by booleanPreference("batteryPlugged", false) { value -> if (enabled) sendDemoCommand("battery", "plugged" to value) } /** * Enables or disables the device's power save mode. Defaults to `false`. */ var powersave by booleanPreference("batteryPowersave", default = false) { value -> if (enabled) sendDemoCommand("battery", "powersave" to value) } } private fun sendDemoCommand(command: String, vararg extras: Pair) { val intent = Intent("com.android.systemui.demo").apply { putExtra("command", command) for ((key, value) in extras) { putExtra(key, value.toString()) } } applicationContext.sendBroadcast(intent) } abstract class DemoModeProperty : ReadWriteProperty, SharedPreferences.OnSharedPreferenceChangeListener { abstract val key: String abstract fun issueDemoModeCommand() abstract fun getStoredValue(): T override fun getValue(thisRef: Any, property: KProperty<*>) = getStoredValue() override fun onSharedPreferenceChanged(p0: SharedPreferences?, changedKey: String?) { if (key == changedKey) issueDemoModeCommand() } } fun booleanPreference(key: String, default: Boolean, onSendCommand: (Boolean) -> Unit) = object : DemoModeProperty() { override val key = key override fun issueDemoModeCommand() = onSendCommand(getStoredValue()) override fun getStoredValue() = sharedPreferences.getBoolean(key, default) override fun setValue(thisRef: Any, property: KProperty<*>, value: Boolean) { sharedPreferences.edit().putBoolean(key, value).apply() } }.apply { sharedPreferences.registerOnSharedPreferenceChangeListener(this) demoModeProperties.add(this) } fun intPreference(key: String, default: Int, onSendCommand: (Int) -> Unit) = object : DemoModeProperty() { override val key = key override fun issueDemoModeCommand() = onSendCommand(getStoredValue()) override fun getStoredValue() = sharedPreferences.getString(key, default.toString()).toInt() override fun setValue(thisRef: Any, property: KProperty<*>, value: Int) { sharedPreferences.edit().putString(key, value.toString()).apply() } }.apply { sharedPreferences.registerOnSharedPreferenceChangeListener(this) demoModeProperties.add(this) } fun stringPreference(key: String, default: String, onSendCommand: (String) -> Unit) = object : DemoModeProperty() { override val key = key override fun issueDemoModeCommand() = onSendCommand(getStoredValue()) override fun getStoredValue() = sharedPreferences.getString(key, default) override fun setValue(thisRef: Any, property: KProperty<*>, value: String) { sharedPreferences.edit().putString(key, value).apply() } }.apply { sharedPreferences.registerOnSharedPreferenceChangeListener(this) demoModeProperties.add(this) } } ================================================ FILE: app/src/main/kotlin/com/pspdfkit/labs/quickdemo/Utils.kt ================================================ /* * Copyright (c) 2016-2019 PSPDFKit GmbH. All rights reserved. * * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT. * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES. * This notice may not be removed from this file */ package com.pspdfkit.labs.quickdemo import android.content.Context import android.widget.Toast /** Shows a normal toast message. */ fun Context.toast(message: CharSequence, length: Int = Toast.LENGTH_SHORT) = Toast.makeText(this, message, length).show() ================================================ FILE: app/src/main/kotlin/com/pspdfkit/labs/quickdemo/activity/ConfigurationActivity.kt ================================================ /* * Copyright (c) 2016-2019 PSPDFKit GmbH. All rights reserved. * * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT. * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES. * This notice may not be removed from this file */ package com.pspdfkit.labs.quickdemo.activity import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter import android.content.SharedPreferences import android.os.Bundle import android.preference.PreferenceFragment import android.preference.SwitchPreference import androidx.annotation.ArrayRes import androidx.appcompat.app.AppCompatActivity import com.pspdfkit.labs.quickdemo.DemoMode import com.pspdfkit.labs.quickdemo.R class ConfigurationActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) supportActionBar?.setIcon(R.drawable.ic_configuration_activity) fragmentManager.beginTransaction().replace(android.R.id.content, DemoModePreferences()).commit() } override fun onStart() { super.onStart() // Whenever this activity comes to the foreground, we check if the required permissions have been granted. // If the permissions are missing, launch the setup guide. val demoMode = DemoMode.get(this) if (!demoMode.requiredPermissionsGranted || !demoMode.demoModeAllowed) { SetupGuideActivity.launch(this) // We have to finish this activity, otherwise users that do not complete the setup guide would end up in a endless loop. finish() } } class DemoModePreferences : PreferenceFragment(), SharedPreferences.OnSharedPreferenceChangeListener { private lateinit var demoMode: DemoMode private var updateFromReceiver: Boolean = false private val demoModeChangeReceiver = object : BroadcastReceiver() { override fun onReceive(p0: Context?, p1: Intent?) { updateFromReceiver = true updateDemoModeSwitch() updateFromReceiver = false } } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) demoMode = DemoMode.get(context) addPreferencesFromResource(R.xml.demo_mode_preferences) preferenceManager.sharedPreferences.registerOnSharedPreferenceChangeListener(this) updateSummaries() } fun updateSummaries() { setSummaryFromArrayValue("batteryLevel", R.array.batteryLevelEscaped, R.array.batteryLevelValues, DemoMode.DEFAULT_BATTERY_LEVEL.toString()) setSummaryFromArrayValue("statusBarMode", R.array.statusBarModes, R.array.statusBarModeValues, DemoMode.DEFAULT_STATUS_BAR_MODE) setSummaryFromArrayValue("networkMobileDatatype", R.array.networkMobileDatatypes, R.array.networkMobileDatatypeValues, DemoMode.DEFAULT_MOBILE_DATATYPE) setSummaryFromArrayValue("networkMobileLevel", R.array.networkReceptionLevels, R.array.networkReceptionLevelValues, DemoMode.DEFAULT_MOBILE_LEVEL.toString()) setSummaryFromArrayValue("networkNumberOfSims", R.array.networkNumOfSims, R.array.networkNumOfSims, DemoMode.DEFAULT_NETWORK_NUM_OF_SIMS.toString()) setSummaryFromArrayValue("networkWifiLevel", R.array.networkReceptionLevels, R.array.networkReceptionLevelValues, DemoMode.DEFAULT_WIFI_LEVEL.toString()) setSummaryFromArrayValue("statusVolume", R.array.statusVolume, R.array.statusVolumeValues, DemoMode.DEFAULT_STATUS_HIDDEN) setSummaryFromArrayValue("statusBluetooth", R.array.statusBluetooth, R.array.statusBluetoothValues, DemoMode.DEFAULT_STATUS_HIDDEN) } fun setSummaryFromArrayValue(key: String, @ArrayRes labelArrayRes: Int, @ArrayRes valueArrayRes: Int, default: String) { val preference = findPreference(key) val value = preferenceManager.sharedPreferences.getString(key, default) val i = resources.getStringArray(valueArrayRes).indexOf(value) if (i >= 0) preference.summary = resources.getStringArray(labelArrayRes)[i] } override fun onStart() { super.onStart() context.registerReceiver(demoModeChangeReceiver, IntentFilter("com.android.systemui.demo")) updateDemoModeSwitch() } override fun onStop() { super.onStop() context.unregisterReceiver(demoModeChangeReceiver) } private fun updateDemoModeSwitch() { val enabled = findPreference("enable_demo") as SwitchPreference enabled.isChecked = demoMode.enabled } override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { when (key) { "enable_demo" -> { if (!updateFromReceiver) demoMode.enabled = sharedPreferences.getBoolean(key, false) } "batteryLevel", "statusBarMode", "networkMobileDatatype", "networkMobileLevel", "networkNumberOfSims", "networkWifiLevel", "statusVolume", "statusBluetooth" -> { updateSummaries() } } } } companion object { fun launch(context: Context) { val intent = Intent(context, ConfigurationActivity::class.java) context.startActivity(intent) } } } ================================================ FILE: app/src/main/kotlin/com/pspdfkit/labs/quickdemo/activity/SetupGuideActivity.kt ================================================ /* * Copyright (c) 2016-2019 PSPDFKit GmbH. All rights reserved. * * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT. * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES. * This notice may not be removed from this file */ package com.pspdfkit.labs.quickdemo.activity import android.content.Context import android.content.Intent import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import android.webkit.WebView import android.widget.Toast import com.pspdfkit.labs.quickdemo.DemoMode import com.pspdfkit.labs.quickdemo.R import com.pspdfkit.labs.quickdemo.toast import io.reactivex.Observable import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.Disposable import java.util.concurrent.TimeUnit /** * An interactive introduction guide for first-time users. */ class SetupGuideActivity : AppCompatActivity() { var permissionChecking: Disposable? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) val demoMode = DemoMode.get(this) // If the app has already been granted the required permissions, there's no need to setup. if (demoMode.requiredPermissionsGranted && demoMode.demoModeAllowed) finish() // Setup content is just informative. We're using a webview to show pre-formatted instructions. setContentView(R.layout.activity_setup_guide) val webView: WebView = findViewById(R.id.webview) webView.loadUrl("file:///android_asset/setup-guide.html") // We periodically check if the permission has been granted. Once this happened, we notify the user and finish the activity. permissionChecking = Observable.interval(1, TimeUnit.SECONDS) .filter { demoMode.requiredPermissionsGranted && demoMode.demoModeAllowed } .observeOn(AndroidSchedulers.mainThread()) .doOnNext { toast("QuickDemo has been successfully set up! Ready for activating demo mode.", Toast.LENGTH_LONG) ConfigurationActivity.launch(this) finish() } .subscribe() } override fun onDestroy() { super.onDestroy() // Stop permission checking when destroying the activity (preventing leaks). permissionChecking?.dispose() permissionChecking = null } companion object { fun launch(context: Context) { context.startActivity(intent(context)) } fun intent(context: Context) = Intent(context, SetupGuideActivity::class.java) } } ================================================ FILE: app/src/main/kotlin/com/pspdfkit/labs/quickdemo/service/DemoModeTileService.kt ================================================ /* * Copyright (c) 2016-2019 PSPDFKit GmbH. All rights reserved. * * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT. * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES. * This notice may not be removed from this file */ package com.pspdfkit.labs.quickdemo.service import android.content.Intent import android.graphics.drawable.Icon import android.service.quicksettings.Tile import android.service.quicksettings.TileService import com.pspdfkit.labs.quickdemo.DemoMode import com.pspdfkit.labs.quickdemo.R import com.pspdfkit.labs.quickdemo.activity.SetupGuideActivity class DemoModeTileService : TileService() { private lateinit var demoMode: DemoMode override fun onCreate() { super.onCreate() demoMode = DemoMode.get(this) } override fun onStartListening() { qsTile.icon = Icon.createWithResource(this, R.drawable.ic_demo_mode) qsTile.label = "Demo mode" updateIcon() } override fun onClick() { if (!demoMode.requiredPermissionsGranted || !demoMode.demoModeAllowed) { startActivityAndCollapse(SetupGuideActivity.intent(this)) return } demoMode.enabled = !demoMode.enabled updateIcon() val it = Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS) sendBroadcast(it) } private fun updateIcon() { qsTile.state = if (demoMode.enabled) Tile.STATE_ACTIVE else Tile.STATE_INACTIVE qsTile.updateTile() } } ================================================ FILE: app/src/main/res/drawable/ic_configuration_activity.xml ================================================ ================================================ FILE: app/src/main/res/drawable/ic_demo_mode.xml ================================================ ================================================ FILE: app/src/main/res/drawable/ic_launcher.xml ================================================ ================================================ FILE: app/src/main/res/layout/activity_setup_guide.xml ================================================ ================================================ FILE: app/src/main/res/values/array.xml ================================================ Transparent Opaque Translucent Semi-Transparent Warning transparent opaque translucent semi-transparent warning 1x 3G 4G Edge GPRS HSPA LTE Roaming Hidden 1x 3g 4g e g h lte roam hidden 100% (fully charged) 85% 70% 50% 30% 15% 0% (depleted) 100%% (fully charged) 85%% 70%% 50%% 30%% 15%% 0%% (depleted) 100 85 70 50 30 15 0 4 (full reception) 3 2 1 0 (no reception) 4 3 2 1 0 1 2 3 4 5 6 7 8 Hidden Silent Vibrate hidden silent vibrate Hidden Connected Disconnected hidden connected disconnected ================================================ FILE: app/src/main/res/values/colors.xml ================================================ #0282BE #015580 #4FC3F7 ================================================ FILE: app/src/main/res/values/dimens.xml ================================================ 16dp 16dp ================================================ FILE: app/src/main/res/values/strings.xml ================================================ QuickDemo Demo mode QuickDemo Settings ================================================ FILE: app/src/main/res/values/styles.xml ================================================ ================================================ FILE: app/src/main/res/values-w820dp/dimens.xml ================================================ 64dp ================================================ FILE: app/src/main/res/xml/demo_mode_preferences.xml ================================================ android:singleLine="true"/> ================================================ FILE: app/src/test/java/com/pspdfkit/labs/quickdemo/ExampleUnitTest.kt ================================================ /* * Copyright (c) 2016-2019 PSPDFKit GmbH. All rights reserved. * * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT. * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES. * This notice may not be removed from this file */ package com.pspdfkit.labs.quickdemo import org.junit.Assert.assertEquals import org.junit.Test /** * Example local unit test, which will execute on the development machine (host). * @see [Testing documentation](http://d.android.com/tools/testing) */ class ExampleUnitTest { @Test @Throws(Exception::class) fun addition_isCorrect() { assertEquals(4, (2 + 2).toLong()) } } ================================================ FILE: build.gradle ================================================ /* * Copyright (c) 2016-2019 PSPDFKit GmbH. All rights reserved. * * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT. * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES. * This notice may not be removed from this file */ buildscript { ext.kotlin_version = '1.3.31' repositories { jcenter() google() } dependencies { classpath 'com.android.tools.build:gradle:3.4.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.novoda:gradle-android-command-plugin:1.6.2' } } allprojects { repositories { jcenter() google() } } task clean(type: Delete) { delete rootProject.buildDir } ================================================ FILE: gradle/wrapper/gradle-wrapper.properties ================================================ # # gradle-wrapper.properties # # PSPDFKit # # Copyright (c) 2016 PSPDFKit GmbH. All rights reserved. # # THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW # AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT. # UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES. # This notice may not be removed from this file # #Mon Oct 16 10:43:14 EDT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip ================================================ FILE: gradle.properties ================================================ # # Copyright (c) 2016-2019 PSPDFKit GmbH. All rights reserved. # # THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW # AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT. # UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES. # This notice may not be removed from this file # org.gradle.jvmargs=-Xmx1536m kotlin.incremental=true android.useAndroidX=true android.enableJetifier=true ================================================ FILE: gradlew ================================================ #!/usr/bin/env bash ############################################################################## ## ## Gradle start up script for UN*X ## ############################################################################## # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS="" APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" warn ( ) { echo "$*" } die ( ) { echo echo "$*" echo exit 1 } # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false case "`uname`" in CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MINGW* ) msys=true ;; esac # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" # Need this for relative symlinks. while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`"/$link" fi done SAVED="`pwd`" cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" cd "$SAVED" >/dev/null CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else JAVACMD="$JAVA_HOME/bin/java" fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD="java" which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi # Increase the maximum file descriptors if we can. if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD="$MAX_FD_LIMIT" fi ulimit -n $MAX_FD if [ $? -ne 0 ] ; then warn "Could not set maximum file descriptor limit: $MAX_FD" fi else warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" fi fi # For Darwin, add options to specify how the application appears in the dock if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi # For Cygwin, switch paths to Windows format before running java if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` SEP="" for dir in $ROOTDIRSRAW ; do ROOTDIRS="$ROOTDIRS$SEP$dir" SEP="|" done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments if [ "$GRADLE_CYGPATTERN" != "" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh i=0 for arg in "$@" ; do CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` else eval `echo args$i`="\"$arg\"" fi i=$((i+1)) done case $i in (0) set -- ;; (1) set -- "$args0" ;; (2) set -- "$args0" "$args1" ;; (3) set -- "$args0" "$args1" "$args2" ;; (4) set -- "$args0" "$args1" "$args2" "$args3" ;; (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules function splitJvmOpts() { JVM_OPTS=("$@") } eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" ================================================ FILE: gradlew.bat ================================================ @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @rem @rem ########################################################################## @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS= set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if "%ERRORLEVEL%" == "0" goto init echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto init echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :init @rem Get command-line arguments, handling Windowz variants if not "%OS%" == "Windows_NT" goto win9xME_args if "%@eval[2+2]" == "4" goto 4NT_args :win9xME_args @rem Slurp the command line arguments. set CMD_LINE_ARGS= set _SKIP=2 :win9xME_args_slurp if "x%~1" == "x" goto execute set CMD_LINE_ARGS=%* goto execute :4NT_args @rem Get arguments from the 4NT Shell from JP Software set CMD_LINE_ARGS=%$ :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% :end @rem End local scope for the variables with windows NT shell if "%ERRORLEVEL%"=="0" goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal :omega ================================================ FILE: settings.gradle ================================================ /* * Copyright (c) 2016-2019 PSPDFKit GmbH. All rights reserved. * * THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW * AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE PSPDFKIT LICENSE AGREEMENT. * UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES. * This notice may not be removed from this file */ include ':app' ================================================ FILE: setup-guide.md ================================================ ***QuickDemo is a tool for Android developers. If you don't know what this application is for, do not use it!*** ## Setup To enable _QuickDemo_ you need to do two things. 1. Enable the System UI demo mode on your phone. 2. Grant the `android.permission.DUMP` to the QuickDemo app. This permissions is protected and can't be requested at runtime. This can be achieved by running the following `gradle` task. ``` ./gradlew setupDemoMode ``` If you don't have the project. Both steps can be performed manually from command line via `adb`. ``` # Ensure demo mode is activated. adb shell settings put global sysui_demo_allowed 1 # Grant required permissions. adb shell pm grant com.pspdfkit.labs.quickdemo android.permission.DUMP ``` **Please note:** The permissions is granted until you revoke it or uninstall the app. ================================================ FILE: setup.sh ================================================ #!/usr/bin/env bash if [[ $1 ]] || [[ ${ANDROID_HOME} ]]; then cd ~ git clone git@github.com:PSPDFKit-labs/QuickDemo.git cd QuickDemo/ if [[ $1 ]]; then echo "sdk.dir="$1 >>local.properties fi ./gradlew installDebug ./gradlew setupDemoMode cd ~ yes | rm -r QuickDemo else echo "Missing ANDROID_HOME" echo "Usage: ./quick_demo.sh ANDROID_HOME" echo "or set an ANROID_HOME environment variable" fi