We are now using AppCompat and support Material

This commit is contained in:
Alexandros Schillings
2015-07-13 16:04:39 +01:00
parent 262fa72910
commit ab6997b5af
17 changed files with 115 additions and 78 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
ext.compileSdkVersion = 18
ext.buildToolsVersion = "21.1.1"
ext.compileSdkVersion = 22
ext.buildToolsVersion = "22.0.1"
ext.minSdkVersion = 18
ext.targetSdkVersion = 22
+2 -2
View File
@@ -85,12 +85,12 @@
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 18 Platform" jdkType="Android SDK" />
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" scope="TEST" name="objenesis-1.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="mockable-android-22" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="mockable-android-18" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="mockito-core-1.9.5" level="project" />
</component>
</module>
+14 -5
View File
@@ -8,6 +8,20 @@ final def androidVersionCode = 100
final def targetSdk = rootProject.targetSdkVersion;
final def minSdkRed = rootProject.minSdkVersion;
repositories {
maven {
url "https://repo.commonsware.com.s3.amazonaws.com"
}
}
dependencies {
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.commonsware.cwac:merge:1.1.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':library')
}
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
@@ -33,8 +47,3 @@ android {
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':library')
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+12 -6
View File
@@ -69,6 +69,10 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.commonsware.cwac/merge/1.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.commonsware.cwac/sacklist/1.0.2/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
@@ -84,14 +88,16 @@
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 18 Platform" jdkType="Android SDK" />
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="merge-1.0.1" level="project" />
<orderEntry type="library" exported="" name="android-support-v4" level="project" />
<orderEntry type="library" exported="" name="sacklist-1.0.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="mockable-android-22" level="project" />
<orderEntry type="library" exported="" name="butterknife-7.0.1" level="project" />
<orderEntry type="library" exported="" name="merge-1.1.0" level="project" />
<orderEntry type="library" exported="" name="sacklist-1.0.2" level="project" />
<orderEntry type="library" exported="" name="EasyCursor-0.1.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="mockable-android-18" level="project" />
<orderEntry type="library" exported="" name="butterknife-4.0.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
<orderEntry type="module" module-name="library" exported="" />
</component>
</module>
@@ -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);
@@ -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) {
+4 -3
View File
@@ -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>
+10 -8
View File
@@ -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>
+13 -10
View File
@@ -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>
+3 -3
View File
@@ -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>