We are now using AppCompat and support Material
This commit is contained in:
+18
-18
@@ -16,7 +16,6 @@
|
||||
|
||||
package uk.co.alt236.btlescan.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.bluetooth.BluetoothGattService;
|
||||
import android.content.BroadcastReceiver;
|
||||
@@ -27,6 +26,7 @@ import android.content.IntentFilter;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@@ -40,8 +40,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
import uk.co.alt236.bluetoothlelib.device.BluetoothLeDevice;
|
||||
import uk.co.alt236.bluetoothlelib.resolvers.GattAttributeResolver;
|
||||
import uk.co.alt236.bluetoothlelib.util.ByteUtils;
|
||||
@@ -54,23 +54,23 @@ import uk.co.alt236.btlescan.services.BluetoothLeService;
|
||||
* communicates with {@code BluetoothLeService}, which in turn interacts with the
|
||||
* Bluetooth LE API.
|
||||
*/
|
||||
public class DeviceControlActivity extends Activity {
|
||||
public class DeviceControlActivity extends AppCompatActivity {
|
||||
public static final String EXTRA_DEVICE = "extra_device";
|
||||
private final static String TAG = DeviceControlActivity.class.getSimpleName();
|
||||
private static final String LIST_NAME = "NAME";
|
||||
private static final String LIST_UUID = "UUID";
|
||||
@InjectView(R.id.gatt_services_list)
|
||||
ExpandableListView mGattServicesList;
|
||||
@InjectView(R.id.connection_state)
|
||||
TextView mConnectionState;
|
||||
@InjectView(R.id.uuid)
|
||||
TextView mGattUUID;
|
||||
@InjectView(R.id.description)
|
||||
TextView mGattUUIDDesc;
|
||||
@InjectView(R.id.data_as_string)
|
||||
TextView mDataAsString;
|
||||
@InjectView(R.id.data_as_array)
|
||||
TextView mDataAsArray;
|
||||
@Bind(R.id.gatt_services_list)
|
||||
protected ExpandableListView mGattServicesList;
|
||||
@Bind(R.id.connection_state)
|
||||
protected TextView mConnectionState;
|
||||
@Bind(R.id.uuid)
|
||||
protected TextView mGattUUID;
|
||||
@Bind(R.id.description)
|
||||
protected TextView mGattUUIDDesc;
|
||||
@Bind(R.id.data_as_string)
|
||||
protected TextView mDataAsString;
|
||||
@Bind(R.id.data_as_array)
|
||||
protected TextView mDataAsArray;
|
||||
private BluetoothGattCharacteristic mNotifyCharacteristic;
|
||||
private BluetoothLeService mBluetoothLeService;
|
||||
private List<List<BluetoothGattCharacteristic>> mGattCharacteristics = new ArrayList<>();
|
||||
@@ -282,14 +282,14 @@ public class DeviceControlActivity extends Activity {
|
||||
mDeviceName = device.getName();
|
||||
mDeviceAddress = device.getAddress();
|
||||
|
||||
ButterKnife.inject(this);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
// Sets up UI references.
|
||||
((TextView) findViewById(R.id.device_address)).setText(mDeviceAddress);
|
||||
mGattServicesList.setOnChildClickListener(servicesListClickListner);
|
||||
|
||||
getActionBar().setTitle(mDeviceName);
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setTitle(mDeviceName);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
final Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
|
||||
bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
|
||||
|
||||
+15
-5
@@ -1,11 +1,14 @@
|
||||
package uk.co.alt236.btlescan.activities;
|
||||
|
||||
import android.app.ListActivity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.commonsware.cwac.merge.MergeAdapter;
|
||||
@@ -13,6 +16,7 @@ import com.commonsware.cwac.merge.MergeAdapter;
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
import uk.co.alt236.bluetoothlelib.device.BluetoothLeDevice;
|
||||
import uk.co.alt236.bluetoothlelib.device.adrecord.AdRecord;
|
||||
@@ -24,9 +28,13 @@ import uk.co.alt236.bluetoothlelib.util.IBeaconUtils;
|
||||
import uk.co.alt236.btlescan.R;
|
||||
import uk.co.alt236.btlescan.util.TimeFormatter;
|
||||
|
||||
public class DeviceDetailsActivity extends ListActivity {
|
||||
public class DeviceDetailsActivity extends AppCompatActivity {
|
||||
public static final String EXTRA_DEVICE = "extra_device";
|
||||
|
||||
@Bind(android.R.id.list)
|
||||
protected ListView mList;
|
||||
@Nullable
|
||||
@Bind(android.R.id.empty)
|
||||
protected View mEmpty;
|
||||
private BluetoothLeDevice mDevice;
|
||||
|
||||
private void appendAdRecordView(final MergeAdapter adapter, final String title, final AdRecord record) {
|
||||
@@ -129,7 +137,9 @@ public class DeviceDetailsActivity extends ListActivity {
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_details);
|
||||
ButterKnife.inject(this);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
mList.setEmptyView(mEmpty);
|
||||
|
||||
mDevice = getIntent().getParcelableExtra(EXTRA_DEVICE);
|
||||
|
||||
@@ -194,7 +204,7 @@ public class DeviceDetailsActivity extends ListActivity {
|
||||
}
|
||||
|
||||
}
|
||||
getListView().setAdapter(adapter);
|
||||
mList.setAdapter(adapter);
|
||||
}
|
||||
|
||||
private static String formatTime(final long time) {
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
package uk.co.alt236.btlescan.activities;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ListActivity;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.SpannableString;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.Bind;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.InjectView;
|
||||
import uk.co.alt236.bluetoothlelib.device.BluetoothLeDevice;
|
||||
import uk.co.alt236.btlescan.R;
|
||||
import uk.co.alt236.btlescan.adapters.LeDeviceListAdapter;
|
||||
@@ -26,13 +27,17 @@ import uk.co.alt236.btlescan.util.BluetoothLeScanner;
|
||||
import uk.co.alt236.btlescan.util.BluetoothUtils;
|
||||
import uk.co.alt236.easycursor.objectcursor.EasyObjectCursor;
|
||||
|
||||
public class MainActivity extends ListActivity {
|
||||
@InjectView(R.id.tvBluetoothLe)
|
||||
TextView mTvBluetoothLeStatus;
|
||||
@InjectView(R.id.tvBluetoothStatus)
|
||||
TextView mTvBluetoothStatus;
|
||||
@InjectView(R.id.tvItemCount)
|
||||
TextView mTvItemCount;
|
||||
public class MainActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {
|
||||
@Bind(R.id.tvBluetoothLe)
|
||||
protected TextView mTvBluetoothLeStatus;
|
||||
@Bind(R.id.tvBluetoothStatus)
|
||||
protected TextView mTvBluetoothStatus;
|
||||
@Bind(R.id.tvItemCount)
|
||||
protected TextView mTvItemCount;
|
||||
@Bind(android.R.id.list)
|
||||
protected ListView mList;
|
||||
@Bind(android.R.id.empty)
|
||||
protected View mEmpty;
|
||||
|
||||
private BluetoothUtils mBluetoothUtils;
|
||||
private BluetoothLeScanner mScanner;
|
||||
@@ -87,8 +92,9 @@ public class MainActivity extends ListActivity {
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
ButterKnife.inject(this);
|
||||
|
||||
ButterKnife.bind(this);
|
||||
mList.setEmptyView(mEmpty);
|
||||
mList.setOnItemClickListener(this);
|
||||
mDeviceStore = new BluetoothLeDeviceStore();
|
||||
mBluetoothUtils = new BluetoothUtils(this);
|
||||
mScanner = new BluetoothLeScanner(mLeScanCallback, mBluetoothUtils);
|
||||
@@ -108,7 +114,7 @@ public class MainActivity extends ListActivity {
|
||||
menu.findItem(R.id.menu_refresh).setActionView(R.layout.actionbar_progress_indeterminate);
|
||||
}
|
||||
|
||||
if (getListView().getCount() > 0) {
|
||||
if (mList.getCount() > 0) {
|
||||
menu.findItem(R.id.menu_share).setVisible(true);
|
||||
} else {
|
||||
menu.findItem(R.id.menu_share).setVisible(false);
|
||||
@@ -118,7 +124,7 @@ public class MainActivity extends ListActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onListItemClick(final ListView l, final View v, final int position, final long id) {
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
|
||||
final BluetoothLeDevice device = mLeDeviceListAdapter.getItem(position);
|
||||
if (device == null) return;
|
||||
|
||||
@@ -181,7 +187,7 @@ public class MainActivity extends ListActivity {
|
||||
updateItemCount(0);
|
||||
|
||||
mLeDeviceListAdapter = new LeDeviceListAdapter(this, mDeviceStore.getDeviceCursor());
|
||||
setListAdapter(mLeDeviceListAdapter);
|
||||
mList.setAdapter(mLeDeviceListAdapter);
|
||||
|
||||
mBluetoothUtils.askUserToEnableBluetoothIfNeeded();
|
||||
if (mIsBluetoothOn && mIsBluetoothLePresent) {
|
||||
|
||||
@@ -14,14 +14,15 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_connect"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="always|withText"
|
||||
android:title="@string/menu_connect"/>
|
||||
android:title="@string/menu_connect"
|
||||
app:showAsAction="always|withText"/>
|
||||
|
||||
|
||||
</menu>
|
||||
@@ -14,28 +14,30 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_refresh"
|
||||
android:checkable="false"
|
||||
android:orderInCategory="1"
|
||||
android:showAsAction="ifRoom"/>
|
||||
android:title=""
|
||||
app:showAsAction="always"/>
|
||||
<item
|
||||
android:id="@+id/menu_share"
|
||||
android:icon="@drawable/ic_action_share"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/menu_share"/>
|
||||
android:title="@string/menu_share"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/menu_connect"
|
||||
android:orderInCategory="102"
|
||||
android:showAsAction="ifRoom|withText"
|
||||
android:title="@string/menu_connect"/>
|
||||
android:title="@string/menu_connect"
|
||||
app:showAsAction="ifRoom|withText"/>
|
||||
<item
|
||||
android:id="@+id/menu_disconnect"
|
||||
android:orderInCategory="103"
|
||||
android:showAsAction="ifRoom|withText"
|
||||
android:title="@string/menu_disconnect"/>
|
||||
android:title="@string/menu_disconnect"
|
||||
app:showAsAction="ifRoom|withText"/>
|
||||
|
||||
</menu>
|
||||
@@ -14,33 +14,36 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_refresh"
|
||||
android:checkable="false"
|
||||
android:orderInCategory="1"
|
||||
android:showAsAction="ifRoom"/>
|
||||
android:title=""
|
||||
app:showAsAction="always"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_scan"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="ifRoom|withText"
|
||||
android:title="@string/menu_scan"/>
|
||||
android:title="@string/menu_scan"
|
||||
app:showAsAction="ifRoom|withText"/>
|
||||
<item
|
||||
android:id="@+id/menu_stop"
|
||||
android:orderInCategory="101"
|
||||
android:showAsAction="ifRoom|withText"
|
||||
android:title="@string/menu_stop"/>
|
||||
android:title="@string/menu_stop"
|
||||
app:showAsAction="ifRoom|withText"/>
|
||||
<item
|
||||
android:id="@+id/menu_share"
|
||||
android:icon="@drawable/ic_action_share"
|
||||
android:orderInCategory="102"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/menu_share"/>
|
||||
android:title="@string/menu_share"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/menu_about"
|
||||
android:orderInCategory="103"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/menu_about"/>
|
||||
android:title="@string/menu_about"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
</menu>
|
||||
@@ -4,7 +4,7 @@
|
||||
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">
|
||||
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- API 11 theme customizations can go here. -->
|
||||
</style>
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
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">
|
||||
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- API 14 theme customizations can go here. -->
|
||||
</style>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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">
|
||||
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!--
|
||||
Theme customizations available in newer API levels can go in
|
||||
res/values-vXX/styles.xml, while customizations related to
|
||||
@@ -17,7 +17,7 @@
|
||||
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
|
||||
</style>
|
||||
|
||||
<style name="GridLayoutDataTextView" parent="android:Widget.Holo.Light.TextView">
|
||||
<style name="GridLayoutDataTextView">
|
||||
<item name="android:textSize">12sp</item>
|
||||
<item name="android:layout_weight">1</item>
|
||||
<item name="android:ellipsize">none</item>
|
||||
@@ -33,7 +33,7 @@
|
||||
<item name="android:typeface">monospace</item>
|
||||
</style>
|
||||
|
||||
<style name="GridLayoutTitleTextView" parent="android:Widget.Holo.Light.TextView">
|
||||
<style name="GridLayoutTitleTextView">
|
||||
<item name="android:textSize">12sp</item>
|
||||
</style>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user