Merge branch 'master' into v/multi-decrypt

this also fixes weird-bug

Conflicts:
	OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java
	OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFilesFragment.java
	OpenKeychain/src/main/res/values/strings.xml
This commit is contained in:
Vincent Breitmoser
2015-06-06 23:39:26 +02:00
40 changed files with 1395 additions and 1382 deletions

View File

@@ -52,12 +52,11 @@ import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.ui.adapter.MultiUserIdsAdapter;
import org.sufficientlysecure.keychain.ui.base.CachingCryptoOperationFragment;
import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment;
import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.ui.widget.CertifyKeySpinner;
import org.sufficientlysecure.keychain.util.Log;
@@ -104,7 +103,7 @@ public class CertifyKeyFragment extends CachingCryptoOperationFragment<CertifyAc
}
mPassthroughMessenger = getActivity().getIntent().getParcelableExtra(
KeychainIntentService.EXTRA_MESSENGER);
KeychainService.EXTRA_MESSENGER);
mPassthroughMessenger = null; // TODO doesn't work with CryptoOperationFragment, disabled for now
ArrayList<Boolean> checkedStates;
@@ -330,31 +329,32 @@ public class CertifyKeyFragment extends CachingCryptoOperationFragment<CertifyAc
cacheActionsParcel(actionsParcel);
}
data.putParcelable(KeychainIntentService.EXTRA_CRYPTO_INPUT, cryptoInput);
data.putParcelable(KeychainIntentService.CERTIFY_PARCEL, actionsParcel);
data.putParcelable(KeychainService.EXTRA_CRYPTO_INPUT, cryptoInput);
data.putParcelable(KeychainService.CERTIFY_PARCEL, actionsParcel);
if (mUploadKeyCheckbox.isChecked()) {
String keyserver = Preferences.getPreferences(getActivity()).getPreferredKeyserver();
data.putString(KeychainIntentService.UPLOAD_KEY_SERVER, keyserver);
data.putString(KeychainService.UPLOAD_KEY_SERVER, keyserver);
}
}
// Send all information needed to service to sign key in other thread
Intent intent = new Intent(getActivity(), KeychainIntentService.class);
intent.setAction(KeychainIntentService.ACTION_CERTIFY_KEYRING);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
Intent intent = new Intent(getActivity(), KeychainService.class);
intent.setAction(KeychainService.ACTION_CERTIFY_KEYRING);
intent.putExtra(KeychainService.EXTRA_DATA, data);
if (mPassthroughMessenger != null) {
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, mPassthroughMessenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, mPassthroughMessenger);
} else {
// Message is received after signing is done in KeychainIntentService
// Message is received after signing is done in KeychainService
ServiceProgressHandler saveHandler = new ServiceProgressHandler(
getActivity(),
getString(R.string.progress_certifying),
ProgressDialog.STYLE_SPINNER,
true,
ProgressDialogFragment.ServiceType.KEYCHAIN_INTENT) {
true
) {
@Override
public void handleMessage(Message message) {
// handle messages by KeychainIntentCryptoServiceHandler first
super.handleMessage(message);
@@ -379,7 +379,7 @@ public class CertifyKeyFragment extends CachingCryptoOperationFragment<CertifyAc
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// show progress dialog
saveHandler.showProgressDialog(getActivity());

View File

@@ -25,9 +25,8 @@ import android.os.Messenger;
import android.support.v4.app.FragmentActivity;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment;
/**
* We can not directly create a dialog on the application context.
@@ -49,12 +48,13 @@ public class ConsolidateDialogActivity extends FragmentActivity {
}
private void consolidateRecovery(boolean recovery) {
// Message is received after importing is done in KeychainIntentService
// Message is received after importing is done in KeychainService
ServiceProgressHandler saveHandler = new ServiceProgressHandler(
this,
getString(R.string.progress_importing),
ProgressDialog.STYLE_HORIZONTAL,
ProgressDialogFragment.ServiceType.KEYCHAIN_INTENT) {
ProgressDialog.STYLE_HORIZONTAL
) {
@Override
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
@@ -68,7 +68,7 @@ public class ConsolidateDialogActivity extends FragmentActivity {
return;
}
final ConsolidateResult result =
returnData.getParcelable(KeychainIntentService.RESULT_CONSOLIDATE);
returnData.getParcelable(KeychainService.RESULT_CONSOLIDATE);
if (result == null) {
return;
}
@@ -81,17 +81,17 @@ public class ConsolidateDialogActivity extends FragmentActivity {
};
// Send all information needed to service to import key in other thread
Intent intent = new Intent(this, KeychainIntentService.class);
intent.setAction(KeychainIntentService.ACTION_CONSOLIDATE);
Intent intent = new Intent(this, KeychainService.class);
intent.setAction(KeychainService.ACTION_CONSOLIDATE);
// fill values for this action
Bundle data = new Bundle();
data.putBoolean(KeychainIntentService.CONSOLIDATE_RECOVERY, recovery);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
data.putBoolean(KeychainService.CONSOLIDATE_RECOVERY, recovery);
intent.putExtra(KeychainService.EXTRA_DATA, data);
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// show progress dialog
saveHandler.showProgressDialog(this);

View File

@@ -38,13 +38,12 @@ import org.sufficientlysecure.keychain.operations.results.EditKeyResult;
import org.sufficientlysecure.keychain.operations.results.OperationResult;
import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.Algorithm;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.ChangeUnlockParcel;
import org.sufficientlysecure.keychain.ui.CreateKeyActivity.FragAction;
import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment;
import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.Preferences;
@@ -195,14 +194,15 @@ public class CreateKeyFinalFragment extends Fragment {
private void createKey() {
Intent intent = new Intent(getActivity(), KeychainIntentService.class);
intent.setAction(KeychainIntentService.ACTION_EDIT_KEYRING);
Intent intent = new Intent(getActivity(), KeychainService.class);
intent.setAction(KeychainService.ACTION_EDIT_KEYRING);
ServiceProgressHandler saveHandler = new ServiceProgressHandler(
getActivity(),
getString(R.string.progress_building_key),
ProgressDialog.STYLE_HORIZONTAL,
ProgressDialogFragment.ServiceType.KEYCHAIN_INTENT) {
ProgressDialog.STYLE_HORIZONTAL
) {
@Override
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
@@ -237,13 +237,13 @@ public class CreateKeyFinalFragment extends Fragment {
Bundle data = new Bundle();
// get selected key entries
data.putParcelable(KeychainIntentService.EDIT_KEYRING_PARCEL, mSaveKeyringParcel);
data.putParcelable(KeychainService.EDIT_KEYRING_PARCEL, mSaveKeyringParcel);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
intent.putExtra(KeychainService.EXTRA_DATA, data);
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
saveHandler.showProgressDialog(getActivity());
@@ -253,9 +253,9 @@ public class CreateKeyFinalFragment extends Fragment {
// TODO move into EditKeyOperation
private void uploadKey(final EditKeyResult saveKeyResult) {
// Send all information needed to service to upload key in other thread
final Intent intent = new Intent(getActivity(), KeychainIntentService.class);
final Intent intent = new Intent(getActivity(), KeychainService.class);
intent.setAction(KeychainIntentService.ACTION_UPLOAD_KEYRING);
intent.setAction(KeychainService.ACTION_UPLOAD_KEYRING);
// set data uri as path to keyring
Uri blobUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(
@@ -267,15 +267,16 @@ public class CreateKeyFinalFragment extends Fragment {
// upload to favorite keyserver
String keyserver = Preferences.getPreferences(getActivity()).getPreferredKeyserver();
data.putString(KeychainIntentService.UPLOAD_KEY_SERVER, keyserver);
data.putString(KeychainService.UPLOAD_KEY_SERVER, keyserver);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
intent.putExtra(KeychainService.EXTRA_DATA, data);
ServiceProgressHandler saveHandler = new ServiceProgressHandler(
getActivity(),
getString(R.string.progress_uploading),
ProgressDialog.STYLE_HORIZONTAL,
ProgressDialogFragment.ServiceType.KEYCHAIN_INTENT) {
ProgressDialog.STYLE_HORIZONTAL
) {
@Override
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
@@ -297,7 +298,7 @@ public class CreateKeyFinalFragment extends Fragment {
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// show progress dialog
saveHandler.showProgressDialog(getActivity());

View File

@@ -40,11 +40,10 @@ import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.ui.CreateKeyActivity.FragAction;
import org.sufficientlysecure.keychain.ui.CreateKeyActivity.NfcListenerFragment;
import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.util.Preferences;
@@ -176,13 +175,13 @@ public class CreateKeyYubiKeyImportFragment extends Fragment implements NfcListe
public void importKey() {
// Message is received after decrypting is done in KeychainIntentService
// Message is received after decrypting is done in KeychainService
ServiceProgressHandler saveHandler = new ServiceProgressHandler(
getActivity(),
getString(R.string.progress_importing),
ProgressDialog.STYLE_HORIZONTAL,
ProgressDialogFragment.ServiceType.KEYCHAIN_INTENT
ProgressDialog.STYLE_HORIZONTAL
) {
@Override
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
@@ -220,29 +219,29 @@ public class CreateKeyYubiKeyImportFragment extends Fragment implements NfcListe
};
// Send all information needed to service to decrypt in other thread
Intent intent = new Intent(getActivity(), KeychainIntentService.class);
Intent intent = new Intent(getActivity(), KeychainService.class);
// fill values for this action
Bundle data = new Bundle();
intent.setAction(KeychainIntentService.ACTION_IMPORT_KEYRING);
intent.setAction(KeychainService.ACTION_IMPORT_KEYRING);
ArrayList<ParcelableKeyRing> keyList = new ArrayList<>();
keyList.add(new ParcelableKeyRing(mNfcFingerprint, null, null));
data.putParcelableArrayList(KeychainIntentService.IMPORT_KEY_LIST, keyList);
data.putParcelableArrayList(KeychainService.IMPORT_KEY_LIST, keyList);
{
Preferences prefs = Preferences.getPreferences(getActivity());
Preferences.CloudSearchPrefs cloudPrefs =
new Preferences.CloudSearchPrefs(true, true, prefs.getPreferredKeyserver());
data.putString(KeychainIntentService.IMPORT_KEY_SERVER, cloudPrefs.keyserver);
data.putString(KeychainService.IMPORT_KEY_SERVER, cloudPrefs.keyserver);
}
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
intent.putExtra(KeychainService.EXTRA_DATA, data);
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
saveHandler.showProgressDialog(getActivity());

View File

@@ -61,22 +61,25 @@ import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.TemporaryStorageProvider;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler.MessageStatus;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
// this import NEEDS to be above the ViewModel one, or it won't compile! (as of 06/06/15)
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.StatusHolder;
import org.sufficientlysecure.keychain.ui.DecryptFilesListFragment.DecryptFilesAdapter.ViewModel;
import org.sufficientlysecure.keychain.ui.adapter.SpacesItemDecoration;
import org.sufficientlysecure.keychain.ui.base.CryptoOperationFragment;
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.StatusHolder;
import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
import org.sufficientlysecure.keychain.util.FileHelper;
import org.sufficientlysecure.keychain.util.Log;
public class DecryptFilesListFragment extends CryptoOperationFragment implements OnMenuItemClickListener {
public class DecryptFilesListFragment
extends CryptoOperationFragment
implements OnMenuItemClickListener {
public static final String ARG_URIS = "uris";
private static final int REQUEST_CODE_OUTPUT = 0x00007007;
@@ -264,12 +267,12 @@ public class DecryptFilesListFragment extends CryptoOperationFragment implements
}
// Send all information needed to service to decrypt in other thread
Intent intent = new Intent(getActivity(), KeychainIntentService.class);
Intent intent = new Intent(getActivity(), KeychainService.class);
// fill values for this action
Bundle data = new Bundle();
// use current operation, either decrypt metadata or decrypt payload
intent.setAction(KeychainIntentService.ACTION_DECRYPT_VERIFY);
intent.setAction(KeychainService.ACTION_DECRYPT_VERIFY);
// data
@@ -279,10 +282,10 @@ public class DecryptFilesListFragment extends CryptoOperationFragment implements
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(mCurrentInputUri, currentOutputUri)
.setAllowSymmetricDecryption(true);
data.putParcelable(KeychainIntentService.DECRYPT_VERIFY_PARCEL, input);
data.putParcelable(KeychainIntentService.EXTRA_CRYPTO_INPUT, cryptoInput);
data.putParcelable(KeychainService.DECRYPT_VERIFY_PARCEL, input);
data.putParcelable(KeychainService.EXTRA_CRYPTO_INPUT, cryptoInput);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
intent.putExtra(KeychainService.EXTRA_DATA, data);
// Message is received after decrypting is done in KeychainIntentService
Handler saveHandler = new Handler() {
@@ -344,7 +347,7 @@ public class DecryptFilesListFragment extends CryptoOperationFragment implements
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// start service with intent
getActivity().startService(intent);

View File

@@ -47,7 +47,7 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.ui.base.CryptoOperationFragment;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
@@ -130,8 +130,9 @@ public abstract class DecryptFragment extends CryptoOperationFragment implements
private void lookupUnknownKey(long unknownKeyId) {
// Message is received after importing is done in KeychainIntentService
// Message is received after importing is done in KeychainService
ServiceProgressHandler serviceHandler = new ServiceProgressHandler(getActivity()) {
@Override
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
@@ -162,7 +163,7 @@ public abstract class DecryptFragment extends CryptoOperationFragment implements
Preferences prefs = Preferences.getPreferences(getActivity());
Preferences.CloudSearchPrefs cloudPrefs =
new Preferences.CloudSearchPrefs(true, true, prefs.getPreferredKeyserver());
data.putString(KeychainIntentService.IMPORT_KEY_SERVER, cloudPrefs.keyserver);
data.putString(KeychainService.IMPORT_KEY_SERVER, cloudPrefs.keyserver);
}
{
@@ -171,17 +172,17 @@ public abstract class DecryptFragment extends CryptoOperationFragment implements
ArrayList<ParcelableKeyRing> selectedEntries = new ArrayList<>();
selectedEntries.add(keyEntry);
data.putParcelableArrayList(KeychainIntentService.IMPORT_KEY_LIST, selectedEntries);
data.putParcelableArrayList(KeychainService.IMPORT_KEY_LIST, selectedEntries);
}
// Send all information needed to service to query keys in other thread
Intent intent = new Intent(getActivity(), KeychainIntentService.class);
intent.setAction(KeychainIntentService.ACTION_IMPORT_KEYRING);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
Intent intent = new Intent(getActivity(), KeychainService.class);
intent.setAction(KeychainService.ACTION_IMPORT_KEYRING);
intent.putExtra(KeychainService.EXTRA_DATA, data);
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(serviceHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
getActivity().startService(intent);
}

View File

@@ -35,10 +35,9 @@ import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.compatibility.ClipboardReflection;
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyInputParcel;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment;
import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.util.ShareHelper;
@@ -161,25 +160,25 @@ public class DecryptTextFragment extends DecryptFragment {
@Override
protected void cryptoOperation(CryptoInputParcel cryptoInput) {
// Send all information needed to service to decrypt in other thread
Intent intent = new Intent(getActivity(), KeychainIntentService.class);
Intent intent = new Intent(getActivity(), KeychainService.class);
// fill values for this action
Bundle data = new Bundle();
intent.setAction(KeychainIntentService.ACTION_DECRYPT_VERIFY);
intent.setAction(KeychainService.ACTION_DECRYPT_VERIFY);
PgpDecryptVerifyInputParcel input = new PgpDecryptVerifyInputParcel(mCiphertext.getBytes());
data.putParcelable(KeychainIntentService.DECRYPT_VERIFY_PARCEL, input);
data.putParcelable(KeychainIntentService.EXTRA_CRYPTO_INPUT, cryptoInput);
data.putParcelable(KeychainService.DECRYPT_VERIFY_PARCEL, input);
data.putParcelable(KeychainService.EXTRA_CRYPTO_INPUT, cryptoInput);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
intent.putExtra(KeychainService.EXTRA_DATA, data);
// Message is received after encrypting is done in KeychainIntentService
// Message is received after encrypting is done in KeychainService
ServiceProgressHandler saveHandler = new ServiceProgressHandler(
getActivity(),
getString(R.string.progress_decrypting),
ProgressDialog.STYLE_HORIZONTAL,
ProgressDialogFragment.ServiceType.KEYCHAIN_INTENT) {
ProgressDialog.STYLE_HORIZONTAL
) {
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
@@ -223,7 +222,7 @@ public class DecryptTextFragment extends DecryptFragment {
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// show progress dialog
saveHandler.showProgressDialog(getActivity());

View File

@@ -50,7 +50,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel.ChangeUnlockParcel;
@@ -66,8 +66,6 @@ import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.Passphrase;
import java.nio.ByteBuffer;
public class EditKeyFragment extends CryptoOperationFragment implements
LoaderManager.LoaderCallbacks<Cursor> {
@@ -603,8 +601,8 @@ public class EditKeyFragment extends CryptoOperationFragment implements
getActivity(),
getString(R.string.progress_saving),
ProgressDialog.STYLE_HORIZONTAL,
true,
ProgressDialogFragment.ServiceType.KEYCHAIN_INTENT) {
true
) {
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
@@ -643,18 +641,18 @@ public class EditKeyFragment extends CryptoOperationFragment implements
};
// Send all information needed to service to import key in other thread
Intent intent = new Intent(getActivity(), KeychainIntentService.class);
intent.setAction(KeychainIntentService.ACTION_EDIT_KEYRING);
Intent intent = new Intent(getActivity(), KeychainService.class);
intent.setAction(KeychainService.ACTION_EDIT_KEYRING);
// fill values for this action
Bundle data = new Bundle();
data.putParcelable(KeychainIntentService.EXTRA_CRYPTO_INPUT, cryptoInput);
data.putParcelable(KeychainIntentService.EDIT_KEYRING_PARCEL, mSaveKeyringParcel);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
data.putParcelable(KeychainService.EXTRA_CRYPTO_INPUT, cryptoInput);
data.putParcelable(KeychainService.EDIT_KEYRING_PARCEL, mSaveKeyringParcel);
intent.putExtra(KeychainService.EXTRA_DATA, data);
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// show progress dialog
saveHandler.showProgressDialog(getActivity());

View File

@@ -73,12 +73,10 @@ public class EncryptFilesActivity extends EncryptActivity {
uris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
}
boolean useArmor = extras.getBoolean(EXTRA_ASCII_ARMOR, false);
if (savedInstanceState == null) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
EncryptFilesFragment encryptFragment = EncryptFilesFragment.newInstance(uris, useArmor);
EncryptFilesFragment encryptFragment = EncryptFilesFragment.newInstance(uris);
transaction.replace(R.id.encrypt_file_container, encryptFragment);
transaction.commit();
}

View File

@@ -49,18 +49,20 @@ import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.pgp.PgpConstants;
import org.sufficientlysecure.keychain.pgp.SignEncryptParcel;
import org.sufficientlysecure.keychain.provider.TemporaryStorageProvider;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.ui.adapter.SpacesItemDecoration;
import org.sufficientlysecure.keychain.ui.base.CachingCryptoOperationFragment;
import org.sufficientlysecure.keychain.ui.dialog.DeleteFileDialogFragment;
import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment;
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.ui.util.Notify.ActionListener;
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
import org.sufficientlysecure.keychain.util.FileHelper;
import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.Passphrase;
import org.sufficientlysecure.keychain.util.Preferences;
import org.sufficientlysecure.keychain.util.ShareHelper;
import java.io.File;
@@ -99,11 +101,10 @@ public class EncryptFilesFragment extends CachingCryptoOperationFragment<SignEnc
/**
* Creates new instance of this fragment
*/
public static EncryptFilesFragment newInstance(ArrayList<Uri> uris, boolean useArmor) {
public static EncryptFilesFragment newInstance(ArrayList<Uri> uris) {
EncryptFilesFragment frag = new EncryptFilesFragment();
Bundle args = new Bundle();
args.putBoolean(ARG_USE_ASCII_ARMOR, useArmor);
args.putParcelableArrayList(ARG_URIS, uris);
frag.setArguments(args);
@@ -167,11 +168,28 @@ public class EncryptFilesFragment extends CachingCryptoOperationFragment<SignEnc
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Preferences prefs = Preferences.getPreferences(getActivity());
Bundle args = savedInstanceState == null ? getArguments() : savedInstanceState;
mDeleteAfterEncrypt = args.getBoolean(ARG_DELETE_AFTER_ENCRYPT, false);
mUseArmor = args.getBoolean(ARG_USE_ASCII_ARMOR, false);
mUseCompression = args.getBoolean(ARG_USE_COMPRESSION, true);
mEncryptFilenames = args.getBoolean(ARG_ENCRYPT_FILENAMES, true);
if (args.containsKey(ARG_USE_ASCII_ARMOR)) {
mUseArmor = args.getBoolean(ARG_USE_ASCII_ARMOR, false);
} else {
mUseArmor = prefs.getUseArmor();
}
if (args.containsKey(ARG_USE_COMPRESSION)) {
mUseCompression = args.getBoolean(ARG_USE_COMPRESSION, true);
} else {
mUseCompression = prefs.getFilesUseCompression();
}
if (args.containsKey(ARG_ENCRYPT_FILENAMES)) {
mEncryptFilenames = args.getBoolean(ARG_ENCRYPT_FILENAMES, true);
} else {
mEncryptFilenames = prefs.getEncryptFilenames();
}
setHasOptionsMenu(true);
}
@@ -262,9 +280,7 @@ public class EncryptFilesFragment extends CachingCryptoOperationFragment<SignEnc
break;
}
case R.id.check_use_armor: {
// we can NOT do this for every item, others might care!
item.setChecked(!item.isChecked());
mUseArmor = item.isChecked();
toggleUseArmor(item, !item.isChecked());
break;
}
case R.id.check_delete_after_encrypt: {
@@ -273,13 +289,11 @@ public class EncryptFilesFragment extends CachingCryptoOperationFragment<SignEnc
break;
}
case R.id.check_enable_compression: {
item.setChecked(!item.isChecked());
mUseCompression = item.isChecked();
toggleEnableCompression(item, !item.isChecked());
break;
}
case R.id.check_encrypt_filenames: {
item.setChecked(!item.isChecked());
mEncryptFilenames = item.isChecked();
toggleEncryptFilenamesCheck(item, !item.isChecked());
break;
}
// case R.id.check_hidden_recipients: {
@@ -294,6 +308,72 @@ public class EncryptFilesFragment extends CachingCryptoOperationFragment<SignEnc
return true;
}
public void toggleUseArmor(MenuItem item, final boolean useArmor) {
mUseArmor = useArmor;
item.setChecked(useArmor);
Notify.create(getActivity(), useArmor
? R.string.snack_armor_on
: R.string.snack_armor_off,
Notify.LENGTH_LONG, Style.OK, new ActionListener() {
@Override
public void onAction() {
Preferences.getPreferences(getActivity()).setUseArmor(useArmor);
Notify.create(getActivity(), useArmor
? R.string.snack_armor_on
: R.string.snack_armor_off,
Notify.LENGTH_SHORT, Style.OK, null, R.string.btn_saved)
.show(EncryptFilesFragment.this, false);
}
}, R.string.btn_save_default).show(this);
}
public void toggleEnableCompression(MenuItem item, final boolean compress) {
mUseCompression = compress;
item.setChecked(compress);
Notify.create(getActivity(), compress
? R.string.snack_compression_on
: R.string.snack_compression_off,
Notify.LENGTH_LONG, Style.OK, new ActionListener() {
@Override
public void onAction() {
Preferences.getPreferences(getActivity()).setFilesUseCompression(compress);
Notify.create(getActivity(), compress
? R.string.snack_compression_on
: R.string.snack_compression_off,
Notify.LENGTH_SHORT, Style.OK, null, R.string.btn_saved)
.show(EncryptFilesFragment.this, false);
}
}, R.string.btn_save_default).show(this);
}
public void toggleEncryptFilenamesCheck(MenuItem item, final boolean encryptFilenames) {
mEncryptFilenames = encryptFilenames;
item.setChecked(encryptFilenames);
Notify.create(getActivity(), encryptFilenames
? R.string.snack_encrypt_filenames_on
: R.string.snack_encrypt_filenames_off,
Notify.LENGTH_LONG, Style.OK, new ActionListener() {
@Override
public void onAction() {
Preferences.getPreferences(getActivity()).setEncryptFilenames(encryptFilenames);
Notify.create(getActivity(), encryptFilenames
? R.string.snack_encrypt_filenames_on
: R.string.snack_encrypt_filenames_off,
Notify.LENGTH_SHORT, Style.OK, null, R.string.btn_saved)
.show(EncryptFilesFragment.this, false);
}
}, R.string.btn_save_default).show(this);
}
public void onEncryptSuccess(final SignEncryptResult result) {
if (mDeleteAfterEncrypt) {
DeleteFileDialogFragment deleteFileDialog =
@@ -505,21 +585,22 @@ public class EncryptFilesFragment extends CachingCryptoOperationFragment<SignEnc
}
// Send all information needed to service to edit key in other thread
Intent intent = new Intent(getActivity(), KeychainIntentService.class);
intent.setAction(KeychainIntentService.ACTION_SIGN_ENCRYPT);
Intent intent = new Intent(getActivity(), KeychainService.class);
intent.setAction(KeychainService.ACTION_SIGN_ENCRYPT);
Bundle data = new Bundle();
data.putParcelable(KeychainIntentService.SIGN_ENCRYPT_PARCEL, actionsParcel);
data.putParcelable(KeychainIntentService.EXTRA_CRYPTO_INPUT, cryptoInput);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
data.putParcelable(KeychainService.SIGN_ENCRYPT_PARCEL, actionsParcel);
data.putParcelable(KeychainService.EXTRA_CRYPTO_INPUT, cryptoInput);
intent.putExtra(KeychainService.EXTRA_DATA, data);
// Message is received after encrypting is done in KeychainIntentService
// Message is received after encrypting is done in KeychainService
ServiceProgressHandler serviceHandler = new ServiceProgressHandler(
getActivity(),
getString(R.string.progress_encrypting),
ProgressDialog.STYLE_HORIZONTAL,
true,
ProgressDialogFragment.ServiceType.KEYCHAIN_INTENT) {
true
) {
@Override
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
@@ -542,7 +623,7 @@ public class EncryptFilesFragment extends CachingCryptoOperationFragment<SignEnc
};
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(serviceHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// show progress dialog
serviceHandler.showProgressDialog(getActivity());

View File

@@ -41,13 +41,15 @@ import org.sufficientlysecure.keychain.operations.results.SignEncryptResult;
import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.pgp.PgpConstants;
import org.sufficientlysecure.keychain.pgp.SignEncryptParcel;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.ui.base.CachingCryptoOperationFragment;
import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment;
import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.ui.util.Notify.ActionListener;
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
import org.sufficientlysecure.keychain.util.Passphrase;
import org.sufficientlysecure.keychain.util.Preferences;
import org.sufficientlysecure.keychain.util.ShareHelper;
import java.util.HashSet;
@@ -131,8 +133,16 @@ public class EncryptTextFragment extends CachingCryptoOperationFragment<SignEncr
mMessage = getArguments().getString(ARG_TEXT);
}
Preferences prefs = Preferences.getPreferences(getActivity());
Bundle args = savedInstanceState == null ? getArguments() : savedInstanceState;
mUseCompression = args.getBoolean(ARG_USE_COMPRESSION, true);
if (args.containsKey(ARG_USE_COMPRESSION)) {
mUseCompression = args.getBoolean(ARG_USE_COMPRESSION, true);
} else {
mUseCompression = prefs.getTextUseCompression();
}
setHasOptionsMenu(true);
}
@@ -147,12 +157,9 @@ public class EncryptTextFragment extends CachingCryptoOperationFragment<SignEncr
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.isCheckable()) {
item.setChecked(!item.isChecked());
}
switch (item.getItemId()) {
case R.id.check_enable_compression: {
mUseCompression = item.isChecked();
toggleEnableCompression(item, !item.isChecked());
break;
}
// case R.id.check_hidden_recipients: {
@@ -175,6 +182,28 @@ public class EncryptTextFragment extends CachingCryptoOperationFragment<SignEncr
return true;
}
public void toggleEnableCompression(MenuItem item, final boolean compress) {
mUseCompression = compress;
item.setChecked(compress);
Notify.create(getActivity(), compress
? R.string.snack_compression_on
: R.string.snack_compression_off,
Notify.LENGTH_LONG, Style.OK, new ActionListener() {
@Override
public void onAction() {
Preferences.getPreferences(getActivity()).setTextUseCompression(compress);
Notify.create(getActivity(), compress
? R.string.snack_compression_on
: R.string.snack_compression_off,
Notify.LENGTH_SHORT, Style.OK, null, R.string.btn_saved)
.show(EncryptTextFragment.this, false);
}
}, R.string.btn_save_default).show(this);
}
protected void onEncryptSuccess(SignEncryptResult result) {
if (mShareAfterEncrypt) {
// Share encrypted message/file
@@ -323,20 +352,21 @@ public class EncryptTextFragment extends CachingCryptoOperationFragment<SignEncr
}
// Send all information needed to service to edit key in other thread
Intent intent = new Intent(getActivity(), KeychainIntentService.class);
intent.setAction(KeychainIntentService.ACTION_SIGN_ENCRYPT);
Intent intent = new Intent(getActivity(), KeychainService.class);
intent.setAction(KeychainService.ACTION_SIGN_ENCRYPT);
Bundle data = new Bundle();
data.putParcelable(KeychainIntentService.SIGN_ENCRYPT_PARCEL, actionsParcel);
data.putParcelable(KeychainIntentService.EXTRA_CRYPTO_INPUT, cryptoInput);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
data.putParcelable(KeychainService.SIGN_ENCRYPT_PARCEL, actionsParcel);
data.putParcelable(KeychainService.EXTRA_CRYPTO_INPUT, cryptoInput);
intent.putExtra(KeychainService.EXTRA_DATA, data);
// Message is received after encrypting is done in KeychainIntentService
// Message is received after encrypting is done in KeychainService
ServiceProgressHandler serviceHandler = new ServiceProgressHandler(
getActivity(),
getString(R.string.progress_encrypting),
ProgressDialog.STYLE_HORIZONTAL,
ProgressDialogFragment.ServiceType.KEYCHAIN_INTENT) {
ProgressDialog.STYLE_HORIZONTAL
) {
@Override
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
@@ -359,7 +389,7 @@ public class EncryptTextFragment extends CachingCryptoOperationFragment<SignEncr
};
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(serviceHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// show progress dialog
serviceHandler.showProgressDialog(getActivity());

View File

@@ -35,11 +35,9 @@ import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry;
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
import org.sufficientlysecure.keychain.operations.results.OperationResult;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.ui.base.BaseNfcActivity;
import org.sufficientlysecure.keychain.service.CloudImportService;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.util.Log;
@@ -383,7 +381,6 @@ public class ImportKeysActivity extends BaseNfcActivity {
* Import keys with mImportData
*/
public void importKeys() {
ImportKeysListFragment.LoaderState ls = mListFragment.getLoaderState();
if (mListFragment.getSelectedEntries().size() == 0) {
Notify.create(this, R.string.error_nothing_import_selected, Notify.Style.ERROR)
@@ -391,32 +388,33 @@ public class ImportKeysActivity extends BaseNfcActivity {
return;
}
ServiceProgressHandler serviceHandler = new ServiceProgressHandler(
this,
getString(R.string.progress_importing),
ProgressDialog.STYLE_HORIZONTAL,
true
) {
@Override
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
ImportKeysActivity.this.handleMessage(message);
}
};
// Send all information needed to service to import key in other thread
Intent intent = new Intent(this, KeychainService.class);
intent.setAction(KeychainService.ACTION_IMPORT_KEYRING);
// fill values for this action
Bundle data = new Bundle();
ImportKeysListFragment.LoaderState ls = mListFragment.getLoaderState();
if (ls instanceof ImportKeysListFragment.BytesLoaderState) {
Log.d(Constants.TAG, "importKeys started");
ServiceProgressHandler serviceHandler = new ServiceProgressHandler(
this,
getString(R.string.progress_importing),
ProgressDialog.STYLE_HORIZONTAL,
true,
ProgressDialogFragment.ServiceType.KEYCHAIN_INTENT) {
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
ImportKeysActivity.this.handleMessage(message);
}
};
// TODO: Currently not using CloudImport here due to https://github.com/open-keychain/open-keychain/issues/1221
// Send all information needed to service to import key in other thread
Intent intent = new Intent(this, KeychainIntentService.class);
intent.setAction(KeychainIntentService.ACTION_IMPORT_KEYRING);
// fill values for this action
Bundle data = new Bundle();
// get DATA from selected key entries
IteratorWithSize<ParcelableKeyRing> selectedEntries = mListFragment.getSelectedData();
@@ -430,11 +428,11 @@ public class ImportKeysActivity extends BaseNfcActivity {
new ParcelableFileCache<>(this, "key_import.pcl");
cache.writeCache(selectedEntries);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
intent.putExtra(KeychainService.EXTRA_DATA, data);
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(serviceHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// show progress dialog
serviceHandler.showProgressDialog(this);
@@ -449,27 +447,7 @@ public class ImportKeysActivity extends BaseNfcActivity {
} else if (ls instanceof ImportKeysListFragment.CloudLoaderState) {
ImportKeysListFragment.CloudLoaderState sls = (ImportKeysListFragment.CloudLoaderState) ls;
ServiceProgressHandler serviceHandler = new ServiceProgressHandler(
this,
getString(R.string.progress_importing),
ProgressDialog.STYLE_HORIZONTAL,
true,
ProgressDialogFragment.ServiceType.CLOUD_IMPORT) {
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
ImportKeysActivity.this.handleMessage(message);
}
};
// Send all information needed to service to query keys in other thread
Intent intent = new Intent(this, CloudImportService.class);
// fill values for this action
Bundle data = new Bundle();
data.putString(CloudImportService.IMPORT_KEY_SERVER, sls.mCloudPrefs.keyserver);
data.putString(KeychainService.IMPORT_KEY_SERVER, sls.mCloudPrefs.keyserver);
// get selected key entries
ArrayList<ParcelableKeyRing> keys = new ArrayList<>();
@@ -482,13 +460,13 @@ public class ImportKeysActivity extends BaseNfcActivity {
);
}
}
data.putParcelableArrayList(CloudImportService.IMPORT_KEY_LIST, keys);
data.putParcelableArrayList(KeychainService.IMPORT_KEY_LIST, keys);
intent.putExtra(CloudImportService.EXTRA_DATA, data);
intent.putExtra(KeychainService.EXTRA_DATA, data);
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(serviceHandler);
intent.putExtra(CloudImportService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// show progress dialog
serviceHandler.showProgressDialog(this);

View File

@@ -43,9 +43,8 @@ import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
import org.sufficientlysecure.keychain.operations.results.OperationResult;
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
import org.sufficientlysecure.keychain.operations.results.SingletonResult;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment;
import org.sufficientlysecure.keychain.util.IntentIntegratorSupportV4;
import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.Preferences;
@@ -206,13 +205,14 @@ public class ImportKeysProxyActivity extends FragmentActivity {
private void startImportService(ArrayList<ParcelableKeyRing> keyRings) {
// Message is received after importing is done in KeychainIntentService
// Message is received after importing is done in KeychainService
ServiceProgressHandler serviceHandler = new ServiceProgressHandler(
this,
getString(R.string.progress_importing),
ProgressDialog.STYLE_HORIZONTAL,
true,
ProgressDialogFragment.ServiceType.KEYCHAIN_INTENT) {
true
) {
@Override
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
@@ -258,19 +258,19 @@ public class ImportKeysProxyActivity extends FragmentActivity {
Preferences prefs = Preferences.getPreferences(this);
Preferences.CloudSearchPrefs cloudPrefs =
new Preferences.CloudSearchPrefs(true, true, prefs.getPreferredKeyserver());
data.putString(KeychainIntentService.IMPORT_KEY_SERVER, cloudPrefs.keyserver);
data.putString(KeychainService.IMPORT_KEY_SERVER, cloudPrefs.keyserver);
}
data.putParcelableArrayList(KeychainIntentService.IMPORT_KEY_LIST, keyRings);
data.putParcelableArrayList(KeychainService.IMPORT_KEY_LIST, keyRings);
// Send all information needed to service to query keys in other thread
Intent intent = new Intent(this, KeychainIntentService.class);
intent.setAction(KeychainIntentService.ACTION_IMPORT_KEYRING);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
Intent intent = new Intent(this, KeychainService.class);
intent.setAction(KeychainService.ACTION_IMPORT_KEYRING);
intent.putExtra(KeychainService.EXTRA_DATA, data);
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(serviceHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// show progress dialog
serviceHandler.showProgressDialog(this);

View File

@@ -64,12 +64,10 @@ import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.CloudImportService;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment;
import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.ui.adapter.KeyAdapter;
import org.sufficientlysecure.keychain.ui.util.Notify;
@@ -578,8 +576,9 @@ public class KeyListFragment extends LoaderFragment
getActivity(),
getString(R.string.progress_updating),
ProgressDialog.STYLE_HORIZONTAL,
true,
ProgressDialogFragment.ServiceType.CLOUD_IMPORT) {
true
) {
@Override
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
@@ -603,7 +602,8 @@ public class KeyListFragment extends LoaderFragment
};
// Send all information needed to service to query keys in other thread
Intent intent = new Intent(getActivity(), CloudImportService.class);
Intent intent = new Intent(getActivity(), KeychainService.class);
intent.setAction(KeychainService.ACTION_IMPORT_KEYRING);
// fill values for this action
Bundle data = new Bundle();
@@ -613,16 +613,16 @@ public class KeyListFragment extends LoaderFragment
Preferences prefs = Preferences.getPreferences(getActivity());
Preferences.CloudSearchPrefs cloudPrefs =
new Preferences.CloudSearchPrefs(true, true, prefs.getPreferredKeyserver());
data.putString(CloudImportService.IMPORT_KEY_SERVER, cloudPrefs.keyserver);
data.putString(KeychainService.IMPORT_KEY_SERVER, cloudPrefs.keyserver);
}
data.putParcelableArrayList(CloudImportService.IMPORT_KEY_LIST, keyList);
data.putParcelableArrayList(KeychainService.IMPORT_KEY_LIST, keyList);
intent.putExtra(CloudImportService.EXTRA_DATA, data);
intent.putExtra(KeychainService.EXTRA_DATA, data);
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(serviceHandler);
intent.putExtra(CloudImportService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// show progress dialog
serviceHandler.showProgressDialog(getActivity());
@@ -632,12 +632,13 @@ public class KeyListFragment extends LoaderFragment
}
private void consolidate() {
// Message is received after importing is done in KeychainIntentService
// Message is received after importing is done in KeychainService
ServiceProgressHandler saveHandler = new ServiceProgressHandler(
getActivity(),
getString(R.string.progress_importing),
ProgressDialog.STYLE_HORIZONTAL,
ProgressDialogFragment.ServiceType.KEYCHAIN_INTENT) {
ProgressDialog.STYLE_HORIZONTAL
) {
@Override
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
@@ -660,18 +661,18 @@ public class KeyListFragment extends LoaderFragment
};
// Send all information needed to service to import key in other thread
Intent intent = new Intent(getActivity(), KeychainIntentService.class);
Intent intent = new Intent(getActivity(), KeychainService.class);
intent.setAction(KeychainIntentService.ACTION_CONSOLIDATE);
intent.setAction(KeychainService.ACTION_CONSOLIDATE);
// fill values for this action
Bundle data = new Bundle();
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
intent.putExtra(KeychainService.EXTRA_DATA, data);
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// show progress dialog
saveHandler.showProgressDialog(getActivity());

View File

@@ -38,10 +38,9 @@ import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
import org.sufficientlysecure.keychain.operations.results.OperationResult;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.ui.base.BaseActivity;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment;
import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.ParcelableFileCache;
@@ -124,13 +123,14 @@ public class SafeSlingerActivity extends BaseActivity {
final FragmentActivity activity = SafeSlingerActivity.this;
// Message is received after importing is done in KeychainIntentService
// Message is received after importing is done in KeychainService
ServiceProgressHandler saveHandler = new ServiceProgressHandler(
activity,
getString(R.string.progress_importing),
ProgressDialog.STYLE_HORIZONTAL,
true,
ProgressDialogFragment.ServiceType.KEYCHAIN_INTENT) {
true
) {
@Override
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
@@ -176,9 +176,9 @@ public class SafeSlingerActivity extends BaseActivity {
Log.d(Constants.TAG, "importKeys started");
// Send all information needed to service to import key in other thread
Intent intent = new Intent(activity, KeychainIntentService.class);
Intent intent = new Intent(activity, KeychainService.class);
intent.setAction(KeychainIntentService.ACTION_IMPORT_KEYRING);
intent.setAction(KeychainService.ACTION_IMPORT_KEYRING);
// instead of giving the entries by Intent extra, cache them into a
// file to prevent Java Binder problems on heavy imports
@@ -195,11 +195,11 @@ public class SafeSlingerActivity extends BaseActivity {
// fill values for this action
Bundle bundle = new Bundle();
intent.putExtra(KeychainIntentService.EXTRA_DATA, bundle);
intent.putExtra(KeychainService.EXTRA_DATA, bundle);
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// show progress dialog
saveHandler.showProgressDialog(activity);

View File

@@ -35,10 +35,9 @@ import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.ui.base.BaseActivity;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment;
import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.Preferences;
@@ -92,9 +91,9 @@ public class UploadKeyActivity extends BaseActivity {
private void uploadKey() {
// Send all information needed to service to upload key in other thread
Intent intent = new Intent(this, KeychainIntentService.class);
Intent intent = new Intent(this, KeychainService.class);
intent.setAction(KeychainIntentService.ACTION_UPLOAD_KEYRING);
intent.setAction(KeychainService.ACTION_UPLOAD_KEYRING);
// set data uri as path to keyring
Uri blobUri = KeyRings.buildUnifiedKeyRingUri(mDataUri);
@@ -104,16 +103,17 @@ public class UploadKeyActivity extends BaseActivity {
Bundle data = new Bundle();
String server = (String) mKeyServerSpinner.getSelectedItem();
data.putString(KeychainIntentService.UPLOAD_KEY_SERVER, server);
data.putString(KeychainService.UPLOAD_KEY_SERVER, server);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
intent.putExtra(KeychainService.EXTRA_DATA, data);
// Message is received after uploading is done in KeychainIntentService
// Message is received after uploading is done in KeychainService
ServiceProgressHandler saveHandler = new ServiceProgressHandler(
this,
getString(R.string.progress_uploading),
ProgressDialog.STYLE_HORIZONTAL,
ProgressDialogFragment.ServiceType.KEYCHAIN_INTENT) {
ProgressDialog.STYLE_HORIZONTAL
) {
@Override
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
@@ -129,7 +129,7 @@ public class UploadKeyActivity extends BaseActivity {
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// show progress dialog
saveHandler.showProgressDialog(this);

View File

@@ -65,7 +65,7 @@ import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler.MessageStatus;
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
@@ -402,8 +402,9 @@ public class ViewKeyActivity extends BaseNfcActivity implements
}
private void startCertifyIntent(Intent intent) {
// Message is received after signing is done in KeychainIntentService
// Message is received after signing is done in KeychainService
ServiceProgressHandler saveHandler = new ServiceProgressHandler(this) {
@Override
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
@@ -418,7 +419,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements
};
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
startActivityForResult(intent, 0);
}
@@ -651,8 +652,9 @@ public class ViewKeyActivity extends BaseNfcActivity implements
ArrayList<ParcelableKeyRing> entries = new ArrayList<>();
entries.add(keyEntry);
// Message is received after importing is done in KeychainIntentService
// Message is received after importing is done in KeychainService
ServiceProgressHandler serviceHandler = new ServiceProgressHandler(this) {
@Override
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
@@ -682,19 +684,19 @@ public class ViewKeyActivity extends BaseNfcActivity implements
Preferences prefs = Preferences.getPreferences(this);
Preferences.CloudSearchPrefs cloudPrefs =
new Preferences.CloudSearchPrefs(true, true, prefs.getPreferredKeyserver());
data.putString(KeychainIntentService.IMPORT_KEY_SERVER, cloudPrefs.keyserver);
data.putString(KeychainService.IMPORT_KEY_SERVER, cloudPrefs.keyserver);
}
data.putParcelableArrayList(KeychainIntentService.IMPORT_KEY_LIST, entries);
data.putParcelableArrayList(KeychainService.IMPORT_KEY_LIST, entries);
// Send all information needed to service to query keys in other thread
Intent intent = new Intent(this, KeychainIntentService.class);
intent.setAction(KeychainIntentService.ACTION_IMPORT_KEYRING);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
Intent intent = new Intent(this, KeychainService.class);
intent.setAction(KeychainService.ACTION_IMPORT_KEYRING);
intent.putExtra(KeychainService.EXTRA_DATA, data);
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(serviceHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// show progress dialog
serviceHandler.showProgressDialog(this);

View File

@@ -140,12 +140,17 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
}
});
mKeyNfcButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mNfcHelper.invokeNfcBeam();
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mKeyNfcButton.setVisibility(View.VISIBLE);
mKeyNfcButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mNfcHelper.invokeNfcBeam();
}
});
} else {
mKeyNfcButton.setVisibility(View.GONE);
}
mKeySafeSlingerButton.setOnClickListener(new View.OnClickListener() {
@Override

View File

@@ -49,9 +49,8 @@ import com.textuality.keybase.lib.User;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.util.Log;
@@ -350,13 +349,13 @@ public class ViewKeyTrustFragment extends LoaderFragment implements
}
private void verify(final Proof proof, final String fingerprint) {
Intent intent = new Intent(getActivity(), KeychainIntentService.class);
Intent intent = new Intent(getActivity(), KeychainService.class);
Bundle data = new Bundle();
intent.setAction(KeychainIntentService.ACTION_VERIFY_KEYBASE_PROOF);
intent.setAction(KeychainService.ACTION_VERIFY_KEYBASE_PROOF);
data.putString(KeychainIntentService.KEYBASE_PROOF, proof.toString());
data.putString(KeychainIntentService.KEYBASE_REQUIRED_FINGERPRINT, fingerprint);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
data.putString(KeychainService.KEYBASE_PROOF, proof.toString());
data.putString(KeychainService.KEYBASE_REQUIRED_FINGERPRINT, fingerprint);
intent.putExtra(KeychainService.EXTRA_DATA, data);
mProofVerifyDetail.setVisibility(View.GONE);
@@ -365,8 +364,9 @@ public class ViewKeyTrustFragment extends LoaderFragment implements
ServiceProgressHandler handler = new ServiceProgressHandler(
getActivity(),
getString(R.string.progress_verifying_signature),
ProgressDialog.STYLE_HORIZONTAL,
ProgressDialogFragment.ServiceType.KEYCHAIN_INTENT) {
ProgressDialog.STYLE_HORIZONTAL
) {
@Override
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
@@ -451,7 +451,7 @@ public class ViewKeyTrustFragment extends LoaderFragment implements
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(handler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// show progress dialog
handler.showProgressDialog(getActivity());

View File

@@ -43,7 +43,7 @@ import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
import org.sufficientlysecure.keychain.operations.results.PromoteKeyResult;
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
@@ -129,6 +129,7 @@ public class ViewKeyYubiKeyFragment extends Fragment
public void promoteToSecretKey() {
ServiceProgressHandler saveHandler = new ServiceProgressHandler(getActivity()) {
@Override
public void handleMessage(Message message) {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
@@ -147,25 +148,25 @@ public class ViewKeyYubiKeyFragment extends Fragment
};
// Send all information needed to service to decrypt in other thread
Intent intent = new Intent(getActivity(), KeychainIntentService.class);
Intent intent = new Intent(getActivity(), KeychainService.class);
// fill values for this action
intent.setAction(KeychainIntentService.ACTION_PROMOTE_KEYRING);
intent.setAction(KeychainService.ACTION_PROMOTE_KEYRING);
Bundle data = new Bundle();
data.putLong(KeychainIntentService.PROMOTE_MASTER_KEY_ID, mMasterKeyId);
data.putByteArray(KeychainIntentService.PROMOTE_CARD_AID, mCardAid);
data.putLong(KeychainService.PROMOTE_MASTER_KEY_ID, mMasterKeyId);
data.putByteArray(KeychainService.PROMOTE_CARD_AID, mCardAid);
long[] subKeyIds = new long[mFingerprints.length];
for (int i = 0; i < subKeyIds.length; i++) {
subKeyIds[i] = KeyFormattingUtils.getKeyIdFromFingerprint(mFingerprints[i]);
}
data.putLongArray(KeychainIntentService.PROMOTE_SUBKEY_IDS, subKeyIds);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
data.putLongArray(KeychainService.PROMOTE_SUBKEY_IDS, subKeyIds);
intent.putExtra(KeychainService.EXTRA_DATA, data);
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// start service with intent
getActivity().startService(intent);

View File

@@ -109,7 +109,7 @@ public class ImportKeysListCloudLoader
ImportKeysListEntry uniqueEntry = searchResult.get(0);
/*
* set fingerprint explicitly after query
* to enforce a check when the key is imported by KeychainIntentService
* to enforce a check when the key is imported by KeychainService
*/
uniqueEntry.setFingerprintHex(fingerprint);
uniqueEntry.setSelected(true);

View File

@@ -36,7 +36,7 @@ import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainService;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.util.Log;
@@ -130,17 +130,17 @@ public class DeleteKeyDialogFragment extends DialogFragment {
public void onClick(DialogInterface dialog, int which) {
// Send all information needed to service to import key in other thread
Intent intent = new Intent(getActivity(), KeychainIntentService.class);
Intent intent = new Intent(getActivity(), KeychainService.class);
intent.setAction(KeychainIntentService.ACTION_DELETE);
intent.setAction(KeychainService.ACTION_DELETE);
// Message is received after importing is done in KeychainIntentService
// Message is received after importing is done in KeychainService
ServiceProgressHandler saveHandler = new ServiceProgressHandler(
getActivity(),
getString(R.string.progress_deleting),
ProgressDialog.STYLE_HORIZONTAL,
true,
ProgressDialogFragment.ServiceType.KEYCHAIN_INTENT) {
true
) {
@Override
public void handleMessage(Message message) {
super.handleMessage(message);
@@ -159,13 +159,13 @@ public class DeleteKeyDialogFragment extends DialogFragment {
// fill values for this action
Bundle data = new Bundle();
data.putLongArray(KeychainIntentService.DELETE_KEY_LIST, masterKeyIds);
data.putBoolean(KeychainIntentService.DELETE_IS_SECRET, hasSecret);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
data.putLongArray(KeychainService.DELETE_KEY_LIST, masterKeyIds);
data.putBoolean(KeychainService.DELETE_IS_SECRET, hasSecret);
intent.putExtra(KeychainService.EXTRA_DATA, data);
// Create a new Messenger for the communication back
Messenger messenger = new Messenger(saveHandler);
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
intent.putExtra(KeychainService.EXTRA_MESSENGER, messenger);
// show progress dialog
saveHandler.showProgressDialog(getActivity());

View File

@@ -19,7 +19,6 @@ package org.sufficientlysecure.keychain.ui.dialog;
import android.app.Activity;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnKeyListener;
@@ -27,31 +26,25 @@ import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.service.CloudImportService;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.service.KeychainService;
/**
* meant to be used
*/
public class ProgressDialogFragment extends DialogFragment {
private static final String ARG_MESSAGE = "message";
private static final String ARG_STYLE = "style";
private static final String ARG_CANCELABLE = "cancelable";
private static final String ARG_SERVICE_TYPE = "service_class";
public enum ServiceType {
KEYCHAIN_INTENT,
CLOUD_IMPORT
}
ServiceType mServiceType;
boolean mCanCancel = false, mPreventCancel = false, mIsCancelled = false;
/**
@@ -59,16 +52,14 @@ public class ProgressDialogFragment extends DialogFragment {
* @param message the message to be displayed initially above the progress bar
* @param style the progress bar style, as defined in ProgressDialog (horizontal or spinner)
* @param cancelable should we let the user cancel this operation
* @param serviceType which Service this progress dialog is meant for
* @return
*/
public static ProgressDialogFragment newInstance(String message, int style, boolean cancelable,
ServiceType serviceType) {
public static ProgressDialogFragment newInstance(String message, int style, boolean cancelable) {
ProgressDialogFragment frag = new ProgressDialogFragment();
Bundle args = new Bundle();
args.putString(ARG_MESSAGE, message);
args.putInt(ARG_STYLE, style);
args.putBoolean(ARG_CANCELABLE, cancelable);
args.putSerializable(ARG_SERVICE_TYPE, serviceType);
frag.setArguments(args);
@@ -121,7 +112,6 @@ public class ProgressDialogFragment extends DialogFragment {
String message = getArguments().getString(ARG_MESSAGE);
int style = getArguments().getInt(ARG_STYLE);
mCanCancel = getArguments().getBoolean(ARG_CANCELABLE);
mServiceType = (ServiceType) getArguments().getSerializable(ARG_SERVICE_TYPE);
dialog.setMessage(message);
dialog.setProgressStyle(style);
@@ -189,23 +179,11 @@ public class ProgressDialogFragment extends DialogFragment {
negative.setTextColor(Color.GRAY);
// send a cancel message. note that this message will be handled by
// KeychainIntentService.onStartCommand, which runs in this thread,
// KeychainService.onStartCommand, which runs in this thread,
// not the service one, and will not queue up a command.
Intent serviceIntent = null;
Intent serviceIntent = new Intent(getActivity(), KeychainService.class);
switch (mServiceType) {
case CLOUD_IMPORT:
serviceIntent = new Intent(getActivity(), CloudImportService.class);
break;
case KEYCHAIN_INTENT:
serviceIntent = new Intent(getActivity(), KeychainIntentService.class);
break;
default:
//should never happen, unless we forget to include a ServiceType enum case
Log.e(Constants.TAG, "Unrecognized ServiceType at ProgressDialogFragment");
}
serviceIntent.setAction(KeychainIntentService.ACTION_CANCEL);
serviceIntent.setAction(KeychainService.ACTION_CANCEL);
getActivity().startService(serviceIntent);
// Set the progress bar accordingly

View File

@@ -62,9 +62,10 @@ public class Notify {
public static final int LENGTH_INDEFINITE = 0;
public static final int LENGTH_LONG = 3500;
public static final int LENGTH_SHORT = 1500;
public static Showable create(final Activity activity, String text, int duration, Style style,
final ActionListener actionListener, int actionResId) {
final ActionListener actionListener, Integer actionResId) {
final Snackbar snackbar = Snackbar.with(activity)
.type(SnackbarType.MULTI_LINE)
.text(text);
@@ -77,14 +78,16 @@ public class Notify {
style.applyToBar(snackbar);
if (actionResId != null) {
snackbar.actionLabel(actionResId);
}
if (actionListener != null) {
snackbar.actionLabel(actionResId)
.actionListener(new ActionClickListener() {
@Override
public void onActionClicked(Snackbar snackbar) {
actionListener.onAction();
}
});
snackbar.actionListener(new ActionClickListener() {
@Override
public void onActionClicked(Snackbar snackbar) {
actionListener.onAction();
}
});
}
if (activity instanceof FabContainer) {
@@ -107,6 +110,13 @@ public class Notify {
SnackbarManager.show(snackbar, activity);
}
@Override
public void show(Fragment fragment, boolean animate) {
snackbar.animation(animate);
snackbar.dismissOnActionClicked(animate);
show(fragment);
}
@Override
public void show(Fragment fragment) {
if (fragment != null) {
@@ -134,7 +144,7 @@ public class Notify {
}
public static Showable create(Activity activity, String text, int duration, Style style) {
return create(activity, text, duration, style, null, -1);
return create(activity, text, duration, style, null, null);
}
public static Showable create(Activity activity, String text, Style style) {
@@ -159,24 +169,26 @@ public class Notify {
/**
* Shows the notification on the bottom of the Activity.
*/
public void show();
void show();
void show(Fragment fragment, boolean animate);
/**
* Shows the notification on the bottom of the Fragment.
*/
public void show(Fragment fragment);
void show(Fragment fragment);
/**
* Shows the notification on the given ViewGroup.
* The viewGroup should be either a RelativeLayout or FrameLayout.
*/
public void show(ViewGroup viewGroup);
void show(ViewGroup viewGroup);
}
public interface ActionListener {
public void onAction();
void onAction();
}