tls-psk: handle scan from ImportKeysProxyActivity
This commit is contained in:
@@ -74,6 +74,9 @@ public final class Constants {
|
|||||||
// used by QR Codes (Guardian Project, Monkeysphere compatibility)
|
// used by QR Codes (Guardian Project, Monkeysphere compatibility)
|
||||||
public static final String FINGERPRINT_SCHEME = "openpgp4fpr";
|
public static final String FINGERPRINT_SCHEME = "openpgp4fpr";
|
||||||
|
|
||||||
|
// used by openpgp-skt
|
||||||
|
public static final String TRANSFER_SCHEME = "pgp+transfer";
|
||||||
|
|
||||||
public static final String BOUNCY_CASTLE_PROVIDER_NAME = BouncyCastleProvider.PROVIDER_NAME;
|
public static final String BOUNCY_CASTLE_PROVIDER_NAME = BouncyCastleProvider.PROVIDER_NAME;
|
||||||
|
|
||||||
// prefix packagename for exported Intents
|
// prefix packagename for exported Intents
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import org.sufficientlysecure.keychain.operations.results.OperationResult.LogTyp
|
|||||||
import org.sufficientlysecure.keychain.operations.results.SingletonResult;
|
import org.sufficientlysecure.keychain.operations.results.SingletonResult;
|
||||||
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
||||||
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
||||||
|
import org.sufficientlysecure.keychain.ui.transfer.view.TransferFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.util.IntentIntegratorSupportV4;
|
import org.sufficientlysecure.keychain.util.IntentIntegratorSupportV4;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
@@ -143,6 +144,17 @@ public class ImportKeysProxyActivity extends FragmentActivity
|
|||||||
|
|
||||||
Log.d(Constants.TAG, "scanned: " + uri);
|
Log.d(Constants.TAG, "scanned: " + uri);
|
||||||
|
|
||||||
|
// example: pgp+transfer:
|
||||||
|
if (uri != null && uri.getScheme() != null && uri.getScheme().equalsIgnoreCase(Constants.TRANSFER_SCHEME)) {
|
||||||
|
Intent intent = new Intent(this, MainActivity.class);
|
||||||
|
intent.putExtra(MainActivity.EXTRA_INIT_FRAG, MainActivity.ID_TRANSFER);
|
||||||
|
intent.putExtra(TransferFragment.EXTRA_OPENPGP_SKT_INFO, uri);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// example: openpgp4fpr:73EE2314F65FA92EC2390D3A718C070100012282
|
// example: openpgp4fpr:73EE2314F65FA92EC2390D3A718C070100012282
|
||||||
if (uri == null || uri.getScheme() == null ||
|
if (uri == null || uri.getScheme() == null ||
|
||||||
!uri.getScheme().toLowerCase(Locale.ENGLISH).equals(Constants.FINGERPRINT_SCHEME)) {
|
!uri.getScheme().toLowerCase(Locale.ENGLISH).equals(Constants.FINGERPRINT_SCHEME)) {
|
||||||
@@ -153,6 +165,7 @@ public class ImportKeysProxyActivity extends FragmentActivity
|
|||||||
returnResult(intent);
|
returnResult(intent);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String fingerprintHex = uri.getEncodedSchemeSpecificPart().toLowerCase(Locale.ENGLISH);
|
final String fingerprintHex = uri.getEncodedSchemeSpecificPart().toLowerCase(Locale.ENGLISH);
|
||||||
if (!fingerprintHex.matches("[a-fA-F0-9]{40}")) {
|
if (!fingerprintHex.matches("[a-fA-F0-9]{40}")) {
|
||||||
SingletonResult result = new SingletonResult(
|
SingletonResult result = new SingletonResult(
|
||||||
|
|||||||
@@ -173,11 +173,35 @@ public class MainActivity extends BaseSecurityTokenActivity implements FabContai
|
|||||||
case ID_APPS:
|
case ID_APPS:
|
||||||
onAppsSelected();
|
onAppsSelected();
|
||||||
break;
|
break;
|
||||||
|
case ID_TRANSFER:
|
||||||
|
onTransferSelected();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNewIntent(Intent data) {
|
||||||
|
super.onNewIntent(data);
|
||||||
|
|
||||||
|
setIntent(data);
|
||||||
|
if (data != null && data.hasExtra(EXTRA_INIT_FRAG)) {
|
||||||
|
// initialize FragmentLayout with KeyListFragment at first
|
||||||
|
switch (data.getIntExtra(EXTRA_INIT_FRAG, -1)) {
|
||||||
|
case ID_ENCRYPT_DECRYPT:
|
||||||
|
onEnDecryptSelected();
|
||||||
|
break;
|
||||||
|
case ID_APPS:
|
||||||
|
onAppsSelected();
|
||||||
|
break;
|
||||||
|
case ID_TRANSFER:
|
||||||
|
onTransferSelected();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void setFragment(Fragment fragment, boolean addToBackStack) {
|
private void setFragment(Fragment fragment, boolean addToBackStack) {
|
||||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||||
fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||||
|
|||||||
@@ -100,6 +100,10 @@ public class TransferPresenter implements KeyTransferCallback, LoaderCallbacks<L
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void onUiInitFromIntentUri(final Uri initUri) {
|
||||||
|
connectionStartConnect(initUri.toString());
|
||||||
|
}
|
||||||
|
|
||||||
public void onUiStart() {
|
public void onUiStart() {
|
||||||
loaderManager.restartLoader(loaderId, null, this);
|
loaderManager.restartLoader(loaderId, null, this);
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import android.content.Intent;
|
|||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
|
import android.net.Uri;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Build.VERSION_CODES;
|
import android.os.Build.VERSION_CODES;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -69,6 +70,8 @@ public class TransferFragment extends Fragment implements TransferMvpView {
|
|||||||
public static final int REQUEST_CODE_SCAN = 1;
|
public static final int REQUEST_CODE_SCAN = 1;
|
||||||
public static final int LOADER_ID = 1;
|
public static final int LOADER_ID = 1;
|
||||||
|
|
||||||
|
public static final String EXTRA_OPENPGP_SKT_INFO = "openpgp_skt_info";
|
||||||
|
|
||||||
|
|
||||||
private ImageView vQrCodeImage;
|
private ImageView vQrCodeImage;
|
||||||
private TransferPresenter presenter;
|
private TransferPresenter presenter;
|
||||||
@@ -125,6 +128,20 @@ public class TransferFragment extends Fragment implements TransferMvpView {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Intent activityIntent = getActivity().getIntent();
|
||||||
|
if (activityIntent != null && activityIntent.hasExtra(EXTRA_OPENPGP_SKT_INFO)) {
|
||||||
|
presenter.onUiInitFromIntentUri(activityIntent.<Uri>getParcelableExtra(EXTRA_OPENPGP_SKT_INFO));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
|||||||
Reference in New Issue
Block a user