diff --git a/OpenKeychain/build.gradle b/OpenKeychain/build.gradle index 97eeb8322..9c06305b6 100644 --- a/OpenKeychain/build.gradle +++ b/OpenKeychain/build.gradle @@ -56,6 +56,7 @@ dependencies { // libs as submodules implementation project(':libkeychain') implementation project(':openpgp-api-lib') + implementation project(':nfcsweetspot') implementation project(':sshauthentication-api') implementation project(':extern:bouncycastle:core') implementation project(':extern:bouncycastle:pg') diff --git a/OpenKeychain/src/main/AndroidManifest.xml b/OpenKeychain/src/main/AndroidManifest.xml index 94d17b8d6..c1362f461 100644 --- a/OpenKeychain/src/main/AndroidManifest.xml +++ b/OpenKeychain/src/main/AndroidManifest.xml @@ -858,7 +858,7 @@ android:theme="@android:style/Theme.NoDisplay" /> diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateSecurityTokenWaitFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateSecurityTokenWaitFragment.java index 2d0740ac5..3678637c3 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateSecurityTokenWaitFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateSecurityTokenWaitFragment.java @@ -33,6 +33,8 @@ import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.animation.Animation; +import de.cotech.sweetspot.NfcSweetspotData; +import de.cotech.sweetspot.ShowNfcSweetspotActivity; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.securitytoken.SecurityTokenInfo; @@ -92,7 +94,7 @@ public class CreateSecurityTokenWaitFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 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); buttonLocateSweetspot.setVisibility(showLocateSweetspot ? View.VISIBLE : View.GONE); buttonLocateSweetspot.setOnClickListener(new OnClickListener() { diff --git a/nfcsweetspot/.gitignore b/nfcsweetspot/.gitignore new file mode 100644 index 000000000..a44cc0f0f --- /dev/null +++ b/nfcsweetspot/.gitignore @@ -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/* \ No newline at end of file diff --git a/nfcsweetspot/build.gradle b/nfcsweetspot/build.gradle new file mode 100644 index 000000000..144a8145c --- /dev/null +++ b/nfcsweetspot/build.gradle @@ -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 + } +} diff --git a/nfcsweetspot/src/main/AndroidManifest.xml b/nfcsweetspot/src/main/AndroidManifest.xml new file mode 100644 index 000000000..2f36697f8 --- /dev/null +++ b/nfcsweetspot/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/securitytoken/NfcSweetspotData.java b/nfcsweetspot/src/main/java/de/cotech/sweetspot/NfcSweetspotData.java similarity index 99% rename from OpenKeychain/src/main/java/org/sufficientlysecure/keychain/securitytoken/NfcSweetspotData.java rename to nfcsweetspot/src/main/java/de/cotech/sweetspot/NfcSweetspotData.java index 44dc7704f..52b55ff88 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/securitytoken/NfcSweetspotData.java +++ b/nfcsweetspot/src/main/java/de/cotech/sweetspot/NfcSweetspotData.java @@ -15,13 +15,14 @@ * along with this program. If not, see . */ -package org.sufficientlysecure.keychain.securitytoken; +package de.cotech.sweetspot; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import android.os.Build; import android.util.Pair; @@ -969,4 +970,16 @@ public class NfcSweetspotData { SWEETSPOT_DATA = Collections.unmodifiableMap(data); } + + public static boolean hasSweetspotData() { + return NfcSweetspotData.SWEETSPOT_DATA.containsKey(Build.MODEL); + } + + public static Pair getSweetspotForBuildModel() { + return getSweetspotForBuildModel(Build.MODEL); + } + + public static Pair getSweetspotForBuildModel(String buildModel) { + return SWEETSPOT_DATA.get(buildModel); + } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ShowNfcSweetspotActivity.java b/nfcsweetspot/src/main/java/de/cotech/sweetspot/ShowNfcSweetspotActivity.java similarity index 66% rename from OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ShowNfcSweetspotActivity.java rename to nfcsweetspot/src/main/java/de/cotech/sweetspot/ShowNfcSweetspotActivity.java index 5522a3306..8b2382010 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ShowNfcSweetspotActivity.java +++ b/nfcsweetspot/src/main/java/de/cotech/sweetspot/ShowNfcSweetspotActivity.java @@ -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 * it under the terms of the GNU General Public License as published by @@ -15,30 +15,19 @@ * along with this program. If not, see . */ -package org.sufficientlysecure.keychain.ui; +package de.cotech.sweetspot; import android.app.Activity; -import android.content.Intent; -import android.os.Build; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import android.util.DisplayMetrics; import android.util.Pair; import android.view.MotionEvent; import android.view.View; 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 sweetspotIcon; private View sweetspotCircle1; @@ -46,15 +35,16 @@ public class ShowNfcSweetspotActivity extends BaseSecurityTokenActivity { private View sweetspotCircle3; @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - + protected void onCreate(Bundle savedInstanceState) { + setTheme(android.R.style.Theme_Translucent_NoTitleBar_Fullscreen); overridePendingTransition(R.anim.fade_in_quick, R.anim.fade_out_quick); - setContentView(R.layout.show_nfc_sweetspot_activity); - sweetspotIndicator = findViewById(R.id.nfc_sweetspot_indicator); + super.onCreate(savedInstanceState); - Pair nfcPosition = NfcSweetspotData.SWEETSPOT_DATA.get(Build.MODEL); + setContentView(R.layout.activity_nfc_sweetspot); + sweetspotIndicator = findViewById(R.id.indicator_nfc_sweetspot); + + Pair nfcPosition = NfcSweetspotData.getSweetspotForBuildModel(); if (nfcPosition == null) { 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); - sweetspotCircle1 = findViewById(R.id.nfc_sweetspot_circle_1); - sweetspotCircle2 = findViewById(R.id.nfc_sweetspot_circle_2); - sweetspotCircle3 = findViewById(R.id.nfc_sweetspot_circle_3); + sweetspotIcon = findViewById(R.id.icon_nfc_sweetspot); + sweetspotCircle1 = findViewById(R.id.circle_nfc_sweetspot_1); + sweetspotCircle2 = findViewById(R.id.circle_nfc_sweetspot_2); + sweetspotCircle3 = findViewById(R.id.circle_nfc_sweetspot_3); sweetspotIcon.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(); } - @Override - protected void initTheme() { - // do nothing - } - @Override public void finish() { super.finish(); @@ -105,14 +90,6 @@ public class ShowNfcSweetspotActivity extends BaseSecurityTokenActivity { 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 public boolean onTouchEvent(MotionEvent event) { if (event.getActionMasked() == MotionEvent.ACTION_UP) { @@ -124,15 +101,10 @@ public class ShowNfcSweetspotActivity extends BaseSecurityTokenActivity { return super.onTouchEvent(event); } - @NonNull private DisplayMetrics getDisplaySize() { DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); return metrics; } - - public static boolean hasSweetspotData() { - return NfcSweetspotData.SWEETSPOT_DATA.containsKey(Build.MODEL); - } } diff --git a/nfcsweetspot/src/main/res/anim/fade_in_quick.xml b/nfcsweetspot/src/main/res/anim/fade_in_quick.xml new file mode 100644 index 000000000..e0725de3d --- /dev/null +++ b/nfcsweetspot/src/main/res/anim/fade_in_quick.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/nfcsweetspot/src/main/res/anim/fade_out_quick.xml b/nfcsweetspot/src/main/res/anim/fade_out_quick.xml new file mode 100644 index 000000000..94fc508d7 --- /dev/null +++ b/nfcsweetspot/src/main/res/anim/fade_out_quick.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/drawable/circle.xml b/nfcsweetspot/src/main/res/drawable/ic_circle.xml similarity index 100% rename from OpenKeychain/src/main/res/drawable/circle.xml rename to nfcsweetspot/src/main/res/drawable/ic_circle.xml diff --git a/nfcsweetspot/src/main/res/drawable/ic_nfc.xml b/nfcsweetspot/src/main/res/drawable/ic_nfc.xml new file mode 100644 index 000000000..6b3c3a680 --- /dev/null +++ b/nfcsweetspot/src/main/res/drawable/ic_nfc.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/show_nfc_sweetspot_activity.xml b/nfcsweetspot/src/main/res/layout/activity_nfc_sweetspot.xml similarity index 66% rename from OpenKeychain/src/main/res/layout/show_nfc_sweetspot_activity.xml rename to nfcsweetspot/src/main/res/layout/activity_nfc_sweetspot.xml index 9f16ea06c..515361595 100644 --- a/OpenKeychain/src/main/res/layout/show_nfc_sweetspot_activity.xml +++ b/nfcsweetspot/src/main/res/layout/activity_nfc_sweetspot.xml @@ -9,7 +9,7 @@ @@ -18,35 +18,36 @@ android:layout_width="36dp" android:layout_height="36dp" android:layout_gravity="center" - android:src="@drawable/ic_nfc_white_24dp" - android:id="@+id/nfc_sweetspot_icon" + android:src="@drawable/ic_nfc" + android:id="@+id/icon_nfc_sweetspot" + android:tint="#fff" /> diff --git a/settings.gradle b/settings.gradle index 01b3c106c..a40f66d1d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1,6 @@ include ':OpenKeychain' include ':libkeychain' +include ':nfcsweetspot' include ':extern:bouncycastle:core' include ':extern:bouncycastle:pg' include ':extern:bouncycastle:prov'