Commit f8567426 authored by Claudio Marforio's avatar Claudio Marforio
Browse files

Version 1.3.0:

- Add Account Migration functionality
- Upgrade to AndroidX
parent dc7470d3
......@@ -7,15 +7,22 @@ android {
defaultConfig {
applicationId "com.futurae.futuraedemo"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
targetSdkVersion 29
versionCode 5
versionName "1.0.0"
resConfigs "en", "el"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
// Latest Butterknife requires Java 8.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
debug {
minifyEnabled false
minifyEnabled true
proguardFile 'proguard/futurae.pro'
proguardFile getDefaultProguardFile('proguard-android.txt')
......@@ -38,17 +45,19 @@ repositories {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.android.gms:play-services-vision:17.0.2'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-messaging:17.4.0'
implementation('com.futurae.sdk:futuraekit:1.2.1')
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.gms:play-services-vision:20.1.3'
implementation 'com.jakewharton:butterknife:10.2.3'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.google.firebase:firebase-core:18.0.3'
implementation 'com.google.firebase:firebase-messaging:21.1.0'
implementation('com.futurae.sdk:futuraekit:1.3.0')
// Use these if you are NOT using Maven
// implementation 'com.squareup.retrofit2:retrofit:2.4.0'
......@@ -57,6 +66,7 @@ dependencies {
// implementation 'com.squareup.okhttp3:okhttp:3.11.0'
// implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'
// implementation 'com.github.nisrulz:easydeviceinfo-base:2.4.1'
// implementation 'com.google.code.gson:gson:2.8.6'
// implementation files('src/main/libs/futuraekit.aar')
}
......
......@@ -5,4 +5,8 @@
-keep class com.futurae.sdk.DeviceInfo {
*;
}
-keep public class com.futurae.sdk.model.AccountsMigrationResource$* {
*;
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.futurae.futuraedemo">
<uses-permission android:name="android.permission.INTERNET" />
......@@ -12,7 +13,9 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
tools:replace="android:allowBackup"
android:allowBackup="true"
android:backupAgent=".DemoBackupAgent"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:name="com.futurae.futuraedemo.AppMain"
......
package com.futurae.futuraedemo;
import android.app.backup.BackupDataInput;
import android.app.backup.BackupDataOutput;
import android.os.ParcelFileDescriptor;
import android.util.Log;
import com.futurae.sdk.BackupAgent;
import java.io.IOException;
public class DemoBackupAgent extends android.app.backup.BackupAgent {
private static final String TAG = DemoBackupAgent.class.getSimpleName();
@Override
public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data, ParcelFileDescriptor newState) {
try {
BackupAgent.onBackupAccounts(this, oldState, data, newState);
} catch (IOException e) {
Log.e(TAG, e.getMessage(), e);
}
}
@Override
public void onRestore(BackupDataInput data, int appVersionCode, ParcelFileDescriptor newState) {
try {
BackupAgent.onRestoreAccounts(this, data, appVersionCode, newState);
} catch (IOException e) {
Log.e(TAG, e.getMessage(), e);
}
}
}
\ No newline at end of file
......@@ -18,8 +18,8 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.hardware.Camera;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MenuItem;
......@@ -28,7 +28,7 @@ import android.view.ScaleGestureDetector;
import android.widget.Toast;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.futurae.futuraedemo.BuildConfig;
import com.futurae.futuraedemo.R;
import com.futurae.futuraedemo.ui.camera.BarcodeGraphic;
import com.futurae.futuraedemo.ui.camera.BarcodeTrackerFactory;
......
......@@ -11,10 +11,10 @@ import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.appcompat.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
......@@ -23,8 +23,10 @@ import com.futurae.sdk.FuturaeCallback;
import com.futurae.sdk.FuturaeClient;
import com.futurae.sdk.FuturaeResultCallback;
import com.futurae.sdk.MalformedQRCodeException;
import com.futurae.sdk.UnknownAccountException;
import com.futurae.sdk.approve.ApproveSession;
import com.futurae.sdk.model.Account;
import com.futurae.sdk.model.AccountsMigrationResource;
import com.futurae.sdk.model.ApproveInfo;
import com.futurae.sdk.model.CurrentTotp;
import com.futurae.sdk.model.SessionInfo;
......@@ -190,6 +192,70 @@ public class MainActivity extends AppCompatActivity {
startActivityForResult(FTRQRCodeActivity.getIntent(this, true, false), FTRQRCodeActivity.RESULT_BARCODE_GENERIC);
}
@OnClick(R.id.main_btn_accounts_migration_check)
protected void onAccountsMigrationCheck() {
Log.i(TAG, "Accounts Migration check started");
FuturaeClient.sharedClient().checkAccountMigrationPossible(
new FuturaeResultCallback<Integer>() {
@Override
public void success(Integer numAccounts) {
if(numAccounts > 0) {
Log.i(TAG, "Accounts Migration is possible. Number of accounts that can be migrated: " + numAccounts);
showAlert("Success", "Accounts Migration is possible.\nNumber of accounts that can be migrated: " + numAccounts);
}
else {
Log.i(TAG, "Accounts Migration is not possible. There were no accounts found that can be migrated.");
showAlert("Info", "Accounts Migration is not possible\nNo accounts found that can be migrated");
}
}
@Override
public void failure(Throwable throwable) {
Log.e(TAG, throwable.getLocalizedMessage());
showAlert("Error", "Checking for accounts migration failed");
}
});
}
@OnClick(R.id.main_btn_accounts_migration_execute)
protected void onAccountsMigrationExecute() {
Log.i(TAG, "Accounts Migration execution started");
FuturaeClient.sharedClient().executeAccountMigration(
new FuturaeResultCallback<AccountsMigrationResource.MigrationAccount[]>() {
@Override
public void success(AccountsMigrationResource.MigrationAccount[] result) {
StringBuilder userIdsMigrated = new StringBuilder();
for (int i = 0; i < result.length; i++) {
if(i > 0) {
userIdsMigrated.append("\n");
}
userIdsMigrated.append(result[i].getUsername());
}
Log.i(TAG, "Accounts migration successful. Accounts migrated (total: " + result.length + "): " + userIdsMigrated);
showAlert("Accounts migration successful", "Accounts migrated (total: " + result.length + "):\n\n" + userIdsMigrated);
}
@Override
public void failure(Throwable throwable) {
Log.e(TAG, throwable.getLocalizedMessage());
showAlert("Error", "Accounts migration execution failed");
}
}
);
}
// QRCode callbacks
private void onEnrollQRCodeScanned(Intent data) {
// TODO: Handle enrollment response
......@@ -362,11 +428,17 @@ public class MainActivity extends AppCompatActivity {
builder.setPositiveButton("Approve", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
String verificationSignature = "";
try {
verificationSignature = FuturaeClient.sharedClient().computeVerificationCodeFromQrcode(qrCode);
} catch (MalformedQRCodeException e) {
e.printStackTrace();
return;
} catch (UnknownAccountException e) {
e.printStackTrace();
return;
}
showOfflineQrcodeSignatureDialog(verificationSignature);
}
});
......
......@@ -21,9 +21,9 @@ import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;
import android.os.Build;
import android.os.SystemClock;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresPermission;
import android.support.annotation.StringDef;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresPermission;
import androidx.annotation.StringDef;
import android.util.Log;
import android.view.Surface;
import android.view.SurfaceHolder;
......@@ -89,23 +89,23 @@ public class CameraSource {
private static final float ASPECT_RATIO_TOLERANCE = 0.01f;
@StringDef({
Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE,
Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO,
Camera.Parameters.FOCUS_MODE_AUTO,
Camera.Parameters.FOCUS_MODE_EDOF,
Camera.Parameters.FOCUS_MODE_FIXED,
Camera.Parameters.FOCUS_MODE_INFINITY,
Camera.Parameters.FOCUS_MODE_MACRO
Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE,
Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO,
Camera.Parameters.FOCUS_MODE_AUTO,
Camera.Parameters.FOCUS_MODE_EDOF,
Camera.Parameters.FOCUS_MODE_FIXED,
Camera.Parameters.FOCUS_MODE_INFINITY,
Camera.Parameters.FOCUS_MODE_MACRO
})
@Retention(RetentionPolicy.SOURCE)
private @interface FocusMode {}
@StringDef({
Camera.Parameters.FLASH_MODE_ON,
Camera.Parameters.FLASH_MODE_OFF,
Camera.Parameters.FLASH_MODE_AUTO,
Camera.Parameters.FLASH_MODE_RED_EYE,
Camera.Parameters.FLASH_MODE_TORCH
Camera.Parameters.FLASH_MODE_ON,
Camera.Parameters.FLASH_MODE_OFF,
Camera.Parameters.FLASH_MODE_AUTO,
Camera.Parameters.FLASH_MODE_RED_EYE,
Camera.Parameters.FLASH_MODE_TORCH
})
@Retention(RetentionPolicy.SOURCE)
private @interface FlashMode {}
......
......@@ -14,7 +14,7 @@ package com.futurae.futuraedemo.ui.camera;
import android.Manifest;
import android.content.Context;
import android.content.res.Configuration;
import android.support.annotation.RequiresPermission;
import androidx.annotation.RequiresPermission;
import android.util.AttributeSet;
import android.util.Log;
import android.view.SurfaceHolder;
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.futurae.futuraedemo.ui.MainActivity"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.futurae.futuraedemo.ui.MainActivity"
>
<Button
......@@ -57,4 +57,20 @@
android:layout_gravity="center"
android:text="@string/main_btn_qr_code_generic" />
<Button
android:id="@+id/main_btn_accounts_migration_check"
style="@style/AppTheme.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/main_btn_accounts_migration_check" />
<Button
android:id="@+id/main_btn_accounts_migration_execute"
style="@style/AppTheme.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/main_btn_accounts_migration_execute" />
</LinearLayout>
......@@ -8,6 +8,8 @@
<string name="main_btn_qr_code_auth">Online QR Code Auth</string>
<string name="main_btn_qr_code_offline_auth">Offline QR Code Auth</string>
<string name="main_btn_qr_code_generic">Scan QR Code</string>
<string name="main_btn_accounts_migration_check">Check account migration</string>
<string name="main_btn_accounts_migration_execute">Execute account migration</string>
<!--QR CODE-->
<string name="qrcode_title">QR Code</string>
......
No preview for this file type
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment