reformatted code
This commit is contained in:
@@ -17,18 +17,17 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.service.input;
|
package org.sufficientlysecure.keychain.service.input;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.util.ParcelableProxy;
|
import org.sufficientlysecure.keychain.util.ParcelableProxy;
|
||||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a base class for the input of crypto operations.
|
* This is a base class for the input of crypto operations.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.getbase.floatingactionbutton.FloatingActionButton;
|
import com.getbase.floatingactionbutton.FloatingActionButton;
|
||||||
import com.getbase.floatingactionbutton.FloatingActionsMenu;
|
import com.getbase.floatingactionbutton.FloatingActionsMenu;
|
||||||
|
|
||||||
import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
|
import se.emilsjolander.stickylistheaders.StickyListHeadersAdapter;
|
||||||
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
import se.emilsjolander.stickylistheaders.StickyListHeadersListView;
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ package org.sufficientlysecure.keychain.ui;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
|
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
|
||||||
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
|
||||||
@@ -29,7 +30,8 @@ import org.sufficientlysecure.keychain.util.Preferences;
|
|||||||
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simply encapsulates a dialog. If orbot is not installed, it shows an install dialog, else a dialog to enable orbot.
|
* Simply encapsulates a dialog. If orbot is not installed, it shows an install dialog, else a
|
||||||
|
* dialog to enable orbot.
|
||||||
*/
|
*/
|
||||||
public class OrbotRequiredDialogActivity extends FragmentActivity {
|
public class OrbotRequiredDialogActivity extends FragmentActivity {
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import android.view.View;
|
|||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
|||||||
@@ -83,11 +83,11 @@ public abstract class CryptoOperationFragment<T extends Parcelable, S extends Op
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* To be overriden by subclasses, if desired. Provides a way to access the method by the
|
* To be overriden by subclasses, if desired. Provides a way to access the method by the
|
||||||
* same name in CryptoOperationHelper, if super.onCryptoOperationSuccess and
|
* same name in CryptoOperationHelper, if super.onCryptoOperationSuccess and
|
||||||
* super.onCryptoOperationError are called at the start of the respective functions in the
|
* super.onCryptoOperationError are called at the start of the respective functions in the
|
||||||
* subclass overriding them
|
* subclass overriding them
|
||||||
|
*
|
||||||
* @param result
|
* @param result
|
||||||
*/
|
*/
|
||||||
protected void onCryptoOperationResult(S result) {
|
protected void onCryptoOperationResult(S result) {
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ import android.os.Messenger;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.operations.results.InputPendingResult;
|
import org.sufficientlysecure.keychain.operations.results.InputPendingResult;
|
||||||
@@ -53,11 +53,15 @@ import org.sufficientlysecure.keychain.util.Log;
|
|||||||
*/
|
*/
|
||||||
public class CryptoOperationHelper<T extends Parcelable, S extends OperationResult> {
|
public class CryptoOperationHelper<T extends Parcelable, S extends OperationResult> {
|
||||||
|
|
||||||
public interface Callback <T extends Parcelable, S extends OperationResult> {
|
public interface Callback<T extends Parcelable, S extends OperationResult> {
|
||||||
T createOperationInput();
|
T createOperationInput();
|
||||||
|
|
||||||
void onCryptoOperationSuccess(S result);
|
void onCryptoOperationSuccess(S result);
|
||||||
|
|
||||||
void onCryptoOperationCancelled();
|
void onCryptoOperationCancelled();
|
||||||
|
|
||||||
void onCryptoOperationError(S result);
|
void onCryptoOperationError(S result);
|
||||||
|
|
||||||
boolean onCryptoSetProgress(String msg, int progress, int max);
|
boolean onCryptoSetProgress(String msg, int progress, int max);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,6 +128,7 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
|
|||||||
Activity activity = mUseFragment ? mFragment.getActivity() : mActivity;
|
Activity activity = mUseFragment ? mFragment.getActivity() : mActivity;
|
||||||
|
|
||||||
switch (requiredInput.mType) {
|
switch (requiredInput.mType) {
|
||||||
|
// TODO: Verify that all started activities add to cryptoInputParcel if necessary (like OrbotRequiredDialogActivity)
|
||||||
// don't forget to set mRequestedCode!
|
// don't forget to set mRequestedCode!
|
||||||
case NFC_MOVE_KEY_TO_CARD:
|
case NFC_MOVE_KEY_TO_CARD:
|
||||||
case NFC_DECRYPT:
|
case NFC_DECRYPT:
|
||||||
@@ -215,12 +220,10 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
|
|||||||
}
|
}
|
||||||
|
|
||||||
case REQUEST_CODE_ENABLE_ORBOT: {
|
case REQUEST_CODE_ENABLE_ORBOT: {
|
||||||
Log.e("PHILIP", "request rec");
|
|
||||||
if (resultCode == Activity.RESULT_OK && data != null) {
|
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||||
CryptoInputParcel cryptoInput =
|
CryptoInputParcel cryptoInput =
|
||||||
data.getParcelableExtra(
|
data.getParcelableExtra(
|
||||||
OrbotRequiredDialogActivity.RESULT_CRYPTO_INPUT);
|
OrbotRequiredDialogActivity.RESULT_CRYPTO_INPUT);
|
||||||
Log.e("PHILIP", "initiating next op");
|
|
||||||
cryptoOperation(cryptoInput);
|
cryptoOperation(cryptoInput);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -294,7 +297,7 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
|
|||||||
@Override
|
@Override
|
||||||
protected void onSetProgress(String msg, int progress, int max) {
|
protected void onSetProgress(String msg, int progress, int max) {
|
||||||
// allow handling of progress in fragment, or delegate upwards
|
// allow handling of progress in fragment, or delegate upwards
|
||||||
if ( ! mCallback.onCryptoSetProgress(msg, progress, max)) {
|
if (!mCallback.onCryptoSetProgress(msg, progress, max)) {
|
||||||
super.onSetProgress(msg, progress, max);
|
super.onSetProgress(msg, progress, max);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ public class ParcelableProxy implements Parcelable {
|
|||||||
public ParcelableProxy(String hostName, int port, Proxy.Type type) {
|
public ParcelableProxy(String hostName, int port, Proxy.Type type) {
|
||||||
mProxyHost = hostName;
|
mProxyHost = hostName;
|
||||||
|
|
||||||
if (hostName == null) return; // represents a null proxy
|
if (hostName == null) {
|
||||||
|
return; // represents a null proxy
|
||||||
|
}
|
||||||
|
|
||||||
mProxyPort = port;
|
mProxyPort = port;
|
||||||
|
|
||||||
@@ -46,7 +48,9 @@ public class ParcelableProxy implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Proxy getProxy() {
|
public Proxy getProxy() {
|
||||||
if (mProxyHost == null) return null;
|
if (mProxyHost == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new Proxy(mProxyType, new InetSocketAddress(mProxyHost, mProxyPort));
|
return new Proxy(mProxyType, new InetSocketAddress(mProxyHost, mProxyPort));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ import android.support.v4.app.DialogFragment;
|
|||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.service.ConsolidateInputParcel;
|
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.SupportInstallDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.SupportInstallDialogFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.OrbotStartDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.OrbotStartDialogFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.PreferenceInstallDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.PreferenceInstallDialogFragment;
|
||||||
|
|||||||
Reference in New Issue
Block a user