return some more results

This commit is contained in:
Dominik Schürmann 2014-08-20 20:08:51 +02:00
parent 0e152d1db0
commit 47bcc6149e
6 changed files with 40 additions and 34 deletions

View File

@ -317,7 +317,7 @@ public class CertifyKeyActivity extends ActionBarActivity implements LoaderManag
OperationResultParcel result = new OperationResultParcel(OperationResultParcel.RESULT_OK, null);
Intent intent = new Intent();
intent.putExtra(OperationResults.ImportKeyResult.EXTRA_RESULT, result);
intent.putExtra(OperationResultParcel.EXTRA_RESULT, result);
CertifyKeyActivity.this.setResult(RESULT_OK, intent);
CertifyKeyActivity.this.finish();
@ -376,7 +376,7 @@ public class CertifyKeyActivity extends ActionBarActivity implements LoaderManag
OperationResultParcel result = new OperationResultParcel(OperationResultParcel.RESULT_OK, null);
Intent intent = new Intent();
intent.putExtra(OperationResults.ImportKeyResult.EXTRA_RESULT, result);
intent.putExtra(OperationResultParcel.EXTRA_RESULT, result);
CertifyKeyActivity.this.setResult(RESULT_OK, intent);
CertifyKeyActivity.this.finish();
}

View File

@ -33,6 +33,7 @@ import android.widget.TextView;
import org.spongycastle.bcpg.PublicKeyAlgorithmTags;
import org.spongycastle.bcpg.sig.KeyFlags;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.helper.Preferences;
import org.sufficientlysecure.keychain.pgp.KeyRing;
@ -42,6 +43,7 @@ import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
import org.sufficientlysecure.keychain.service.OperationResultParcel;
import org.sufficientlysecure.keychain.service.OperationResults;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.Notify;
public class CreateKeyFinalFragment extends Fragment {
@ -142,23 +144,18 @@ public class CreateKeyFinalFragment extends Fragment {
final OperationResults.SaveKeyringResult result =
returnData.getParcelable(OperationResultParcel.EXTRA_RESULT);
if (result == null) {
Log.e(Constants.TAG, "result == null");
return;
}
if (result.getResult() == OperationResultParcel.RESULT_OK) {
if (mUploadCheckbox.isChecked()) {
// result will be displayed after upload
uploadKey(result);
} else {
// TODO: return result
result.createNotify(getActivity());
getActivity().setResult(Activity.RESULT_OK);
getActivity().finish();
}
if (mUploadCheckbox.isChecked()) {
// result will be displayed after upload
uploadKey(result);
} else {
// display result on error without finishing activity
result.createNotify(getActivity());
Intent data = new Intent();
data.putExtra(OperationResultParcel.EXTRA_RESULT, result);
getActivity().setResult(Activity.RESULT_OK, data);
getActivity().finish();
}
}
}
@ -217,20 +214,16 @@ public class CreateKeyFinalFragment extends Fragment {
super.handleMessage(message);
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
// TODO: not supported by upload?
// if (result.getResult() == OperationResultParcel.RESULT_OK) {
// TODO: return result
editKeyResult.createNotify(getActivity());
// TODO: upload operation needs a result!
// TODO: then combine these results
//if (result.getResult() == OperationResultParcel.RESULT_OK) {
//Notify.showNotify(getActivity(), R.string.key_send_success,
//Notify.Style.INFO);
Notify.showNotify(getActivity(), R.string.key_send_success,
Notify.Style.INFO);
getActivity().setResult(Activity.RESULT_OK);
Intent data = new Intent();
data.putExtra(OperationResultParcel.EXTRA_RESULT, editKeyResult);
getActivity().setResult(Activity.RESULT_OK, data);
getActivity().finish();
// } else {
// // display result on error without finishing activity
// editKeyResult.createNotify(getActivity());
// }
}
}
};

View File

@ -51,7 +51,7 @@ public class FirstTimeActivity extends ActionBarActivity {
mSkipSetup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finishSetup();
finishSetup(null);
}
});
@ -80,18 +80,20 @@ public class FirstTimeActivity extends ActionBarActivity {
if (requestCode == REQUEST_CODE_CREATE_OR_IMPORT_KEY) {
if (resultCode == RESULT_OK) {
finishSetup();
finishSetup(data);
}
} else {
Log.e(Constants.TAG, "No valid request code!");
}
}
private void finishSetup() {
private void finishSetup(Intent srcData) {
Preferences prefs = Preferences.getPreferences(this);
prefs.setFirstTime(false);
Intent intent = new Intent(FirstTimeActivity.this, KeyListActivity.class);
startActivity(intent);
Intent intent = new Intent(this, KeyListActivity.class);
// give intent through to display notify
intent.putExtras(srcData);
startActivityForResult(intent, 0);
finish();
}
}

View File

@ -145,7 +145,7 @@ public class KeyListActivity extends DrawerActivity {
private void createKey() {
Intent intent = new Intent(this, CreateKeyActivity.class);
startActivity(intent);
startActivityForResult(intent, 0);
}
private void consolidate() {
@ -197,4 +197,15 @@ public class KeyListActivity extends DrawerActivity {
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// if a result has been returned, display a notify
if (data != null && data.hasExtra(OperationResultParcel.EXTRA_RESULT)) {
OperationResultParcel result = data.getParcelableExtra(OperationResultParcel.EXTRA_RESULT);
result.createNotify(this).show();
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
}

View File

@ -179,7 +179,6 @@ public class LogDisplayFragment extends ListFragment implements OnTouchListener
(Integer) entry.mParameters[0],
entry.mParameters));
} else {
Log.d(Constants.TAG, "entry.mType.getMsgId() "+entry.mType.name());
ih.mText.setText(getResources().getString(entry.mType.getMsgId(),
entry.mParameters));
}

View File

@ -313,6 +313,7 @@ public class ViewKeyActivity extends ActionBarActivity implements
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// if a result has been returned, display a notify
if (data != null && data.hasExtra(OperationResultParcel.EXTRA_RESULT)) {
OperationResultParcel result = data.getParcelableExtra(OperationResultParcel.EXTRA_RESULT);
result.createNotify(this).show();