extract sweetspot activity into separate module
This commit is contained in:
parent
e36aab6a97
commit
365cebdc72
|
@ -56,6 +56,7 @@ dependencies {
|
||||||
// libs as submodules
|
// libs as submodules
|
||||||
implementation project(':libkeychain')
|
implementation project(':libkeychain')
|
||||||
implementation project(':openpgp-api-lib')
|
implementation project(':openpgp-api-lib')
|
||||||
|
implementation project(':nfcsweetspot')
|
||||||
implementation project(':sshauthentication-api')
|
implementation project(':sshauthentication-api')
|
||||||
implementation project(':extern:bouncycastle:core')
|
implementation project(':extern:bouncycastle:core')
|
||||||
implementation project(':extern:bouncycastle:pg')
|
implementation project(':extern:bouncycastle:pg')
|
||||||
|
|
|
@ -858,7 +858,7 @@
|
||||||
android:theme="@android:style/Theme.NoDisplay" />
|
android:theme="@android:style/Theme.NoDisplay" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.ShowNfcSweetspotActivity"
|
android:name="de.cotech.sweetspot.ShowNfcSweetspotActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/Theme.Keychain.AppCompat.Transparent.Fullscreen"
|
android:theme="@style/Theme.Keychain.AppCompat.Transparent.Fullscreen"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -33,6 +33,8 @@ import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
|
|
||||||
|
import de.cotech.sweetspot.NfcSweetspotData;
|
||||||
|
import de.cotech.sweetspot.ShowNfcSweetspotActivity;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.securitytoken.SecurityTokenInfo;
|
import org.sufficientlysecure.keychain.securitytoken.SecurityTokenInfo;
|
||||||
|
@ -92,7 +94,7 @@ public class CreateSecurityTokenWaitFragment extends Fragment {
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.create_security_token_wait_fragment, container, false);
|
View view = inflater.inflate(R.layout.create_security_token_wait_fragment, container, false);
|
||||||
|
|
||||||
boolean showLocateSweetspot = ShowNfcSweetspotActivity.hasSweetspotData();
|
boolean showLocateSweetspot = NfcSweetspotData.hasSweetspotData();
|
||||||
View buttonLocateSweetspot = view.findViewById(R.id.button_locate_nfc);
|
View buttonLocateSweetspot = view.findViewById(R.id.button_locate_nfc);
|
||||||
buttonLocateSweetspot.setVisibility(showLocateSweetspot ? View.VISIBLE : View.GONE);
|
buttonLocateSweetspot.setVisibility(showLocateSweetspot ? View.VISIBLE : View.GONE);
|
||||||
buttonLocateSweetspot.setOnClickListener(new OnClickListener() {
|
buttonLocateSweetspot.setOnClickListener(new OnClickListener() {
|
||||||
|
|
33
nfcsweetspot/.gitignore
vendored
Normal file
33
nfcsweetspot/.gitignore
vendored
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#Android specific
|
||||||
|
bin
|
||||||
|
gen
|
||||||
|
obj
|
||||||
|
lint.xml
|
||||||
|
local.properties
|
||||||
|
release.properties
|
||||||
|
ant.properties
|
||||||
|
*.class
|
||||||
|
*.apk
|
||||||
|
|
||||||
|
#Gradle
|
||||||
|
.gradle
|
||||||
|
build
|
||||||
|
gradle.properties
|
||||||
|
|
||||||
|
#Maven
|
||||||
|
target
|
||||||
|
pom.xml.*
|
||||||
|
|
||||||
|
#Eclipse
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.settings
|
||||||
|
.metadata
|
||||||
|
|
||||||
|
#IntelliJ IDEA
|
||||||
|
.idea
|
||||||
|
*.iml
|
||||||
|
|
||||||
|
#Lint output
|
||||||
|
lint-report.html
|
||||||
|
lint-report_files/*
|
18
nfcsweetspot/build.gradle
Normal file
18
nfcsweetspot/build.gradle
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion rootProject.ext.compileSdkVersion
|
||||||
|
buildToolsVersion rootProject.ext.buildToolsVersion
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion 14
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not abort build if lint finds errors
|
||||||
|
lintOptions {
|
||||||
|
abortOnError false
|
||||||
|
}
|
||||||
|
}
|
2
nfcsweetspot/src/main/AndroidManifest.xml
Normal file
2
nfcsweetspot/src/main/AndroidManifest.xml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest package="de.cotech.sweetspot" />
|
|
@ -15,13 +15,14 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.sufficientlysecure.keychain.securitytoken;
|
package de.cotech.sweetspot;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import android.os.Build;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
|
|
||||||
|
@ -969,4 +970,16 @@ public class NfcSweetspotData {
|
||||||
|
|
||||||
SWEETSPOT_DATA = Collections.unmodifiableMap(data);
|
SWEETSPOT_DATA = Collections.unmodifiableMap(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasSweetspotData() {
|
||||||
|
return NfcSweetspotData.SWEETSPOT_DATA.containsKey(Build.MODEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Pair<Double, Double> getSweetspotForBuildModel() {
|
||||||
|
return getSweetspotForBuildModel(Build.MODEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Pair<Double, Double> getSweetspotForBuildModel(String buildModel) {
|
||||||
|
return SWEETSPOT_DATA.get(buildModel);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2017 Schürmann & Breitmoser GbR
|
* Copyright (C) 2018 Schürmann & Breitmoser GbR
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -15,30 +15,19 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui;
|
package de.cotech.sweetspot;
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.DecelerateInterpolator;
|
import android.view.animation.DecelerateInterpolator;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
|
||||||
import org.sufficientlysecure.keychain.securitytoken.NfcSweetspotData;
|
|
||||||
import org.sufficientlysecure.keychain.securitytoken.SecurityTokenConnection;
|
|
||||||
import org.sufficientlysecure.keychain.ui.base.BaseSecurityTokenActivity;
|
|
||||||
|
|
||||||
|
|
||||||
public class ShowNfcSweetspotActivity extends BaseSecurityTokenActivity {
|
|
||||||
public static final String EXTRA_TOKEN_INFO = "token_info";
|
|
||||||
|
|
||||||
|
public class ShowNfcSweetspotActivity extends Activity {
|
||||||
private View sweetspotIndicator;
|
private View sweetspotIndicator;
|
||||||
private View sweetspotIcon;
|
private View sweetspotIcon;
|
||||||
private View sweetspotCircle1;
|
private View sweetspotCircle1;
|
||||||
|
@ -46,15 +35,16 @@ public class ShowNfcSweetspotActivity extends BaseSecurityTokenActivity {
|
||||||
private View sweetspotCircle3;
|
private View sweetspotCircle3;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
setTheme(android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
|
||||||
|
|
||||||
overridePendingTransition(R.anim.fade_in_quick, R.anim.fade_out_quick);
|
overridePendingTransition(R.anim.fade_in_quick, R.anim.fade_out_quick);
|
||||||
|
|
||||||
setContentView(R.layout.show_nfc_sweetspot_activity);
|
super.onCreate(savedInstanceState);
|
||||||
sweetspotIndicator = findViewById(R.id.nfc_sweetspot_indicator);
|
|
||||||
|
|
||||||
Pair<Double, Double> nfcPosition = NfcSweetspotData.SWEETSPOT_DATA.get(Build.MODEL);
|
setContentView(R.layout.activity_nfc_sweetspot);
|
||||||
|
sweetspotIndicator = findViewById(R.id.indicator_nfc_sweetspot);
|
||||||
|
|
||||||
|
Pair<Double, Double> nfcPosition = NfcSweetspotData.getSweetspotForBuildModel();
|
||||||
if (nfcPosition == null) {
|
if (nfcPosition == null) {
|
||||||
throw new IllegalArgumentException("No data available for this model. This activity should not be called!");
|
throw new IllegalArgumentException("No data available for this model. This activity should not be called!");
|
||||||
}
|
}
|
||||||
|
@ -71,10 +61,10 @@ public class ShowNfcSweetspotActivity extends BaseSecurityTokenActivity {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
sweetspotIcon = findViewById(R.id.nfc_sweetspot_icon);
|
sweetspotIcon = findViewById(R.id.icon_nfc_sweetspot);
|
||||||
sweetspotCircle1 = findViewById(R.id.nfc_sweetspot_circle_1);
|
sweetspotCircle1 = findViewById(R.id.circle_nfc_sweetspot_1);
|
||||||
sweetspotCircle2 = findViewById(R.id.nfc_sweetspot_circle_2);
|
sweetspotCircle2 = findViewById(R.id.circle_nfc_sweetspot_2);
|
||||||
sweetspotCircle3 = findViewById(R.id.nfc_sweetspot_circle_3);
|
sweetspotCircle3 = findViewById(R.id.circle_nfc_sweetspot_3);
|
||||||
|
|
||||||
sweetspotIcon.setAlpha(0.0f);
|
sweetspotIcon.setAlpha(0.0f);
|
||||||
sweetspotCircle1.setAlpha(0.0f);
|
sweetspotCircle1.setAlpha(0.0f);
|
||||||
|
@ -93,11 +83,6 @@ public class ShowNfcSweetspotActivity extends BaseSecurityTokenActivity {
|
||||||
sweetspotCircle3.animate().alpha(1.0f).setInterpolator(interpolator).setDuration(1000).setStartDelay(300).start();
|
sweetspotCircle3.animate().alpha(1.0f).setInterpolator(interpolator).setDuration(1000).setStartDelay(300).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initTheme() {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void finish() {
|
public void finish() {
|
||||||
super.finish();
|
super.finish();
|
||||||
|
@ -105,14 +90,6 @@ public class ShowNfcSweetspotActivity extends BaseSecurityTokenActivity {
|
||||||
overridePendingTransition(R.anim.fade_in_quick, R.anim.fade_out_quick);
|
overridePendingTransition(R.anim.fade_in_quick, R.anim.fade_out_quick);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSecurityTokenPostExecute(SecurityTokenConnection stConnection) {
|
|
||||||
Intent result = new Intent();
|
|
||||||
result.putExtra(EXTRA_TOKEN_INFO, tokenInfo);
|
|
||||||
setResult(Activity.RESULT_OK, result);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
if (event.getActionMasked() == MotionEvent.ACTION_UP) {
|
if (event.getActionMasked() == MotionEvent.ACTION_UP) {
|
||||||
|
@ -124,15 +101,10 @@ public class ShowNfcSweetspotActivity extends BaseSecurityTokenActivity {
|
||||||
return super.onTouchEvent(event);
|
return super.onTouchEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
|
||||||
private DisplayMetrics getDisplaySize() {
|
private DisplayMetrics getDisplaySize() {
|
||||||
DisplayMetrics metrics = new DisplayMetrics();
|
DisplayMetrics metrics = new DisplayMetrics();
|
||||||
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||||
|
|
||||||
return metrics;
|
return metrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasSweetspotData() {
|
|
||||||
return NfcSweetspotData.SWEETSPOT_DATA.containsKey(Build.MODEL);
|
|
||||||
}
|
|
||||||
}
|
}
|
7
nfcsweetspot/src/main/res/anim/fade_in_quick.xml
Normal file
7
nfcsweetspot/src/main/res/anim/fade_in_quick.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
|
||||||
|
android:interpolator="@android:anim/bounce_interpolator"
|
||||||
|
android:duration="400"
|
||||||
|
/>
|
||||||
|
</set>
|
7
nfcsweetspot/src/main/res/anim/fade_out_quick.xml
Normal file
7
nfcsweetspot/src/main/res/anim/fade_out_quick.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<alpha android:fromAlpha="1.0" android:toAlpha="0.0"
|
||||||
|
android:interpolator="@android:anim/decelerate_interpolator"
|
||||||
|
android:duration="150"
|
||||||
|
/>
|
||||||
|
</set>
|
8
nfcsweetspot/src/main/res/drawable/ic_nfc.xml
Normal file
8
nfcsweetspot/src/main/res/drawable/ic_nfc.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:height="24dp"
|
||||||
|
android:width="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path android:fillColor="#000" android:pathData="M10.59,7.66C10.59,7.66 11.19,7.39 11.57,7.82C11.95,8.26 12.92,9.94 12.92,11.62C12.92,13.3 12.5,15.09 12.05,15.68C11.62,16.28 11.19,16.28 10.86,16.06C10.54,15.85 5.5,12 5.23,11.89C4.95,11.78 4.85,12.05 5.12,13.5C5.39,15 4.95,15.41 4.57,15.47C4.2,15.5 3.06,15.2 3,12.16C2.95,9.13 3.76,8.64 4.14,8.64C4.85,8.64 10.27,13.5 10.64,13.46C10.97,13.41 11.13,11.35 10.5,9.72C9.78,7.96 10.59,7.66 10.59,7.66M19.3,4.63C21.12,8.24 21,11.66 21,12C21,12.34 21.12,15.76 19.3,19.37C19.3,19.37 18.83,19.92 18.12,19.59C17.42,19.26 17.66,18.4 17.66,18.4C17.66,18.4 19.14,15.55 19.1,12.05V12C19.14,8.5 17.66,5.6 17.66,5.6C17.66,5.6 17.42,4.74 18.12,4.41C18.83,4.08 19.3,4.63 19.3,4.63M15.77,6.25C17.26,8.96 17.16,11.66 17.14,12C17.16,12.34 17.26,14.92 15.77,17.85C15.77,17.85 15.3,18.4 14.59,18.07C13.89,17.74 14.13,16.88 14.13,16.88C14.13,16.88 15.09,15.5 15.24,12.05V12C15.14,8.53 14.13,7.23 14.13,7.23C14.13,7.23 13.89,6.36 14.59,6.04C15.3,5.71 15.77,6.25 15.77,6.25Z" />
|
||||||
|
</vector>
|
|
@ -9,7 +9,7 @@
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/nfc_sweetspot_indicator"
|
android:id="@+id/indicator_nfc_sweetspot"
|
||||||
tools:layout_marginLeft="60dp"
|
tools:layout_marginLeft="60dp"
|
||||||
tools:layout_marginTop="100dp"
|
tools:layout_marginTop="100dp"
|
||||||
tools:ignore="UselessParent">
|
tools:ignore="UselessParent">
|
||||||
|
@ -18,35 +18,36 @@
|
||||||
android:layout_width="36dp"
|
android:layout_width="36dp"
|
||||||
android:layout_height="36dp"
|
android:layout_height="36dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:src="@drawable/ic_nfc_white_24dp"
|
android:src="@drawable/ic_nfc"
|
||||||
android:id="@+id/nfc_sweetspot_icon"
|
android:id="@+id/icon_nfc_sweetspot"
|
||||||
|
android:tint="#fff"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="60dp"
|
android:layout_width="60dp"
|
||||||
android:layout_height="60dp"
|
android:layout_height="60dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:src="@drawable/circle"
|
android:src="@drawable/ic_circle"
|
||||||
android:id="@+id/nfc_sweetspot_circle_1"
|
android:id="@+id/circle_nfc_sweetspot_1"
|
||||||
android:tint="@color/md_white_1000"
|
android:tint="#fff"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="95dp"
|
android:layout_width="95dp"
|
||||||
android:layout_height="95dp"
|
android:layout_height="95dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:src="@drawable/circle"
|
android:src="@drawable/ic_circle"
|
||||||
android:id="@+id/nfc_sweetspot_circle_2"
|
android:id="@+id/circle_nfc_sweetspot_2"
|
||||||
android:tint="@color/md_white_1000"
|
android:tint="#fff"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="130dp"
|
android:layout_width="130dp"
|
||||||
android:layout_height="130dp"
|
android:layout_height="130dp"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:src="@drawable/circle"
|
android:src="@drawable/ic_circle"
|
||||||
android:id="@+id/nfc_sweetspot_circle_3"
|
android:id="@+id/circle_nfc_sweetspot_3"
|
||||||
android:tint="@color/md_white_1000"
|
android:tint="#fff"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
|
@ -1,5 +1,6 @@
|
||||||
include ':OpenKeychain'
|
include ':OpenKeychain'
|
||||||
include ':libkeychain'
|
include ':libkeychain'
|
||||||
|
include ':nfcsweetspot'
|
||||||
include ':extern:bouncycastle:core'
|
include ':extern:bouncycastle:core'
|
||||||
include ':extern:bouncycastle:pg'
|
include ':extern:bouncycastle:pg'
|
||||||
include ':extern:bouncycastle:prov'
|
include ':extern:bouncycastle:prov'
|
||||||
|
|
Loading…
Reference in a new issue