├── .editorconfig ├── .gitignore ├── .gitmodules ├── .travis.yml ├── CONTRIBUTING.md ├── CONTRIBUTORS ├── LICENSE ├── README.md ├── android ├── LICENSE ├── PhysicalWeb │ ├── .gitignore │ ├── app │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── config │ │ │ ├── checkstyle │ │ │ │ ├── checkstyle.xml │ │ │ │ └── suppressions.xml │ │ │ ├── findbugs │ │ │ │ └── exclude-filter.xml │ │ │ └── pmd │ │ │ │ └── pmd-ruleset.xml │ │ ├── libs │ │ │ ├── uribeacon-library-release.aar │ │ │ └── volley.aar │ │ ├── manifest-merger-release-report.txt │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── androidTest │ │ │ └── java │ │ │ │ └── org │ │ │ │ └── physical_web │ │ │ │ └── physicalweb │ │ │ │ ├── ApplicationTest.java │ │ │ │ └── BeaconDisplayListTest.java │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ │ └── org │ │ │ │ │ └── physical_web │ │ │ │ │ ├── demos │ │ │ │ │ ├── Demo.java │ │ │ │ │ ├── FatBeaconHelloWorld.java │ │ │ │ │ └── WifiDirectHelloWorld.java │ │ │ │ │ └── physicalweb │ │ │ │ │ ├── AboutFragment.java │ │ │ │ │ ├── AutostartPwoDiscoveryServiceReceiver.java │ │ │ │ │ ├── BleUrlDeviceDiscoverer.java │ │ │ │ │ ├── BlockedFragment.java │ │ │ │ │ ├── BluetoothSite.java │ │ │ │ │ ├── BroadcastActivity.java │ │ │ │ │ ├── ConnectionListener.java │ │ │ │ │ ├── DemosFragment.java │ │ │ │ │ ├── FatBeaconBroadcastService.java │ │ │ │ │ ├── FileBroadcastServer.java │ │ │ │ │ ├── FileBroadcastService.java │ │ │ │ │ ├── Log.java │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ ├── MdnsUrlDeviceDiscoverer.java │ │ │ │ │ ├── NearbyBeaconsFragment.java │ │ │ │ │ ├── OfflineTransportConnectionActivity.java │ │ │ │ │ ├── OobActivity.java │ │ │ │ │ ├── PermissionCheck.java │ │ │ │ │ ├── PhysicalWebBroadcastService.java │ │ │ │ │ ├── ScreenListenerService.java │ │ │ │ │ ├── SettingsFragment.java │ │ │ │ │ ├── SsdpUrlDeviceDiscoverer.java │ │ │ │ │ ├── SwipeDismissListViewTouchListener.java │ │ │ │ │ ├── SwipeRefreshWidget.java │ │ │ │ │ ├── UrlDeviceDiscoverer.java │ │ │ │ │ ├── UrlDeviceDiscoveryService.java │ │ │ │ │ ├── UrlShortenerClient.java │ │ │ │ │ ├── Utils.java │ │ │ │ │ ├── WifiDirectConnect.java │ │ │ │ │ ├── WifiUrlDeviceDiscoverer.java │ │ │ │ │ ├── ble │ │ │ │ │ ├── AdvertiseDataUtils.java │ │ │ │ │ ├── BluetoothUuid.java │ │ │ │ │ ├── ScanRecord.java │ │ │ │ │ └── Utils.java │ │ │ │ │ └── ssdp │ │ │ │ │ ├── Ssdp.java │ │ │ │ │ └── SsdpMessage.java │ │ │ └── res │ │ │ │ ├── animator │ │ │ │ ├── fade_in_activity.xml │ │ │ │ ├── fade_in_and_slide_up_fragment.xml │ │ │ │ └── fade_out_fragment.xml │ │ │ │ ├── drawable-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── unresolved_result_icon.png │ │ │ │ ├── drawable-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── unresolved_result_icon.png │ │ │ │ ├── drawable-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── unresolved_result_icon.png │ │ │ │ ├── drawable-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_notification.png │ │ │ │ ├── ic_scanning_0.png │ │ │ │ ├── ic_scanning_1.png │ │ │ │ ├── ic_scanning_2.png │ │ │ │ ├── menu_item_background.9.png │ │ │ │ ├── scanning_animation.xml │ │ │ │ ├── settings_xxhdpi.png │ │ │ │ └── unresolved_result_icon.png │ │ │ │ ├── drawable-xxxhdpi │ │ │ │ ├── ic_leak_add_white_24dp.png │ │ │ │ └── unresolved_result_icon.png │ │ │ │ ├── drawable │ │ │ │ ├── ic_star_black_24dp.xml │ │ │ │ └── ic_star_border_black_24dp.xml │ │ │ │ ├── layout │ │ │ │ ├── activity_main.xml │ │ │ │ ├── activity_oob.xml │ │ │ │ ├── folder_item_nearby_beacon.xml │ │ │ │ ├── fragment_about.xml │ │ │ │ ├── fragment_blocked.xml │ │ │ │ ├── fragment_demos.xml │ │ │ │ ├── fragment_nearby_beacons.xml │ │ │ │ ├── list_item_blocked.xml │ │ │ │ ├── list_item_demo.xml │ │ │ │ ├── list_item_nearby_beacon.xml │ │ │ │ └── notification_big_view.xml │ │ │ │ ├── menu │ │ │ │ ├── main.xml │ │ │ │ └── menu_oob.xml │ │ │ │ ├── raw │ │ │ │ ├── fatbeacon_default_webpage.html │ │ │ │ └── wifi_direct_default_webpage.html │ │ │ │ ├── values │ │ │ │ ├── arrays.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── config-strings.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ │ └── xml │ │ │ │ ├── file_paths.xml │ │ │ │ └── settings.xml │ │ │ └── test │ │ │ └── java │ │ │ └── org │ │ │ └── physical_web │ │ │ └── physicalweb │ │ │ └── UtilsTest.java │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle └── README.md ├── documentation ├── WiFi_Direct_Support.md ├── android_client_walkthrough.md ├── branding_guidelines.md ├── development_resources │ └── helloEdisonPackage.zip ├── getting_started.md ├── images │ ├── IntelEdison.jpg │ ├── android_walkthrough_1.png │ ├── android_walkthrough_2.png │ ├── android_walkthrough_3.png │ ├── android_walkthrough_4.png │ ├── android_walkthrough_5.png │ ├── example.png │ ├── logo │ │ ├── Physical Web Logo.svg │ │ ├── Physical Web logo.ai │ │ ├── logo-black.png │ │ ├── logo-blue.png │ │ └── logo-white.png │ └── uribeacon1.png ├── introduction.md ├── mDNS_Support.md ├── physical_web_service_support.md ├── ssdp_support.md ├── technical_overview.md └── techpack.md ├── implementation-status.md ├── ios ├── PhyWeb.xcodeproj │ └── project.pbxproj ├── PhyWeb │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Backend │ │ ├── PWBeacon.h │ │ ├── PWBeacon.m │ │ ├── PWBeaconManager.h │ │ ├── PWBeaconManager.m │ │ ├── PWMetadataRequest.h │ │ ├── PWMetadataRequest.m │ │ ├── PWURLShortener.h │ │ ├── PWURLShortener.m │ │ ├── uribeacon-tests │ │ │ ├── Info.plist │ │ │ ├── NSData+UBUnitTest.h │ │ │ ├── NSData+UBUnitTest.m │ │ │ └── uribeacon_tests.m │ │ └── uribeacon │ │ │ ├── NSString+UB.h │ │ │ ├── NSString+UB.m │ │ │ ├── NSURL+UB.h │ │ │ ├── NSURL+UB.m │ │ │ ├── UBConfigurableURIBeaconPrivate.h │ │ │ ├── UBConfigurableUriBeacon.h │ │ │ ├── UBConfigurableUriBeacon.m │ │ │ ├── UBUriBeacon.h │ │ │ ├── UBUriBeacon.m │ │ │ ├── UBUriBeaconPrivate.h │ │ │ ├── UBUriBeaconReader.h │ │ │ ├── UBUriBeaconReader.m │ │ │ ├── UBUriBeaconScanner.h │ │ │ ├── UBUriBeaconScanner.m │ │ │ ├── UBUriBeaconScannerPrivate.h │ │ │ ├── UBUriBeaconWriter.h │ │ │ ├── UBUriBeaconWriter.m │ │ │ ├── UBUriReader.h │ │ │ ├── UBUriReader.m │ │ │ ├── UBUriWriter.h │ │ │ ├── UBUriWriter.m │ │ │ └── UriBeacon.h │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── icon-100.png │ │ │ ├── icon-114.png │ │ │ ├── icon-120-1.png │ │ │ ├── icon-120.png │ │ │ ├── icon-144.png │ │ │ ├── icon-152.png │ │ │ ├── icon-180.png │ │ │ ├── icon-29-1.png │ │ │ ├── icon-29.png │ │ │ ├── icon-40.png │ │ │ ├── icon-50.png │ │ │ ├── icon-57.png │ │ │ ├── icon-58-1.png │ │ │ ├── icon-58.png │ │ │ ├── icon-72.png │ │ │ ├── icon-76.png │ │ │ ├── icon-80-1.png │ │ │ ├── icon-80.png │ │ │ └── icon-87.png │ │ └── LaunchImage.launchimage │ │ │ └── Contents.json │ ├── Info.plist │ ├── PhyWeb.entitlements │ ├── Resources │ │ ├── 37x-Checkmark.png │ │ ├── 37x-Checkmark@2x.png │ │ ├── LaunchIcon.png │ │ ├── LaunchScreen.xib │ │ ├── Progress1.png │ │ ├── Progress2.png │ │ ├── Progress3.png │ │ ├── ScanError.png │ │ ├── gear.png │ │ ├── gear@2x.png │ │ ├── icon-100.png │ │ ├── icon-114.png │ │ ├── icon-120.png │ │ ├── icon-144.png │ │ ├── icon-152.png │ │ ├── icon-180.png │ │ ├── icon-29.png │ │ ├── icon-40.png │ │ ├── icon-50.png │ │ ├── icon-512.png │ │ ├── icon-57.png │ │ ├── icon-58.png │ │ ├── icon-72.png │ │ ├── icon-76.png │ │ ├── icon-80.png │ │ ├── icon-87.png │ │ └── licenses.html │ ├── UI │ │ ├── PWActivityIndicator.h │ │ ├── PWActivityIndicator.m │ │ ├── PWBeaconCell.h │ │ ├── PWBeaconCell.m │ │ ├── PWBeaconChartTableViewCell.h │ │ ├── PWBeaconChartTableViewCell.m │ │ ├── PWBeaconsViewController.h │ │ ├── PWBeaconsViewController.m │ │ ├── PWChartViewController.h │ │ ├── PWChartViewController.m │ │ ├── PWConfigureViewController.h │ │ ├── PWConfigureViewController.m │ │ ├── PWGradientView.h │ │ ├── PWGradientView.m │ │ ├── PWPlaceholderView.h │ │ ├── PWPlaceholderView.m │ │ ├── PWSettingsViewController.h │ │ ├── PWSettingsViewController.m │ │ ├── PWSignalStrengthView.h │ │ ├── PWSignalStrengthView.m │ │ ├── PWSimpleWebViewController.h │ │ └── PWSimpleWebViewController.m │ ├── main.m │ └── third-party │ │ └── JBChartView │ │ ├── JBBarChartView.h │ │ ├── JBBarChartView.m │ │ ├── JBChartView.h │ │ ├── JBChartView.m │ │ ├── JBLineChartView.h │ │ ├── JBLineChartView.m │ │ ├── LICENSE │ │ └── README ├── README.md ├── scripts │ ├── make-dev.sh │ └── update-build.sh └── today │ ├── Info.plist │ ├── TodayViewController.h │ ├── TodayViewController.m │ └── today.entitlements ├── java └── libs │ ├── .gitignore │ ├── README.md │ ├── build.gradle │ ├── config │ ├── checkstyle │ │ ├── checkstyle.xml │ │ └── suppressions.xml │ ├── findbugs │ │ └── exclude-filter.xml │ └── pmd │ │ └── pmd-ruleset.xml │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── settings.gradle │ └── src │ ├── integrationTest │ └── java │ │ └── org │ │ └── physical_web │ │ └── collection │ │ └── IntegrationTest.java │ ├── main │ └── java │ │ └── org │ │ └── physical_web │ │ └── collection │ │ ├── BitmapRequest.java │ │ ├── EddystoneBeacon.java │ │ ├── JsonObjectRequest.java │ │ ├── PhysicalWebCollection.java │ │ ├── PhysicalWebCollectionException.java │ │ ├── PwPair.java │ │ ├── PwsClient.java │ │ ├── PwsResult.java │ │ ├── PwsResultCallback.java │ │ ├── PwsResultIconCallback.java │ │ ├── Request.java │ │ ├── UrlDevice.java │ │ ├── UrlGroup.java │ │ └── Utils.java │ └── test │ └── java │ └── org │ └── physical_web │ └── collection │ ├── EddystoneBeaconTest.java │ ├── PhysicalWebCollectionTest.java │ ├── PwPairTest.java │ ├── PwsResultTest.java │ ├── UrlDeviceTest.java │ └── UrlGroupTest.java ├── nodejs ├── FatBeaconPeripheral │ ├── FatBeacon.js │ ├── README.md │ ├── html │ │ └── fatBeaconDefault.html │ └── webpageCharacteristic.js └── README.md ├── travis └── build.sh └── web-service ├── .gitignore ├── LICENSE ├── README.md ├── app.yaml ├── appengine_config.py ├── config.SAMPLE.json ├── examples └── title-only.html ├── experimental.py ├── favicon.ico ├── handlers.py ├── helpers.py ├── models.py ├── shortener.py ├── static ├── index.html └── raw.html └── tests.py /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 4 6 | end_of_line = LF 7 | trim_trailing_whitespace = true 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | 4 | *~ 5 | 6 | #OS X System Files 7 | .DS_Store 8 | 9 | # Xcode 10 | # 11 | build/ 12 | *.pbxuser 13 | !default.pbxuser 14 | *.mode1v3 15 | !default.mode1v3 16 | *.mode2v3 17 | !default.mode2v3 18 | *.perspectivev3 19 | !default.perspectivev3 20 | xcuserdata 21 | *.xccheckout 22 | *.moved-aside 23 | DerivedData 24 | *.hmap 25 | *.ipa 26 | *.xcuserstate 27 | 28 | .idea/ 29 | /android/PhysicalWeb/app/src/main/res/values/keys.xml 30 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "ios/PhyWeb/third-party/SDWebImage"] 2 | path = ios/PhyWeb/third-party/SDWebImage 3 | url = https://github.com/rs/SDWebImage 4 | [submodule "ios/PhyWeb/third-party/uribeacon"] 5 | path = ios/PhyWeb/third-party/uribeacon 6 | url = https://github.com/google/uribeacon 7 | [submodule "ios/PhyWeb/third-party/MBProgressHUD"] 8 | path = ios/PhyWeb/third-party/MBProgressHUD 9 | url = https://github.com/jdg/MBProgressHUD 10 | [submodule "ios/PhyWeb/third-party/SVPullToRefresh"] 11 | path = ios/PhyWeb/third-party/SVPullToRefresh 12 | url = https://github.com/dinhviethoa/SVPullToRefresh 13 | branch = contentinset-update 14 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | jdk: oraclejdk7 3 | 4 | android: 5 | components: 6 | # The BuildTools version used by your project 7 | - build-tools-21.1.2 8 | 9 | # The SDK version used to compile your project 10 | - android-21 11 | 12 | # Use extra android repo locations to find the appcompat-v7:21.0.3 support library 13 | - extra 14 | 15 | #specify the build script to run. currently in the root directory along with .travis.yml file 16 | script: "./travis/build.sh" 17 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute # 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | 7 | ## Contributor License Agreement ## 8 | 9 | Contributions to any Google project must be accompanied by a Contributor 10 | License Agreement. This is not a copyright **assignment**, it simply gives 11 | Google permission to use and redistribute your contributions as part of the 12 | project. 13 | 14 | * If you are an individual writing original source code and you're sure you 15 | own the intellectual property, then you'll need to sign an [individual 16 | CLA][]. 17 | 18 | * If you work for a company that wants to allow you to contribute your work, 19 | then you'll need to sign a [corporate CLA][]. 20 | 21 | You generally only need to submit a CLA once, so if you've already submitted 22 | one (even if it was for a different project), you probably don't need to do it 23 | again. 24 | 25 | [individual CLA]: https://developers.google.com/open-source/cla/individual 26 | [corporate CLA]: https://developers.google.com/open-source/cla/corporate 27 | 28 | Once your CLA is submitted (or if you already submitted one for 29 | another Google project), make a commit adding yourself to the 30 | [CONTRIBUTORS][] file. This commit can be part of your first [pull request][]. 31 | 32 | [CONTRIBUTORS]: CONTRIBUTORS 33 | 34 | 35 | ## Submitting a patch ## 36 | 37 | 1. It's generally best to start by opening a new issue describing the bug or 38 | feature you're intending to fix. Even if you think it's relatively minor, 39 | it's helpful to know what people are working on. Mention in the initial 40 | issue that you are planning to work on that bug or feature so that it can 41 | be assigned to you. 42 | 43 | 2. Follow the normal process of [forking][] the project, and setup a new 44 | branch to work in. It's important that each group of changes be done in 45 | separate branches in order to ensure that a pull request only includes the 46 | commits related to that bug or feature. 47 | 48 | 3. Do your best to have [well-formed commit messages][] for each change. 49 | This provides consistency throughout the project, and ensures that commit 50 | messages are able to be formatted properly by various git tools. If you 51 | are contributing to the codebase, make sure your code adheres to the 52 | appropriate [style guide][]. 53 | 54 | 4. Finally, push the commits to your fork and submit a [pull request][]. 55 | 56 | [forking]: https://help.github.com/articles/fork-a-repo 57 | [well-formed commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html 58 | [style guide]: https://github.com/google/physical-web/wiki/Coding-Style-Guides 59 | [pull request]: https://help.github.com/articles/creating-a-pull-request 60 | -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | CLA Signers 2 | ---------------------------------------- 3 | 4 | By default, anyone with an @google.com email address already has a CLA 5 | signed for them. Congratulations! 6 | 7 | alexyoung 8 | arkpog 9 | asagrawal 10 | daviddoran 11 | dermike 12 | devashishmamgain 13 | dinhviethoa 14 | don 15 | g-ortuno 16 | gbuesing 17 | grahamoregan 18 | gshaw 19 | ianobermiller 20 | jcrabtr 21 | jonathanstark 22 | keremgocen 23 | matthewsibigtroth 24 | morganchen12 25 | meriac 26 | MrNice 27 | Peeja 28 | Primigenus 29 | sandeepmistry 30 | schilit 31 | scottjenson 32 | ThunderKeg 33 | wen 34 | louaybassbouss 35 | devunwired 36 | ColeMurray 37 | edent 38 | kevinahuber 39 | angst7 40 | -------------------------------------------------------------------------------- /android/PhysicalWeb/.gitignore: -------------------------------------------------------------------------------- 1 | # Keystore files for signing 2 | *.jks 3 | *.keystore 4 | 5 | *.iml 6 | .gradle 7 | .idea 8 | .DS_Store 9 | build 10 | local.properties 11 | signing.properties 12 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | .idea -------------------------------------------------------------------------------- /android/PhysicalWeb/app/config/checkstyle/suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/config/findbugs/exclude-filter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/config/pmd/pmd-ruleset.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | Custom ruleset for Android application 8 | 9 | .*/R.java 10 | .*/gen/.* 11 | .*/ble/UriBeacon.java 12 | .*/ble/Utils.java 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 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/libs/uribeacon-library-release.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/app/libs/uribeacon-library-release.aar -------------------------------------------------------------------------------- /android/PhysicalWeb/app/libs/volley.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/app/libs/volley.aar -------------------------------------------------------------------------------- /android/PhysicalWeb/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 /Applications/Android Studio.app/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 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/androidTest/java/org/physical_web/physicalweb/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package org.physical_web.physicalweb; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Basic application test. 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/java/org/physical_web/demos/Demo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.physical_web.demos; 17 | 18 | /** 19 | * Provides an interface for Demos to be added to the demo section. 20 | */ 21 | public interface Demo { 22 | 23 | /** 24 | * @return The summary of the demo. 25 | */ 26 | String getSummary(); 27 | 28 | /** 29 | * @return The title of the demo. 30 | */ 31 | String getTitle(); 32 | 33 | /** 34 | * Checks to see if the demo is running. 35 | * @return True if the demo has been started and not stopped. 36 | */ 37 | boolean isDemoStarted(); 38 | 39 | /** 40 | * Starts the demo. 41 | */ 42 | void startDemo(); 43 | 44 | /** 45 | * Stops the demo. 46 | */ 47 | void stopDemo(); 48 | } 49 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/java/org/physical_web/demos/FatBeaconHelloWorld.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.physical_web.demos; 17 | 18 | import org.physical_web.physicalweb.FatBeaconBroadcastService; 19 | import org.physical_web.physicalweb.R; 20 | 21 | import android.content.ContentResolver; 22 | import android.content.Context; 23 | import android.content.Intent; 24 | 25 | /** 26 | * Hello world demo for FatBeacon. 27 | */ 28 | public class FatBeaconHelloWorld implements Demo { 29 | private static final String TAG = FatBeaconHelloWorld.class.getSimpleName(); 30 | private static boolean mIsDemoStarted = false; 31 | private Context mContext; 32 | 33 | public FatBeaconHelloWorld(Context context) { 34 | mContext = context; 35 | } 36 | 37 | @Override 38 | public String getSummary() { 39 | return mContext.getString(R.string.fat_beacon_demo_summary); 40 | } 41 | 42 | @Override 43 | public String getTitle() { 44 | return mContext.getString(R.string.fat_beacon_demo_title); 45 | } 46 | 47 | @Override 48 | public boolean isDemoStarted() { 49 | return mIsDemoStarted; 50 | } 51 | 52 | @Override 53 | public void startDemo() { 54 | Intent intent = new Intent(mContext, FatBeaconBroadcastService.class); 55 | intent.putExtra(FatBeaconBroadcastService.TITLE_KEY, "Hello World"); 56 | String uriString = ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + 57 | mContext.getPackageName() + "/" + R.raw.fatbeacon_default_webpage; 58 | intent.putExtra(FatBeaconBroadcastService.URI_KEY, uriString); 59 | mContext.startService(intent); 60 | mIsDemoStarted = true; 61 | } 62 | 63 | @Override 64 | public void stopDemo() { 65 | mContext.stopService(new Intent(mContext, FatBeaconBroadcastService.class)); 66 | mIsDemoStarted = false; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/java/org/physical_web/demos/WifiDirectHelloWorld.java: -------------------------------------------------------------------------------- 1 | package org.physical_web.demos; 2 | 3 | import org.physical_web.physicalweb.FileBroadcastService; 4 | import org.physical_web.physicalweb.R; 5 | 6 | import android.content.ContentResolver; 7 | import android.content.Context; 8 | import android.content.Intent; 9 | 10 | /** 11 | * Hello world demo for WifiDirect. 12 | */ 13 | public class WifiDirectHelloWorld implements Demo { 14 | private static final String TAG = WifiDirectHelloWorld.class.getSimpleName(); 15 | private static boolean mIsDemoStarted = false; 16 | private final Context mContext; 17 | 18 | public WifiDirectHelloWorld(Context context) { 19 | mContext = context; 20 | } 21 | 22 | @Override 23 | public String getSummary() { 24 | return mContext.getString(R.string.wifi_direct_demo_summary); 25 | } 26 | 27 | @Override 28 | public String getTitle() { 29 | return mContext.getString(R.string.wifi_direct_demo_title); 30 | } 31 | 32 | @Override 33 | public boolean isDemoStarted() { 34 | return mIsDemoStarted; 35 | } 36 | 37 | @Override 38 | public void startDemo() { 39 | Intent intent = new Intent(mContext, FileBroadcastService.class); 40 | String uriString = ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + 41 | mContext.getPackageName() + "/" + R.raw.wifi_direct_default_webpage; 42 | intent.putExtra(FileBroadcastService.FILE_KEY, uriString); 43 | intent.putExtra(FileBroadcastService.MIME_TYPE_KEY, "text/html"); 44 | intent.putExtra(FileBroadcastService.TITLE_KEY, "Hello World"); 45 | mContext.startService(intent); 46 | mIsDemoStarted = true; 47 | } 48 | 49 | @Override 50 | public void stopDemo() { 51 | mContext.stopService(new Intent(mContext, FileBroadcastService.class)); 52 | mIsDemoStarted = false; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/AboutFragment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | package org.physical_web.physicalweb; 19 | 20 | import android.annotation.SuppressLint; 21 | import android.app.Fragment; 22 | import android.os.Bundle; 23 | import android.view.LayoutInflater; 24 | import android.view.Menu; 25 | import android.view.View; 26 | import android.view.ViewGroup; 27 | import android.webkit.WebView; 28 | import android.webkit.WebViewClient; 29 | import android.widget.TextView; 30 | 31 | /** 32 | * The fragment that displays info about the app. 33 | */ 34 | public class AboutFragment extends Fragment { 35 | 36 | @SuppressWarnings("WeakerAccess") 37 | public AboutFragment() { 38 | } 39 | 40 | private void initializeApplicationVersionText() { 41 | String versionString = getString(R.string.about_version_label) + " " + BuildConfig.VERSION_NAME; 42 | View view = getView(); 43 | if (view != null) { 44 | TextView versionView = (TextView) view.findViewById(R.id.version); 45 | versionView.setText(versionString); 46 | } 47 | } 48 | 49 | @SuppressLint("SetJavaScriptEnabled") 50 | private void initializeWebView() { 51 | WebView webView = (WebView) getActivity().findViewById(R.id.about_webview); 52 | webView.getSettings().setJavaScriptEnabled(true); 53 | webView.setWebViewClient(new WebViewClient()); 54 | webView.loadUrl(getString(R.string.url_getting_started)); 55 | } 56 | 57 | @Override 58 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 59 | Bundle savedInstanceState) { 60 | setHasOptionsMenu(true); 61 | getActivity().getActionBar().setDisplayHomeAsUpEnabled(true); 62 | return inflater.inflate(R.layout.fragment_about, container, false); 63 | } 64 | 65 | @Override 66 | public void onResume() { 67 | super.onResume(); 68 | //noinspection ConstantConditions 69 | getActivity().getActionBar().setTitle(R.string.title_about); 70 | initializeWebView(); 71 | initializeApplicationVersionText(); 72 | } 73 | 74 | @Override 75 | public void onPrepareOptionsMenu(Menu menu) { 76 | super.onPrepareOptionsMenu(menu); 77 | Utils.hideAllMenuItems(menu); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/AutostartPwoDiscoveryServiceReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.physical_web.physicalweb; 18 | 19 | import android.content.BroadcastReceiver; 20 | import android.content.Context; 21 | import android.content.Intent; 22 | 23 | /** 24 | * This receiver starts the UriBeaconDiscoveryService. 25 | */ 26 | public class AutostartPwoDiscoveryServiceReceiver extends BroadcastReceiver { 27 | public void onReceive(Context context, Intent intent) { 28 | // Make sure we don't get spoofed with the wrong action. 29 | if (!intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) { 30 | return; 31 | } 32 | 33 | if (Utils.checkIfUserHasOptedIn(context)) { 34 | return; 35 | } 36 | 37 | Intent newIntent = new Intent(context, ScreenListenerService.class); 38 | context.startService(newIntent); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/ConnectionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.physical_web.physicalweb; 17 | 18 | /** 19 | * Provides a callback for when a connection has finished. 20 | */ 21 | public interface ConnectionListener { 22 | 23 | /** 24 | * onConnectionFinished is called when the connection has finished. 25 | */ 26 | void onConnectionFinished(); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/FileBroadcastServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.physical_web.physicalweb; 17 | 18 | import java.io.ByteArrayInputStream; 19 | import java.io.InputStream; 20 | import fi.iki.elonen.NanoHTTPD; 21 | 22 | /** 23 | * HTTP Server to serve. 24 | **/ 25 | public class FileBroadcastServer extends NanoHTTPD { 26 | String mType; 27 | byte[] mFile; 28 | 29 | public FileBroadcastServer(int port, String type, byte[] file) { 30 | super(port); 31 | mType = type; 32 | mFile = file; 33 | } 34 | 35 | @Override 36 | public NanoHTTPD.Response serve(IHTTPSession session) { 37 | InputStream fis = new ByteArrayInputStream(mFile); 38 | return NanoHTTPD.newFixedLengthResponse(NanoHTTPD.Response.Status.OK, 39 | mType, fis, mFile.length); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/Log.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.physical_web.physicalweb; 18 | 19 | /** 20 | * Convenience Log class. 21 | */ 22 | public class Log { 23 | private static final String TAG = "PW-"; 24 | 25 | public static void d(String tag, String msg) { 26 | android.util.Log.d(TAG + tag, msg); 27 | } 28 | 29 | public static void d(String tag, String msg, Throwable tr) { 30 | android.util.Log.d(TAG + tag, msg, tr); 31 | } 32 | 33 | public static void e(String tag, String msg) { 34 | android.util.Log.e(TAG + tag, msg); 35 | } 36 | 37 | public static void e(String tag, String msg, Throwable tr) { 38 | android.util.Log.e(TAG + tag, msg, tr); 39 | } 40 | 41 | public static String getStackTraceString(Throwable tr) { 42 | return android.util.Log.getStackTraceString(tr); 43 | } 44 | 45 | public static void i(String tag, String msg) { 46 | android.util.Log.i(TAG + tag, msg); 47 | } 48 | 49 | public static void i(String tag, String msg, Throwable tr) { 50 | android.util.Log.i(TAG + tag, msg, tr); 51 | } 52 | 53 | public static boolean isLoggable(String tag, int i) { 54 | return android.util.Log.isLoggable(TAG + tag, i); 55 | } 56 | 57 | public static void println(int priority, String tag, String msg) { 58 | android.util.Log.println(priority, TAG + tag, msg); 59 | } 60 | 61 | public static void v(String tag, String msg) { 62 | android.util.Log.v(TAG + tag, msg); 63 | } 64 | 65 | public static void v(String tag, String msg, Throwable tr) { 66 | android.util.Log.v(TAG + tag, msg, tr); 67 | } 68 | 69 | public static void w(String tag, String msg) { 70 | android.util.Log.w(TAG + tag, msg); 71 | } 72 | 73 | public static void w(String tag, String msg, Throwable tr) { 74 | android.util.Log.w(TAG + tag, msg, tr); 75 | } 76 | 77 | public static void wtf(String tag, String msg) { 78 | android.util.Log.wtf(TAG + tag, msg); 79 | } 80 | 81 | public static void wtf(String tag, String msg, Throwable tr) { 82 | android.util.Log.wtf(TAG + tag, msg, tr); 83 | } 84 | 85 | public static void wtf(String tag, Throwable tr) { 86 | android.util.Log.wtf(TAG + tag, tr); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/OfflineTransportConnectionActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.physical_web.physicalweb; 17 | 18 | import org.physical_web.collection.UrlDevice; 19 | 20 | import android.app.Activity; 21 | import android.content.Intent; 22 | 23 | /** 24 | * Activity that handles intents for offline transports that need to be connected to before opening 25 | * the page. This is used when the user clicks on the notification for a connectable transports, 26 | * such as FatBeacon. 27 | */ 28 | public class OfflineTransportConnectionActivity extends Activity { 29 | private static final String TAG = OfflineTransportConnectionActivity.class.getSimpleName(); 30 | public static final String EXTRA_DEVICE_ADDRESS = "address"; 31 | public static final String EXTRA_DEVICE_PORT = "port"; 32 | public static final String EXTRA_PAGE_TITLE = "title"; 33 | public static final String EXTRA_CONNECTION_TYPE = "connection_type"; 34 | public static final String EXTRA_FAT_BEACON_CONNECTION = "fat_beacon"; 35 | public static final String EXTRA_WIFI_DIRECT_CONNECTION = "wi-fi_direct"; 36 | 37 | private ConnectionListener listener = new ConnectionListener() { 38 | @Override 39 | public void onConnectionFinished() { 40 | finish(); 41 | } 42 | }; 43 | 44 | @Override 45 | protected void onStart() { 46 | super.onStart(); 47 | Intent intent = getIntent(); 48 | String connectionType = intent.getStringExtra(EXTRA_CONNECTION_TYPE); 49 | String deviceAddress = intent.getStringExtra(EXTRA_DEVICE_ADDRESS); 50 | int devicePort = intent.getIntExtra(EXTRA_DEVICE_PORT, -1); 51 | String title = intent.getStringExtra(EXTRA_PAGE_TITLE); 52 | if (connectionType.equals(EXTRA_FAT_BEACON_CONNECTION) && deviceAddress != null && 53 | title != null) { 54 | (new BluetoothSite(this)).connect(deviceAddress, title, listener); 55 | } else if (connectionType.equals(EXTRA_WIFI_DIRECT_CONNECTION) && deviceAddress != null && 56 | devicePort != -1 && title != null) { 57 | UrlDevice device = new Utils.UrlDeviceBuilder("id", "url") 58 | .setWifiAddress(deviceAddress) 59 | .setWifiPort(devicePort) 60 | .build(); 61 | (new WifiDirectConnect(this)).connect(device, title, listener); 62 | } else { 63 | finish(); 64 | } 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/OobActivity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.physical_web.physicalweb; 18 | 19 | import android.annotation.SuppressLint; 20 | import android.content.Intent; 21 | import android.os.Bundle; 22 | import android.support.v7.app.AppCompatActivity; 23 | import android.view.Menu; 24 | import android.view.View; 25 | import android.webkit.WebView; 26 | import android.webkit.WebViewClient; 27 | 28 | /** 29 | * The out of the box activity that let's the user know what this app is all about. 30 | */ 31 | public class OobActivity extends AppCompatActivity { 32 | 33 | View.OnClickListener mAcceptButtonOnClickListener = new View.OnClickListener() { 34 | 35 | @Override 36 | public void onClick(View v) { 37 | // Save the opt in preference 38 | Utils.setOptInPreference(OobActivity.this); 39 | 40 | // Exit the activity 41 | finish(); 42 | } 43 | }; 44 | 45 | @SuppressLint("SetJavaScriptEnabled") 46 | private void initializeWebView() { 47 | WebView webView = (WebView) findViewById(R.id.oob_webview); 48 | // Force the background color to update (it uses the color specified in the layout xml) 49 | webView.setBackgroundColor(0x000); 50 | webView.getSettings().setJavaScriptEnabled(true); 51 | webView.setWebViewClient(new WebViewClient()); 52 | webView.loadUrl(getString(R.string.url_getting_started)); 53 | } 54 | 55 | @Override 56 | protected void onCreate(Bundle savedInstanceState) { 57 | super.onCreate(savedInstanceState); 58 | setContentView(R.layout.activity_oob); 59 | findViewById(R.id.oob_accept_button).setOnClickListener(mAcceptButtonOnClickListener); 60 | initializeWebView(); 61 | } 62 | 63 | @Override 64 | public boolean onCreateOptionsMenu(Menu menu) { 65 | // Inflate the menu; this adds items to the action bar if it is present. 66 | getMenuInflater().inflate(R.menu.menu_oob, menu); 67 | return true; 68 | } 69 | 70 | @Override 71 | public void onBackPressed() { 72 | super.onBackPressed(); 73 | // Make sure that the back button brings the user to the home screen 74 | Intent intent = new Intent(Intent.ACTION_MAIN); 75 | intent.addCategory(Intent.CATEGORY_HOME); 76 | startActivity(intent); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/PermissionCheck.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.physical_web.physicalweb; 17 | 18 | /** 19 | * Stores states of permission checking so that 20 | * components can access it. 21 | */ 22 | public class PermissionCheck { 23 | private static PermissionCheck instance = null; 24 | public boolean mCheckingPermissions; 25 | 26 | protected PermissionCheck() { 27 | } 28 | 29 | public static PermissionCheck getInstance() { 30 | if (instance == null) { 31 | instance = new PermissionCheck(); 32 | } 33 | return instance; 34 | } 35 | 36 | public void setCheckingPermissions(boolean value) { 37 | mCheckingPermissions = value; 38 | } 39 | 40 | public boolean isCheckingPermissions() { 41 | return mCheckingPermissions; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/ScreenListenerService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.physical_web.physicalweb; 18 | 19 | import android.app.Service; 20 | import android.content.BroadcastReceiver; 21 | import android.content.Context; 22 | import android.content.Intent; 23 | import android.content.IntentFilter; 24 | import android.os.IBinder; 25 | 26 | /** 27 | * This is a service registers a broadcast receiver to listen for screen on/off events. 28 | * It is a very unfortunate service that must exist because we can't register for screen on/off 29 | * in the manifest. 30 | */ 31 | 32 | public class ScreenListenerService extends Service { 33 | private BroadcastReceiver mScreenStateBroadcastReceiver = new BroadcastReceiver() { 34 | @Override 35 | public void onReceive(Context context, Intent intent) { 36 | Intent discoveryIntent = new Intent(context, UrlDeviceDiscoveryService.class); 37 | if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) { 38 | context.startService(discoveryIntent); 39 | } else if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { 40 | context.stopService(discoveryIntent); 41 | } 42 | } 43 | }; 44 | 45 | @Override 46 | public void onCreate() { 47 | super.onCreate(); 48 | IntentFilter intentFilter = new IntentFilter(); 49 | intentFilter.addAction(Intent.ACTION_SCREEN_ON); 50 | intentFilter.addAction(Intent.ACTION_SCREEN_OFF); 51 | registerReceiver(mScreenStateBroadcastReceiver, intentFilter); 52 | } 53 | 54 | @Override 55 | public void onDestroy() { 56 | unregisterReceiver(mScreenStateBroadcastReceiver); 57 | super.onDestroy(); 58 | } 59 | 60 | @Override 61 | public IBinder onBind(Intent intent) { 62 | // Nothing should bind to this service 63 | return null; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/SwipeRefreshWidget.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.physical_web.physicalweb; 18 | 19 | import android.content.Context; 20 | import android.util.AttributeSet; 21 | import android.widget.ListView; 22 | 23 | /** 24 | * Subclass of {@link android.support.v4.widget.SwipeRefreshLayout} that supports containing a 25 | * ViewGroup whose first child is a ListView. The ViewGroup can contain other views. 26 | */ 27 | public class SwipeRefreshWidget extends android.support.v4.widget.SwipeRefreshLayout { 28 | 29 | public SwipeRefreshWidget(Context context) { 30 | super(context); 31 | } 32 | 33 | public SwipeRefreshWidget(Context context, AttributeSet attributeSet) { 34 | super(context, attributeSet); 35 | } 36 | 37 | @Override 38 | public boolean canChildScrollUp() { 39 | // The real child maps cares about is the list, so check if that can scroll. 40 | ListView target = (ListView) findViewById(android.R.id.list); 41 | return target.getChildCount() > 0 42 | && (target.getFirstVisiblePosition() > 0 43 | || target.getChildAt(0).getTop() < target.getPaddingTop()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/UrlDeviceDiscoverer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.physical_web.physicalweb; 18 | 19 | import org.physical_web.collection.UrlDevice; 20 | 21 | import android.os.SystemClock; 22 | 23 | abstract class UrlDeviceDiscoverer { 24 | private UrlDeviceDiscoveryCallback mUrlDeviceDiscoveryCallback; 25 | private long mScanStartTime; 26 | 27 | public abstract void startScanImpl(); 28 | public abstract void stopScanImpl(); 29 | 30 | public void startScan() { 31 | mScanStartTime = SystemClock.elapsedRealtime(); 32 | startScanImpl(); 33 | } 34 | 35 | public void stopScan() { 36 | stopScanImpl(); 37 | } 38 | 39 | public void restartScan() { 40 | stopScan(); 41 | startScan(); 42 | } 43 | 44 | public void setCallback(UrlDeviceDiscoveryCallback urlDeviceDiscoveryCallback) { 45 | mUrlDeviceDiscoveryCallback = urlDeviceDiscoveryCallback; 46 | } 47 | 48 | protected Utils.UrlDeviceBuilder createUrlDeviceBuilder(String id, String url) { 49 | return new Utils.UrlDeviceBuilder(id, url) 50 | .setScanTimeMillis(SystemClock.elapsedRealtime() - mScanStartTime); 51 | } 52 | 53 | protected void reportUrlDevice(UrlDevice urlDevice) { 54 | mUrlDeviceDiscoveryCallback.onUrlDeviceDiscovered(urlDevice); 55 | } 56 | 57 | public interface UrlDeviceDiscoveryCallback { 58 | public void onUrlDeviceDiscovered(UrlDevice urlDevice); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/java/org/physical_web/physicalweb/ble/Utils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // THIS IS MODIFIED COPY OF THE "L" PLATFORM CLASS. BE CAREFUL ABOUT EDITS. 18 | // THIS CODE SHOULD FOLLOW ANDROID STYLE. 19 | // 20 | // Changes: 21 | // Removed the last two equals() methods. 22 | 23 | package org.physical_web.physicalweb.ble; 24 | 25 | import android.util.SparseArray; 26 | 27 | import java.util.Arrays; 28 | import java.util.Iterator; 29 | import java.util.Map; 30 | 31 | /** 32 | * Helper class for Bluetooth LE utils. 33 | * 34 | * @hide 35 | */ 36 | public class Utils { 37 | 38 | /** 39 | * Returns a string composed from a {@link SparseArray}. 40 | */ 41 | static String toString(SparseArray array) { 42 | if (array == null) { 43 | return "null"; 44 | } 45 | if (array.size() == 0) { 46 | return "{}"; 47 | } 48 | StringBuilder buffer = new StringBuilder(); 49 | buffer.append('{'); 50 | for (int i = 0; i < array.size(); ++i) { 51 | buffer.append(array.keyAt(i)).append('=').append(array.valueAt(i)); 52 | } 53 | buffer.append('}'); 54 | return buffer.toString(); 55 | } 56 | 57 | /** 58 | * Returns a string composed from a {@link Map}. 59 | */ 60 | static String toString(Map map) { 61 | if (map == null) { 62 | return "null"; 63 | } 64 | if (map.isEmpty()) { 65 | return "{}"; 66 | } 67 | StringBuilder buffer = new StringBuilder(); 68 | buffer.append('{'); 69 | Iterator> it = map.entrySet().iterator(); 70 | while (it.hasNext()) { 71 | Map.Entry entry = it.next(); 72 | Object key = entry.getKey(); 73 | buffer.append(key).append('=').append(Arrays.toString(map.get(key))); 74 | if (it.hasNext()) { 75 | buffer.append(", "); 76 | } 77 | } 78 | buffer.append('}'); 79 | return buffer.toString(); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/animator/fade_in_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/animator/fade_in_and_slide_up_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 16 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/animator/fade_out_fragment.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable-hdpi/unresolved_result_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/app/src/main/res/drawable-hdpi/unresolved_result_icon.png -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable-mdpi/unresolved_result_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/app/src/main/res/drawable-mdpi/unresolved_result_icon.png -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable-xhdpi/unresolved_result_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/app/src/main/res/drawable-xhdpi/unresolved_result_icon.png -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable-xxhdpi/ic_notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/app/src/main/res/drawable-xxhdpi/ic_notification.png -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable-xxhdpi/ic_scanning_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/app/src/main/res/drawable-xxhdpi/ic_scanning_0.png -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable-xxhdpi/ic_scanning_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/app/src/main/res/drawable-xxhdpi/ic_scanning_1.png -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable-xxhdpi/ic_scanning_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/app/src/main/res/drawable-xxhdpi/ic_scanning_2.png -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable-xxhdpi/menu_item_background.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/app/src/main/res/drawable-xxhdpi/menu_item_background.9.png -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable-xxhdpi/scanning_animation.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable-xxhdpi/settings_xxhdpi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/app/src/main/res/drawable-xxhdpi/settings_xxhdpi.png -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable-xxhdpi/unresolved_result_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/app/src/main/res/drawable-xxhdpi/unresolved_result_icon.png -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable-xxxhdpi/ic_leak_add_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/app/src/main/res/drawable-xxxhdpi/ic_leak_add_white_24dp.png -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable-xxxhdpi/unresolved_result_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/app/src/main/res/drawable-xxxhdpi/unresolved_result_icon.png -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable/ic_star_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/drawable/ic_star_border_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/layout/activity_oob.xml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 17 | 18 | 22 | 23 | 24 | 35 | 36 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/layout/folder_item_nearby_beacon.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/layout/fragment_about.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 19 | 20 | 29 | 30 | 37 | 38 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/layout/fragment_blocked.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 17 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/layout/fragment_demos.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 17 | 18 | 19 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/layout/fragment_nearby_beacons.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 11 | 12 | 17 | 18 | 19 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /android/PhysicalWeb/app/src/main/res/layout/list_item_blocked.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | 23 | 24 | 25 | 72 | 73 | 74 |

75 | 76 |


77 |     

78 | 79 | 80 | -------------------------------------------------------------------------------- /web-service/static/raw.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 19 | 20 | 21 | 49 | 50 | 51 | 52 |

/resolve-scan

53 |

Request Data

54 | 94 |

Request Data

95 |

96 |     
97 |   
98 | 
99 | 


--------------------------------------------------------------------------------