Added about dialog in sample app
This commit is contained in:
@@ -97,7 +97,7 @@ An IBeaconDevice extends BluetoothLeDevice, so you still have access to the same
|
|||||||
You can also lookup values and convert them to human friendly strings:
|
You can also lookup values and convert them to human friendly strings:
|
||||||
* `BluetoothClassResolver.resolveDeviceClass(int btClass)`: Will try to resolve a Blueotooth Device class
|
* `BluetoothClassResolver.resolveDeviceClass(int btClass)`: Will try to resolve a Blueotooth Device class
|
||||||
* `CompanyIdentifierResolver.getCompanyName(int companyId, String fallback)`: Will try to resolve a Company identifier to the company name
|
* `CompanyIdentifierResolver.getCompanyName(int companyId, String fallback)`: Will try to resolve a Company identifier to the company name
|
||||||
* GattAttributeResolver.getAttributeName(String uuid, String fallback): Will try to convert a UUID to its name.
|
* `GattAttributeResolver.getAttributeName(String uuid, String fallback)`: Will try to convert a UUID to its name.
|
||||||
|
|
||||||
**Note:** The data can be found as ODS (Open Office Spreadsheets) in the documents folder.
|
**Note:** The data can be found as ODS (Open Office Spreadsheets) in the documents folder.
|
||||||
|
|
||||||
@@ -129,12 +129,10 @@ Author: [Alexandros Schillings](https://github.com/alt236).
|
|||||||
|
|
||||||
* The Accuracy calculation algorithm was taken from: http://stackoverflow.com/questions/20416218/understanding-ibeacon-distancing
|
* The Accuracy calculation algorithm was taken from: http://stackoverflow.com/questions/20416218/understanding-ibeacon-distancing
|
||||||
* The AdRecord parser was taken from: https://github.com/devunwired/accessory-samples
|
* The AdRecord parser was taken from: https://github.com/devunwired/accessory-samples
|
||||||
* The sample application has been adapted from
|
* The sample application has been adapted from Android's Bluetooth LE example
|
||||||
|
|
||||||
All logos are the property of their respective owners.
|
All logos are the property of their respective owners.
|
||||||
|
|
||||||
The icons used for the example app were downloaded from here: [Android Design](http://developer.android.com/design/downloads/index.htm)
|
|
||||||
|
|
||||||
The code in this project is licensed under the Apache Software License 2.0.
|
The code in this project is licensed under the Apache Software License 2.0.
|
||||||
|
|
||||||
Copyright (c) 2014 Alexandros Schillings.
|
Copyright (c) 2014 Alexandros Schillings.
|
||||||
@@ -31,5 +31,10 @@
|
|||||||
android:orderInCategory="101"
|
android:orderInCategory="101"
|
||||||
android:showAsAction="ifRoom|withText"
|
android:showAsAction="ifRoom|withText"
|
||||||
android:title="@string/menu_stop"/>
|
android:title="@string/menu_stop"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_about"
|
||||||
|
android:orderInCategory="102"
|
||||||
|
android:showAsAction="ifRoom|withText"
|
||||||
|
android:title="@string/menu_about"/>
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
@@ -5,14 +5,13 @@
|
|||||||
<string name="app_name">Bluetooth LE Scanner</string>
|
<string name="app_name">Bluetooth LE Scanner</string>
|
||||||
<string name="connected">Connected</string>
|
<string name="connected">Connected</string>
|
||||||
<string name="disconnected">Disconnected</string>
|
<string name="disconnected">Disconnected</string>
|
||||||
<string name="hello_world">Hello world!</string>
|
|
||||||
<string name="no_data">No data</string>
|
<string name="no_data">No data</string>
|
||||||
<string name="not_supported">Not supported</string>
|
<string name="not_supported">Not supported</string>
|
||||||
<string name="off">Off</string>
|
<string name="off">Off</string>
|
||||||
<string name="on">On</string>
|
<string name="on">On</string>
|
||||||
<string name="supported">Supported</string>
|
<string name="supported">Supported</string>
|
||||||
<string name="unknown_characteristic">Unknown characteristic</string>
|
<string name="unknown_characteristic">Unknown characteristic</string>
|
||||||
<string name="unknown_device">Unknown Device</string>
|
<string name="unknown_device">Unknown device</string>
|
||||||
<string name="unknown_service">Unknown service</string>
|
<string name="unknown_service">Unknown service</string>
|
||||||
|
|
||||||
<!-- Formatters -->
|
<!-- Formatters -->
|
||||||
@@ -20,6 +19,7 @@
|
|||||||
<string name="formatter_db">%sdb</string>
|
<string name="formatter_db">%sdb</string>
|
||||||
|
|
||||||
<!-- Menu items -->
|
<!-- Menu items -->
|
||||||
|
<string name="menu_about">About</string>
|
||||||
<string name="menu_connect">Connect</string>
|
<string name="menu_connect">Connect</string>
|
||||||
<string name="menu_disconnect">Disconnect</string>
|
<string name="menu_disconnect">Disconnect</string>
|
||||||
<string name="menu_scan">Scan</string>
|
<string name="menu_scan">Scan</string>
|
||||||
@@ -37,4 +37,7 @@
|
|||||||
<string name="label_tx_power">TX Power:</string>
|
<string name="label_tx_power">TX Power:</string>
|
||||||
<string name="label_uuid">UUID:</string>
|
<string name="label_uuid">UUID:</string>
|
||||||
|
|
||||||
|
|
||||||
|
<string name="about_dialog_text">This is a sample application using the Bluetooth LE Library.\n\nGithub: https://github.com/alt236/Bluetooth-LE-Library---Android\n\nCopyright: Alexandros Schillings</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -6,11 +6,16 @@ import uk.co.alt236.btlescan.adapters.LeDeviceListAdapter;
|
|||||||
import uk.co.alt236.btlescan.containers.BluetoothLeDeviceStore;
|
import uk.co.alt236.btlescan.containers.BluetoothLeDeviceStore;
|
||||||
import uk.co.alt236.btlescan.util.BluetoothLeScanner;
|
import uk.co.alt236.btlescan.util.BluetoothLeScanner;
|
||||||
import uk.co.alt236.btlescan.util.BluetoothUtils;
|
import uk.co.alt236.btlescan.util.BluetoothUtils;
|
||||||
|
import android.app.AlertDialog;
|
||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
import android.bluetooth.BluetoothAdapter;
|
import android.bluetooth.BluetoothAdapter;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.SpannableString;
|
||||||
|
import android.text.method.LinkMovementMethod;
|
||||||
|
import android.text.util.Linkify;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -44,16 +49,29 @@ public class MainActivity extends ListActivity {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override
|
private void displayAboutDialog(){
|
||||||
protected void onListItemClick(ListView l, View v, int position, long id) {
|
// REALLY REALLY LAZY LIKIFIED DIALOG
|
||||||
final BluetoothLeDevice device = mLeDeviceListAdapter.getItem(position);
|
final int paddingSizeDp = 5;
|
||||||
if (device == null) return;
|
final float scale = getResources().getDisplayMetrics().density;
|
||||||
|
final int dpAsPixels = (int) (paddingSizeDp * scale + 0.5f);
|
||||||
|
|
||||||
|
final TextView textView=new TextView(this);
|
||||||
|
final SpannableString text = new SpannableString(getString(R.string.about_dialog_text));
|
||||||
|
|
||||||
final Intent intent = new Intent(this, DeviceDetailsActivity.class);
|
textView.setText(text);
|
||||||
intent.putExtra(DeviceDetailsActivity.EXTRA_DEVICE, device);
|
textView.setAutoLinkMask(RESULT_OK);
|
||||||
|
textView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
textView.setPadding(dpAsPixels, dpAsPixels, dpAsPixels, dpAsPixels);
|
||||||
|
|
||||||
startActivity(intent);
|
Linkify.addLinks(text, Linkify.ALL);
|
||||||
|
new AlertDialog.Builder(this)
|
||||||
|
.setTitle(R.string.menu_about)
|
||||||
|
.setCancelable(false)
|
||||||
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {}
|
||||||
|
})
|
||||||
|
.setView(textView)
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -82,6 +100,18 @@ public class MainActivity extends ListActivity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onListItemClick(ListView l, View v, int position, long id) {
|
||||||
|
final BluetoothLeDevice device = mLeDeviceListAdapter.getItem(position);
|
||||||
|
if (device == null) return;
|
||||||
|
|
||||||
|
|
||||||
|
final Intent intent = new Intent(this, DeviceDetailsActivity.class);
|
||||||
|
intent.putExtra(DeviceDetailsActivity.EXTRA_DEVICE, device);
|
||||||
|
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
@@ -92,6 +122,9 @@ public class MainActivity extends ListActivity {
|
|||||||
mScanner.scanLeDevice(-1, false);
|
mScanner.scanLeDevice(-1, false);
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
break;
|
break;
|
||||||
|
case R.id.menu_about:
|
||||||
|
displayAboutDialog();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user