Split the project into a library and sample app

This commit is contained in:
Alexandros Schillings
2014-03-11 17:08:17 +00:00
parent cad6427b49
commit cb6e9db082
59 changed files with 200 additions and 38 deletions
+9
View File
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
+6
View File
@@ -0,0 +1,6 @@
/bin
/gen
local.properties
.idea/
lint.xml
/.apt_generated
+33
View File
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Bluetooth LE Library</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6
+17
View File
@@ -0,0 +1,17 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="uk.co.alt236.bluetoothlelib"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="18"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
</application>
</manifest>
Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

+15
View File
@@ -0,0 +1,15 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-19
android.library=true
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

+5
View File
@@ -0,0 +1,5 @@
<resources>
<string name="app_name">Bluetooth LE Library</string>
</resources>
@@ -1,9 +1,10 @@
package uk.co.alt236.btlescan.containers;
package uk.co.alt236.bluetoothlelib.device;
import java.util.Arrays;
import uk.co.alt236.btlescan.util.AdRecordUtils;
import uk.co.alt236.btlescan.util.ByteUtils;
import uk.co.alt236.bluetoothlelib.device.adrecord.AdRecordStore;
import uk.co.alt236.bluetoothlelib.util.AdRecordUtils;
import uk.co.alt236.bluetoothlelib.util.ByteUtils;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.os.Bundle;
@@ -1,4 +1,4 @@
package uk.co.alt236.btlescan.containers;
package uk.co.alt236.bluetoothlelib.device.adrecord;
import java.util.Arrays;
import android.os.Bundle;
@@ -1,10 +1,10 @@
package uk.co.alt236.btlescan.containers;
package uk.co.alt236.bluetoothlelib.device.adrecord;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import uk.co.alt236.btlescan.util.AdRecordUtils;
import uk.co.alt236.bluetoothlelib.util.AdRecordUtils;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;
@@ -1,12 +1,14 @@
package uk.co.alt236.btlescan.containers;
package uk.co.alt236.bluetoothlelib.device.mfdata;
import java.util.Arrays;
import java.util.UUID;
import uk.co.alt236.btlescan.util.ByteUtils;
import uk.co.alt236.bluetoothlelib.device.BluetoothLeDevice;
import uk.co.alt236.bluetoothlelib.device.adrecord.AdRecord;
import uk.co.alt236.bluetoothlelib.util.ByteUtils;
import android.util.Log;
public final class ManufacturerDataIBeacon {
public final class IBeaconManufacturerData {
// 0 4C # Byte 1 (LSB) of Company identifier code
// 1 00 # Byte 0 (MSB) of Company identifier code (0x004C == Apple)
// 2 02 # Byte 0 of iBeacon advertisement indicator
@@ -41,11 +43,11 @@ public final class ManufacturerDataIBeacon {
private final int mMinor;
private final UUID mUUID;
public ManufacturerDataIBeacon(BluetoothLeDevice device){
public IBeaconManufacturerData(BluetoothLeDevice device){
this(device.getAdRecordStore().getRecord(AdRecord.TYPE_MANUFACTURER_SPECIFIC_DATA).getData());
}
public ManufacturerDataIBeacon(byte[] data){
public IBeaconManufacturerData(byte[] data){
mData = data;
Log.d("TAG", "~ Reading iBeacon Data: " + ByteUtils.byteArrayToHexString(data));
@@ -1,4 +1,4 @@
package uk.co.alt236.btlescan.util;
package uk.co.alt236.bluetoothlelib.util;
import java.util.ArrayList;
import java.util.Arrays;
@@ -7,7 +7,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import uk.co.alt236.btlescan.containers.AdRecord;
import uk.co.alt236.bluetoothlelib.device.adrecord.AdRecord;
import android.annotation.SuppressLint;
import android.util.SparseArray;
@@ -1,4 +1,4 @@
package uk.co.alt236.btlescan.util;
package uk.co.alt236.bluetoothlelib.util;
import java.nio.ByteBuffer;
@@ -1,6 +1,6 @@
package uk.co.alt236.btlescan.util;
package uk.co.alt236.bluetoothlelib.util;
import uk.co.alt236.btlescan.containers.BluetoothLeDevice;
import uk.co.alt236.bluetoothlelib.device.BluetoothLeDevice;
public class IBeaconUtils {
private static final byte[] SCAN_RECORD_PREFIX_IBEACON_1 = new byte[]{0x02, 0x01, 0x1A, 0x1A, (byte) 0xFF, 0x4C, 0x00, 0x02, 0x15};
+6
View File
@@ -0,0 +1,6 @@
/bin
/gen
local.properties
.idea/
lint.xml
/.apt_generated
View File

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.
+20
View File
@@ -0,0 +1,20 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
@@ -12,3 +12,4 @@
# Project target.
target=Google Inc.:Google APIs:19
android.library.reference.1=../library

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Before

Width:  |  Height:  |  Size: 824 B

After

Width:  |  Height:  |  Size: 824 B

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

+11
View File
@@ -0,0 +1,11 @@
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>
+12
View File
@@ -0,0 +1,12 @@
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>
+20
View File
@@ -0,0 +1,20 @@
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
@@ -2,13 +2,13 @@ package uk.co.alt236.btlescan.activities;
import java.util.Collection;
import uk.co.alt236.bluetoothlelib.device.BluetoothLeDevice;
import uk.co.alt236.bluetoothlelib.device.adrecord.AdRecord;
import uk.co.alt236.bluetoothlelib.device.mfdata.IBeaconManufacturerData;
import uk.co.alt236.bluetoothlelib.util.AdRecordUtils;
import uk.co.alt236.bluetoothlelib.util.ByteUtils;
import uk.co.alt236.bluetoothlelib.util.IBeaconUtils;
import uk.co.alt236.btlescan.R;
import uk.co.alt236.btlescan.containers.AdRecord;
import uk.co.alt236.btlescan.containers.BluetoothLeDevice;
import uk.co.alt236.btlescan.containers.ManufacturerDataIBeacon;
import uk.co.alt236.btlescan.util.AdRecordUtils;
import uk.co.alt236.btlescan.util.ByteUtils;
import uk.co.alt236.btlescan.util.IBeaconUtils;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
@@ -70,7 +70,7 @@ public class DetailsActivity extends Activity{
append(sb, "Is iBeacon", isIBeacon);
if(isIBeacon){
final ManufacturerDataIBeacon iBeaconData = new ManufacturerDataIBeacon(device);
final IBeaconManufacturerData iBeaconData = new IBeaconManufacturerData(device);
append(sb, "Company ID", iBeaconData.getCompanyIdentifier() + " (" + Integer.toHexString( iBeaconData.getCompanyIdentifier() ) + ")");
append(sb, "iBeacon Advertisment", iBeaconData.getIBeaconAdvertisement() + " (" + Integer.toHexString( iBeaconData.getIBeaconAdvertisement() ) + ")");
append(sb, "UUID", iBeaconData.getUUID().toString());
@@ -83,22 +83,22 @@ public class DetailsActivity extends Activity{
mTvDetails.setText(sb.toString());
}
private void append(StringBuilder sb, String label, boolean value) {
append(sb, label, String.valueOf(value));
}
private void append(StringBuilder sb, String label, int value) {
append(sb, label, String.valueOf(value));
}
private void append(StringBuilder sb, String label, long value) {
append(sb, label, String.valueOf(value));
}
private static void append(StringBuilder sb, byte[] value){
append(sb, ByteUtils.byteArrayToHexString(value), null);
}
private static void append(StringBuilder sb, String label, boolean value) {
append(sb, label, String.valueOf(value));
}
private static void append(StringBuilder sb, String label, int value) {
append(sb, label, String.valueOf(value));
}
private static void append(StringBuilder sb, String label, long value) {
append(sb, label, String.valueOf(value));
}
private static void append(StringBuilder sb, String label, String value){
if(value != null){
sb.append("\u2022" + label +":\t" + value + "\n");
@@ -1,8 +1,8 @@
package uk.co.alt236.btlescan.activities;
import uk.co.alt236.bluetoothlelib.device.BluetoothLeDevice;
import uk.co.alt236.btlescan.R;
import uk.co.alt236.btlescan.adapters.LeDeviceListAdapter;
import uk.co.alt236.btlescan.containers.BluetoothLeDevice;
import uk.co.alt236.btlescan.util.BluetoothLeScanner;
import uk.co.alt236.btlescan.util.BluetoothUtils;
import android.app.ListActivity;
@@ -3,9 +3,9 @@ package uk.co.alt236.btlescan.adapters;
import java.util.ArrayList;
import java.util.List;
import uk.co.alt236.bluetoothlelib.device.BluetoothLeDevice;
import uk.co.alt236.bluetoothlelib.util.IBeaconUtils;
import uk.co.alt236.btlescan.R;
import uk.co.alt236.btlescan.containers.BluetoothLeDevice;
import uk.co.alt236.btlescan.util.IBeaconUtils;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;