mirror of
https://github.com/moparisthebest/k-9
synced 2024-08-13 17:03:48 -04:00
astyle
This commit is contained in:
parent
107408c0d9
commit
32b5afc702
@ -139,8 +139,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProgress(boolean progress)
|
public void setProgress(boolean progress) {
|
||||||
{
|
|
||||||
mHandler.progress(progress);
|
mHandler.progress(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,8 +241,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNewIntent(Intent intent)
|
public void onNewIntent(Intent intent) {
|
||||||
{
|
|
||||||
Uri uri = intent.getData();
|
Uri uri = intent.getData();
|
||||||
Log.i(K9.LOG_TAG, "Accounts Activity got uri " + uri);
|
Log.i(K9.LOG_TAG, "Accounts Activity got uri " + uri);
|
||||||
if (uri != null) {
|
if (uri != null) {
|
||||||
@ -783,8 +781,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onImport()
|
private void onImport() {
|
||||||
{
|
|
||||||
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
|
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
i.addCategory(Intent.CATEGORY_OPENABLE);
|
i.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
i.setType("*/*");
|
i.setType("*/*");
|
||||||
@ -792,66 +789,52 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
{
|
|
||||||
Log.i(K9.LOG_TAG, "onActivityResult requestCode = " + requestCode + ", resultCode = " + resultCode + ", data = " + data);
|
Log.i(K9.LOG_TAG, "onActivityResult requestCode = " + requestCode + ", resultCode = " + resultCode + ", data = " + data);
|
||||||
if (resultCode != RESULT_OK)
|
if (resultCode != RESULT_OK)
|
||||||
return;
|
return;
|
||||||
if (data == null)
|
if (data == null) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (requestCode)
|
switch (requestCode) {
|
||||||
{
|
case ACTIVITY_REQUEST_PICK_SETTINGS_FILE:
|
||||||
case ACTIVITY_REQUEST_PICK_SETTINGS_FILE:
|
onImport(data.getData());
|
||||||
onImport(data.getData());
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onImport(Uri uri)
|
private void onImport(Uri uri) {
|
||||||
{
|
|
||||||
Log.i(K9.LOG_TAG, "onImport importing from URI " + uri.getPath());
|
Log.i(K9.LOG_TAG, "onImport importing from URI " + uri.getPath());
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
final String fileName = uri.getPath();
|
final String fileName = uri.getPath();
|
||||||
ContentResolver resolver = getContentResolver();
|
ContentResolver resolver = getContentResolver();
|
||||||
final InputStream is = resolver.openInputStream(uri);
|
final InputStream is = resolver.openInputStream(uri);
|
||||||
|
|
||||||
PasswordEntryDialog dialog = new PasswordEntryDialog(this, getString(R.string.settings_encryption_password_prompt),
|
PasswordEntryDialog dialog = new PasswordEntryDialog(this, getString(R.string.settings_encryption_password_prompt),
|
||||||
new PasswordEntryDialog.PasswordEntryListener()
|
new PasswordEntryDialog.PasswordEntryListener() {
|
||||||
{
|
public void passwordChosen(String chosenPassword) {
|
||||||
public void passwordChosen(String chosenPassword)
|
String toastText = Accounts.this.getString(R.string.settings_importing);
|
||||||
{
|
|
||||||
String toastText = Accounts.this.getString(R.string.settings_importing );
|
|
||||||
Toast toast = Toast.makeText(Accounts.this.getApplication(), toastText, Toast.LENGTH_SHORT);
|
Toast toast = Toast.makeText(Accounts.this.getApplication(), toastText, Toast.LENGTH_SHORT);
|
||||||
toast.show();
|
toast.show();
|
||||||
mHandler.progress(true);
|
mHandler.progress(true);
|
||||||
AsyncUIProcessor.getInstance(Accounts.this.getApplication()).importSettings(is, chosenPassword, new ImportListener()
|
AsyncUIProcessor.getInstance(Accounts.this.getApplication()).importSettings(is, chosenPassword, new ImportListener() {
|
||||||
{
|
public void failure(final String message, Exception e) {
|
||||||
public void failure(final String message, Exception e)
|
Accounts.this.runOnUiThread(new Runnable() {
|
||||||
{
|
public void run() {
|
||||||
Accounts.this.runOnUiThread(new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
mHandler.progress(false);
|
mHandler.progress(false);
|
||||||
showDialog(Accounts.this, R.string.settings_import_failed_header, Accounts.this.getString(R.string.settings_import_failure, fileName, message));
|
showDialog(Accounts.this, R.string.settings_import_failed_header, Accounts.this.getString(R.string.settings_import_failure, fileName, message));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void importSuccess(final int numAccounts)
|
public void importSuccess(final int numAccounts) {
|
||||||
{
|
Accounts.this.runOnUiThread(new Runnable() {
|
||||||
Accounts.this.runOnUiThread(new Runnable()
|
public void run() {
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
mHandler.progress(false);
|
mHandler.progress(false);
|
||||||
String messageText =
|
String messageText =
|
||||||
numAccounts != 1
|
numAccounts != 1
|
||||||
? Accounts.this.getString(R.string.settings_import_success_multiple, numAccounts, fileName )
|
? Accounts.this.getString(R.string.settings_import_success_multiple, numAccounts, fileName)
|
||||||
: Accounts.this.getString(R.string.settings_import_success_single, fileName );
|
: Accounts.this.getString(R.string.settings_import_success_single, fileName);
|
||||||
showDialog(Accounts.this, R.string.settings_import_success_header, messageText);
|
showDialog(Accounts.this, R.string.settings_import_success_header, messageText);
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
@ -860,22 +843,18 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancel()
|
public void cancel() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
} catch (FileNotFoundException fnfe) {
|
||||||
catch (FileNotFoundException fnfe)
|
String toastText = Accounts.this.getString(R.string.settings_import_failure, uri.getPath(), fnfe.getMessage());
|
||||||
{
|
|
||||||
String toastText = Accounts.this.getString(R.string.settings_import_failure, uri.getPath(), fnfe.getMessage() );
|
|
||||||
Toast toast = Toast.makeText(Accounts.this.getApplication(), toastText, 1);
|
Toast toast = Toast.makeText(Accounts.this.getApplication(), toastText, 1);
|
||||||
toast.show();
|
toast.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void showDialog(final Activity activity, int headerRes, String message)
|
private static void showDialog(final Activity activity, int headerRes, String message) {
|
||||||
{
|
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
builder.setTitle(headerRes);
|
builder.setTitle(headerRes);
|
||||||
builder.setMessage(message);
|
builder.setMessage(message);
|
||||||
|
@ -37,8 +37,7 @@ public class ActivityListener extends MessagingListener {
|
|||||||
String displayName = mLoadingFolderName;
|
String displayName = mLoadingFolderName;
|
||||||
if (K9.INBOX.equalsIgnoreCase(displayName)) {
|
if (K9.INBOX.equalsIgnoreCase(displayName)) {
|
||||||
displayName = context.getString(R.string.special_mailbox_name_inbox);
|
displayName = context.getString(R.string.special_mailbox_name_inbox);
|
||||||
}
|
} else if ((mAccount != null) && mAccount.getOutboxFolderName().equals(displayName)) {
|
||||||
else if ((mAccount != null) && mAccount.getOutboxFolderName().equals(displayName)) {
|
|
||||||
displayName = context.getString(R.string.special_mailbox_name_outbox);
|
displayName = context.getString(R.string.special_mailbox_name_outbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,8 +48,7 @@ public class ExportHelper {
|
|||||||
});
|
});
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
private static void showDialog(final Activity activity, int headerRes, String message)
|
private static void showDialog(final Activity activity, int headerRes, String message) {
|
||||||
{
|
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
builder.setTitle(headerRes);
|
builder.setTitle(headerRes);
|
||||||
builder.setMessage(message);
|
builder.setMessage(message);
|
||||||
|
@ -151,8 +151,7 @@ public class FolderList extends K9ListActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProgress(boolean progress)
|
public void setProgress(boolean progress) {
|
||||||
{
|
|
||||||
mHandler.progress(progress);
|
mHandler.progress(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,8 +519,7 @@ public class MessageList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProgress(boolean progress)
|
public void setProgress(boolean progress) {
|
||||||
{
|
|
||||||
mHandler.progress(progress);
|
mHandler.progress(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -943,13 +943,13 @@ public class MessageView extends K9Activity implements OnClickListener {
|
|||||||
@Override
|
@Override
|
||||||
protected Dialog onCreateDialog(final int id) {
|
protected Dialog onCreateDialog(final int id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case R.id.dialog_confirm_delete:
|
case R.id.dialog_confirm_delete:
|
||||||
return createConfirmDeleteDialog(id);
|
return createConfirmDeleteDialog(id);
|
||||||
case R.id.dialog_attachment_progress:
|
case R.id.dialog_attachment_progress:
|
||||||
ProgressDialog d = new ProgressDialog(this);
|
ProgressDialog d = new ProgressDialog(this);
|
||||||
d.setIndeterminate(true);
|
d.setIndeterminate(true);
|
||||||
d.setTitle(R.string.dialog_attachment_progress_title);
|
d.setTitle(R.string.dialog_attachment_progress_title);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
return super.onCreateDialog(id);
|
return super.onCreateDialog(id);
|
||||||
}
|
}
|
||||||
|
@ -853,12 +853,10 @@ public class AccountSettings extends K9PreferenceActivity {
|
|||||||
|
|
||||||
// TODO: In the future the call above should be changed to only return remote folders.
|
// TODO: In the future the call above should be changed to only return remote folders.
|
||||||
// For now we just remove the Outbox folder if present.
|
// For now we just remove the Outbox folder if present.
|
||||||
Iterator<? extends Folder> iter = folders.iterator();
|
Iterator <? extends Folder > iter = folders.iterator();
|
||||||
while (iter.hasNext())
|
while (iter.hasNext()) {
|
||||||
{
|
|
||||||
Folder folder = iter.next();
|
Folder folder = iter.next();
|
||||||
if (mAccount.getOutboxFolderName().equals(folder.getName()))
|
if (mAccount.getOutboxFolderName().equals(folder.getName())) {
|
||||||
{
|
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ public class EncoderUtil {
|
|||||||
int encodedLength = bEncodedLength(bytes);
|
int encodedLength = bEncodedLength(bytes);
|
||||||
|
|
||||||
int totalLength = prefix.length() + encodedLength
|
int totalLength = prefix.length() + encodedLength
|
||||||
+ ENC_WORD_SUFFIX.length();
|
+ ENC_WORD_SUFFIX.length();
|
||||||
if (totalLength <= ENCODED_WORD_MAX_LENGTH) {
|
if (totalLength <= ENCODED_WORD_MAX_LENGTH) {
|
||||||
return prefix + org.apache.james.mime4j.codec.EncoderUtil.encodeB(bytes) + ENC_WORD_SUFFIX;
|
return prefix + org.apache.james.mime4j.codec.EncoderUtil.encodeB(bytes) + ENC_WORD_SUFFIX;
|
||||||
} else {
|
} else {
|
||||||
@ -111,7 +111,7 @@ public class EncoderUtil {
|
|||||||
int encodedLength = qEncodedLength(bytes);
|
int encodedLength = qEncodedLength(bytes);
|
||||||
|
|
||||||
int totalLength = prefix.length() + encodedLength
|
int totalLength = prefix.length() + encodedLength
|
||||||
+ ENC_WORD_SUFFIX.length();
|
+ ENC_WORD_SUFFIX.length();
|
||||||
if (totalLength <= ENCODED_WORD_MAX_LENGTH) {
|
if (totalLength <= ENCODED_WORD_MAX_LENGTH) {
|
||||||
return prefix + org.apache.james.mime4j.codec.EncoderUtil.encodeQ(bytes, org.apache.james.mime4j.codec.EncoderUtil.Usage.WORD_ENTITY) + ENC_WORD_SUFFIX;
|
return prefix + org.apache.james.mime4j.codec.EncoderUtil.encodeQ(bytes, org.apache.james.mime4j.codec.EncoderUtil.Usage.WORD_ENTITY) + ENC_WORD_SUFFIX;
|
||||||
} else {
|
} else {
|
||||||
|
@ -142,8 +142,7 @@ public class MimeHeader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCharset(String charset)
|
public void setCharset(String charset) {
|
||||||
{
|
|
||||||
mCharset = charset;
|
mCharset = charset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,21 +14,18 @@ import javax.crypto.spec.SecretKeySpec;
|
|||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
|
||||||
public class K9Krypto
|
public class K9Krypto {
|
||||||
{
|
|
||||||
final Base64 mBase64;
|
final Base64 mBase64;
|
||||||
final Cipher mCipher;
|
final Cipher mCipher;
|
||||||
|
|
||||||
private final static String AES = "AES";
|
private final static String AES = "AES";
|
||||||
private final static String SECURE_RANDOM_TYPE = "SHA1PRNG";
|
private final static String SECURE_RANDOM_TYPE = "SHA1PRNG";
|
||||||
|
|
||||||
public enum MODE
|
public enum MODE {
|
||||||
{
|
|
||||||
ENCRYPT(Cipher.ENCRYPT_MODE), DECRYPT(Cipher.DECRYPT_MODE);
|
ENCRYPT(Cipher.ENCRYPT_MODE), DECRYPT(Cipher.DECRYPT_MODE);
|
||||||
|
|
||||||
int mode;
|
int mode;
|
||||||
private MODE(int nMode)
|
private MODE(int nMode) {
|
||||||
{
|
|
||||||
mode = nMode;
|
mode = nMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,8 +53,7 @@ public class K9Krypto
|
|||||||
return new String(plainText);
|
return new String(plainText);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Cipher setupCipher(int mode, byte[] processedKey) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException
|
private Cipher setupCipher(int mode, byte[] processedKey) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException {
|
||||||
{
|
|
||||||
SecretKeySpec secretKeySpec = new SecretKeySpec(processedKey, AES);
|
SecretKeySpec secretKeySpec = new SecretKeySpec(processedKey, AES);
|
||||||
Cipher cipher = Cipher.getInstance(AES);
|
Cipher cipher = Cipher.getInstance(AES);
|
||||||
cipher.init(mode, secretKeySpec);
|
cipher.init(mode, secretKeySpec);
|
||||||
|
Loading…
Reference in New Issue
Block a user