Skip to content

Commit

Permalink
Merge pull request #97 from marnberg/twoAuth
Browse files Browse the repository at this point in the history
Update sample to Android 12 and fixes conclave problem
  • Loading branch information
marnberg authored Mar 10, 2022
2 parents fbe5c87 + 32379ba commit a6ecb48
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 14 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
author: Tony Myles
title: "AferoJavaSDK"
date: 2022-Feb-28
status: 1.5.0
date: 2022-March-10
status: 1.5.1
---

# AferoJavaSDK
Expand Down Expand Up @@ -32,24 +32,24 @@ The SDK is composed of four separate modules.

The `afero-sdk-core` module is required for base functionality such as interacting with the Afero Cloud and manipulating devices.
```Gradle
implementation 'io.afero.sdk:afero-sdk-core:1.5.0'
implementation 'io.afero.sdk:afero-sdk-core:1.5.1'
```

The `afero-sdk-client-retrofit2` module provides an optional implementation of the AferoClient REST API interface using [Retrofit2](http://square.github.io/retrofit/) and [okhttp3](http://square.github.io/okhttp/). If you choose not to include this module in your project, you will need to develop your own implementation of AferoClient using your preferred http client library.

```Gradle
implementation 'io.afero.sdk:afero-sdk-client-retrofit2:1.5.0'
implementation 'io.afero.sdk:afero-sdk-client-retrofit2:1.5.1'
```

The `afero-sdk-android` module is required for Android development.
```Gradle
implementation 'io.afero.sdk:afero-sdk-android:1.5.0'
implementation 'io.afero.sdk:afero-sdk-android:1.5.1'
```

The `afero-sdk-softhub` module is required for soft hub functionality on Android.
```Gradle
implementation 'io.afero.sdk:afero-sdk-softhub:1.5.0'
implementation "io.afero.sdk:hubby:1.0.844@aar"
implementation 'io.afero.sdk:afero-sdk-softhub:1.5.1'
implementation "io.afero.sdk:hubby:1.0.957@aar"
```

## License
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,10 @@ public void call(Throwable t) {
@Override
public void call(InvalidateMessage im) {
try {
if (im.deviceId == null) {
AfLog.e("Got invalidate without deviceId");
return;
}
DeviceModel deviceModel = getDevice(im.deviceId);
if (deviceModel == null) {
AfLog.e("Got invalidate on unknown deviceId: " + im.deviceId);
Expand Down
6 changes: 3 additions & 3 deletions samples/afero-lab/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
apply plugin: 'com.android.application'

final String sdkRepoKey = project.findProperty('aferoSDKConsumeRepoKey') ?: 'afero-java-sdk'
final String sdkVersion = project.findProperty('aferoSDKVersion') ?: '1.5.0'
final String sdkVersion = project.findProperty('aferoSDKVersion') ?: '1.5.1'

repositories {
maven {
Expand All @@ -31,12 +31,12 @@ configurations.all {


android {
compileSdkVersion 30
compileSdkVersion 32

defaultConfig {
applicationId 'io.afero.aferolab'
minSdkVersion 26
targetSdkVersion 30
targetSdkVersion 32

versionCode 1
versionName '1.0'
Expand Down
9 changes: 7 additions & 2 deletions samples/afero-lab/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.CAMERA"/>

<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>

<application
android:allowBackup="false"
android:icon="@mipmap/sdk_app_icon_android"
Expand All @@ -24,7 +28,8 @@
android:name=".MainActivity"
android:configChanges="orientation|screenSize"
android:launchMode="singleTop"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:exported="true">

<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand All @@ -34,7 +39,7 @@
<activity
android:name="net.openid.appauth.RedirectUriReceiverActivity"
tools:node="replace"
>
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ public class PermissionsHelper {

// See http://developer.radiusnetworks.com/2015/09/29/is-your-beacon-app-ready-for-android-6.html
public static void checkRequiredPermissions(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
boolean hasCamera = activity.checkSelfPermission(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED;
boolean hasBluetooth = activity.checkSelfPermission(Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED;

if (!hasCamera || !hasBluetooth) {
askUserForAllPermissions(activity);
} else {
AfLog.d("checkRequiredPermissions: permissions granted");
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// Android M Permission check
boolean hasLocation = activity.checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED;
boolean hasCamera = activity.checkSelfPermission(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED;
Expand All @@ -42,7 +51,15 @@ private static void askUserForAllPermissions(final Activity activity) {
builder.setPositiveButton(android.R.string.ok, null);
builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
public void onDismiss(DialogInterface dialog) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
activity.requestPermissions(
new String[]{
Manifest.permission.BLUETOOTH_SCAN,
Manifest.permission.BLUETOOTH_CONNECT,
Manifest.permission.CAMERA
},
PERMISSION_REQUEST_ALL);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
activity.requestPermissions(
new String[]{
Manifest.permission.ACCESS_FINE_LOCATION,
Expand Down

0 comments on commit a6ecb48

Please sign in to comment.