├── README.md
├── examples
├── module06
│ └── HelloAndroidThings
│ │ ├── .gitignore
│ │ ├── .idea
│ │ ├── compiler.xml
│ │ ├── copyright
│ │ │ └── profiles_settings.xml
│ │ ├── gradle.xml
│ │ ├── inspectionProfiles
│ │ │ ├── Project_Default.xml
│ │ │ └── profiles_settings.xml
│ │ ├── misc.xml
│ │ ├── modules.xml
│ │ └── runConfigurations.xml
│ │ ├── app
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ ├── androidTest
│ │ │ └── java
│ │ │ │ └── net
│ │ │ │ └── macdidi5
│ │ │ │ └── at
│ │ │ │ └── helloandroidthings
│ │ │ │ └── ExampleInstrumentedTest.java
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ │ └── net
│ │ │ │ │ └── macdidi5
│ │ │ │ │ └── at
│ │ │ │ │ └── helloandroidthings
│ │ │ │ │ └── MainActivity.java
│ │ │ └── res
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ └── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ └── test
│ │ │ └── java
│ │ │ └── net
│ │ │ └── macdidi5
│ │ │ └── at
│ │ │ └── helloandroidthings
│ │ │ └── ExampleUnitTest.java
│ │ ├── build.gradle
│ │ ├── gradle.properties
│ │ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
├── module08
│ └── HelloLED
│ │ ├── .gitignore
│ │ ├── .idea
│ │ ├── compiler.xml
│ │ ├── copyright
│ │ │ └── profiles_settings.xml
│ │ ├── encodings.xml
│ │ ├── gradle.xml
│ │ ├── misc.xml
│ │ ├── modules.xml
│ │ └── runConfigurations.xml
│ │ ├── app
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ ├── androidTest
│ │ │ └── java
│ │ │ │ └── net
│ │ │ │ └── macdidi5
│ │ │ │ └── at
│ │ │ │ └── helloled
│ │ │ │ └── ExampleInstrumentedTest.java
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ │ └── net
│ │ │ │ │ └── macdidi5
│ │ │ │ │ └── at
│ │ │ │ │ └── helloled
│ │ │ │ │ └── MainActivity.java
│ │ │ └── res
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ └── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ └── test
│ │ │ └── java
│ │ │ └── net
│ │ │ └── macdidi5
│ │ │ └── at
│ │ │ └── helloled
│ │ │ └── ExampleUnitTest.java
│ │ ├── build.gradle
│ │ ├── gradle.properties
│ │ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
├── module09
│ └── HelloSevenSegment
│ │ ├── .gitignore
│ │ ├── .idea
│ │ ├── compiler.xml
│ │ ├── copyright
│ │ │ └── profiles_settings.xml
│ │ ├── gradle.xml
│ │ ├── inspectionProfiles
│ │ │ ├── Project_Default.xml
│ │ │ └── profiles_settings.xml
│ │ ├── misc.xml
│ │ ├── modules.xml
│ │ └── runConfigurations.xml
│ │ ├── app
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ ├── androidTest
│ │ │ └── java
│ │ │ │ └── net
│ │ │ │ └── macdidi5
│ │ │ │ └── at
│ │ │ │ └── hellosevensegment
│ │ │ │ └── ExampleInstrumentedTest.java
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ │ └── net
│ │ │ │ │ └── macdidi5
│ │ │ │ │ └── at
│ │ │ │ │ └── hellosevensegment
│ │ │ │ │ ├── DisplayMap.java
│ │ │ │ │ └── MainActivity.java
│ │ │ └── res
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ └── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ └── test
│ │ │ └── java
│ │ │ └── net
│ │ │ └── macdidi5
│ │ │ └── at
│ │ │ └── hellosevensegment
│ │ │ └── ExampleUnitTest.java
│ │ ├── build.gradle
│ │ ├── gradle.properties
│ │ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
├── module10
│ └── HelloRelay
│ │ ├── .gitignore
│ │ ├── .idea
│ │ ├── compiler.xml
│ │ ├── copyright
│ │ │ └── profiles_settings.xml
│ │ ├── gradle.xml
│ │ ├── inspectionProfiles
│ │ │ ├── Project_Default.xml
│ │ │ └── profiles_settings.xml
│ │ ├── misc.xml
│ │ ├── modules.xml
│ │ └── runConfigurations.xml
│ │ ├── app
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ ├── androidTest
│ │ │ └── java
│ │ │ │ └── net
│ │ │ │ └── macdidi5
│ │ │ │ └── at
│ │ │ │ └── hellorelay
│ │ │ │ └── ExampleInstrumentedTest.java
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ │ └── net
│ │ │ │ │ └── macdidi5
│ │ │ │ │ └── at
│ │ │ │ │ └── hellorelay
│ │ │ │ │ └── MainActivity.java
│ │ │ └── res
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ └── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ └── test
│ │ │ └── java
│ │ │ └── net
│ │ │ └── macdidi5
│ │ │ └── at
│ │ │ └── hellorelay
│ │ │ └── ExampleUnitTest.java
│ │ ├── build.gradle
│ │ ├── gradle.properties
│ │ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
├── module11
│ └── HelloButton
│ │ ├── .gitignore
│ │ ├── .idea
│ │ ├── compiler.xml
│ │ ├── copyright
│ │ │ └── profiles_settings.xml
│ │ ├── encodings.xml
│ │ ├── gradle.xml
│ │ ├── misc.xml
│ │ ├── modules.xml
│ │ └── runConfigurations.xml
│ │ ├── app
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ ├── androidTest
│ │ │ └── java
│ │ │ │ └── net
│ │ │ │ └── macdidi5
│ │ │ │ └── at
│ │ │ │ └── hellobutton
│ │ │ │ └── ExampleInstrumentedTest.java
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ │ └── net
│ │ │ │ │ └── macdidi5
│ │ │ │ │ └── at
│ │ │ │ │ └── hellobutton
│ │ │ │ │ └── MainActivity.java
│ │ │ └── res
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ └── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ └── test
│ │ │ └── java
│ │ │ └── net
│ │ │ └── macdidi5
│ │ │ └── at
│ │ │ └── hellobutton
│ │ │ └── ExampleUnitTest.java
│ │ ├── build.gradle
│ │ ├── gradle.properties
│ │ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ │ ├── gradlew
│ │ ├── gradlew.bat
│ │ └── settings.gradle
└── module12
│ └── HelloMiniReed
│ ├── .gitignore
│ ├── .idea
│ ├── compiler.xml
│ ├── copyright
│ │ └── profiles_settings.xml
│ ├── gradle.xml
│ ├── inspectionProfiles
│ │ ├── Project_Default.xml
│ │ └── profiles_settings.xml
│ ├── misc.xml
│ ├── modules.xml
│ └── runConfigurations.xml
│ ├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── net
│ │ │ └── macdidi5
│ │ │ └── at
│ │ │ └── hellominireed
│ │ │ └── ExampleInstrumentedTest.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── net
│ │ │ │ └── macdidi5
│ │ │ │ └── at
│ │ │ │ └── hellominireed
│ │ │ │ └── MainActivity.java
│ │ └── res
│ │ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ └── values
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── test
│ │ └── java
│ │ └── net
│ │ └── macdidi5
│ │ └── at
│ │ └── hellominireed
│ │ └── ExampleUnitTest.java
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── projects
├── ThingsCommander
│ ├── .gitignore
│ ├── .idea
│ │ ├── compiler.xml
│ │ ├── copyright
│ │ │ └── profiles_settings.xml
│ │ ├── gradle.xml
│ │ ├── misc.xml
│ │ ├── modules.xml
│ │ └── runConfigurations.xml
│ ├── app
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ ├── google-services.json
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ ├── androidTest
│ │ │ └── java
│ │ │ │ └── net
│ │ │ │ └── macdidi5
│ │ │ │ └── at
│ │ │ │ └── thingscommander
│ │ │ │ └── ExampleInstrumentedTest.java
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ │ └── net
│ │ │ │ │ └── macdidi5
│ │ │ │ │ └── at
│ │ │ │ │ └── thingscommander
│ │ │ │ │ ├── Camera.java
│ │ │ │ │ ├── ChildEventListenerAdapter.java
│ │ │ │ │ ├── Device.java
│ │ │ │ │ ├── GpioContainer.java
│ │ │ │ │ ├── MCP3008.java
│ │ │ │ │ ├── MainActivity.java
│ │ │ │ │ ├── PiGPIO.java
│ │ │ │ │ ├── PiPWM.java
│ │ │ │ │ └── Screen.java
│ │ │ └── res
│ │ │ │ ├── drawable
│ │ │ │ ├── ic_add_a_photo_white.png
│ │ │ │ ├── ic_eye_center.png
│ │ │ │ ├── ic_eye_left.png
│ │ │ │ ├── ic_eye_right.png
│ │ │ │ ├── ic_hello.png
│ │ │ │ ├── ic_lightbulb_outline_white.png
│ │ │ │ ├── ic_lock_open_white.png
│ │ │ │ ├── ic_lock_white.png
│ │ │ │ ├── ic_settings_white.png
│ │ │ │ └── ic_warning_white.png
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ └── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ └── test
│ │ │ └── java
│ │ │ └── net
│ │ │ └── macdidi5
│ │ │ └── at
│ │ │ └── thingscommander
│ │ │ └── ExampleUnitTest.java
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
└── ThingsCommanderApp
│ ├── .gitignore
│ ├── .idea
│ ├── compiler.xml
│ ├── copyright
│ │ └── profiles_settings.xml
│ ├── gradle.xml
│ ├── misc.xml
│ ├── modules.xml
│ └── runConfigurations.xml
│ ├── app
│ ├── .gitignore
│ ├── build.gradle
│ ├── google-services.json
│ ├── libs
│ │ └── enzo-release-1.9.aar
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── net
│ │ │ └── macdidi5
│ │ │ └── at
│ │ │ └── thingscommanderapp
│ │ │ └── ExampleInstrumentedTest.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── net
│ │ │ │ └── macdidi5
│ │ │ │ └── at
│ │ │ │ ├── dynamicgrid
│ │ │ │ ├── AbstractDynamicGridAdapter.java
│ │ │ │ ├── BaseDynamicGridAdapter.java
│ │ │ │ ├── DynamicGridAdapterInterface.java
│ │ │ │ ├── DynamicGridUtils.java
│ │ │ │ └── DynamicGridView.java
│ │ │ │ └── thingscommanderapp
│ │ │ │ ├── ChildEventListenerAdapter.java
│ │ │ │ ├── CommanderItem.java
│ │ │ │ ├── Device.java
│ │ │ │ ├── DeviceAdapter.java
│ │ │ │ ├── ItemActivity.java
│ │ │ │ ├── ItemListenActivity.java
│ │ │ │ ├── ListenService.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── PiGPIO.java
│ │ │ │ ├── PiViewPager.java
│ │ │ │ ├── SpacesItemDecoration.java
│ │ │ │ ├── SpeedometerView.java
│ │ │ │ └── TurtleUtil.java
│ │ └── res
│ │ │ ├── drawable
│ │ │ ├── background_dialog.xml
│ │ │ ├── background_disable.xml
│ │ │ ├── background_enable.xml
│ │ │ ├── background_item.xml
│ │ │ ├── bg_connected.png
│ │ │ ├── bg_disconnected.png
│ │ │ ├── ic_add_circle_outline_white_48dp.png
│ │ │ ├── ic_apps_black_48dp.png
│ │ │ ├── ic_apps_white_48dp.png
│ │ │ ├── ic_cloud_done_white_48dp.png
│ │ │ ├── ic_cloud_queue_white_48dp.png
│ │ │ ├── ic_lock_open_white_48dp.png
│ │ │ ├── ic_lock_white_48dp.png
│ │ │ ├── notify_big_picture.jpg
│ │ │ ├── notify_icon.png
│ │ │ └── spot_mask.png
│ │ │ ├── layout
│ │ │ ├── activity_item.xml
│ │ │ ├── activity_item_listen.xml
│ │ │ ├── activity_main.xml
│ │ │ ├── commander_item.xml
│ │ │ ├── device_item.xml
│ │ │ ├── fragment_commander.xml
│ │ │ ├── fragment_device.xml
│ │ │ ├── fragment_monitor.xml
│ │ │ ├── monitor_item.xml
│ │ │ └── select_gpio_view.xml
│ │ │ ├── menu
│ │ │ └── menu_main.xml
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── values-w820dp
│ │ │ └── dimens.xml
│ │ │ └── values
│ │ │ ├── app_info.xml
│ │ │ ├── attrs.xml
│ │ │ ├── colors.xml
│ │ │ ├── dimens.xml
│ │ │ ├── ids.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── test
│ │ └── java
│ │ └── net
│ │ └── macdidi5
│ │ └── at
│ │ └── thingscommanderapp
│ │ └── ExampleUnitTest.java
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
└── resources
└── thingscommander-f3f74-export.json
/README.md:
--------------------------------------------------------------------------------
1 | # Android Things Tutorial
2 |
3 | 從2016年12月開始,Android開發人員多了一個新的選擇:[Android Things](https://developer.android.com/things/index.html)。網頁裡面很豪邁的告訴你「If you can build an app, you can build a device」,它說的是如果你可以開發Android app,你也可以開發與設計Android設備。這些設備包含智慧家庭、自動化與各種嵌入式設備,它們運作的是Android Things作業系統,你可以使用Android Studio開發一個Android Things App,把App安裝到這些設備並運作以後,就可以執行各種與硬體的控制,例如控制電燈與馬達,還有讀取溫度與光線資訊。
4 |
5 | 對Android開發人員來說,想要進入嵌入式應用程式與物聯網的領域,這是一個最好的作業系統與開發平台。
6 |
7 | 專欄目錄:
8 |
9 | 1. [Android Things Tutorial(一)Hello! Android Things!](http://www.codedata.com.tw/java/att01/)
10 | 2. [Android Things Tutorial(二)建立Android Things開發與執行環境](http://www.codedata.com.tw/java/att02/)
11 | 3. [Android Things Tutorial(三)建立Android Things作業系統](http://www.codedata.com.tw/java/att03/)
12 | 4. [Android Things Tutorial(四)啟動與設定Android Things作業系統](http://www.codedata.com.tw/java/att04/)
13 | 5. [Android Things Tutorial(五)使用Android ADB工具管理Android Things](http://www.codedata.com.tw/java/att05/)
14 | 6. [Android Things Tutorial(六)第一個Android Things應用程式](http://www.codedata.com.tw/java/att06/)
15 | 7. [Android Things Tutorial(七)認識Raspberry Pi的GPIO與基本零件](http://www.codedata.com.tw/java/att07/)
16 | 8. [Android Things Tutorial(八)GPIO輸出 - LED](http://www.codedata.com.tw/java/att08/)
17 | 9. [Android Things Tutorial(九)GPIO輸出 - 七段顯示器](http://www.codedata.com.tw/java/att09/)
18 | 10. [Android Things Tutorial(十)GPIO輸出 - 繼電器模組](http://www.codedata.com.tw/java/att10/)
19 | 11. [Android Things Tutorial(十一)GPIO輸入 - 開關](http://www.codedata.com.tw/java/att11/)
20 | 12. [Android Things Tutorial(十二)GPIO輸入 - 磁簧開關模組](http://www.codedata.com.tw/java/att12/)
21 | 13. Android Things Tutorial(十三)GPIO輸出入整合應用 - 雷射光接收模組
22 | 14. Android Things Tutorial(十四)GPIO輸出入整合應用 - 超音波測距模組
23 | 15. Android Things Tutorial(十五)數位類比轉換器MCP3008
24 | 16. Android Things Tutorial(十四)數位類比轉換器 - 可變電阻與光敏電阻
25 | 17. Android Things Tutorial(十五)數位類比轉換器 - MQ2氣體感測模組
26 | 18. Android Things Tutorial(十六)IIC - 三軸感應模組MMA7660FC
27 | 19. Android Things Tutorial(十七)IIC - 環境感應器BMP280
28 | 20. Android Things Tutorial(十八)IIC - 單色顯示器SSD1306
29 | 21. Android Things Tutorial(十九)遠端監控系統 I - 使用Firebase即時資料庫
30 | 22. Android Things Tutorial(二十)遠端監控系統 II - 控制
31 | 23. Android Things Tutorial(二十一)遠端監控系統 III - 監聽
32 | 24. Android Things Tutorial(二十二)整合應用 - ThingsCommander
33 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "net.macdidi5.at.helloandroidthings"
8 | minSdkVersion 24
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | testCompile 'junit:junit:4.12'
28 |
29 | provided 'com.google.android.things:androidthings:0.3-devpreview'
30 | }
31 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/MichaelChang/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/src/androidTest/java/net/macdidi5/at/helloandroidthings/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.helloandroidthings;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("net.macdidi5.at.helloandroidthings", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/src/main/java/net/macdidi5/at/helloandroidthings/MainActivity.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.helloandroidthings;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 |
7 | import java.util.Properties;
8 |
9 | public class MainActivity extends Activity {
10 |
11 | private static final String TAG = MainActivity.class.getSimpleName();
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | Log.d(TAG, "onCreate");
17 |
18 | Properties ps = System.getProperties();
19 | Log.d(TAG, "os.name: " + ps.getProperty("os.name"));
20 | Log.d(TAG, "os.arch: " + ps.getProperty("os.arch"));
21 | }
22 |
23 | @Override
24 | protected void onDestroy() {
25 | super.onDestroy();
26 | Log.d(TAG, "onDestroy");
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module06/HelloAndroidThings/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Hello Android Things
3 |
4 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/app/src/test/java/net/macdidi5/at/helloandroidthings/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.helloandroidthings;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module06/HelloAndroidThings/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 12 19:17:33 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/examples/module06/HelloAndroidThings/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "net.macdidi5.at.helloled"
8 | minSdkVersion 24
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | testCompile 'junit:junit:4.12'
28 |
29 | provided 'com.google.android.things:androidthings:0.3-devpreview'
30 | }
31 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/MichaelChang/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/app/src/androidTest/java/net/macdidi5/at/helloled/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.helloled;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("net.macdidi5.at.helloled", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/app/src/main/java/net/macdidi5/at/helloled/MainActivity.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.helloled;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.os.Handler;
6 | import android.util.Log;
7 |
8 | import com.google.android.things.pio.Gpio;
9 | import com.google.android.things.pio.PeripheralManagerService;
10 |
11 | import java.io.IOException;
12 |
13 | public class MainActivity extends Activity {
14 |
15 | private static final String TAG = MainActivity.class.getSimpleName();
16 |
17 | // 控制LED閃爍的Handler物件
18 | private Handler ledHandler = new Handler();
19 | // 連接LED的GPIO物件
20 | private Gpio ledGpio;
21 | // 連接LED的GPIO pin
22 | private final String PIN_NAME = "BCM23";
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 |
28 | Log.i(TAG, "onCreate");
29 |
30 | // 建立設備管理員服物物件
31 | PeripheralManagerService service = new PeripheralManagerService();
32 |
33 | try {
34 | // 建立GPIO物件
35 | ledGpio = service.openGpio(PIN_NAME);
36 | // 設定GPIO為輸出模式,預設為低電壓
37 | ledGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
38 |
39 | // 啟動控制LED閃爍的Handler物件
40 | ledHandler.post(ledRunnable);
41 | }
42 | catch (IOException e) {
43 | Log.e(TAG, e.toString());
44 | }
45 | }
46 |
47 | @Override
48 | protected void onDestroy() {
49 | super.onDestroy();
50 |
51 | Log.i(TAG, "onDestroy");
52 |
53 | // 移除控制LED閃爍的Handler物件
54 | ledHandler.removeCallbacks(ledRunnable);
55 |
56 | try {
57 | // 關閉GPIO物件
58 | ledGpio.close();
59 | }
60 | catch (IOException e) {
61 | Log.e(TAG, e.toString());
62 | }
63 | finally {
64 | ledGpio = null;
65 | }
66 | }
67 |
68 | // 控制LED閃爍的Handler物件
69 | private Runnable ledRunnable = new Runnable() {
70 | @Override
71 | public void run() {
72 | if (ledGpio == null) {
73 | return;
74 | }
75 |
76 | try {
77 | // 設定GPIO狀態
78 | ledGpio.setValue(!ledGpio.getValue());
79 | Log.i(TAG, "LED: " + (ledGpio.getValue() ? "ON" : "OFF"));
80 | // 1秒以後重複執行
81 | ledHandler.postDelayed(ledRunnable, 1000);
82 | }
83 | catch (IOException e) {
84 | Log.e(TAG, e.toString());
85 | }
86 | }
87 | };
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module08/HelloLED/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module08/HelloLED/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module08/HelloLED/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module08/HelloLED/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module08/HelloLED/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module08/HelloLED/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module08/HelloLED/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module08/HelloLED/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module08/HelloLED/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module08/HelloLED/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | HelloLED
3 |
4 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/app/src/test/java/net/macdidi5/at/helloled/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.helloled;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/examples/module08/HelloLED/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.3'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module08/HelloLED/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/examples/module08/HelloLED/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/examples/module08/HelloLED/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "net.macdidi5.at.hellosevensegment"
8 | minSdkVersion 24
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | testCompile 'junit:junit:4.12'
28 |
29 | provided 'com.google.android.things:androidthings:0.3-devpreview'
30 | }
31 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/MichaelChang/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/src/androidTest/java/net/macdidi5/at/hellosevensegment/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.hellosevensegment;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("net.macdidi5.at.hellosevensegment", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/src/main/java/net/macdidi5/at/hellosevensegment/DisplayMap.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.hellosevensegment;
2 |
3 | public class DisplayMap {
4 |
5 | // 共陰極數字與顯示器針腳對照表
6 | public static final int[][] COMMON_CATHODE = {
7 | // a, b, c, d, e, f, g
8 | {1, 1, 1, 1, 1, 1, 0}, // 0
9 | {0, 1, 1, 0, 0, 0, 0}, // 1
10 | {1, 1, 0, 1, 1, 0, 1}, // 2
11 | {1, 1, 1, 1, 0, 0, 1}, // 3
12 | {0, 1, 1, 0, 0, 1, 1}, // 4
13 | {1, 0, 1, 1, 0, 1, 1}, // 5
14 | {0, 0, 1, 1, 1, 1, 1}, // 6
15 | {1, 1, 1, 0, 0, 0, 0}, // 7
16 | {1, 1, 1, 1, 1, 1, 1}, // 8
17 | {1, 1, 1, 0, 0, 1, 1} // 9
18 | };
19 |
20 | // 共陽極數字與顯示器針腳對照表
21 | public static final int[][] COMMON_ANODE = {
22 | // a, b, c, d, e, f, g
23 | {0, 0, 0, 0, 0, 0, 1}, // 0
24 | {1, 0, 0, 1, 1, 1, 1}, // 1
25 | {0, 0, 1, 0, 0, 1, 0}, // 2
26 | {0, 0, 0, 0, 1, 1, 0}, // 3
27 | {1, 0, 0, 1, 1, 0, 0}, // 4
28 | {0, 1, 0, 0, 1, 0, 0}, // 5
29 | {1, 1, 0, 0, 0, 0, 0}, // 6
30 | {0, 0, 0, 1, 1, 1, 1}, // 7
31 | {0, 0, 0, 0, 0, 0, 0}, // 8
32 | {0, 0, 0, 1, 1, 0, 0} // 9
33 | };
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module09/HelloSevenSegment/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | HelloSevenSegment
3 |
4 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/app/src/test/java/net/macdidi5/at/hellosevensegment/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.hellosevensegment;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module09/HelloSevenSegment/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Apr 27 23:49:00 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/examples/module09/HelloSevenSegment/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "net.macdidi5.at.hellorelay"
8 | minSdkVersion 24
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | testCompile 'junit:junit:4.12'
28 |
29 | provided 'com.google.android.things:androidthings:0.3-devpreview'
30 | }
31 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/MichaelChang/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/src/androidTest/java/net/macdidi5/at/hellorelay/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.hellorelay;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("net.macdidi5.at.hellorelay", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/src/main/java/net/macdidi5/at/hellorelay/MainActivity.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.hellorelay;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.os.Handler;
6 | import android.util.Log;
7 |
8 | import com.google.android.things.pio.Gpio;
9 | import com.google.android.things.pio.PeripheralManagerService;
10 |
11 | import java.io.IOException;
12 |
13 | public class MainActivity extends Activity {
14 |
15 | private static final String TAG = MainActivity.class.getSimpleName();
16 |
17 | // 控制繼電器的Handler物件
18 | private Handler relayHandler = new Handler();
19 | // 連接繼電器的GPIO物件
20 | private Gpio relayGpio;
21 | // 連接繼電器的GPIO pin
22 | private final String PIN_NAME = "BCM23";
23 |
24 | @Override
25 | protected void onCreate(Bundle savedInstanceState) {
26 | super.onCreate(savedInstanceState);
27 |
28 | Log.i(TAG, "onCreate");
29 |
30 | // 建立設備管理員服物物件
31 | PeripheralManagerService service = new PeripheralManagerService();
32 |
33 | try {
34 | // 建立GPIO物件
35 | relayGpio = service.openGpio(PIN_NAME);
36 | // 設定GPIO為輸出模式,預設為低電壓
37 | relayGpio.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
38 |
39 | // 啟動控制繼電器的Handler物件
40 | relayHandler.post(relayRunnable);
41 | }
42 | catch (IOException e) {
43 | Log.e(TAG, e.toString());
44 | }
45 | }
46 |
47 | @Override
48 | protected void onDestroy() {
49 | super.onDestroy();
50 |
51 | Log.i(TAG, "onDestroy");
52 |
53 | // 移除控制繼電器的Handler物件
54 | relayHandler.removeCallbacks(relayRunnable);
55 |
56 | try {
57 | // 關閉GPIO物件
58 | relayGpio.close();
59 | }
60 | catch (IOException e) {
61 | Log.e(TAG, e.toString());
62 | }
63 | finally {
64 | relayGpio = null;
65 | }
66 | }
67 |
68 | // 控制繼電器的Handler物件
69 | private Runnable relayRunnable = new Runnable() {
70 | @Override
71 | public void run() {
72 | if (relayGpio == null) {
73 | return;
74 | }
75 |
76 | try {
77 | // 設定GPIO狀態
78 | relayGpio.setValue(!relayGpio.getValue());
79 | Log.i(TAG, "Relay: " + (relayGpio.getValue() ? "ON" : "OFF"));
80 | // 1秒以後重複執行
81 | relayHandler.postDelayed(relayRunnable, 1000);
82 | }
83 | catch (IOException e) {
84 | Log.e(TAG, e.toString());
85 | }
86 | }
87 | };
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module10/HelloRelay/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module10/HelloRelay/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module10/HelloRelay/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module10/HelloRelay/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module10/HelloRelay/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module10/HelloRelay/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module10/HelloRelay/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module10/HelloRelay/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module10/HelloRelay/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module10/HelloRelay/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | HelloRelay
3 |
4 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/app/src/test/java/net/macdidi5/at/hellorelay/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.hellorelay;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module10/HelloRelay/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Apr 28 11:22:18 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/examples/module10/HelloRelay/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "net.macdidi5.at.hellobutton"
8 | minSdkVersion 24
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | testCompile 'junit:junit:4.12'
28 |
29 | provided 'com.google.android.things:androidthings:0.3-devpreview'
30 | }
31 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/MichaelChang/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/app/src/androidTest/java/net/macdidi5/at/hellobutton/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.hellobutton;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("net.macdidi5.at.hellobutton", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module11/HelloButton/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module11/HelloButton/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module11/HelloButton/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module11/HelloButton/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module11/HelloButton/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module11/HelloButton/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module11/HelloButton/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module11/HelloButton/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module11/HelloButton/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module11/HelloButton/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | HelloButton
3 |
4 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/app/src/test/java/net/macdidi5/at/hellobutton/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.hellobutton;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/examples/module11/HelloButton/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.3'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module11/HelloButton/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/examples/module11/HelloButton/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/examples/module11/HelloButton/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "net.macdidi5.at.hellominireed"
8 | minSdkVersion 24
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | testCompile 'junit:junit:4.12'
28 |
29 | provided 'com.google.android.things:androidthings:0.3-devpreview'
30 | }
31 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/MichaelChang/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/src/androidTest/java/net/macdidi5/at/hellominireed/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.hellominireed;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("net.macdidi5.at.hellominireed", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module12/HelloMiniReed/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module12/HelloMiniReed/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module12/HelloMiniReed/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module12/HelloMiniReed/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module12/HelloMiniReed/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module12/HelloMiniReed/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module12/HelloMiniReed/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module12/HelloMiniReed/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module12/HelloMiniReed/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module12/HelloMiniReed/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | HelloMiniReed
3 |
4 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/app/src/test/java/net/macdidi5/at/hellominireed/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.hellominireed;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/examples/module12/HelloMiniReed/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu May 11 16:14:21 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/examples/module12/HelloMiniReed/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 24
5 | buildToolsVersion "24.0.3"
6 | defaultConfig {
7 | applicationId "net.macdidi5.at.thingscommander"
8 | minSdkVersion 24
9 | targetSdkVersion 24
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | testCompile 'junit:junit:4.12'
28 |
29 | provided 'com.google.android.things:androidthings:0.2-devpreview'
30 | compile 'com.google.android.things.contrib:driver-ssd1306:0.2'
31 | compile 'com.google.android.things.contrib:driver-bmx280:0.1'
32 | compile 'com.google.android.things.contrib:driver-pwmservo:0.1'
33 |
34 | compile 'com.google.firebase:firebase-core:9.4.0'
35 | compile 'com.google.firebase:firebase-database:9.4.0'
36 | }
37 |
38 | apply plugin: 'com.google.gms.google-services'
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/google-services.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_info": {
3 | "project_number": "405901711753",
4 | "firebase_url": "https://thingscommander-f3f74.firebaseio.com",
5 | "project_id": "thingscommander-f3f74",
6 | "storage_bucket": "thingscommander-f3f74.appspot.com"
7 | },
8 | "client": [
9 | {
10 | "client_info": {
11 | "mobilesdk_app_id": "1:405901711753:android:381abbf53702315a",
12 | "android_client_info": {
13 | "package_name": "net.macdidi5.at.thingscommander"
14 | }
15 | },
16 | "oauth_client": [
17 | {
18 | "client_id": "405901711753-27ua5tmje2dav58e5kjm0k2rp0l66t2f.apps.googleusercontent.com",
19 | "client_type": 1,
20 | "android_info": {
21 | "package_name": "net.macdidi5.at.thingscommander",
22 | "certificate_hash": "EF2A3810EE94CACEA0CBB7167163F7895E2A3F4C"
23 | }
24 | },
25 | {
26 | "client_id": "405901711753-t8m1t6533d112kvr337oe9blfu6cn6ns.apps.googleusercontent.com",
27 | "client_type": 3
28 | }
29 | ],
30 | "api_key": [
31 | {
32 | "current_key": "AIzaSyAQfudDp5YFWoedBZOurY2_rKzujmLNehQ"
33 | }
34 | ],
35 | "services": {
36 | "analytics_service": {
37 | "status": 1
38 | },
39 | "appinvite_service": {
40 | "status": 2,
41 | "other_platform_oauth_client": [
42 | {
43 | "client_id": "405901711753-t8m1t6533d112kvr337oe9blfu6cn6ns.apps.googleusercontent.com",
44 | "client_type": 3
45 | }
46 | ]
47 | },
48 | "ads_service": {
49 | "status": 2
50 | }
51 | }
52 | }
53 | ],
54 | "configuration_version": "1"
55 | }
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/MichaelChang/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/androidTest/java/net/macdidi5/at/thingscommander/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.thingscommander;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("net.macdidi5.at.thingscommander", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/java/net/macdidi5/at/thingscommander/ChildEventListenerAdapter.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.thingscommander;
2 |
3 | import com.google.firebase.database.ChildEventListener;
4 | import com.google.firebase.database.DataSnapshot;
5 | import com.google.firebase.database.DatabaseError;
6 |
7 | // Firebase ChildEventListener 包裝類別
8 | public class ChildEventListenerAdapter implements ChildEventListener {
9 |
10 | @Override
11 | public void onChildAdded(DataSnapshot ds, String previousChildKey) { }
12 |
13 | @Override
14 | public void onChildChanged(DataSnapshot ds, String previousChildKey) { }
15 |
16 | @Override
17 | public void onChildRemoved(DataSnapshot ds) { }
18 |
19 | @Override
20 | public void onChildMoved(DataSnapshot ds, String previousChildKey) { }
21 |
22 | @Override
23 | public void onCancelled(DatabaseError de) { }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/java/net/macdidi5/at/thingscommander/Device.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.thingscommander;
2 |
3 | public class Device {
4 |
5 | // 代號, 名稱, 值, 遞增, 精確度, 通道
6 | private String id;
7 | private String name;
8 | private float value;
9 | private boolean isIncrememt;
10 | private int accuracy;
11 | private int channel;
12 |
13 | public Device() {
14 | this("", "", 0.0F, false, 0, 0);
15 | }
16 |
17 | public Device(String id, String name, float value,
18 | boolean isIncrememt, int accuracy, int channel) {
19 | this.id = id;
20 | this.name = name;
21 | this.value = value;
22 | this.isIncrememt = isIncrememt;
23 | this.accuracy = accuracy;
24 | this.channel = channel;
25 | }
26 |
27 | public String getId() {
28 | return id;
29 | }
30 |
31 | public void setId(String id) {
32 | this.id = id;
33 | }
34 |
35 | public String getName() {
36 | return name;
37 | }
38 |
39 | public void setName(String name) {
40 | this.name = name;
41 | }
42 |
43 | public float getValue() {
44 | return value;
45 | }
46 |
47 | public void setValue(float value) {
48 | this.value = value;
49 | }
50 |
51 | public boolean isIsIncrememt() {
52 | return isIncrememt;
53 | }
54 |
55 | public void setIsIncrememt(boolean isIncrememt) {
56 | this.isIncrememt = isIncrememt;
57 | }
58 |
59 | public int getAccuracy() {
60 | return accuracy;
61 | }
62 |
63 | public void setAccuracy(int accuracy) {
64 | this.accuracy = accuracy;
65 | }
66 |
67 | public int getChannel() {
68 | return channel;
69 | }
70 |
71 | public void setChannel(int channel) {
72 | this.channel = channel;
73 | }
74 |
75 | @Override
76 | public String toString() {
77 | return "Device{" + "id=" + id + ", name=" + name +
78 | ", value=" + value + ", isIncrememt=" + isIncrememt +
79 | ", accuracy=" + accuracy + ", channel=" + channel + '}';
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/java/net/macdidi5/at/thingscommander/GpioContainer.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.thingscommander;
2 |
3 | import com.google.android.things.pio.Gpio;
4 | import com.google.android.things.pio.PeripheralManagerService;
5 |
6 | import java.io.IOException;
7 | import java.util.HashMap;
8 | import java.util.List;
9 | import java.util.Map;
10 |
11 | public class GpioContainer {
12 |
13 | private PeripheralManagerService service;
14 | private final Map pins;
15 | private final List portList;
16 |
17 | public GpioContainer(PeripheralManagerService service) {
18 | this.service = service;
19 | pins = new HashMap<>();
20 | portList = service.getGpioList();
21 | }
22 |
23 | // GPIO 物件是否已經存在
24 | public boolean isExist(PiGPIO pin) {
25 | Gpio result = pins.get(pin);
26 | return !(result == null);
27 | }
28 |
29 | // 建立或取得保存中的 GPIO 物件
30 | public Gpio getPin(PiGPIO pin) throws IOException {
31 | if (portList.indexOf(pin.name()) == -1) {
32 | return null;
33 | }
34 |
35 | // 取得保存中的 GPIO 物件
36 | Gpio result = pins.get(pin);
37 |
38 | // 如果不存在
39 | if (result == null) {
40 | result = service.openGpio(pin.name());
41 | result.setDirection(Gpio.DIRECTION_OUT_INITIALLY_LOW);
42 | pins.put(pin, result);
43 | }
44 |
45 | return result;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/java/net/macdidi5/at/thingscommander/PiGPIO.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.thingscommander;
2 |
3 | public enum PiGPIO {
4 |
5 | BCM4, BCM12, BCM16,
6 | BCM17, BCM20, BCM21,BCM22,
7 | BCM23, BCM24, BCM25, BCM27;
8 |
9 | // BCM4, BCM5, BCM6, BCM12, BCM16,
10 | // BCM17, BCM19, BCM20, BCM21,BCM22,
11 | // BCM23, BCM24, BCM25, BCM26, BCM27;
12 |
13 |
14 | public static PiGPIO getPiGPIO(String pinName) {
15 | final PiGPIO[] ps = values();
16 |
17 | for (PiGPIO p : ps) {
18 | if (p.name().equals(pinName)) {
19 | return p;
20 | }
21 | }
22 |
23 | return null;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/java/net/macdidi5/at/thingscommander/PiPWM.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.thingscommander;
2 |
3 | public enum PiPWM {
4 |
5 | PWM0, PWM1;
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/res/drawable/ic_add_a_photo_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/projects/ThingsCommander/app/src/main/res/drawable/ic_add_a_photo_white.png
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/res/drawable/ic_eye_center.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/projects/ThingsCommander/app/src/main/res/drawable/ic_eye_center.png
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/res/drawable/ic_eye_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/projects/ThingsCommander/app/src/main/res/drawable/ic_eye_left.png
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/res/drawable/ic_eye_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/projects/ThingsCommander/app/src/main/res/drawable/ic_eye_right.png
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/res/drawable/ic_hello.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/projects/ThingsCommander/app/src/main/res/drawable/ic_hello.png
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/res/drawable/ic_lightbulb_outline_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/projects/ThingsCommander/app/src/main/res/drawable/ic_lightbulb_outline_white.png
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/res/drawable/ic_lock_open_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/projects/ThingsCommander/app/src/main/res/drawable/ic_lock_open_white.png
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/res/drawable/ic_lock_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/projects/ThingsCommander/app/src/main/res/drawable/ic_lock_white.png
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/res/drawable/ic_settings_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/projects/ThingsCommander/app/src/main/res/drawable/ic_settings_white.png
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/res/drawable/ic_warning_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/projects/ThingsCommander/app/src/main/res/drawable/ic_warning_white.png
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/projects/ThingsCommander/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/projects/ThingsCommander/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/projects/ThingsCommander/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/projects/ThingsCommander/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/projects/ThingsCommander/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ThingsCommander
3 |
4 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/app/src/test/java/net/macdidi5/at/thingscommander/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.thingscommander;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/projects/ThingsCommander/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.3'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | classpath 'com.google.gms:google-services:3.0.0'
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | jcenter()
19 | }
20 | }
21 |
22 | task clean(type: Delete) {
23 | delete rootProject.buildDir
24 | }
25 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/projects/ThingsCommander/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/projects/ThingsCommander/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/projects/ThingsCommander/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/projects/ThingsCommanderApp/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/projects/ThingsCommanderApp/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/projects/ThingsCommanderApp/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/projects/ThingsCommanderApp/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/projects/ThingsCommanderApp/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/projects/ThingsCommanderApp/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/projects/ThingsCommanderApp/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/projects/ThingsCommanderApp/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/projects/ThingsCommanderApp/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "net.macdidi5.at.thingscommanderapp"
8 | minSdkVersion 21
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.1.1'
28 | testCompile 'junit:junit:4.12'
29 |
30 | compile 'com.google.firebase:firebase-core:9.4.0'
31 | compile 'com.google.firebase:firebase-database:9.4.0'
32 |
33 | compile 'com.android.support:design:25.1.1'
34 | compile(name:'enzo-release-1.9', ext:'aar')
35 | compile 'com.android.support:multidex:1.0.0'
36 | compile 'com.jjoe64:graphview:4.1.0'
37 | compile 'com.android.support:recyclerview-v7:25.1.1'
38 | compile 'com.android.support:cardview-v7:25.1.1'
39 | }
40 |
41 | repositories{
42 | flatDir{
43 | dirs 'libs'
44 | }
45 | }
46 |
47 | apply plugin: 'com.google.gms.google-services'
--------------------------------------------------------------------------------
/projects/ThingsCommanderApp/app/libs/enzo-release-1.9.aar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/macdidi5/Android-Things-Tutorial/412bd11dfc0809db9c1a9307474b3dbbcdce18ce/projects/ThingsCommanderApp/app/libs/enzo-release-1.9.aar
--------------------------------------------------------------------------------
/projects/ThingsCommanderApp/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/MichaelChang/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/projects/ThingsCommanderApp/app/src/androidTest/java/net/macdidi5/at/thingscommanderapp/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.thingscommanderapp;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("net.macdidi5.at.thingscommanderapp", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/projects/ThingsCommanderApp/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
38 |
39 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/projects/ThingsCommanderApp/app/src/main/java/net/macdidi5/at/dynamicgrid/AbstractDynamicGridAdapter.java:
--------------------------------------------------------------------------------
1 | package net.macdidi5.at.dynamicgrid;
2 |
3 | import android.widget.BaseAdapter;
4 |
5 | import java.util.HashMap;
6 | import java.util.List;
7 |
8 | public abstract class AbstractDynamicGridAdapter extends BaseAdapter implements DynamicGridAdapterInterface {
9 | public static final int INVALID_ID = -1;
10 |
11 | private int nextStableId = 0;
12 |
13 | private HashMap