├── .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 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/android/PhysicalWeb/app/src/main/res/layout/list_item_demo.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
20 |
21 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/android/PhysicalWeb/app/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
26 |
--------------------------------------------------------------------------------
/android/PhysicalWeb/app/src/main/res/menu/menu_oob.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/android/PhysicalWeb/app/src/main/res/values/arrays.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Version 1
5 | Version 2
6 |
7 |
8 |
9 | 1
10 | 2
11 |
12 |
13 |
--------------------------------------------------------------------------------
/android/PhysicalWeb/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #1C47C1
4 | #099F39
5 | #545454
6 | #333333
7 | #5A5A5A
8 | #FFFFFF
9 | #70a2d3
10 | #c2c2c2
11 | #4184c5
12 |
13 |
--------------------------------------------------------------------------------
/android/PhysicalWeb/app/src/main/res/values/config-strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | https://google.github.io/physical-web/mobile/android/getting-started.html
4 | pws_endpoint
5 | custom_pws_endpoint
6 | custom_pws_url
7 | custom_pws_version
8 | custom_pws_key
9 | scan_settings
10 | mDNS
11 | wifidirect
12 | fatbeacon
13 | debug
14 | wifiport
15 |
16 |
--------------------------------------------------------------------------------
/android/PhysicalWeb/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
15 |
16 |
22 |
23 |
28 |
29 |
32 |
33 |
36 |
37 |
41 |
42 |
46 |
47 |
51 |
52 |
--------------------------------------------------------------------------------
/android/PhysicalWeb/app/src/main/res/xml/file_paths.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/android/PhysicalWeb/app/src/main/res/xml/settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
11 |
12 |
16 |
17 |
24 |
25 |
29 |
30 |
31 |
32 |
36 |
37 |
42 |
47 |
48 |
53 |
54 |
55 |
58 |
59 |
64 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/android/PhysicalWeb/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 | maven {
7 | url "https://plugins.gradle.org/m2/"
8 | }
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:2.1.0'
12 | classpath 'gradle.plugin.si.dlabs.gradle:soter:1.0.8'
13 |
14 | // NOTE: Do not place your application dependencies here; they belong
15 | // in the individual module build.gradle files
16 | }
17 | }
18 |
19 | allprojects {
20 | repositories {
21 | jcenter()
22 | }
23 | gradle.projectsEvaluated {
24 | tasks.withType(JavaCompile) {
25 | options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
26 | }
27 | }
28 | }
29 |
30 | task wrapper(type: Wrapper) {
31 | gradleVersion = '2.14'
32 | }
33 |
--------------------------------------------------------------------------------
/android/PhysicalWeb/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Settings specified in this file will override any Gradle settings
5 | # configured through the IDE.
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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/android/PhysicalWeb/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/android/PhysicalWeb/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/android/PhysicalWeb/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jun 22 14:19:31 PDT 2016
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-bin.zip
7 |
--------------------------------------------------------------------------------
/android/PhysicalWeb/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 |
--------------------------------------------------------------------------------
/android/PhysicalWeb/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':libs'
2 |
3 | project(':libs').projectDir = new File('../../java/libs')
4 |
--------------------------------------------------------------------------------
/android/README.md:
--------------------------------------------------------------------------------
1 | # Android client
2 |
3 | This Android client can be downloaded from the [Google Play store](https://play.google.com/store/apps/details?id=physical_web.org.physicalweb). A walkthrough of the app [is here](http://github.com/google/physical-web/blob/master/documentation/android_client_walkthrough.md) and will show you how to put your URL into a beacon.
4 |
5 | Keep in mind that this software is just a prototype. We are doing it this way to easily and quickly test the concept. Eventually, the goal is to have this Physical Web code rolled into each browser.
--------------------------------------------------------------------------------
/documentation/WiFi_Direct_Support.md:
--------------------------------------------------------------------------------
1 | ## Wi-Fi Direct Support
2 |
3 | [Wi-Fi Direct](http://www.wi-fi.org/discover-wi-fi/wi-fi-direct) allows devices to connect directly rather than through an Access Point. This way, a device can connect and received data through a peer-to-peer connection rather than over the internet. With Wi-Fi Direct, the Physical Web will allow beacons to broadcast and serve data to users. The advantage this provides is allowing devices without internet connectivity to access data.
4 |
5 | Broadcast instructions:
6 |
7 | To "broadcast", a device must be in a Wi-Fi Direct discoverable state.
8 | In addition, the device name must conform to the following naming convention: `PW--`
9 |
10 | `` is the title of the content. `` is the port the HTTP service is running at.
--------------------------------------------------------------------------------
/documentation/branding_guidelines.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Physical Web™
4 | If we believe in Moore's Law whatsoever, then small, cheap, connected devices will soon explode into our lives, filling our homes, workplaces, and public spaces. Today, most IoT devices require installing a dedicated app, which simply doesn't scale when you want to interact with a multitude of smart “things” around you every day. The web is a natural fit, offering interaction on demand without the friction and overhead of installation. The Physical Web is an approach to unleash the core superpower of the web, enabling interaction that’s just a tap away.
5 |
6 |
7 | ## Branding Guidelines
8 |
9 | The following guidelines provide you with guidance for using the Physical Web name and the corresponding Physical Web logo. You can use the name and the logo on your website or in print without pre-approval, provided you follow these basic guidelines.
10 |
11 | * **Do** use the trademark symbol in the first or most prominent instance of Physical Web™ in your creative
12 | * **Do** modify the logo’s foreground color, background color, and size
13 | * **Do** use the logo in conjunction with the Physical Web name, or as a standalone logo
14 | * **Do** use the Physical Web name and/or logo to indicate that a nearby device is broadcasting [Eddystone-URL](https://github.com/google/eddystone/tree/master/eddystone-url) advertisement packets, e.g. on your visual advertisements or in your coffee shop
15 | * **Don’t** modify the dimensions of the logo or distort it
16 | * **Don’t** combine the Physical Web logo with other logos, including your own
17 | * **Don’t** put “Google” before or after the Physical Web name or associate “Google” directly with the Physical Web logo
18 | * Incorrect: "Google’s Physical Web”
19 | * Incorrect: "Physical Web from Google”
20 | * Correct: Just use the Physical Web logo with TM only (nothing else required)
21 | * Correct: "Physical Web, an open web discovery layer built on top of Eddystone-URL”
22 |
23 | * **Don’t** use Google or Android logos on product pages where the Physical Web name or logo appear
24 |
25 | You may display, modify according to the above rules, or use the Physical Web name and logo only in connection with compliant implementations of Eddystone-URL and compliant implementations of the Physical Web. A compliant implementation of Eddystone-URL is a Bluetooth Low Energy device that broadcasts advertisement packets according to the unmodified Eddystone-URL specification found in the corresponding GitHub repository. A compliant implementation of the Physical Web is software that scans for Eddystone-URL advertisement packets and presents results to the user that directly correspond to these scanned packets.
26 |
27 | Use of the Physical Web name or logo in ways not expressly covered by this document is not allowed without written permission. For questions, please file an issue in the public Physical Web GitHub repository: .
28 |
29 |
--------------------------------------------------------------------------------
/documentation/development_resources/helloEdisonPackage.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/documentation/development_resources/helloEdisonPackage.zip
--------------------------------------------------------------------------------
/documentation/getting_started.md:
--------------------------------------------------------------------------------
1 | # Getting started testing the Physical Web
2 |
3 | In order to get up and running you need two things:
4 |
5 | 1. A hardware beacon (or two) that supports [Eddystone-URL](https://github.com/google/eddystone/tree/master/eddystone-url) advertisement packets.
6 | 2. Software on your phone/tablet to scan for Eddystone-URL advertisement packets.
7 |
8 | The software is easy thing to take care of once you have beacons. There is a Physical Web demo app on the [Google Play store](https://play.google.com/store/apps/details?id=physical_web.org.physicalweb) as well as the [Apple App Store](https://itunes.apple.com/us/app/physical-web/id927653608?mt=8). A walkthrough of the app [is here](http://github.com/google/physical-web/blob/master/documentation/android_client_walkthrough.md).
9 |
10 | Keep in mind that this software is just a prototype. We are doing it this way to easily and quickly test the concept.
--------------------------------------------------------------------------------
/documentation/images/IntelEdison.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/documentation/images/IntelEdison.jpg
--------------------------------------------------------------------------------
/documentation/images/android_walkthrough_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/documentation/images/android_walkthrough_1.png
--------------------------------------------------------------------------------
/documentation/images/android_walkthrough_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/documentation/images/android_walkthrough_2.png
--------------------------------------------------------------------------------
/documentation/images/android_walkthrough_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/documentation/images/android_walkthrough_3.png
--------------------------------------------------------------------------------
/documentation/images/android_walkthrough_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/documentation/images/android_walkthrough_4.png
--------------------------------------------------------------------------------
/documentation/images/android_walkthrough_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/documentation/images/android_walkthrough_5.png
--------------------------------------------------------------------------------
/documentation/images/example.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/documentation/images/example.png
--------------------------------------------------------------------------------
/documentation/images/logo/Physical Web Logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/documentation/images/logo/Physical Web logo.ai:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/documentation/images/logo/Physical Web logo.ai
--------------------------------------------------------------------------------
/documentation/images/logo/logo-black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/documentation/images/logo/logo-black.png
--------------------------------------------------------------------------------
/documentation/images/logo/logo-blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/documentation/images/logo/logo-blue.png
--------------------------------------------------------------------------------
/documentation/images/logo/logo-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/documentation/images/logo/logo-white.png
--------------------------------------------------------------------------------
/documentation/images/uribeacon1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/documentation/images/uribeacon1.png
--------------------------------------------------------------------------------
/documentation/mDNS_Support.md:
--------------------------------------------------------------------------------
1 | ## mDNS Support
2 |
3 | The Physical Web is about getting URLs into the physical world. However, this isn't limited to just Bluetooth Low Energy (BLE) beacons. [mDNS](http://en.wikipedia.org/wiki/Multicast_DNS) is a service broadcast technique used in Wi-Fi networks. It has two advantages over BLE:
4 |
5 | 1. Only people logged into your Wi-Fi can see the mDNS URLs. This means that in an apartment, your neighbors can't see your devices.
6 | 2. It doesn't have the length restrictions of BLE, so a URL can be as long as you'd like (well, at least up to 100 characters).
7 |
8 | Below is an example of how to setup a Raspberry Pi to broadcast a Physical Web URL using mDNS. We hope others are willing to contribute and offer more versions. If so, we'll create an mDNS directory for all the alternatives.
9 |
10 | Using any zeroconf networking implementation that supports mDNS service registration, register a service as follows: (below our examples are using the dns-sd tool on Mac)
11 |
12 | If you want to broadcast a public url:
13 |
14 | ```shell
15 | dns-sd -R "example_name" _physicalweb._tcp local 80 url="www.example_url.com"
16 | ```
17 |
18 | "example_name" should be replaced by any name unique to your network. Use `dns-sd -B _physicalweb._tcp local` to find all registered names. Replace www.example_url.com with the url you wish to broadcast.
19 |
20 | If you want to broadcast a private url:
21 |
22 | ```shell
23 | dns-sd -R "example_name" _physicalweb._tcp local 80 url="www.example_local_url.com" title="Example Title" desc="Example Description"
24 | ```
25 |
26 | Replace the Url, Title, and Description with your local page's metadata.
27 |
28 | That should be it. If you have the latest client on your phone, the web page you wish to broadcast will now show up in your list of nearby devices.
29 |
30 | Note: if the URL is global, it shows up just like a BLE beacon with Title, Description, and favicon information. If the URL is local, the meta data isn't supported yet, only the URL and given metadata will be displayed.
--------------------------------------------------------------------------------
/documentation/physical_web_service_support.md:
--------------------------------------------------------------------------------
1 | ## Physical Web Service Support
2 |
3 | The Physical Web app comes configured to use Google's internal Physical Web Service (PWS), but you can choose to use other services as well. The app has built in support for 3 different services; Google's internal PWS, the production open source PWS, and the development open source PWS.
4 |
5 | Google's internal PWS is the same PWS that Chrome uses. The production open source PWS is the one previously used for the app. The development open source PWS is for experimental features. In most cases users will want to select from the Google PWS or the Production PWS.
6 |
7 | The app also allows for a custom PWS. To configure a custom PWS you will need to; select the Custom Physical Web Service from the list of Physical Web Service, add a Custom Physical Web Service URL, select the Custom Physical Web Service API version, and if selecting version 2 or higher an API key is needed.
8 |
--------------------------------------------------------------------------------
/implementation-status.md:
--------------------------------------------------------------------------------
1 | # Implementation Status
2 | This document shows the implementation status of Physical Web on different scanning clients.
3 | File issues either on GitHub or by emailing physical-web-discuss@googlegroups.com
4 |
5 | # Chrome
6 |
7 | Feature | iOS | Android
8 | ------------------------- | :-------: | :-------:
9 | Eddystone-URL scanning | ✓ | ✓
10 | Notifications | | ✓
11 | Favicon support | | ✓
12 | HTTPS only | | ✓
13 |
14 | ### Notes
15 |
16 | * iOS blog post: [Exploring the Physical Web with Chrome for iOS](https://blog.chromium.org/2015/07/exploring-physical-web-with-chrome-for.html)
17 | * Android blog post: [The Physical Web expands to Chrome for Android](https://blog.chromium.org/2016/02/the-physical-web-expands-to-chrome-for_10.html)
18 |
19 | # Opera
20 |
21 | Implemented in [Labs release](https://dev.opera.com/articles/release-the-beacons/).
22 |
23 | # Physical Web apps
24 |
25 | * iOS: [App Store download](https://itunes.apple.com/us/app/physical-web/id927653608?mt=8)
26 | * Android: [Play Store download](https://play.google.com/store/apps/details?id=physical_web.org.physicalweb&hl=en)
27 |
--------------------------------------------------------------------------------
/ios/PhyWeb/AppDelegate.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | @interface AppDelegate : UIResponder
20 |
21 | @property(strong, nonatomic) UIWindow *window;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/ios/PhyWeb/AppDelegate.m:
--------------------------------------------------------------------------------
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 | #import "AppDelegate.h"
18 |
19 | #import "PWBeaconsViewController.h"
20 | #import "PWBeaconManager.h"
21 |
22 | @interface AppDelegate ()
23 |
24 | @end
25 |
26 | @implementation AppDelegate {
27 | PWBeaconsViewController *_mainViewController;
28 | }
29 |
30 | - (void)applicationDidBecomeActive:(UIApplication *)application {
31 | if ([[PWBeaconManager sharedManager] isStarted]) {
32 | [[PWBeaconManager sharedManager] stop];
33 | }
34 | [_mainViewController disablePlaceholder];
35 | [[PWBeaconManager sharedManager] resetBeacons];
36 | [[PWBeaconManager sharedManager] start];
37 | [_mainViewController updateBeaconsNow];
38 | }
39 |
40 | - (BOOL)application:(UIApplication *)application
41 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
42 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
43 | self.window.backgroundColor = [UIColor whiteColor];
44 | [self.window makeKeyAndVisible];
45 |
46 | _mainViewController = [[PWBeaconsViewController alloc] init];
47 | [[self window] setRootViewController:_mainViewController];
48 |
49 | return YES;
50 | }
51 |
52 | @end
53 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/PWBeacon.h:
--------------------------------------------------------------------------------
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 | #import
18 | #import "UriBeacon.h"
19 |
20 | @interface PWBeacon : NSObject
21 |
22 | - (id)initWithUriBeacon:(UBUriBeacon *)beacon info:(NSDictionary *)info;
23 |
24 | @property(nonatomic, retain) UBUriBeacon *uriBeacon;
25 |
26 | // URL of the page stored on the beacon.
27 | @property(nonatomic, copy) NSURL *URL;
28 |
29 | // URL of the page to display to the user.
30 | @property(nonatomic, copy) NSURL *displayURL;
31 |
32 | // Whether the display URL has been set by the server.
33 | @property(nonatomic, assign) BOOL hasDisplayURL;
34 |
35 | // Title of the page.
36 | @property(nonatomic, copy) NSString *title;
37 |
38 | // Snippet of the page.
39 | @property(nonatomic, copy) NSString *snippet;
40 |
41 | // Favicon.
42 | @property(nonatomic, copy) NSURL *iconURL;
43 |
44 | // Date of discovery of the beacon.
45 | @property(nonatomic, retain) NSDate *date;
46 |
47 | // The beacon is in the first batch. We should sort it by region.
48 | @property(nonatomic, assign) BOOL sortByRegion;
49 |
50 | // Region of the beacon.
51 | @property(nonatomic, assign) UBUriBeaconRegion region;
52 |
53 | // Rank of the beacon, computed by the metadata server.
54 | @property(nonatomic, assign) double rank;
55 |
56 | // Returns YES if the rank has been computed by the metadata server.
57 | @property(nonatomic, assign) BOOL hasRank;
58 |
59 | // Returns the delay to discover the beacon via bluetooth.
60 | @property(nonatomic, assign) NSTimeInterval discoveryDelay;
61 |
62 | // Returns the delay to get the metadata of the beacon via The Physical Web
63 | // Server.
64 | @property(nonatomic, assign) NSTimeInterval requestDelay;
65 |
66 | @property (nonatomic, retain, readonly) NSArray * rssiHistory;
67 |
68 | // Returns the region name of the beacon when it was created.
69 | - (NSString *)debugRegionName;
70 |
71 | // Returns the updated region name of the beacon.
72 | - (NSString *)debugUriRegionName;
73 |
74 | @end
75 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/PWBeaconManager.h:
--------------------------------------------------------------------------------
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 | #import
18 | #import "UriBeacon.h"
19 |
20 | @interface PWBeaconManager : NSObject
21 |
22 | // Singleton.
23 | + (instancetype)sharedManager;
24 |
25 | // Returns the list of nearby augmented beacons.
26 | - (NSArray* /* PWBeacon */)beacons;
27 |
28 | // Returns the list of configurable beacons.
29 | - (NSArray* /* UBConfigurableUriBeacon */)configurableBeacons;
30 |
31 | - (NSTimeInterval) startTime;
32 |
33 | // Register a callback block when there's a change in the list of beacons.
34 | // It returns an object that need to be used to unregister the callback.
35 | // It needs to be passed to -unregisterChangeBlock:.
36 | - (id)registerChangeBlock:(void (^)(void))block;
37 |
38 | // Unregister a handler of change in list of beacons.
39 | - (void)unregisterChangeBlock:(id)registeredBlock;
40 |
41 | // Registers a callback block when the list of configurable beacons changed.
42 | // It returns an object that need to be used to unregister the callback.
43 | // It needs to be passed to -unregisterConfigurationChangeBlock:.
44 | - (id)registerConfigurationChangeBlock:(void (^)(void))block;
45 |
46 | // Unregister a handler of change in list of configurable beacons.
47 | - (void)unregisterConfigurationChangeBlock:(id)registeredBlock;
48 |
49 | // Starts scanning for beacons.
50 | - (void)start;
51 |
52 | // Stops scanning for beacons.
53 | - (void)stop;
54 |
55 | // Empty the list of beacons.
56 | - (void)resetBeacons;
57 |
58 | // Returns YES is it's scanning for beacons.
59 | - (BOOL)isStarted;
60 |
61 | // Store beacons in defaults shared between the today extension and the app.
62 | // It will save only the URL and the title since it's only what we need to
63 | // show them in the today extension.
64 | - (void)serializeBeacons:(NSArray*)beacons;
65 |
66 | // Retrieve the beacons from the defaults.
67 | - (NSArray*)unserializedBeacons;
68 |
69 | // List won't reorder if it's set to YES.
70 | @property(nonatomic, assign, getter=isStableMode) BOOL stableMode;
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/PWMetadataRequest.h:
--------------------------------------------------------------------------------
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 | #import
18 | #import "UriBeacon.h"
19 |
20 | @protocol PWMetadataRequestDelegate;
21 |
22 | // This class will request to the metadata server the information about a
23 | // beacon.
24 | @interface PWMetadataRequest : NSObject
25 |
26 | // Returns the name of the physical web server.
27 | + (NSString *)hostname;
28 |
29 | // The list of peripherals.
30 | @property(nonatomic, retain) NSArray * /* UBUriBeacon */ uriBeacons;
31 |
32 | // Requests demo meta data.
33 | @property(nonatomic, assign, getter=isDemo) BOOL demo;
34 |
35 | // Delegate of the request. The delegate will be notified when the request is
36 | // done.
37 | @property(nonatomic, weak) id delegate;
38 |
39 | // List of beacons augmented with their metadata.
40 | @property(nonatomic, retain, readonly) NSArray * /* PWBeacon */ results;
41 |
42 | // It will be nil if no error happened. Otherwise, it's the error that happened
43 | // during the request.
44 | @property(nonatomic, retain, readonly) NSError *error;
45 |
46 | @property(nonatomic, assign, readonly) NSTimeInterval delay;
47 |
48 | // Start the request.
49 | - (void)start;
50 |
51 | // Cancel the request.
52 | - (void)cancel;
53 |
54 | @end
55 |
56 | @protocol PWMetadataRequestDelegate
57 |
58 | - (void)metadataRequest_done:(PWMetadataRequest *)request;
59 |
60 | @end
61 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/PWURLShortener.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | typedef void (^PWURLShortenerCompletionBlock)(NSString *shortUrl);
20 |
21 | @interface PWURLShortener : NSObject
22 |
23 | // Shortens a URL using goo.gl. The completion block is called when the URL
24 | // has been shortened. If there's an error, resultURL is be same as URL.
25 | + (void)shortenURL:(NSURL *)URL
26 | completion:(void (^)(NSError *error, NSURL *resultURL))block;
27 |
28 | // Expands a URL if it's one of the supported URL shorteners. The completion
29 | // block is called when the URL has been expanded. If there's an error,
30 | // resultURL will be the same as URL.
31 | + (void)expandURL:(NSURL *)URL
32 | completion:(void (^)(NSError *error, NSURL *resultURL))block;
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/uribeacon-tests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | org.uribeacon.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/uribeacon-tests/NSData+UBUnitTest.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | @interface NSData (UBUnitTest)
20 |
21 | - (NSArray *)ub_unitTestValue;
22 | + (NSData *)ub_dataWithUnitTestValue:(NSArray *)array;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/uribeacon-tests/NSData+UBUnitTest.m:
--------------------------------------------------------------------------------
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 | #import "NSData+UBUnitTest.h"
18 |
19 | @implementation NSData (UBUnitTest)
20 |
21 | - (NSArray *)ub_unitTestValue {
22 | NSMutableArray *result = [NSMutableArray array];
23 | NSMutableString *currentString = nil;
24 | const unsigned char *buf = [self bytes];
25 | for (NSUInteger i = 0; i < [self length]; ++i) {
26 | // Convert to string data after offset 10.
27 | if ((buf[i] >= 32) && (buf[i] < 127) && (i >= 10)) {
28 | if (currentString == nil) {
29 | currentString = [NSMutableString string];
30 | }
31 | [currentString appendFormat:@"%c", buf[i]];
32 | } else {
33 | if (currentString != nil) {
34 | [result addObject:currentString];
35 | currentString = nil;
36 | }
37 | [result addObject:[NSNumber numberWithInt:buf[i]]];
38 | }
39 | }
40 | if (currentString != nil) {
41 | [result addObject:currentString];
42 | currentString = nil;
43 | }
44 | return result;
45 | }
46 |
47 | + (NSData *)ub_dataWithUnitTestValue:(NSArray *)array {
48 | if (array == nil) {
49 | return nil;
50 | }
51 | if (array == (NSArray *)[NSNull null]) {
52 | return nil;
53 | }
54 | NSMutableData *result = [NSMutableData data];
55 | for (NSUInteger i = 0; i < [array count]; i++) {
56 | if ([array[i] isKindOfClass:[NSNumber class]]) {
57 | unsigned char value = [array[i] intValue];
58 | [result appendBytes:&value length:1];
59 | } else if ([array[i] isKindOfClass:[NSString class]]) {
60 | [result appendData:[(NSString *)array[i]
61 | dataUsingEncoding:NSUTF8StringEncoding]];
62 | }
63 | }
64 | return result;
65 | }
66 |
67 | @end
68 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/uribeacon/NSString+UB.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | @interface NSString (PW)
20 |
21 | + (NSString *)ub_decodedBeaconURIString:(NSData *)data;
22 | - (NSData *)ub_encodedBeaconURIString;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/uribeacon/NSURL+UB.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | @interface NSURL (PW)
20 |
21 | + (NSURL *)ub_decodedBeaconURI:(NSData *)data;
22 | - (NSData *)ub_encodedBeaconURI;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/uribeacon/NSURL+UB.m:
--------------------------------------------------------------------------------
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 | #import "NSURL+UB.h"
18 |
19 | #import "NSString+UB.h"
20 |
21 | @implementation NSURL (PW)
22 |
23 | + (NSURL *)ub_decodedBeaconURI:(NSData *)data {
24 | if (data == nil) {
25 | return nil;
26 | }
27 | return [NSURL URLWithString:[NSString ub_decodedBeaconURIString:data]];
28 | }
29 |
30 | - (NSData *)ub_encodedBeaconURI {
31 | return [[self absoluteString] ub_encodedBeaconURIString];
32 | }
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/uribeacon/UBConfigurableURIBeaconPrivate.h:
--------------------------------------------------------------------------------
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 | #import "UBConfigurableUriBeacon.h"
18 |
19 | #import
20 |
21 | @class UBUriBeaconScanner;
22 |
23 | @interface UBConfigurableUriBeacon (Private)
24 |
25 | - (id)initWithPeripheral:(CBPeripheral *)peripheral
26 | advertisementData:(NSDictionary *)advertisementData
27 | RSSI:(NSNumber *)RSSI;
28 |
29 | @property(nonatomic, weak) UBUriBeaconScanner *scanner;
30 |
31 | - (void)_updateWithConfigurableBeacon:(UBConfigurableUriBeacon *)beacon;
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/uribeacon/UBConfigurableUriBeacon.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | @class UBUriBeacon;
20 |
21 | /**
22 | This class represents a configurable UriBeacon.
23 |
24 | Here's an example of how to configure a beacon:
25 |
41 | */
42 | @interface UBConfigurableUriBeacon : NSObject
43 |
44 | /** iOS bluetooth device identifier. */
45 | @property(nonatomic, copy) NSUUID* identifier;
46 |
47 | /** RSSI value. */
48 | @property(nonatomic, assign) NSInteger RSSI;
49 |
50 | /**
51 | * To hold a beacon in configuration mode, you need to connect to it.
52 | *
53 | * @param block The block will be called when the connection is established.
54 | */
55 | - (void)connect:(void (^)(NSError* error))block;
56 |
57 | /**
58 | * Disconnects when configuration is done to reflect the changes.
59 | *
60 | * @param block The block will be called when the connection is terminated.
61 | */
62 | - (void)disconnect:(void (^)(NSError* error))block;
63 |
64 | /**
65 | * Writes beacon advertisement data. The beacon must be connected before writing
66 | * to it.
67 | *
68 | * @param beacon The beacon information to write.
69 | * @param block The block will be called when the data have been written.
70 | */
71 | - (void)writeBeacon:(UBUriBeacon*)beacon
72 | completionBlock:(void (^)(NSError* error))block;
73 |
74 | /**
75 | * Reads beacon advertisement data. The beacon must be connected before reading
76 | * it.
77 | *
78 | * @param block The block will be called when the data have been read.
79 | */
80 | - (void)readBeaconWithCompletionBlock:(void (^)(NSError* error,
81 | UBUriBeacon* beacon))block;
82 |
83 | @end
84 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/uribeacon/UBUriBeacon.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | // Flags of UI Beacons.
20 | typedef NSUInteger UBUriBeaconFlags;
21 |
22 | typedef enum UBUriBeaconRegion {
23 | UBUriBeaconRegionNear, /* between 0 and 0.5 meter */
24 | UBUriBeaconRegionMid, /* between 0.5 and 2 meters */
25 | UBUriBeaconRegionFar, /* larger than 2 meters */
26 | UBUriBeaconRegionUnknown, /* distance could not be determined */
27 | } UBUriBeaconRegion;
28 |
29 | /**
30 | * UBUriBeacon holds the decoded content of a UriBeacon and some information
31 | * related to the physical device such as the identifier and the received signal
32 | * strength indicator.
33 | */
34 | @interface UBUriBeacon : NSObject
35 |
36 | /**
37 | * Initializes a UBUriBeacon with a URI and a transmit power.
38 | *
39 | * @param URI URI of the beacon.
40 | * @param txPowerLevel Transmit power level of the beacon.
41 | */
42 | - (id)initWithURI:(NSURL*)URI txPowerLevel:(int)txPowerLevel;
43 |
44 | /**
45 | * Initializes a UBUriBeacon with a URI, a transmit power and flags.
46 | *
47 | * @param URI URI of the beacon.
48 | * @param txPowerLevel Transmit power level of the beacon.
49 | * @param flags Flags of the beacon. It should be set to 0.
50 | */
51 | - (id)initWithURI:(NSURL*)URI
52 | txPowerLevel:(int)txPowerLevel
53 | flags:(UBUriBeaconFlags)flags;
54 |
55 | /** iOS bluetooth device identifier. */
56 | @property(nonatomic, copy) NSUUID* identifier;
57 |
58 | /**
59 | * When UBUriBeacon is returned from `-[UBUriBeaconScanner beacons]`,
60 | * the value is the current received signal strength indicator of the
61 | * related bluetooth device, in decibels.
62 | */
63 | @property(nonatomic, assign) NSInteger RSSI;
64 |
65 | /** URI of the beacon. */
66 | @property(nonatomic, copy) NSURL* URI;
67 |
68 | /** Transmit power level. */
69 | @property(nonatomic, assign) int txPowerLevel;
70 |
71 | /** Flags. The flags need to be set to 0. */
72 | @property(nonatomic, assign) UBUriBeaconFlags flags;
73 |
74 | /** returns YES if it's going to fit in a bluetooth LE advertisement packet. */
75 | - (BOOL)isValid;
76 |
77 | /** returns the region of the beacon */
78 | - (UBUriBeaconRegion)region;
79 |
80 | @end
81 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/uribeacon/UBUriBeaconPrivate.h:
--------------------------------------------------------------------------------
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 | #import "UBUriBeacon.h"
18 |
19 | #import
20 |
21 | #define URIBEACON_SERVICE @"FED8"
22 | #define EDDYSTONE_SERVICE @"FEAA"
23 |
24 | #define CONFIG_V1_SERVICE @"b35d7da6-eed4-4d59-8f89-f6573edea967"
25 | // ^
26 |
27 | #define CONFIG_V1_CHARACTERISTIC_DATA1 @"b35d7da7-eed4-4d59-8f89-f6573edea967"
28 | // ^
29 |
30 | #define CONFIG_V1_CHARACTERISTIC_DATA2 @"b35d7da8-eed4-4d59-8f89-f6573edea967"
31 | // ^
32 |
33 | #define CONFIG_V1_CHARACTERISTIC_DATASIZE @"b35d7da9-eed4-4d59-8f89-f6573edea967"
34 | // ^
35 |
36 | #define CONFIG_V2_SERVICE @"ee0c2080-8786-40ba-ab96-99b91ac981d8"
37 |
38 | #define CONFIG_V2_CHARACTERISTIC_LOCKSTATE @"ee0c2081-8786-40ba-ab96-99b91ac981d8"
39 | #define CONFIG_V2_CHARACTERISTIC_LOCK @"ee0c2082-8786-40ba-ab96-99b91ac981d8"
40 | #define CONFIG_V2_CHARACTERISTIC_UNLOCK @"ee0c2083-8786-40ba-ab96-99b91ac981d8"
41 | #define CONFIG_V2_CHARACTERISTIC_URI @"ee0c2084-8786-40ba-ab96-99b91ac981d8"
42 | #define CONFIG_V2_CHARACTERISTIC_FLAGS @"ee0c2085-8786-40ba-ab96-99b91ac981d8"
43 | #define CONFIG_V2_CHARACTERISTIC_ADVERTIVEDTXPOWERLEVELS @"ee0c2086-8786-40ba-ab96-99b91ac981d8"
44 | #define CONFIG_V2_CHARACTERISTIC_TXPOWERMODE @"ee0c2087-8786-40ba-ab96-99b91ac981d8"
45 | #define CONFIG_V2_CHARACTERISTIC_PERIOD @"ee0c2088-8786-40ba-ab96-99b91ac981d8"
46 | #define CONFIG_V2_CHARACTERISTIC_RESET @"ee0c2089-8786-40ba-ab96-99b91ac981d8"
47 |
48 | @interface UBUriBeacon (Private)
49 |
50 | - (id)initWithPeripheral:(CBPeripheral *)peripheral
51 | advertisementData:(NSDictionary *)advertisementData
52 | RSSI:(NSNumber *)RSSI;
53 |
54 | - (id)initWithPeripheral:(CBPeripheral *)peripheral
55 | data:(NSData *)data
56 | RSSI:(NSInteger)RSSI;
57 |
58 | - (NSData *)_advertisementData;
59 |
60 | - (void)_updateWithBeacon:(UBUriBeacon *)beacon;
61 |
62 | @end
63 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/uribeacon/UBUriBeaconReader.h:
--------------------------------------------------------------------------------
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 | #import
18 | #import
19 |
20 | @interface UBUriBeaconReader : NSObject
21 |
22 | @property(nonatomic, retain) CBPeripheral *peripheral;
23 |
24 | - (void)readWithCompletionBlock:(void (^)(NSError *error, NSData *data))block;
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/uribeacon/UBUriBeaconScanner.h:
--------------------------------------------------------------------------------
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 | #import
18 | #import
19 |
20 | @class UBUriBeacon;
21 | @class UBConfigurableUriBeacon;
22 |
23 | /**
24 | UBUriBeaconScanner will scan for UriBeacons and configurable UriBeacons.
25 | It will scan for beacons when the application is running in the background if
26 | the application supports it. You'll need to add the background capability
27 | `bluetooth-central` in the Info.plist file. When it's scanning in background,
28 | only non-configurable beacons will be discovered.
29 |
30 | Here's an example of how to scan beacons:
31 |
38 | */
39 | @interface UBUriBeaconScanner : NSObject
40 |
41 | /**
42 | * Initializes the scanner.
43 | * The -[UIApplication sharedApplication] should be given as argument.
44 | * If you're running in an extension, you should use nil.
45 | */
46 | - (id)initWithApplication:(UIApplication*)application;
47 |
48 | /**
49 | * Start discovering UriBeacons. It will check frequently for beacon
50 | * to know whether some appear or disappear.
51 | * @param block The block will be called when there's a change in the list of
52 | * beacons or configurable beacons.
53 | */
54 | - (void)startScanningWithUpdateBlock:(void (^)(void))block;
55 |
56 | /** Stop discovery of UriBeacons and configurable UriBeacons. */
57 | - (void)stopScanning;
58 |
59 | /** Returns the list of nearby UriBeacons. */
60 | - (NSArray* /* UBUriBeacon */)beacons;
61 |
62 | /** Returns the list of UriBeacons that can be configured. */
63 | - (NSArray* /* UBConfigurableUriBeacon */)configurableBeacons;
64 |
65 | @end
66 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/uribeacon/UBUriBeaconScannerPrivate.h:
--------------------------------------------------------------------------------
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 | #import "UBUriBeaconScanner.h"
18 |
19 | #import
20 |
21 | @interface UBUriBeaconScanner (Private)
22 |
23 | - (void)_connectBeaconWithPeripheral:(CBPeripheral *)peripheral
24 | completionBlock:(void (^)(NSError *error))block;
25 |
26 | - (void)_disconnectBeaconWithPeripheral:(CBPeripheral *)peripheral
27 | completionBlock:(void (^)(NSError *error))block;
28 |
29 | - (void)_writeBeaconWithPeripheral:(CBPeripheral *)peripheral
30 | advertisementData:(NSData *)data
31 | completionBlock:(void (^)(NSError *error))block;
32 |
33 | - (void)_readBeaconWithPeripheral:(CBPeripheral *)peripheral
34 | completionBlock:(void (^)(NSError *error, NSData *data))block;
35 |
36 | - (void)_writeURIv2WithPeripheral:(CBPeripheral *)peripheral
37 | url:(NSURL *)url
38 | completionBlock:(void (^)(NSError *error))block;
39 |
40 | - (void)_readURIv2WithPeripheral:(CBPeripheral *)peripheral
41 | completionBlock:(void (^)(NSError *error, NSURL *uri))block;
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/uribeacon/UBUriBeaconWriter.h:
--------------------------------------------------------------------------------
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 | #import
18 | #import
19 |
20 | @interface UBUriBeaconWriter : NSObject
21 |
22 | @property(nonatomic, retain) CBPeripheral *peripheral;
23 | @property(nonatomic, retain) NSData *data;
24 |
25 | - (void)writeWithCompletionBlock:(void (^)(NSError *error))block;
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/uribeacon/UBUriReader.h:
--------------------------------------------------------------------------------
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 | #import
18 | #import
19 |
20 | @interface UBUriReader : NSObject
21 |
22 | @property(nonatomic, retain) CBPeripheral *peripheral;
23 | @property(nonatomic, copy) NSString *characteristic;
24 |
25 | - (void)readWithCompletionBlock:(void (^)(NSError *error, NSData *data))block;
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/uribeacon/UBUriWriter.h:
--------------------------------------------------------------------------------
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 | #import
18 | #import
19 |
20 | @interface UBUriWriter : NSObject
21 |
22 | @property(nonatomic, retain) CBPeripheral *peripheral;
23 | @property(nonatomic, retain) NSData *data;
24 | @property(nonatomic, copy) NSString *characteristic;
25 |
26 | - (void)writeWithCompletionBlock:(void (^)(NSError *error))block;
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Backend/uribeacon/UriBeacon.h:
--------------------------------------------------------------------------------
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 | #import "UBUriBeaconScanner.h"
18 | #import "UBUriBeacon.h"
19 | #import "UBConfigurableUriBeacon.h"
20 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "29x29",
5 | "idiom" : "iphone",
6 | "filename" : "icon-29.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "29x29",
11 | "idiom" : "iphone",
12 | "filename" : "icon-58.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "icon-87.png",
19 | "scale" : "3x"
20 | },
21 | {
22 | "size" : "40x40",
23 | "idiom" : "iphone",
24 | "filename" : "icon-80-1.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "40x40",
29 | "idiom" : "iphone",
30 | "filename" : "icon-120-1.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "57x57",
35 | "idiom" : "iphone",
36 | "filename" : "icon-57.png",
37 | "scale" : "1x"
38 | },
39 | {
40 | "size" : "57x57",
41 | "idiom" : "iphone",
42 | "filename" : "icon-114.png",
43 | "scale" : "2x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "icon-120.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "icon-180.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "29x29",
59 | "idiom" : "ipad",
60 | "filename" : "icon-29-1.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "29x29",
65 | "idiom" : "ipad",
66 | "filename" : "icon-58-1.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "40x40",
71 | "idiom" : "ipad",
72 | "filename" : "icon-40.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "40x40",
77 | "idiom" : "ipad",
78 | "filename" : "icon-80.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "50x50",
83 | "idiom" : "ipad",
84 | "filename" : "icon-50.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "50x50",
89 | "idiom" : "ipad",
90 | "filename" : "icon-100.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "72x72",
95 | "idiom" : "ipad",
96 | "filename" : "icon-72.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "72x72",
101 | "idiom" : "ipad",
102 | "filename" : "icon-144.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "76x76",
107 | "idiom" : "ipad",
108 | "filename" : "icon-76.png",
109 | "scale" : "1x"
110 | },
111 | {
112 | "size" : "76x76",
113 | "idiom" : "ipad",
114 | "filename" : "icon-152.png",
115 | "scale" : "2x"
116 | },
117 | {
118 | "idiom" : "car",
119 | "size" : "120x120",
120 | "scale" : "1x"
121 | }
122 | ],
123 | "info" : {
124 | "version" : 1,
125 | "author" : "xcode"
126 | }
127 | }
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-100.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-114.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-114.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-120-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-120-1.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-120.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-144.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-144.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-152.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-180.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-29-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-29-1.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-29.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-40.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-50.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-57.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-58-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-58-1.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-58.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-72.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-76.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-80-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-80-1.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-80.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-80.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-87.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Images.xcassets/AppIcon.appiconset/icon-87.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Info.plist:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Info.plist
--------------------------------------------------------------------------------
/ios/PhyWeb/PhyWeb.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.application-groups
6 |
7 | group.physical-web.iosapp
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/37x-Checkmark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/37x-Checkmark.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/37x-Checkmark@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/37x-Checkmark@2x.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/LaunchIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/LaunchIcon.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/Progress1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/Progress1.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/Progress2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/Progress2.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/Progress3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/Progress3.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/ScanError.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/ScanError.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/gear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/gear.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/gear@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/gear@2x.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/icon-100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/icon-100.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/icon-114.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/icon-114.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/icon-120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/icon-120.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/icon-144.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/icon-144.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/icon-152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/icon-152.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/icon-180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/icon-180.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/icon-29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/icon-29.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/icon-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/icon-40.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/icon-50.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/icon-50.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/icon-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/icon-512.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/icon-57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/icon-57.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/icon-58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/icon-58.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/icon-72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/icon-72.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/icon-76.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/icon-80.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/icon-80.png
--------------------------------------------------------------------------------
/ios/PhyWeb/Resources/icon-87.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/ios/PhyWeb/Resources/icon-87.png
--------------------------------------------------------------------------------
/ios/PhyWeb/UI/PWActivityIndicator.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | // This view shows a bluetooth scanning activity feedback.
20 |
21 | @interface PWActivityIndicator : UIView
22 |
23 | // Start animation.
24 | - (void)start;
25 |
26 | // Stops animation.
27 | - (void)stop;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/ios/PhyWeb/UI/PWBeaconCell.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | @class PWBeacon;
20 |
21 | @interface PWBeaconCell : UITableViewCell
22 |
23 | // Beacon to show.
24 | @property(nonatomic, retain) PWBeacon *beacon;
25 |
26 | // Initializer.
27 | - (instancetype)initWithStyle:(UITableViewCellStyle)style
28 | reuseIdentifier:(NSString *)reuseIdentifier;
29 |
30 | // Returns cell height required to show the given beacon.
31 | + (CGFloat)heightForDevice:(PWBeacon *)beacon
32 | tableView:(UITableView *)tableView;
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/ios/PhyWeb/UI/PWBeaconChartTableViewCell.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | @interface PWBeaconChartTableViewCell : UITableViewCell
20 |
21 | @property(nonatomic, retain, readonly) UILabel* rssiLabel;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/ios/PhyWeb/UI/PWBeaconChartTableViewCell.m:
--------------------------------------------------------------------------------
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 | #import "PWBeaconChartTableViewCell.h"
18 |
19 | @implementation PWBeaconChartTableViewCell {
20 | UILabel *_rssiLabel;
21 | }
22 |
23 | @synthesize rssiLabel = _rssiLabel;
24 |
25 | - (id)initWithStyle:(UITableViewCellStyle)style
26 | reuseIdentifier:(NSString *)reuseIdentifier {
27 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
28 |
29 | _rssiLabel = [[UILabel alloc] initWithFrame:CGRectZero];
30 | [_rssiLabel setTextAlignment:NSTextAlignmentRight];
31 | [[self contentView] addSubview:_rssiLabel];
32 |
33 | return self;
34 | }
35 |
36 | - (void)layoutSubviews {
37 | [super layoutSubviews];
38 | CGRect frame = CGRectMake(10, 10, [self bounds].size.width - 100, 40);
39 | [[self textLabel] setFrame:frame];
40 |
41 | frame = CGRectMake([self bounds].size.width - 90, 10, 80, 40);
42 | [_rssiLabel setFrame:frame];
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/ios/PhyWeb/UI/PWBeaconsViewController.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | // This part of the UI will show a list of beacons.
20 | @interface PWBeaconsViewController : UIViewController
21 |
22 | - (void)updateBeaconsNow;
23 |
24 | - (void)disablePlaceholder;
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/ios/PhyWeb/UI/PWChartViewController.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | @class PWBeacon;
20 |
21 | @interface PWChartViewController : UIViewController
22 |
23 | @property (nonatomic, copy) NSURL * URL;
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/ios/PhyWeb/UI/PWConfigureViewController.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | #import "UriBeacon.h"
20 |
21 | // This part of the UI will show a configuration panel for a configurable
22 | // beacon. It will let the user set a URL for it.
23 | @interface PWConfigureViewController : UIViewController
24 |
25 | // Beacon to configure.
26 | @property(nonatomic, retain) UBConfigurableUriBeacon *beacon;
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/ios/PhyWeb/UI/PWGradientView.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | // This object will show a linear gradient from top to bottom.
20 | @interface PWGradientView : UIView
21 |
22 | // Color to show at the top of the gradient.
23 | @property(nonatomic, retain) UIColor* topColor;
24 |
25 | // Color to show at the bottom of the gradient.
26 | @property(nonatomic, retain) UIColor* bottomColor;
27 |
28 | @end
29 |
--------------------------------------------------------------------------------
/ios/PhyWeb/UI/PWGradientView.m:
--------------------------------------------------------------------------------
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 | #import "PWGradientView.h"
18 |
19 | @implementation PWGradientView {
20 | UIColor* _bottomColor;
21 | UIColor* _topColor;
22 | }
23 |
24 | @synthesize bottomColor = _bottomColor;
25 | @synthesize topColor = _topColor;
26 |
27 | - (instancetype)initWithFrame:(CGRect)frame {
28 | self = [super initWithFrame:frame];
29 | self.opaque = NO;
30 | return self;
31 | }
32 |
33 | - (void)drawRect:(CGRect)rect {
34 | CGContextRef context = UIGraphicsGetCurrentContext();
35 |
36 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
37 | CGFloat locations[3] = {0., 0.6, 1.};
38 | CGFloat components[12] = {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 0.};
39 | CGGradientRef gradient =
40 | CGGradientCreateWithColorComponents(colorSpace, components, locations, 3);
41 | CGRect bounds = [self bounds];
42 | CGPoint point = bounds.origin;
43 | point.y += bounds.size.height;
44 | CGContextDrawLinearGradient(context, gradient, bounds.origin, point, 0);
45 | CFRelease(gradient);
46 | CFRelease(colorSpace);
47 |
48 | [super drawRect:rect];
49 | }
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/ios/PhyWeb/UI/PWPlaceholderView.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | @interface PWPlaceholderView : UIView
20 |
21 | @property(nonatomic, assign) BOOL showLabel;
22 | @property(nonatomic, copy) NSString* label;
23 | @property(nonatomic, assign) BOOL bluetoothEnabled;
24 |
25 | // Start animation.
26 | - (void)start;
27 |
28 | // Stops animation.
29 | - (void)stop;
30 |
31 | - (void)setShowLabel:(BOOL)showLabel animated:(BOOL)animated;
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/ios/PhyWeb/UI/PWSettingsViewController.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | // This part of the UI will show instructions about how to .
20 | @interface PWSettingsViewController : UIViewController
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/ios/PhyWeb/UI/PWSignalStrengthView.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | // This object will show a signal strength icon that will change
20 | // depending on the quality.
21 | @interface PWSignalStrengthView : UIView
22 |
23 | // This is a linear value between 0 and 100
24 | // 0: bad quality, 100: excellent quality.
25 | @property(nonatomic, assign) NSInteger quality;
26 |
27 | @end
28 |
--------------------------------------------------------------------------------
/ios/PhyWeb/UI/PWSignalStrengthView.m:
--------------------------------------------------------------------------------
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 | #import "PWSignalStrengthView.h"
18 |
19 | @implementation PWSignalStrengthView {
20 | NSInteger _quality;
21 | }
22 |
23 | @synthesize quality = _quality;
24 |
25 | - (instancetype)initWithFrame:(CGRect)frame {
26 | self = [super initWithFrame:frame];
27 | self.opaque = NO;
28 | return self;
29 | }
30 |
31 | - (void)setQuality:(NSInteger)quality {
32 | _quality = quality;
33 | [self setNeedsDisplay];
34 | }
35 |
36 | - (void)drawRect:(CGRect)rect {
37 | [[UIColor blackColor] setFill];
38 | if (_quality >= 5) {
39 | CGRect rect = CGRectMake(0, 9, 3, 6);
40 | UIRectFill(rect);
41 | }
42 | if (_quality >= 25) {
43 | CGRect rect = CGRectMake(4, 6, 3, 9);
44 | UIRectFill(rect);
45 | }
46 | if (_quality >= 50) {
47 | CGRect rect = CGRectMake(8, 3, 3, 12);
48 | UIRectFill(rect);
49 | }
50 | if (_quality >= 75) {
51 | CGRect rect = CGRectMake(12, 0, 3, 15);
52 | UIRectFill(rect);
53 | }
54 | }
55 |
56 | @end
57 |
--------------------------------------------------------------------------------
/ios/PhyWeb/UI/PWSimpleWebViewController.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | @protocol PWSimpleWebViewControllerDelegate;
20 |
21 | @interface PWSimpleWebViewController : UIViewController
22 |
23 | @property(nonatomic, copy) NSString *title;
24 | @property(nonatomic, assign) id delegate;
25 | @property(nonatomic, assign) BOOL proceedButtonVisible;
26 |
27 | - (instancetype)initWithURL:(NSURL *)url;
28 | - (instancetype)initWithHTMLString:(NSString *)htmlString;
29 |
30 | @end
31 |
32 | @protocol PWSimpleWebViewControllerDelegate
33 |
34 | @optional
35 | - (void)simpleWebViewControllerProceedPressed:
36 | (PWSimpleWebViewController *)controller;
37 |
38 | @end
39 |
--------------------------------------------------------------------------------
/ios/PhyWeb/main.m:
--------------------------------------------------------------------------------
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 | #import
18 | #import "AppDelegate.h"
19 |
20 | int main(int argc, char* argv[]) {
21 | @autoreleasepool {
22 | return UIApplicationMain(argc, argv, nil,
23 | NSStringFromClass([AppDelegate class]));
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ios/PhyWeb/third-party/JBChartView/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2013 Jawbone Inc.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
--------------------------------------------------------------------------------
/ios/PhyWeb/third-party/JBChartView/README:
--------------------------------------------------------------------------------
1 | Original repository: https://github.com/Jawbone/JBChartView
2 |
--------------------------------------------------------------------------------
/ios/README.md:
--------------------------------------------------------------------------------
1 | # iOS client
2 |
3 | This iOS client can be downloaded from the [Apple App Store](https://itunes.apple.com/us/app/physical-web/id927653608?mt=8). A walkthrough of the app [is here](http://github.com/google/physical-web/blob/master/documentation/android_client_walkthrough.md) (Android version) and will show you how to put your URL into a beacon.
4 |
5 | Keep in mind that this software is just a prototype. We are doing it this way to easily and quickly test the concept. Eventually, the goal is to have this Physical Web code rolled into each browser.
--------------------------------------------------------------------------------
/ios/scripts/make-dev.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | folder="`pwd`"
3 | version=`defaults read "$folder/Info.plist" CFBundleShortVersionString`
4 | version=`echo $version|sed -e 's/\(.*\)-.*/\1/'`
5 | defaults write "$folder/Info.plist" CFBundleShortVersionString "${version}-dev"
6 |
--------------------------------------------------------------------------------
/ios/scripts/update-build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | folder="`pwd`"
3 | build_version=`defaults read "$folder/Info.plist" CFBundleVersion`
4 | build_version=$(($build_version+1))
5 | defaults write "$folder/Info.plist" CFBundleVersion $build_version
6 | version=`defaults read "$folder/Info.plist" CFBundleShortVersionString`
7 | version=`echo $version|sed -e 's/\(.*\)-.*/\1/'`
8 | defaults write "$folder/Info.plist" CFBundleShortVersionString $version
9 |
--------------------------------------------------------------------------------
/ios/today/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | Physical Web Beacons
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | org.physical-web.iosapp.today
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | XPC!
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 16
25 | NSExtension
26 |
27 | NSExtensionPrincipalClass
28 | TodayViewController
29 | NSExtensionPointIdentifier
30 | com.apple.widget-extension
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/ios/today/TodayViewController.h:
--------------------------------------------------------------------------------
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 | #import
18 |
19 | @interface TodayViewController : UIViewController
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/ios/today/today.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.application-groups
6 |
7 | group.physical-web.iosapp
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/java/libs/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | .idea
4 | build
5 |
--------------------------------------------------------------------------------
/java/libs/README.md:
--------------------------------------------------------------------------------
1 | # Physical Web Collection library for java
2 |
3 | This java library contains data structures and convenience utilities for
4 | storing metadata related to devices that broadcast URLs. This library is
5 | intended to help bootstrap new Physical Web clients written in java.
6 |
--------------------------------------------------------------------------------
/java/libs/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'checkstyle'
3 | id 'findbugs'
4 | id 'java'
5 | id 'pmd'
6 | }
7 |
8 | repositories {
9 | jcenter()
10 | }
11 |
12 | sourceSets {
13 | integrationTest {
14 | java {
15 | compileClasspath += main.output + test.output
16 | runtimeClasspath += main.output + test.output
17 | srcDir file('src/integrationTest/java')
18 | }
19 | }
20 | }
21 |
22 | configurations {
23 | integrationTestCompile.extendsFrom testCompile
24 | integrationTestRuntime.extendsFrom testRuntime
25 | }
26 |
27 | gradle.projectsEvaluated {
28 | tasks.withType(JavaCompile) {
29 | options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
30 | }
31 | }
32 |
33 | dependencies {
34 | compile 'org.json:json:20140107'
35 | testCompile 'junit:junit:4.11'
36 | testCompile 'org.skyscreamer:jsonassert:1.2.3'
37 | compile 'commons-codec:commons-codec:1.10'
38 | }
39 |
40 | task integrationTest(type: Test) {
41 | testClassesDir = sourceSets.integrationTest.output.classesDir
42 | classpath = sourceSets.integrationTest.runtimeClasspath
43 | outputs.upToDateWhen { false }
44 | }
45 |
46 | findbugsMain {
47 | ignoreFailures = false
48 | effort = "max"
49 | reportLevel = "low"
50 | reports {
51 | xml.enabled = false
52 | html.enabled = true
53 | }
54 | }
55 |
56 | findbugsTest {
57 | ignoreFailures = false
58 | effort = "max"
59 | reportLevel = "low"
60 | reports {
61 | xml.enabled = false
62 | html.enabled = true
63 | }
64 | }
65 |
66 | findbugs {
67 | reportsDir = new File(buildDir, "reports/findbugs")
68 | excludeFilter = new File(projectDir, "config/findbugs/exclude-filter.xml")
69 | }
70 |
71 | checkstyle {
72 | configProperties.checkstyleSuppressionsPath =
73 | new File(projectDir, "config/checkstyle/suppressions.xml")
74 | }
75 |
76 | pmdMain {
77 | reports {
78 | xml.enabled = false
79 | html.enabled = true
80 | }
81 | }
82 |
83 | pmd {
84 | ignoreFailures = false
85 | ruleSetFiles = files(new File(projectDir, "config/pmd/pmd-ruleset.xml"))
86 | ruleSets = []
87 | reportsDir = new File(buildDir, "reports/findbugs")
88 | }
89 |
90 | javadoc {
91 | source = sourceSets.main.java
92 | classpath = sourceSets.main.runtimeClasspath
93 | }
94 |
95 | tasks.withType(Test) {
96 | reports.html.destination = file("${reporting.baseDir}/${name}")
97 | }
98 |
99 | task wrapper(type: Wrapper) {
100 | gradleVersion = '2.14'
101 | }
102 |
103 | integrationTest.dependsOn assemble
104 |
--------------------------------------------------------------------------------
/java/libs/config/checkstyle/suppressions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/java/libs/config/findbugs/exclude-filter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/java/libs/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 |
--------------------------------------------------------------------------------
/java/libs/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/java/libs/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/java/libs/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jun 22 15:19:42 PDT 2016
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-bin.zip
7 |
--------------------------------------------------------------------------------
/java/libs/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 |
--------------------------------------------------------------------------------
/java/libs/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'libs'
2 |
--------------------------------------------------------------------------------
/java/libs/src/main/java/org/physical_web/collection/BitmapRequest.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.collection;
17 |
18 | import java.io.ByteArrayOutputStream;
19 | import java.io.IOException;
20 | import java.io.InputStream;
21 | import java.net.HttpURLConnection;
22 | import java.net.MalformedURLException;
23 |
24 | /**
25 | * A class that represents an HTTP request for an image.
26 | * The response is a byte array of bitmap data.
27 | */
28 | class BitmapRequest extends Request {
29 | /**
30 | * Construct a bitmap HTTP request.
31 | * @param url The url to make this HTTP request to.
32 | * @param callback The callback run when the HTTP response is received.
33 | * The callback can be called with a null bitmap if the image
34 | * couldn't be decoded.
35 | * @throws MalformedURLException on invalid url
36 | */
37 | public BitmapRequest(String url, RequestCallback callback) throws MalformedURLException {
38 | super(url, callback);
39 | }
40 |
41 | /**
42 | * The callback that gets run after the request is made.
43 | */
44 | public interface RequestCallback extends Request.RequestCallback {}
45 |
46 | /**
47 | * Helper method to make an HTTP request.
48 | * @param urlConnection The HTTP connection.
49 | */
50 | public void writeToUrlConnection(HttpURLConnection urlConnection) throws IOException {}
51 |
52 | /**
53 | * Helper method to read an HTTP response.
54 | * @param is The InputStream.
55 | * @return The decoded image.
56 | */
57 | protected byte[] readInputStream(InputStream is) throws IOException {
58 | ByteArrayOutputStream os = new ByteArrayOutputStream();
59 | byte[] buffer = new byte[1024];
60 | int len;
61 | while ((len = is.read(buffer)) != -1) {
62 | os.write(buffer, 0, len);
63 | }
64 | return os.toByteArray();
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/java/libs/src/main/java/org/physical_web/collection/PhysicalWebCollectionException.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 | package org.physical_web.collection;
17 |
18 | /**
19 | * Exception class used when PhysicalWebCollection runs into problems.
20 | */
21 | public class PhysicalWebCollectionException extends Exception {
22 | /**
23 | * Construct a PhysicalWebCollectionException.
24 | * @param message The detail message string.
25 | */
26 | public PhysicalWebCollectionException(String message) {
27 | super(message);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/java/libs/src/main/java/org/physical_web/collection/PwPair.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 | package org.physical_web.collection;
17 |
18 | /**
19 | * A physical web pair represents a UrlDevice and its corresponding PwsResult.
20 | */
21 | public class PwPair {
22 | private final UrlDevice mUrlDevice;
23 | private final PwsResult mPwsResult;
24 |
25 | /**
26 | * Construct a PwPair.
27 | * @param urlDevice The URL device.
28 | * @param pwsResult The metadata returned by PWS for the URL broadcast by the device.
29 | */
30 | public PwPair(UrlDevice urlDevice, PwsResult pwsResult) {
31 | mUrlDevice = urlDevice;
32 | mPwsResult = pwsResult;
33 | }
34 |
35 | /**
36 | * Get the UrlDevice represented in the pair.
37 | * @return the UrlDevice.
38 | */
39 | public UrlDevice getUrlDevice() {
40 | return mUrlDevice;
41 | }
42 |
43 | /**
44 | * Get the PwsResult represented in the pair.
45 | * @return the PwsResult.
46 | */
47 | public PwsResult getPwsResult() {
48 | return mPwsResult;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/java/libs/src/main/java/org/physical_web/collection/PwsResultCallback.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 | package org.physical_web.collection;
17 |
18 | import java.util.Collection;
19 |
20 | /**
21 | * Callback to implement for requests made to the Physical Web Service.
22 | */
23 | public abstract class PwsResultCallback {
24 | /**
25 | * Handles a valid PwsResult.
26 | * @param pwsResult The result returned from the Physical Web Service.
27 | */
28 | public abstract void onPwsResult(PwsResult pwsResult);
29 |
30 | /**
31 | * Handles a URL that did not receive a result from the PWS.
32 | * @param url The URL sent to the Physical Web Service.
33 | */
34 | public void onPwsResultAbsent(String url) {}
35 |
36 | /**
37 | * Handles an error that occurred while attempting to use the Physical Web Service.
38 | * @param urls The urls sent in batch to the Physical Web Service.
39 | * @param httpResponseCode The HTTP response code returned by the Physical
40 | * Web Service. This will be 0 if a response was never received.
41 | * @param e The encountered exception.
42 | */
43 | public void onPwsResultError(Collection urls, int httpResponseCode, Exception e) {}
44 |
45 | /**
46 | * Handles error that occurred while attempting to use the Physical Web Service.
47 | * @param durationMillis The number of milliseconds it took to receive a response.
48 | */
49 | public void onResponseReceived(long durationMillis) {}
50 | }
51 |
--------------------------------------------------------------------------------
/java/libs/src/main/java/org/physical_web/collection/PwsResultIconCallback.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.collection;
17 |
18 | /**
19 | * Callback to implement for requests made to fetch icons.
20 | */
21 | public abstract class PwsResultIconCallback {
22 | /**
23 | * Handle a valid PwsResult.
24 | * @param icon The icon returned from the HTTP request.
25 | */
26 | public abstract void onIcon(byte[] icon);
27 |
28 | /**
29 | * Handle an error that occurred while attempting to use the Physical Web
30 | * Service.
31 | * @param httpResponseCode The HTTP response code returned by the Physical
32 | * Web Service. This will be 0 if a response was never received.
33 | * @param e The encountered exception.
34 | */
35 | public void onError(int httpResponseCode, Exception e) {}
36 | }
37 |
--------------------------------------------------------------------------------
/java/libs/src/main/java/org/physical_web/collection/UrlGroup.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 | package org.physical_web.collection;
17 |
18 | import java.util.ArrayList;
19 | import java.util.Collections;
20 | import java.util.Comparator;
21 | import java.util.List;
22 |
23 | /**
24 | * A collection of similar URLs, the devices broadcasting those URLs, and associated metadata.
25 | */
26 | public class UrlGroup {
27 | private String mGroupId;
28 | private List mPwPairs;
29 |
30 | /**
31 | * Construct a UrlGroup.
32 | * @param groupId The URL group ID of this group.
33 | */
34 | public UrlGroup(String groupId) {
35 | mGroupId = groupId;
36 | mPwPairs = new ArrayList();
37 | }
38 |
39 | /**
40 | * Gets the group ID for this group.
41 | * @return Group ID
42 | */
43 | public String getGroupId() {
44 | return mGroupId;
45 | }
46 |
47 | /**
48 | * Add a PwPair to this group.
49 | * @param pwPair The PwPair to add.
50 | */
51 | public void addPair(PwPair pwPair) {
52 | mPwPairs.add(pwPair);
53 | }
54 |
55 | /**
56 | * Get the top-ranked PwPair in this group.
57 | * @return The top PwPair.
58 | */
59 | public PwPair getTopPair(Comparator comparator) {
60 | Collections.sort(mPwPairs, comparator);
61 | return mPwPairs.get(0);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/java/libs/src/main/java/org/physical_web/collection/Utils.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 | package org.physical_web.collection;
17 |
18 | /**
19 | * Utility methods for the Physical Web library.
20 | */
21 | class Utils {
22 | /**
23 | * Compare two nullable comparables, preferring any non-null value over null.
24 | * @param o1 first object to compare
25 | * @param o2 second object to compare
26 | * @param a type that implements Comparable<T>
27 | * @return comparison value
28 | */
29 | public static > int nullSafeCompare(T o1, T o2) {
30 | if (o1 == o2) {
31 | return 0;
32 | }
33 | if (o1 == null) {
34 | return -1;
35 | }
36 | if (o2 == null) {
37 | return 1;
38 | }
39 | return o1.compareTo(o2);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/java/libs/src/test/java/org/physical_web/collection/PwPairTest.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 | package org.physical_web.collection;
17 |
18 | import static org.junit.Assert.*;
19 |
20 | import org.junit.Before;
21 | import org.junit.Test;
22 |
23 | /**
24 | * PwPair unit test class.
25 | */
26 | public class PwPairTest {
27 | private static final String ID1 = "id1";
28 | private static final String ID2 = "id2";
29 | private static final String URL1 = "http://example.com";
30 | private static final String URL2 = "http://physical-web.org";
31 | private static final String TITLE1 = "title1";
32 | private static final String TITLE2 = "title2";
33 | private static final String DESCRIPTION1 = "description1";
34 | private static final String DESCRIPTION2 = "description2";
35 | private static final String ICON_URL1 = "http://example.com/favicon.ico";
36 | private static final String ICON_URL2 = "http://physical-web.org/favicon.ico";
37 | private static final String GROUP_ID1 = "group1";
38 | private static final String GROUP_ID2 = "group2";
39 | private static final double RANK1 = 0.5d;
40 | private static final double RANK2 = 0.9d;
41 | private UrlDevice mUrlDevice1;
42 | private PwsResult mPwsResult1;
43 | private PwPair mPwPair1 = null;
44 |
45 | @Before
46 | public void setUp() {
47 | mUrlDevice1 = new UrlDevice(ID1, URL1);
48 | mPwsResult1 = new PwsResult.Builder(URL1, URL1)
49 | .setTitle(TITLE1)
50 | .setDescription(DESCRIPTION1)
51 | .setIconUrl(ICON_URL1)
52 | .setGroupId(GROUP_ID1)
53 | .build();
54 | mPwPair1 = new PwPair(mUrlDevice1, mPwsResult1);
55 | }
56 |
57 | @Test
58 | public void constructorCreatesProperObject() {
59 | assertEquals(mUrlDevice1, mPwPair1.getUrlDevice());
60 | assertEquals(mPwsResult1, mPwPair1.getPwsResult());
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/nodejs/FatBeaconPeripheral/README.md:
--------------------------------------------------------------------------------
1 | FatBeacon on Raspberry Pi
2 | =========================
3 |
4 | This is a nodejs implementation of a Fatbeacon developed on a Raspberry Pi 3.
5 | It will advertise a connectable Fatbeacon over Bluetooth Low Energy (BLE).
6 | When the central (client) connects to the peripheral (Fatbeacon/server), the
7 | central will attempt to read the webpageCharacteristic, which serves a HTML.
8 | There is also the option to have this data be compressed with gzip.
9 |
10 | Instructions for Raspbian:
11 | --------------------------
12 | 1. Clone repository onto Pi. If you're using a Pi2 or earlier, make sure you
13 | have a bluetooth chip installed.
14 | 2. Make sure you have nodejs
15 |
16 | ```$ node -v```
17 |
18 | If not, then run
19 |
20 | ```$ sudo apt install nodejs```
21 |
22 | 3. For bleno make sure bluetooth, bluez, libbluetooth-dev, and libudev-dev
23 | are installed
24 |
25 | ```$ sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev```
26 |
27 | 4. Navigate to the repository directory and run
28 |
29 | ```$ sudo npm install```
30 |
31 | This should download all required nodejs libraries.
32 | 5. To run
33 |
34 | ```$ sudo node FatBeacon.js```
35 |
--------------------------------------------------------------------------------
/nodejs/FatBeaconPeripheral/webpageCharacteristic.js:
--------------------------------------------------------------------------------
1 | var util = require('util');
2 | var bleno = require('bleno');
3 | var CHARACTERISTIC_UUID = 'd1a517f0-2499-46ca-9ccc-809bc1c966fa';
4 |
5 | var WebpageCharacteristic = function() {
6 | WebpageCharacteristic.super_.call(this, {
7 | uuid: CHARACTERISTIC_UUID,
8 | properties: ['read'],
9 | value: null
10 | });
11 |
12 | this._value = Buffer.alloc(0);
13 | this._updateValueCallback = null;
14 |
15 | this._mtuSize = 500; // 5 less than the specified mtu
16 | this._start = 0;
17 | this._end = this._mtuSize;
18 | };
19 |
20 | util.inherits(WebpageCharacteristic, bleno.Characteristic);
21 |
22 | WebpageCharacteristic.prototype.onReadRequest = function(offset, callback) {
23 | var tempBuffer = this._value.slice(this._start, this._end);
24 | callback(this.RESULT_SUCCESS, tempBuffer);
25 |
26 | this._start = this._end;
27 | this._end = this._end + this._mtuSize;
28 | if(this._start >= this._value.length) {
29 | this._start = 0;
30 | this._end = this._mtuSize;
31 | }
32 | };
33 |
34 | WebpageCharacteristic.prototype.onWriteRequest = function(data, offset, withoutResponse, callback) {
35 | this._value = data;
36 |
37 | console.log(`Writing ${this._value.length} bytes`);
38 |
39 | if (this._updateValueCallback) {
40 | console.log('WebpageCharacteristic - onWriteRequest: notifying');
41 |
42 | this._updateValueCallback(this._value);
43 | }
44 |
45 | if(callback) {
46 | callback(this.RESULT_SUCCESS);
47 | }
48 | };
49 |
50 | WebpageCharacteristic.prototype.onSubscribe = function(maxValueSize, updateValueCallback) {
51 | console.log('WebpageCharacteristic - onSubscribe');
52 | this._updateValueCallback = updateValueCallback;
53 | };
54 |
55 | WebpageCharacteristic.prototype.onUnsubscribe = function() {
56 | console.log('WebpageCharacteristic - onUnsubscribe');
57 | this._updateValueCallback = null;
58 | };
59 |
60 | module.exports = WebpageCharacteristic;
61 |
--------------------------------------------------------------------------------
/nodejs/README.md:
--------------------------------------------------------------------------------
1 | ## node-eddystone-beacon-scanner
2 |
3 | There is an excellent node.js scanner module written by [@sandeepmistry](https://github.com/sandeepmistry). If you'd like to build a RasperryPi/laptop client to scan for beacons, please use this.
4 |
5 | [node-eddystone-beacon-scanner](https://github.com/sandeepmistry/node-eddystone-beacon-scanner)
6 |
7 | ## physical-web-scan
8 |
9 | If you don't want to build your own client, you can use this for Mac OSX. It fetches metadata from the [Physical Web Service](../web-service) and displays found beacons in both the terminal and notification center.
10 |
11 | [physical-web-scan](https://github.com/dermike/physical-web-scan)
12 |
--------------------------------------------------------------------------------
/travis/build.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Test the android project
4 | (
5 | cd android/PhysicalWeb/
6 | # This will run our linters etc.
7 | # NOTE: check depends on assembleDebug
8 | ./gradlew check
9 | ./gradlew test
10 | )
11 |
12 | # Test the Physical Web java libraries
13 | (
14 | cd java/libs
15 | ./gradlew check
16 | ./gradlew test
17 | )
18 |
--------------------------------------------------------------------------------
/web-service/.gitignore:
--------------------------------------------------------------------------------
1 | # Common Nonsense
2 | **/*.pyc
3 | **/.DS_Store
4 |
5 | # Do not commit these files
6 | /API_KEYS.json
7 | *.SECRET.*
8 |
--------------------------------------------------------------------------------
/web-service/app.yaml:
--------------------------------------------------------------------------------
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 | application: url-caster
18 | version: 1
19 | runtime: python27
20 | api_version: 1
21 | threadsafe: yes
22 |
23 | handlers:
24 | - url: /favicon\.ico
25 | static_files: favicon.ico
26 | upload: favicon\.ico
27 |
28 | - url: /webui
29 | static_files: static/index.html
30 | upload: static/index\.html
31 |
32 | - url: /webui.raw
33 | static_files: static/raw.html
34 | upload: static/raw\.html
35 |
36 | - url: /shorten-url
37 | script: shortener.app
38 |
39 | - url: /experimental/.*
40 | script: experimental.app
41 |
42 | - url: .*
43 | script: handlers.app
44 |
45 | libraries:
46 | - name: webapp2
47 | version: "2.5.2"
48 |
49 | - name: lxml
50 | version: "2.3.5"
51 |
52 | builtins:
53 | - appstats: on
54 |
--------------------------------------------------------------------------------
/web-service/appengine_config.py:
--------------------------------------------------------------------------------
1 | def webapp_add_wsgi_middleware(app):
2 | from google.appengine.ext.appstats import recording
3 | app = recording.appstats_wsgi_middleware(app)
4 | return app
5 |
--------------------------------------------------------------------------------
/web-service/config.SAMPLE.json:
--------------------------------------------------------------------------------
1 | {
2 | "oauth_keys": {
3 | "goo.gl": "Insert OAuth key here, by following these docs: https://developers.google.com/url-shortener/v1/getting_started"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/web-service/examples/title-only.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Sample Title
5 |
6 |
7 |
--------------------------------------------------------------------------------
/web-service/experimental.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2015 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 | import helpers
18 | import json
19 | import logging
20 | import models
21 | import webapp2
22 |
23 | ################################################################################
24 |
25 | class GooglRedirect(webapp2.RequestHandler):
26 | def get(self, path):
27 | return self._redirect(path);
28 |
29 | def head(self, path):
30 | return self._redirect(path);
31 |
32 | def _redirect(self, path):
33 | try:
34 | distance = float(self.request.headers['X-PhysicalWeb-Distance'])
35 | except:
36 | distance = None
37 |
38 | logging.info('GoogleRedirect with distance:{0}'.format(distance))
39 |
40 | if distance > 2:
41 | self.response.set_status(204)
42 | return
43 |
44 | self.redirect('http://goo.gl/{0}'.format(path))
45 |
46 | ################################################################################
47 |
48 | app = webapp2.WSGIApplication([
49 | ('/experimental/googl/(.*)', GooglRedirect),
50 | ], debug=True)
51 |
52 | if not helpers.ENABLE_EXPERIMENTAL:
53 | app = webapp2.WSGIApplication([], debug=True)
54 |
--------------------------------------------------------------------------------
/web-service/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/google/physical-web/12604319e99b6d6dff451fc5a58a13a271f1dc7a/web-service/favicon.ico
--------------------------------------------------------------------------------
/web-service/models.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2015 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 | from google.appengine.ext import ndb
18 |
19 | class BaseModel(ndb.Model):
20 | added_on = ndb.DateTimeProperty(auto_now_add = True)
21 | updated_on = ndb.DateTimeProperty(auto_now = True)
22 |
23 | class SiteInformation(BaseModel):
24 | url = ndb.TextProperty()
25 | favicon_url = ndb.TextProperty(indexed = True)
26 | title = ndb.TextProperty()
27 | description = ndb.TextProperty()
28 | jsonlds = ndb.TextProperty()
29 |
--------------------------------------------------------------------------------
/web-service/shortener.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | #
3 | # Copyright 2015 Google Inc.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | from google.appengine.api import urlfetch
18 | import helpers
19 | import json
20 | import webapp2
21 |
22 | ################################################################################
23 |
24 | class ShortURL(webapp2.RequestHandler):
25 | def post(self):
26 | input_data = self.request.body
27 | config = helpers.GetConfig()
28 | apikey = config['oauth_keys']['goo.gl']
29 | url = 'https://www.googleapis.com/urlshortener/v1/url?key=' + apikey
30 | referer = 'url-cast.physical-web.org'
31 | result = urlfetch.fetch(url,
32 | validate_certificate=True,
33 | method=urlfetch.POST,
34 | payload=input_data,
35 | headers = {
36 | 'Content-Type': 'application/json',
37 | 'Referer': referer
38 | })
39 | self.response.headers['Content-Type'] = 'application/json'
40 | self.response.write(result.content)
41 |
42 | ################################################################################
43 |
44 | app = webapp2.WSGIApplication([
45 | ('/shorten-url', ShortURL),
46 | ], debug=True)
47 |
--------------------------------------------------------------------------------
/web-service/static/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
17 |
18 |
19 |
20 |
21 |
61 |
62 |
63 |
64 |