major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 Thialfihar <thi@thialfihar.org>
|
|
|
|
*
|
|
|
|
* 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;
|
|
|
|
|
2010-05-04 11:56:55 -04:00
|
|
|
import java.io.File;
|
|
|
|
|
2010-04-28 19:35:11 -04:00
|
|
|
import org.bouncycastle2.bcpg.HashAlgorithmTags;
|
|
|
|
import org.bouncycastle2.openpgp.PGPEncryptedData;
|
|
|
|
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
import android.app.Activity;
|
|
|
|
import android.app.AlertDialog;
|
|
|
|
import android.app.Dialog;
|
|
|
|
import android.app.ProgressDialog;
|
2010-05-15 12:09:49 -04:00
|
|
|
import android.content.Context;
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.Intent;
|
2010-04-28 19:35:11 -04:00
|
|
|
import android.content.SharedPreferences;
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
import android.os.Bundle;
|
2010-05-25 20:33:26 -04:00
|
|
|
import android.os.Environment;
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
import android.os.Handler;
|
|
|
|
import android.os.Message;
|
2010-05-15 12:09:49 -04:00
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.View;
|
|
|
|
import android.widget.TextView;
|
2010-05-04 11:56:55 -04:00
|
|
|
import android.widget.Toast;
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
|
|
|
|
public class BaseActivity extends Activity
|
|
|
|
implements Runnable, ProgressDialogUpdater,
|
|
|
|
AskForSecretKeyPassPhrase.PassPhraseCallbackInterface {
|
|
|
|
|
|
|
|
private ProgressDialog mProgressDialog = null;
|
|
|
|
private Thread mRunningThread = null;
|
|
|
|
|
|
|
|
private long mSecretKeyId = 0;
|
2010-05-04 11:56:55 -04:00
|
|
|
private String mDeleteFile = null;
|
2010-04-28 19:35:11 -04:00
|
|
|
protected static SharedPreferences mPreferences = null;
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
|
|
|
|
private Handler mHandler = new Handler() {
|
|
|
|
@Override
|
|
|
|
public void handleMessage(Message msg) {
|
|
|
|
handlerCallback(msg);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
2010-05-26 11:25:14 -04:00
|
|
|
Apg.initialize(this);
|
|
|
|
|
2010-04-28 19:35:11 -04:00
|
|
|
if (mPreferences == null) {
|
|
|
|
mPreferences = getPreferences(MODE_PRIVATE);
|
|
|
|
}
|
2010-05-25 20:33:26 -04:00
|
|
|
|
|
|
|
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
|
|
|
File dir = new File(Constants.path.app_dir);
|
|
|
|
if (!dir.exists() && !dir.mkdirs()) {
|
|
|
|
// ignore this for now, it's not crucial
|
|
|
|
// that the directory doesn't exist at this point
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-03 12:17:55 -04:00
|
|
|
Intent intent = new Intent(this, Service.class);
|
|
|
|
intent.putExtra(Service.EXTRA_TTL, getPassPhraseCacheTtl());
|
|
|
|
startService(intent);
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
}
|
|
|
|
|
2010-05-15 12:09:49 -04:00
|
|
|
@Override
|
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
|
menu.add(0, Id.menu.option.preferences, 0, R.string.menu_preferences)
|
|
|
|
.setIcon(android.R.drawable.ic_menu_preferences);
|
|
|
|
menu.add(0, Id.menu.option.about, 1, R.string.menu_about)
|
|
|
|
.setIcon(android.R.drawable.ic_menu_info_details);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
case Id.menu.option.about: {
|
|
|
|
showDialog(Id.dialog.about);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Id.menu.option.preferences: {
|
|
|
|
startActivity(new Intent(this, PreferencesActivity.class));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-06-05 18:44:47 -04:00
|
|
|
case Id.menu.option.search: {
|
|
|
|
startSearch("", false, null, false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-15 12:09:49 -04:00
|
|
|
default: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
@Override
|
|
|
|
protected Dialog onCreateDialog(int id) {
|
|
|
|
// in case it is a progress dialog
|
|
|
|
mProgressDialog = new ProgressDialog(this);
|
|
|
|
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
|
|
|
mProgressDialog.setCancelable(false);
|
|
|
|
switch (id) {
|
|
|
|
case Id.dialog.encrypting: {
|
2010-05-13 16:41:32 -04:00
|
|
|
mProgressDialog.setMessage(this.getString(R.string.progress_initializing));
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
return mProgressDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Id.dialog.decrypting: {
|
2010-05-13 16:41:32 -04:00
|
|
|
mProgressDialog.setMessage(this.getString(R.string.progress_initializing));
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
return mProgressDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Id.dialog.saving: {
|
2010-05-13 16:41:32 -04:00
|
|
|
mProgressDialog.setMessage(this.getString(R.string.progress_saving));
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
return mProgressDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Id.dialog.importing: {
|
2010-05-13 16:41:32 -04:00
|
|
|
mProgressDialog.setMessage(this.getString(R.string.progress_importing));
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
return mProgressDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Id.dialog.exporting: {
|
2010-05-13 16:41:32 -04:00
|
|
|
mProgressDialog.setMessage(this.getString(R.string.progress_exporting));
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
return mProgressDialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
default: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mProgressDialog = null;
|
|
|
|
|
|
|
|
switch (id) {
|
2010-05-15 12:09:49 -04:00
|
|
|
case Id.dialog.about: {
|
|
|
|
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
|
|
|
|
2010-06-08 09:46:21 -04:00
|
|
|
alert.setTitle("About " + Apg.getFullVersion(this));
|
2010-05-15 12:09:49 -04:00
|
|
|
|
|
|
|
LayoutInflater inflater =
|
|
|
|
(LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
View layout = inflater.inflate(R.layout.info, null);
|
|
|
|
TextView message = (TextView) layout.findViewById(R.id.message);
|
|
|
|
message.setText("This is an attempt to bring OpenPGP to Android. " +
|
|
|
|
"It is far from complete, but more features are planned (see website).\n\n" +
|
|
|
|
"Feel free to send bug reports, suggestions, feature requests, feedback, " +
|
|
|
|
"photographs.\n\n" +
|
|
|
|
"mail: thi@thialfihar.org\n" +
|
|
|
|
"site: http://apg.thialfihar.org\n\n" +
|
|
|
|
"This software is provided \"as is\", without warranty of any kind.");
|
|
|
|
alert.setView(layout);
|
|
|
|
|
|
|
|
alert.setPositiveButton(android.R.string.ok,
|
|
|
|
new DialogInterface.OnClickListener() {
|
|
|
|
public void onClick(DialogInterface dialog, int id) {
|
|
|
|
BaseActivity.this.removeDialog(Id.dialog.about);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return alert.create();
|
|
|
|
}
|
|
|
|
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
case Id.dialog.pass_phrase: {
|
|
|
|
return AskForSecretKeyPassPhrase.createDialog(this, getSecretKeyId(), this);
|
|
|
|
}
|
|
|
|
|
|
|
|
case Id.dialog.pass_phrases_do_not_match: {
|
|
|
|
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
|
|
|
|
|
|
|
alert.setIcon(android.R.drawable.ic_dialog_alert);
|
2010-05-13 16:41:32 -04:00
|
|
|
alert.setTitle(R.string.error);
|
|
|
|
alert.setMessage(R.string.passPhrasesDoNotMatch);
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
|
|
|
|
alert.setPositiveButton(android.R.string.ok,
|
|
|
|
new DialogInterface.OnClickListener() {
|
|
|
|
public void onClick(DialogInterface dialog, int id) {
|
|
|
|
removeDialog(Id.dialog.pass_phrases_do_not_match);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
alert.setCancelable(false);
|
|
|
|
|
|
|
|
return alert.create();
|
|
|
|
}
|
|
|
|
|
|
|
|
case Id.dialog.no_pass_phrase: {
|
|
|
|
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
|
|
|
|
|
|
|
alert.setIcon(android.R.drawable.ic_dialog_alert);
|
2010-05-13 16:41:32 -04:00
|
|
|
alert.setTitle(R.string.error);
|
|
|
|
alert.setMessage(R.string.passPhraseMustNotBeEmpty);
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
|
|
|
|
alert.setPositiveButton(android.R.string.ok,
|
|
|
|
new DialogInterface.OnClickListener() {
|
|
|
|
public void onClick(DialogInterface dialog, int id) {
|
|
|
|
removeDialog(Id.dialog.no_pass_phrase);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
alert.setCancelable(false);
|
|
|
|
|
|
|
|
return alert.create();
|
|
|
|
}
|
|
|
|
|
2010-05-04 11:56:55 -04:00
|
|
|
case Id.dialog.delete_file: {
|
|
|
|
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
|
|
|
|
|
|
|
alert.setIcon(android.R.drawable.ic_dialog_alert);
|
2010-05-13 16:41:32 -04:00
|
|
|
alert.setTitle(R.string.warning);
|
|
|
|
alert.setMessage(this.getString(R.string.fileDeleteConfirmation, getDeleteFile()));
|
2010-05-04 11:56:55 -04:00
|
|
|
|
|
|
|
alert.setPositiveButton(android.R.string.ok,
|
2010-05-13 16:41:32 -04:00
|
|
|
new DialogInterface.OnClickListener() {
|
|
|
|
public void onClick(DialogInterface dialog, int id) {
|
|
|
|
removeDialog(Id.dialog.delete_file);
|
|
|
|
File file = new File(getDeleteFile());
|
|
|
|
String msg = "";
|
|
|
|
if (file.delete()) {
|
|
|
|
msg = BaseActivity.this.getString(
|
|
|
|
R.string.fileDeleteSuccessful);
|
|
|
|
} else {
|
|
|
|
msg = BaseActivity.this.getString(
|
|
|
|
R.string.errorMessage,
|
|
|
|
BaseActivity.this.getString(
|
|
|
|
R.string.error_fileDeleteFailed, file));
|
|
|
|
}
|
|
|
|
Toast.makeText(BaseActivity.this,
|
|
|
|
msg, Toast.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
});
|
2010-05-04 11:56:55 -04:00
|
|
|
alert.setNegativeButton(android.R.string.cancel,
|
|
|
|
new DialogInterface.OnClickListener() {
|
|
|
|
public void onClick(DialogInterface dialog, int id) {
|
|
|
|
removeDialog(Id.dialog.delete_file);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
alert.setCancelable(true);
|
|
|
|
|
|
|
|
return alert.create();
|
|
|
|
}
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
|
|
|
|
default: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return super.onCreateDialog(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
switch (requestCode) {
|
2010-04-19 09:56:43 -04:00
|
|
|
case Id.request.secret_keys: {
|
|
|
|
if (resultCode == RESULT_OK) {
|
|
|
|
Bundle bundle = data.getExtras();
|
2010-05-31 19:15:20 -04:00
|
|
|
setSecretKeyId(bundle.getLong(Apg.EXTRA_KEY_ID));
|
2010-04-19 09:56:43 -04:00
|
|
|
} else {
|
2010-05-15 11:19:56 -04:00
|
|
|
setSecretKeyId(Id.key.none);
|
2010-04-19 09:56:43 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
default: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
}
|
|
|
|
|
2010-05-13 18:47:19 -04:00
|
|
|
public void setProgress(int resourceId, int progress, int max) {
|
|
|
|
setProgress(getString(resourceId), progress, max);
|
|
|
|
}
|
|
|
|
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
public void setProgress(int progress, int max) {
|
|
|
|
Message msg = new Message();
|
|
|
|
Bundle data = new Bundle();
|
2010-05-31 19:15:20 -04:00
|
|
|
data.putInt(Apg.EXTRA_STATUS, Id.message.progress_update);
|
|
|
|
data.putInt(Apg.EXTRA_PROGRESS, progress);
|
|
|
|
data.putInt(Apg.EXTRA_MAX, max);
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
msg.setData(data);
|
|
|
|
mHandler.sendMessage(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setProgress(String message, int progress, int max) {
|
|
|
|
Message msg = new Message();
|
|
|
|
Bundle data = new Bundle();
|
2010-05-31 19:15:20 -04:00
|
|
|
data.putInt(Apg.EXTRA_STATUS, Id.message.progress_update);
|
|
|
|
data.putString(Apg.EXTRA_MESSAGE, message);
|
|
|
|
data.putInt(Apg.EXTRA_PROGRESS, progress);
|
|
|
|
data.putInt(Apg.EXTRA_MAX, max);
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
msg.setData(data);
|
|
|
|
mHandler.sendMessage(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void handlerCallback(Message msg) {
|
|
|
|
Bundle data = msg.getData();
|
|
|
|
if (data == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-05-31 19:15:20 -04:00
|
|
|
int type = data.getInt(Apg.EXTRA_STATUS);
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
switch (type) {
|
|
|
|
case Id.message.progress_update: {
|
2010-05-31 19:15:20 -04:00
|
|
|
String message = data.getString(Apg.EXTRA_MESSAGE);
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
if (mProgressDialog != null) {
|
|
|
|
if (message != null) {
|
|
|
|
mProgressDialog.setMessage(message);
|
|
|
|
}
|
2010-05-31 19:15:20 -04:00
|
|
|
mProgressDialog.setMax(data.getInt(Apg.EXTRA_MAX));
|
|
|
|
mProgressDialog.setProgress(data.getInt(Apg.EXTRA_PROGRESS));
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case Id.message.import_done: // intentionall no break
|
|
|
|
case Id.message.export_done: // intentionall no break
|
|
|
|
case Id.message.done: {
|
|
|
|
mProgressDialog = null;
|
|
|
|
doneCallback(msg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void doneCallback(Message msg) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-05-15 11:19:56 -04:00
|
|
|
public void passPhraseCallback(long keyId, String passPhrase) {
|
|
|
|
Apg.setCachedPassPhrase(keyId, passPhrase);
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public void sendMessage(Message msg) {
|
|
|
|
mHandler.sendMessage(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void startThread() {
|
|
|
|
mRunningThread = new Thread(this);
|
|
|
|
mRunningThread.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSecretKeyId(long id) {
|
|
|
|
mSecretKeyId = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getSecretKeyId() {
|
|
|
|
return mSecretKeyId;
|
|
|
|
}
|
2010-04-28 19:35:11 -04:00
|
|
|
|
2010-05-16 09:17:45 -04:00
|
|
|
public int getPassPhraseCacheTtl() {
|
2010-06-03 12:24:04 -04:00
|
|
|
int ttl = mPreferences.getInt(Constants.pref.pass_phrase_cache_ttl, 180);
|
|
|
|
// fix the value if it was set to "never" in previous versions, which currently is not
|
|
|
|
// supported
|
|
|
|
if (ttl == 0) {
|
|
|
|
ttl = 180;
|
|
|
|
setPassPhraseCacheTtl(ttl);
|
|
|
|
}
|
|
|
|
return ttl;
|
2010-05-15 12:09:49 -04:00
|
|
|
}
|
|
|
|
|
2010-05-16 09:17:45 -04:00
|
|
|
public void setPassPhraseCacheTtl(int value) {
|
2010-05-15 12:09:49 -04:00
|
|
|
SharedPreferences.Editor editor = mPreferences.edit();
|
2010-05-16 09:17:45 -04:00
|
|
|
editor.putInt(Constants.pref.pass_phrase_cache_ttl, value);
|
2010-05-15 12:09:49 -04:00
|
|
|
editor.commit();
|
2010-05-16 09:17:45 -04:00
|
|
|
|
2010-06-03 12:17:55 -04:00
|
|
|
Intent intent = new Intent(this, Service.class);
|
2010-06-03 12:24:04 -04:00
|
|
|
intent.putExtra(Service.EXTRA_TTL, value);
|
2010-06-03 12:17:55 -04:00
|
|
|
startService(intent);
|
2010-05-15 12:09:49 -04:00
|
|
|
}
|
|
|
|
|
2010-04-28 19:35:11 -04:00
|
|
|
public int getDefaultEncryptionAlgorithm() {
|
|
|
|
return mPreferences.getInt(Constants.pref.default_encryption_algorithm,
|
|
|
|
PGPEncryptedData.AES_256);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDefaultEncryptionAlgorithm(int value) {
|
|
|
|
SharedPreferences.Editor editor = mPreferences.edit();
|
|
|
|
editor.putInt(Constants.pref.default_encryption_algorithm, value);
|
|
|
|
editor.commit();
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getDefaultHashAlgorithm() {
|
|
|
|
return mPreferences.getInt(Constants.pref.default_hash_algorithm,
|
|
|
|
HashAlgorithmTags.SHA256);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDefaultHashAlgorithm(int value) {
|
|
|
|
SharedPreferences.Editor editor = mPreferences.edit();
|
|
|
|
editor.putInt(Constants.pref.default_hash_algorithm, value);
|
|
|
|
editor.commit();
|
|
|
|
}
|
|
|
|
|
2010-05-16 10:20:17 -04:00
|
|
|
public int getDefaultMessageCompression() {
|
|
|
|
return mPreferences.getInt(Constants.pref.default_message_compression,
|
2010-05-19 10:38:06 -04:00
|
|
|
Id.choice.compression.zlib);
|
2010-05-16 10:20:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setDefaultMessageCompression(int value) {
|
|
|
|
SharedPreferences.Editor editor = mPreferences.edit();
|
|
|
|
editor.putInt(Constants.pref.default_message_compression, value);
|
|
|
|
editor.commit();
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getDefaultFileCompression() {
|
|
|
|
return mPreferences.getInt(Constants.pref.default_file_compression,
|
2010-05-19 10:38:06 -04:00
|
|
|
Id.choice.compression.none);
|
2010-05-16 10:20:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setDefaultFileCompression(int value) {
|
|
|
|
SharedPreferences.Editor editor = mPreferences.edit();
|
|
|
|
editor.putInt(Constants.pref.default_file_compression, value);
|
|
|
|
editor.commit();
|
|
|
|
}
|
|
|
|
|
2010-04-28 19:35:11 -04:00
|
|
|
public boolean getDefaultAsciiArmour() {
|
|
|
|
return mPreferences.getBoolean(Constants.pref.default_ascii_armour, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDefaultAsciiArmour(boolean value) {
|
|
|
|
SharedPreferences.Editor editor = mPreferences.edit();
|
|
|
|
editor.putBoolean(Constants.pref.default_ascii_armour, value);
|
|
|
|
editor.commit();
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasSeenChangeLog() {
|
2010-06-08 09:46:21 -04:00
|
|
|
return mPreferences.getBoolean(Constants.pref.has_seen_change_log + Apg.getVersion(this),
|
|
|
|
false);
|
2010-04-28 19:35:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setHasSeenChangeLog(boolean value) {
|
|
|
|
SharedPreferences.Editor editor = mPreferences.edit();
|
2010-06-08 09:46:21 -04:00
|
|
|
editor.putBoolean(Constants.pref.has_seen_change_log + Apg.getVersion(this), value);
|
2010-04-28 19:35:11 -04:00
|
|
|
editor.commit();
|
|
|
|
}
|
2010-05-04 11:56:55 -04:00
|
|
|
|
|
|
|
protected void setDeleteFile(String deleteFile) {
|
|
|
|
mDeleteFile = deleteFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected String getDeleteFile() {
|
|
|
|
return mDeleteFile;
|
|
|
|
}
|
major restructuring, moving dialog, message, menu, option menu, task, type IDs into Id in a similar structure as the generated R, also introducing a BaseActivity class that almost all activities derive from, which generates some common dialogs, handles the progress update, thread management, and thread communication
also adding first draft of encrypt file activity, not very functional yet
2010-04-18 22:12:13 -04:00
|
|
|
}
|