mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-17 07:30:14 -05:00
simplified use of progressdialog with apgservice
This commit is contained in:
parent
23ce0e37fd
commit
68301ee918
@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.thialfihar.android.apg.service;
|
||||
|
||||
import org.thialfihar.android.apg.R;
|
||||
import org.thialfihar.android.apg.ui.dialog.ProgressDialogFragment;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class ApgHandler extends Handler {
|
||||
|
||||
// possible messages send from this service to handler on ui
|
||||
public static final int MESSAGE_OKAY = 1;
|
||||
public static final int MESSAGE_EXCEPTION = 2;
|
||||
public static final int MESSAGE_UPDATE_PROGRESS = 3;
|
||||
|
||||
// possible data keys for messages
|
||||
public static final String DATA_ERROR = "error";
|
||||
public static final String DATA_PROGRESS = "progress";
|
||||
public static final String DATA_PROGRESS_MAX = "max";
|
||||
public static final String DATA_MESSAGE = "message";
|
||||
public static final String DATA_MESSAGE_ID = "message_id";
|
||||
|
||||
Activity mActivity;
|
||||
ProgressDialogFragment mProgressDialogFragment;
|
||||
|
||||
public ApgHandler(Activity activity) {
|
||||
this.mActivity = activity;
|
||||
}
|
||||
|
||||
public ApgHandler(Activity activity, ProgressDialogFragment progressDialogFragment) {
|
||||
this.mActivity = activity;
|
||||
this.mProgressDialogFragment = progressDialogFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message message) {
|
||||
Bundle data = message.getData();
|
||||
|
||||
switch (message.arg1) {
|
||||
case MESSAGE_OKAY:
|
||||
mProgressDialogFragment.dismiss();
|
||||
|
||||
break;
|
||||
|
||||
case MESSAGE_EXCEPTION:
|
||||
mProgressDialogFragment.dismiss();
|
||||
|
||||
// show error from service
|
||||
if (data.containsKey(DATA_ERROR)) {
|
||||
Toast.makeText(mActivity,
|
||||
mActivity.getString(R.string.errorMessage, data.getString(DATA_ERROR)),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case MESSAGE_UPDATE_PROGRESS:
|
||||
if (data.containsKey(DATA_PROGRESS) && data.containsKey(DATA_PROGRESS_MAX)) {
|
||||
|
||||
// update progress from service
|
||||
if (data.containsKey(DATA_MESSAGE)) {
|
||||
mProgressDialogFragment.setProgress(data.getString(DATA_MESSAGE),
|
||||
data.getInt(DATA_PROGRESS), data.getInt(DATA_PROGRESS_MAX));
|
||||
} else if (data.containsKey(DATA_MESSAGE_ID)) {
|
||||
mProgressDialogFragment.setProgress(data.getInt(DATA_MESSAGE_ID),
|
||||
data.getInt(DATA_PROGRESS), data.getInt(DATA_PROGRESS_MAX));
|
||||
} else {
|
||||
mProgressDialogFragment.setProgress(data.getInt(DATA_PROGRESS),
|
||||
data.getInt(DATA_PROGRESS_MAX));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -368,7 +368,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
||||
|
||||
OtherHelper.logDebugBundle(resultData, "resultData");
|
||||
|
||||
sendMessageToHandler(ApgHandler.MESSAGE_OKAY, resultData);
|
||||
sendMessageToHandler(ApgServiceHandler.MESSAGE_OKAY, resultData);
|
||||
} catch (Exception e) {
|
||||
sendErrorToHandler(e);
|
||||
}
|
||||
@ -501,7 +501,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
||||
|
||||
OtherHelper.logDebugBundle(resultData, "resultData");
|
||||
|
||||
sendMessageToHandler(ApgHandler.MESSAGE_OKAY, resultData);
|
||||
sendMessageToHandler(ApgServiceHandler.MESSAGE_OKAY, resultData);
|
||||
} catch (Exception e) {
|
||||
sendErrorToHandler(e);
|
||||
}
|
||||
@ -532,7 +532,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
||||
PGPMain.setCachedPassPhrase(masterKeyId, newPassPhrase);
|
||||
|
||||
/* Output */
|
||||
sendMessageToHandler(ApgHandler.MESSAGE_OKAY);
|
||||
sendMessageToHandler(ApgServiceHandler.MESSAGE_OKAY);
|
||||
} catch (Exception e) {
|
||||
sendErrorToHandler(e);
|
||||
}
|
||||
@ -563,7 +563,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
||||
|
||||
OtherHelper.logDebugBundle(resultData, "resultData");
|
||||
|
||||
sendMessageToHandler(ApgHandler.MESSAGE_OKAY, resultData);
|
||||
sendMessageToHandler(ApgServiceHandler.MESSAGE_OKAY, resultData);
|
||||
} catch (Exception e) {
|
||||
sendErrorToHandler(e);
|
||||
}
|
||||
@ -592,7 +592,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
||||
|
||||
OtherHelper.logDebugBundle(resultData, "resultData");
|
||||
|
||||
sendMessageToHandler(ApgHandler.MESSAGE_OKAY, resultData);
|
||||
sendMessageToHandler(ApgServiceHandler.MESSAGE_OKAY, resultData);
|
||||
} catch (Exception e) {
|
||||
sendErrorToHandler(e);
|
||||
}
|
||||
@ -616,7 +616,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
||||
}
|
||||
|
||||
/* Output */
|
||||
sendMessageToHandler(ApgHandler.MESSAGE_OKAY);
|
||||
sendMessageToHandler(ApgServiceHandler.MESSAGE_OKAY);
|
||||
} catch (Exception e) {
|
||||
sendErrorToHandler(e);
|
||||
}
|
||||
@ -666,7 +666,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
||||
Bundle resultData = new Bundle();
|
||||
resultData = PGPMain.importKeyRings(this, keyType, inputData, this);
|
||||
|
||||
sendMessageToHandler(ApgHandler.MESSAGE_OKAY, resultData);
|
||||
sendMessageToHandler(ApgServiceHandler.MESSAGE_OKAY, resultData);
|
||||
} catch (Exception e) {
|
||||
sendErrorToHandler(e);
|
||||
}
|
||||
@ -714,7 +714,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
||||
Bundle resultData = new Bundle();
|
||||
resultData = PGPMain.exportKeyRings(this, keyRingIds, outStream, this);
|
||||
|
||||
sendMessageToHandler(ApgHandler.MESSAGE_OKAY, resultData);
|
||||
sendMessageToHandler(ApgServiceHandler.MESSAGE_OKAY, resultData);
|
||||
} catch (Exception e) {
|
||||
sendErrorToHandler(e);
|
||||
}
|
||||
@ -744,7 +744,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
||||
}
|
||||
}
|
||||
|
||||
sendMessageToHandler(ApgHandler.MESSAGE_OKAY);
|
||||
sendMessageToHandler(ApgServiceHandler.MESSAGE_OKAY);
|
||||
} catch (Exception e) {
|
||||
sendErrorToHandler(e);
|
||||
}
|
||||
@ -777,7 +777,7 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
||||
resultData.putString(RESULT_QUERY_KEY_KEY_DATA, keyData);
|
||||
}
|
||||
|
||||
sendMessageToHandler(ApgHandler.MESSAGE_OKAY, resultData);
|
||||
sendMessageToHandler(ApgServiceHandler.MESSAGE_OKAY, resultData);
|
||||
} catch (Exception e) {
|
||||
sendErrorToHandler(e);
|
||||
}
|
||||
@ -795,8 +795,8 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
||||
e.printStackTrace();
|
||||
|
||||
Bundle data = new Bundle();
|
||||
data.putString(ApgHandler.DATA_ERROR, e.getMessage());
|
||||
sendMessageToHandler(ApgHandler.MESSAGE_EXCEPTION, null, data);
|
||||
data.putString(ApgServiceHandler.DATA_ERROR, e.getMessage());
|
||||
sendMessageToHandler(ApgServiceHandler.MESSAGE_EXCEPTION, null, data);
|
||||
}
|
||||
|
||||
private void sendMessageToHandler(Integer arg1, Integer arg2, Bundle data) {
|
||||
@ -835,12 +835,12 @@ public class ApgService extends IntentService implements ProgressDialogUpdater {
|
||||
|
||||
Bundle data = new Bundle();
|
||||
if (message != null) {
|
||||
data.putString(ApgHandler.DATA_MESSAGE, message);
|
||||
data.putString(ApgServiceHandler.DATA_MESSAGE, message);
|
||||
}
|
||||
data.putInt(ApgHandler.DATA_PROGRESS, progress);
|
||||
data.putInt(ApgHandler.DATA_PROGRESS_MAX, max);
|
||||
data.putInt(ApgServiceHandler.DATA_PROGRESS, progress);
|
||||
data.putInt(ApgServiceHandler.DATA_PROGRESS_MAX, max);
|
||||
|
||||
sendMessageToHandler(ApgHandler.MESSAGE_UPDATE_PROGRESS, null, data);
|
||||
sendMessageToHandler(ApgServiceHandler.MESSAGE_UPDATE_PROGRESS, null, data);
|
||||
}
|
||||
|
||||
public void setProgress(int resourceId, int progress, int max) {
|
||||
|
@ -22,7 +22,7 @@ import org.thialfihar.android.apg.Id;
|
||||
import org.thialfihar.android.apg.helper.FileHelper;
|
||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||
import org.thialfihar.android.apg.helper.PGPMain;
|
||||
import org.thialfihar.android.apg.service.ApgHandler;
|
||||
import org.thialfihar.android.apg.service.ApgServiceHandler;
|
||||
import org.thialfihar.android.apg.service.ApgService;
|
||||
import org.thialfihar.android.apg.ui.dialog.DeleteFileDialogFragment;
|
||||
import org.thialfihar.android.apg.ui.dialog.FileDialogFragment;
|
||||
@ -124,7 +124,6 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
|
||||
private long mSecretKeyId = Id.key.none;
|
||||
|
||||
private ProgressDialogFragment mDecryptingDialog;
|
||||
private FileDialogFragment mFileDialog;
|
||||
|
||||
private boolean mLookupUnknownKey = true;
|
||||
@ -734,17 +733,14 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
|
||||
intent.putExtra(ApgService.EXTRA_DATA, data);
|
||||
|
||||
// create progress dialog
|
||||
mDecryptingDialog = ProgressDialogFragment.newInstance(R.string.progress_decrypting,
|
||||
ProgressDialog.STYLE_HORIZONTAL);
|
||||
|
||||
// Message is received after encrypting is done in ApgService
|
||||
ApgHandler saveHandler = new ApgHandler(this, mDecryptingDialog) {
|
||||
ApgServiceHandler saveHandler = new ApgServiceHandler(this, R.string.progress_decrypting,
|
||||
ProgressDialog.STYLE_HORIZONTAL) {
|
||||
public void handleMessage(Message message) {
|
||||
// handle messages by standard ApgHandler first
|
||||
super.handleMessage(message);
|
||||
|
||||
if (message.arg1 == ApgHandler.MESSAGE_OKAY) {
|
||||
if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
|
||||
// get returned data bundle
|
||||
Bundle returnData = message.getData();
|
||||
|
||||
@ -837,7 +833,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
|
||||
|
||||
// show progress dialog
|
||||
mDecryptingDialog.show(getSupportFragmentManager(), "decryptingDialog");
|
||||
saveHandler.showProgressDialog(this);
|
||||
|
||||
// start service with intent
|
||||
startService(intent);
|
||||
|
@ -24,7 +24,7 @@ import org.thialfihar.android.apg.Id;
|
||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||
import org.thialfihar.android.apg.helper.PGPMain;
|
||||
import org.thialfihar.android.apg.helper.PGPConversionHelper;
|
||||
import org.thialfihar.android.apg.service.ApgHandler;
|
||||
import org.thialfihar.android.apg.service.ApgServiceHandler;
|
||||
import org.thialfihar.android.apg.service.ApgService;
|
||||
import org.thialfihar.android.apg.ui.dialog.ProgressDialogFragment;
|
||||
import org.thialfihar.android.apg.ui.dialog.SetPassphraseDialogFragment;
|
||||
@ -88,9 +88,6 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
||||
|
||||
private CheckBox mNoPassphrase;
|
||||
|
||||
private ProgressDialogFragment mSavingDialog;
|
||||
private ProgressDialogFragment mGeneratingDialog;
|
||||
|
||||
Vector<String> mUserIds;
|
||||
Vector<PGPSecretKey> mKeys;
|
||||
Vector<Integer> mKeysUsages;
|
||||
@ -204,17 +201,14 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
||||
|
||||
intent.putExtra(ApgService.EXTRA_DATA, data);
|
||||
|
||||
// show progress dialog
|
||||
mGeneratingDialog = ProgressDialogFragment.newInstance(
|
||||
R.string.progress_generating, ProgressDialog.STYLE_SPINNER);
|
||||
|
||||
// Message is received after generating is done in ApgService
|
||||
ApgHandler saveHandler = new ApgHandler(this, mGeneratingDialog) {
|
||||
ApgServiceHandler saveHandler = new ApgServiceHandler(this,
|
||||
R.string.progress_generating, ProgressDialog.STYLE_SPINNER) {
|
||||
public void handleMessage(Message message) {
|
||||
// handle messages by standard ApgHandler first
|
||||
super.handleMessage(message);
|
||||
|
||||
if (message.arg1 == ApgHandler.MESSAGE_OKAY) {
|
||||
if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
|
||||
// get new key from data bundle returned from service
|
||||
Bundle data = message.getData();
|
||||
PGPSecretKeyRing masterKeyRing = PGPConversionHelper
|
||||
@ -246,7 +240,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
||||
Messenger messenger = new Messenger(saveHandler);
|
||||
intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
|
||||
|
||||
mGeneratingDialog.show(getSupportFragmentManager(), "dialog");
|
||||
saveHandler.showProgressDialog(this);
|
||||
|
||||
// start service with intent
|
||||
startService(intent);
|
||||
@ -420,17 +414,14 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
||||
|
||||
intent.putExtra(ApgService.EXTRA_DATA, data);
|
||||
|
||||
// show progress dialog
|
||||
mSavingDialog = ProgressDialogFragment.newInstance(R.string.progress_saving,
|
||||
ProgressDialog.STYLE_HORIZONTAL);
|
||||
|
||||
// Message is received after saving is done in ApgService
|
||||
ApgHandler saveHandler = new ApgHandler(this, mSavingDialog) {
|
||||
ApgServiceHandler saveHandler = new ApgServiceHandler(this, R.string.progress_saving,
|
||||
ProgressDialog.STYLE_HORIZONTAL) {
|
||||
public void handleMessage(Message message) {
|
||||
// handle messages by standard ApgHandler first
|
||||
super.handleMessage(message);
|
||||
|
||||
if (message.arg1 == ApgHandler.MESSAGE_OKAY) {
|
||||
if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
@ -440,7 +431,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
||||
Messenger messenger = new Messenger(saveHandler);
|
||||
intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
|
||||
|
||||
mSavingDialog.show(getSupportFragmentManager(), "savingDialog");
|
||||
saveHandler.showProgressDialog(this);
|
||||
|
||||
// start service with intent
|
||||
startService(intent);
|
||||
|
@ -27,12 +27,11 @@ import org.thialfihar.android.apg.helper.FileHelper;
|
||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||
import org.thialfihar.android.apg.helper.PGPMain;
|
||||
import org.thialfihar.android.apg.helper.Preferences;
|
||||
import org.thialfihar.android.apg.service.ApgHandler;
|
||||
import org.thialfihar.android.apg.service.ApgServiceHandler;
|
||||
import org.thialfihar.android.apg.service.ApgService;
|
||||
import org.thialfihar.android.apg.ui.dialog.DeleteFileDialogFragment;
|
||||
import org.thialfihar.android.apg.ui.dialog.FileDialogFragment;
|
||||
import org.thialfihar.android.apg.ui.dialog.PassphraseDialogFragment;
|
||||
import org.thialfihar.android.apg.ui.dialog.ProgressDialogFragment;
|
||||
import org.thialfihar.android.apg.util.Choice;
|
||||
import org.thialfihar.android.apg.util.Compatibility;
|
||||
import org.thialfihar.android.apg.R;
|
||||
@ -138,7 +137,6 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
|
||||
private long mSecretKeyId = Id.key.none;
|
||||
|
||||
private ProgressDialogFragment mEncryptingDialog;
|
||||
private FileDialogFragment mFileDialog;
|
||||
|
||||
public void setSecretKeyId(long id) {
|
||||
@ -819,17 +817,14 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
|
||||
intent.putExtra(ApgService.EXTRA_DATA, data);
|
||||
|
||||
// create progress dialog
|
||||
mEncryptingDialog = ProgressDialogFragment.newInstance(R.string.progress_encrypting,
|
||||
ProgressDialog.STYLE_HORIZONTAL);
|
||||
|
||||
// Message is received after encrypting is done in ApgService
|
||||
ApgHandler saveHandler = new ApgHandler(this, mEncryptingDialog) {
|
||||
ApgServiceHandler saveHandler = new ApgServiceHandler(this, R.string.progress_encrypting,
|
||||
ProgressDialog.STYLE_HORIZONTAL) {
|
||||
public void handleMessage(Message message) {
|
||||
// handle messages by standard ApgHandler first
|
||||
super.handleMessage(message);
|
||||
|
||||
if (message.arg1 == ApgHandler.MESSAGE_OKAY) {
|
||||
if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
|
||||
// get returned data bundle
|
||||
Bundle data = message.getData();
|
||||
|
||||
@ -895,7 +890,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
|
||||
|
||||
// show progress dialog
|
||||
mEncryptingDialog.show(getSupportFragmentManager(), "encryptingDialog");
|
||||
saveHandler.showProgressDialog(this);
|
||||
|
||||
// start service with intent
|
||||
startService(intent);
|
||||
|
@ -19,9 +19,8 @@ package org.thialfihar.android.apg.ui;
|
||||
|
||||
import org.thialfihar.android.apg.Constants;
|
||||
import org.thialfihar.android.apg.Id;
|
||||
import org.thialfihar.android.apg.service.ApgHandler;
|
||||
import org.thialfihar.android.apg.service.ApgServiceHandler;
|
||||
import org.thialfihar.android.apg.service.ApgService;
|
||||
import org.thialfihar.android.apg.ui.dialog.ProgressDialogFragment;
|
||||
import org.thialfihar.android.apg.R;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
@ -181,17 +180,14 @@ public class ImportFromQRCodeActivity extends SherlockFragmentActivity {
|
||||
|
||||
intent.putExtra(ApgService.EXTRA_DATA, data);
|
||||
|
||||
// create progress dialog
|
||||
ProgressDialogFragment importingDialog = ProgressDialogFragment.newInstance(
|
||||
R.string.progress_importing, ProgressDialog.STYLE_HORIZONTAL);
|
||||
|
||||
// Message is received after importing is done in ApgService
|
||||
ApgHandler saveHandler = new ApgHandler(this, importingDialog) {
|
||||
ApgServiceHandler saveHandler = new ApgServiceHandler(this,
|
||||
R.string.progress_importing, ProgressDialog.STYLE_HORIZONTAL) {
|
||||
public void handleMessage(Message message) {
|
||||
// handle messages by standard ApgHandler first
|
||||
super.handleMessage(message);
|
||||
|
||||
if (message.arg1 == ApgHandler.MESSAGE_OKAY) {
|
||||
if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
|
||||
// get returned data bundle
|
||||
Bundle returnData = message.getData();
|
||||
|
||||
@ -237,7 +233,7 @@ public class ImportFromQRCodeActivity extends SherlockFragmentActivity {
|
||||
intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
|
||||
|
||||
// show progress dialog
|
||||
importingDialog.show(getSupportFragmentManager(), "importingDialog");
|
||||
saveHandler.showProgressDialog(this);
|
||||
|
||||
// start service with intent
|
||||
startService(intent);
|
||||
|
@ -24,12 +24,11 @@ import org.thialfihar.android.apg.helper.PGPMain;
|
||||
import org.thialfihar.android.apg.provider.KeyRings;
|
||||
import org.thialfihar.android.apg.provider.Keys;
|
||||
import org.thialfihar.android.apg.provider.UserIds;
|
||||
import org.thialfihar.android.apg.service.ApgHandler;
|
||||
import org.thialfihar.android.apg.service.ApgServiceHandler;
|
||||
import org.thialfihar.android.apg.service.ApgService;
|
||||
import org.thialfihar.android.apg.ui.dialog.DeleteFileDialogFragment;
|
||||
import org.thialfihar.android.apg.ui.dialog.DeleteKeyDialogFragment;
|
||||
import org.thialfihar.android.apg.ui.dialog.FileDialogFragment;
|
||||
import org.thialfihar.android.apg.ui.dialog.ProgressDialogFragment;
|
||||
import org.thialfihar.android.apg.R;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
@ -299,17 +298,14 @@ public class KeyListActivity extends SherlockFragmentActivity {
|
||||
|
||||
intent.putExtra(ApgService.EXTRA_DATA, data);
|
||||
|
||||
// create progress dialog
|
||||
ProgressDialogFragment importingDialog = ProgressDialogFragment.newInstance(
|
||||
R.string.progress_importing, ProgressDialog.STYLE_HORIZONTAL);
|
||||
|
||||
// Message is received after importing is done in ApgService
|
||||
ApgHandler saveHandler = new ApgHandler(this, importingDialog) {
|
||||
ApgServiceHandler saveHandler = new ApgServiceHandler(this, R.string.progress_importing,
|
||||
ProgressDialog.STYLE_HORIZONTAL) {
|
||||
public void handleMessage(Message message) {
|
||||
// handle messages by standard ApgHandler first
|
||||
super.handleMessage(message);
|
||||
|
||||
if (message.arg1 == ApgHandler.MESSAGE_OKAY) {
|
||||
if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
|
||||
// get returned data bundle
|
||||
Bundle returnData = message.getData();
|
||||
|
||||
@ -360,7 +356,7 @@ public class KeyListActivity extends SherlockFragmentActivity {
|
||||
intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
|
||||
|
||||
// show progress dialog
|
||||
importingDialog.show(getSupportFragmentManager(), "importingDialog");
|
||||
saveHandler.showProgressDialog(this);
|
||||
|
||||
// start service with intent
|
||||
startService(intent);
|
||||
@ -390,17 +386,14 @@ public class KeyListActivity extends SherlockFragmentActivity {
|
||||
|
||||
intent.putExtra(ApgService.EXTRA_DATA, data);
|
||||
|
||||
// create progress dialog
|
||||
ProgressDialogFragment exportingDialog = ProgressDialogFragment.newInstance(
|
||||
R.string.progress_exporting, ProgressDialog.STYLE_HORIZONTAL);
|
||||
|
||||
// Message is received after exporting is done in ApgService
|
||||
ApgHandler exportHandler = new ApgHandler(this, exportingDialog) {
|
||||
ApgServiceHandler exportHandler = new ApgServiceHandler(this, R.string.progress_exporting,
|
||||
ProgressDialog.STYLE_HORIZONTAL) {
|
||||
public void handleMessage(Message message) {
|
||||
// handle messages by standard ApgHandler first
|
||||
super.handleMessage(message);
|
||||
|
||||
if (message.arg1 == ApgHandler.MESSAGE_OKAY) {
|
||||
if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
|
||||
// get returned data bundle
|
||||
Bundle returnData = message.getData();
|
||||
|
||||
@ -424,7 +417,7 @@ public class KeyListActivity extends SherlockFragmentActivity {
|
||||
intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
|
||||
|
||||
// show progress dialog
|
||||
exportingDialog.show(getSupportFragmentManager(), "exportingDialog");
|
||||
exportHandler.showProgressDialog(this);
|
||||
|
||||
// start service with intent
|
||||
startService(intent);
|
||||
|
@ -22,9 +22,8 @@ import org.thialfihar.android.apg.Constants;
|
||||
import org.thialfihar.android.apg.Id;
|
||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||
import org.thialfihar.android.apg.helper.Preferences;
|
||||
import org.thialfihar.android.apg.service.ApgHandler;
|
||||
import org.thialfihar.android.apg.service.ApgServiceHandler;
|
||||
import org.thialfihar.android.apg.service.ApgService;
|
||||
import org.thialfihar.android.apg.ui.dialog.ProgressDialogFragment;
|
||||
import org.thialfihar.android.apg.util.Log;
|
||||
import org.thialfihar.android.apg.util.KeyServer.KeyInfo;
|
||||
|
||||
@ -185,17 +184,14 @@ public class KeyServerQueryActivity extends SherlockFragmentActivity {
|
||||
|
||||
intent.putExtra(ApgService.EXTRA_DATA, data);
|
||||
|
||||
// create progress dialog
|
||||
ProgressDialogFragment queryingDialog = ProgressDialogFragment.newInstance(
|
||||
R.string.progress_querying, ProgressDialog.STYLE_SPINNER);
|
||||
|
||||
// Message is received after querying is done in ApgService
|
||||
ApgHandler saveHandler = new ApgHandler(this, queryingDialog) {
|
||||
ApgServiceHandler saveHandler = new ApgServiceHandler(this, R.string.progress_querying,
|
||||
ProgressDialog.STYLE_SPINNER) {
|
||||
public void handleMessage(Message message) {
|
||||
// handle messages by standard ApgHandler first
|
||||
super.handleMessage(message);
|
||||
|
||||
if (message.arg1 == ApgHandler.MESSAGE_OKAY) {
|
||||
if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
|
||||
// get returned data bundle
|
||||
Bundle returnData = message.getData();
|
||||
|
||||
@ -245,7 +241,7 @@ public class KeyServerQueryActivity extends SherlockFragmentActivity {
|
||||
intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
|
||||
|
||||
// show progress dialog
|
||||
queryingDialog.show(getSupportFragmentManager(), "queryingDialog");
|
||||
saveHandler.showProgressDialog(this);
|
||||
|
||||
// start service with intent
|
||||
startService(intent);
|
||||
|
@ -20,9 +20,8 @@ package org.thialfihar.android.apg.ui;
|
||||
import org.thialfihar.android.apg.Constants;
|
||||
import org.thialfihar.android.apg.R;
|
||||
import org.thialfihar.android.apg.helper.Preferences;
|
||||
import org.thialfihar.android.apg.service.ApgHandler;
|
||||
import org.thialfihar.android.apg.service.ApgServiceHandler;
|
||||
import org.thialfihar.android.apg.service.ApgService;
|
||||
import org.thialfihar.android.apg.ui.dialog.ProgressDialogFragment;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
@ -118,17 +117,14 @@ public class KeyServerUploadActivity extends SherlockFragmentActivity {
|
||||
|
||||
intent.putExtra(ApgService.EXTRA_DATA, data);
|
||||
|
||||
// create progress dialog
|
||||
ProgressDialogFragment uploadingDialog = ProgressDialogFragment.newInstance(
|
||||
R.string.progress_importing, ProgressDialog.STYLE_HORIZONTAL);
|
||||
|
||||
// Message is received after uploading is done in ApgService
|
||||
ApgHandler saveHandler = new ApgHandler(this, uploadingDialog) {
|
||||
ApgServiceHandler saveHandler = new ApgServiceHandler(this, R.string.progress_importing,
|
||||
ProgressDialog.STYLE_HORIZONTAL) {
|
||||
public void handleMessage(Message message) {
|
||||
// handle messages by standard ApgHandler first
|
||||
super.handleMessage(message);
|
||||
|
||||
if (message.arg1 == ApgHandler.MESSAGE_OKAY) {
|
||||
if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
|
||||
|
||||
Toast.makeText(KeyServerUploadActivity.this, R.string.keySendSuccess,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
@ -142,7 +138,7 @@ public class KeyServerUploadActivity extends SherlockFragmentActivity {
|
||||
intent.putExtra(ApgService.EXTRA_MESSENGER, messenger);
|
||||
|
||||
// show progress dialog
|
||||
uploadingDialog.show(getSupportFragmentManager(), "uploadingDialog");
|
||||
saveHandler.showProgressDialog(this);
|
||||
|
||||
// start service with intent
|
||||
startService(intent);
|
||||
|
@ -17,7 +17,7 @@
|
||||
package org.thialfihar.android.apg.ui.dialog;
|
||||
|
||||
import org.thialfihar.android.apg.R;
|
||||
import org.thialfihar.android.apg.service.ApgHandler;
|
||||
import org.thialfihar.android.apg.service.ApgServiceHandler;
|
||||
import org.thialfihar.android.apg.service.ApgService;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
@ -83,12 +83,12 @@ public class DeleteFileDialogFragment extends DialogFragment {
|
||||
R.string.progress_deletingSecurely, ProgressDialog.STYLE_HORIZONTAL);
|
||||
|
||||
// Message is received after deleting is done in ApgService
|
||||
ApgHandler saveHandler = new ApgHandler(activity, deletingDialog) {
|
||||
ApgServiceHandler saveHandler = new ApgServiceHandler(activity, deletingDialog) {
|
||||
public void handleMessage(Message message) {
|
||||
// handle messages by standard ApgHandler first
|
||||
super.handleMessage(message);
|
||||
|
||||
if (message.arg1 == ApgHandler.MESSAGE_OKAY) {
|
||||
if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
|
||||
Toast.makeText(activity, R.string.fileDeleteSuccessful,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.thialfihar.android.apg.Id;
|
||||
import org.thialfihar.android.apg.helper.PGPMain;
|
||||
import org.thialfihar.android.apg.helper.PGPConversionHelper;
|
||||
import org.thialfihar.android.apg.service.ApgHandler;
|
||||
import org.thialfihar.android.apg.service.ApgServiceHandler;
|
||||
import org.thialfihar.android.apg.service.ApgService;
|
||||
import org.thialfihar.android.apg.ui.dialog.ProgressDialogFragment;
|
||||
import org.thialfihar.android.apg.ui.widget.Editor.EditorListener;
|
||||
@ -277,12 +277,12 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
ProgressDialog.STYLE_SPINNER);
|
||||
|
||||
// Message is received after generating is done in ApgService
|
||||
ApgHandler saveHandler = new ApgHandler(mActivity, mGeneratingDialog) {
|
||||
ApgServiceHandler saveHandler = new ApgServiceHandler(mActivity, mGeneratingDialog) {
|
||||
public void handleMessage(Message message) {
|
||||
// handle messages by standard ApgHandler first
|
||||
super.handleMessage(message);
|
||||
|
||||
if (message.arg1 == ApgHandler.MESSAGE_OKAY) {
|
||||
if (message.arg1 == ApgServiceHandler.MESSAGE_OKAY) {
|
||||
// get new key from data bundle returned from service
|
||||
Bundle data = message.getData();
|
||||
PGPSecretKeyRing newKeyRing = PGPConversionHelper.BytesToPGPSecretKeyRing(data
|
||||
|
Loading…
Reference in New Issue
Block a user