mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-17 07:30:14 -05:00
work on edit key
This commit is contained in:
parent
6d7a9ec48a
commit
c2ba7e2420
@ -80,7 +80,7 @@ public abstract class OperationResults {
|
||||
}
|
||||
};
|
||||
|
||||
public void displayToast(final Activity activity) {
|
||||
public void displayNotify(final Activity activity) {
|
||||
|
||||
int resultType = getResult();
|
||||
|
||||
@ -130,6 +130,7 @@ public abstract class OperationResults {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: externalize into Notify class?
|
||||
boolean button = getLog() != null && !getLog().isEmpty();
|
||||
SuperCardToast toast = new SuperCardToast(activity,
|
||||
button ? SuperToast.Type.BUTTON : SuperToast.Type.STANDARD,
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
@ -27,7 +29,6 @@ import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@ -43,12 +44,17 @@ import org.sufficientlysecure.keychain.helper.ActionBarHelper;
|
||||
import org.sufficientlysecure.keychain.pgp.WrappedSecretKeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||
import org.sufficientlysecure.keychain.service.OperationResults;
|
||||
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.UserIdsArrayAdapter;
|
||||
import org.sufficientlysecure.keychain.ui.dialog.AddUserIdDialogFragment;
|
||||
import org.sufficientlysecure.keychain.ui.dialog.EditUserIdDialogFragment;
|
||||
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
|
||||
import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
@ -260,8 +266,6 @@ public class EditKeyFragment extends LoaderFragment implements
|
||||
String newPassphrase = data
|
||||
.getString(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE);
|
||||
|
||||
// updatePassphraseButtonText();
|
||||
// somethingChanged();
|
||||
mSaveKeyringParcel.newPassphrase = newPassphrase;
|
||||
}
|
||||
}
|
||||
@ -270,14 +274,6 @@ public class EditKeyFragment extends LoaderFragment implements
|
||||
// Create a new Messenger for the communication back
|
||||
Messenger messenger = new Messenger(returnHandler);
|
||||
|
||||
// set title based on isPassphraseSet()
|
||||
// int title;
|
||||
// if (isPassphraseSet()) {
|
||||
// title = R.string.title_change_passphrase;
|
||||
// } else {
|
||||
// title = R.string.title_set_passphrase;
|
||||
// }
|
||||
|
||||
SetPassphraseDialogFragment setPassphraseDialog = SetPassphraseDialogFragment.newInstance(
|
||||
messenger, R.string.title_change_passphrase);
|
||||
|
||||
@ -356,8 +352,73 @@ public class EditKeyFragment extends LoaderFragment implements
|
||||
}
|
||||
|
||||
private void save() {
|
||||
getActivity().finish();
|
||||
// TODO
|
||||
String passphrase = PassphraseCacheService.getCachedPassphrase(getActivity(),
|
||||
mSaveKeyringParcel.mMasterKeyId);
|
||||
if (passphrase == null) {
|
||||
PassphraseDialogFragment.show(getActivity(), mSaveKeyringParcel.mMasterKeyId,
|
||||
new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message message) {
|
||||
if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) {
|
||||
saveFinal();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
private void saveFinal() {
|
||||
// Message is received after importing is done in KeychainIntentService
|
||||
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(
|
||||
getActivity(),
|
||||
getString(R.string.progress_saving),
|
||||
ProgressDialog.STYLE_HORIZONTAL) {
|
||||
public void handleMessage(Message message) {
|
||||
// handle messages by standard KeychainIntentServiceHandler first
|
||||
super.handleMessage(message);
|
||||
|
||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
||||
// get returned data bundle
|
||||
Bundle returnData = message.getData();
|
||||
if (returnData == null) {
|
||||
return;
|
||||
}
|
||||
final OperationResults.SaveKeyringResult result =
|
||||
returnData.getParcelable(KeychainIntentService.RESULT);
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if good -> finish, return result to showkey and display there!
|
||||
// if bad -> display here!
|
||||
|
||||
// result.displayNotify(ImportKeysActivity.this);
|
||||
|
||||
// getActivity().finish();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Send all information needed to service to import key in other thread
|
||||
Intent intent = new Intent(getActivity(), KeychainIntentService.class);
|
||||
intent.setAction(KeychainIntentService.ACTION_SAVE_KEYRING);
|
||||
|
||||
// fill values for this action
|
||||
Bundle data = new Bundle();
|
||||
data.putParcelable(KeychainIntentService.SAVE_KEYRING_PARCEL, mSaveKeyringParcel);
|
||||
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
||||
|
||||
// Create a new Messenger for the communication back
|
||||
Messenger messenger = new Messenger(saveHandler);
|
||||
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
|
||||
|
||||
// show progress dialog
|
||||
saveHandler.showProgressDialog(getActivity());
|
||||
|
||||
// start service with intent
|
||||
getActivity().startService(intent);
|
||||
}
|
||||
}
|
@ -18,7 +18,6 @@
|
||||
package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
@ -37,11 +36,6 @@ import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.github.johnpersano.supertoasts.SuperCardToast;
|
||||
import com.github.johnpersano.supertoasts.SuperToast;
|
||||
import com.github.johnpersano.supertoasts.util.OnClickWrapper;
|
||||
import com.github.johnpersano.supertoasts.util.Style;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.helper.OtherHelper;
|
||||
@ -55,6 +49,7 @@ import org.sufficientlysecure.keychain.service.OperationResults.ImportResult;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
|
||||
import org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.Notify;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
@ -382,11 +377,7 @@ public class ImportKeysActivity extends ActionBarActivity {
|
||||
|
||||
private boolean isFingerprintValid(String fingerprint) {
|
||||
if (fingerprint == null || fingerprint.length() < 40) {
|
||||
SuperCardToast toast = SuperCardToast.create(this,
|
||||
getString(R.string.import_qr_code_too_short_fingerprint),
|
||||
SuperToast.Duration.LONG);
|
||||
toast.setBackground(SuperToast.Background.RED);
|
||||
toast.show();
|
||||
Notify.showNotify(this, R.string.import_qr_code_too_short_fingerprint, Notify.Style.ERROR);
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
@ -460,7 +451,7 @@ public class ImportKeysActivity extends ActionBarActivity {
|
||||
return;
|
||||
}
|
||||
|
||||
result.displayToast(ImportKeysActivity.this);
|
||||
result.displayNotify(ImportKeysActivity.this);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -546,11 +537,7 @@ public class ImportKeysActivity extends ActionBarActivity {
|
||||
startService(intent);
|
||||
|
||||
} else {
|
||||
SuperCardToast toast = SuperCardToast.create(this,
|
||||
getString(R.string.error_nothing_import),
|
||||
SuperToast.Duration.LONG);
|
||||
toast.setBackground(SuperToast.Background.RED);
|
||||
toast.show();
|
||||
Notify.showNotify(this, R.string.error_nothing_import, Notify.Style.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
@ -358,7 +357,7 @@ public class ViewKeyActivity extends ActionBarActivity implements
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
ImportResult result = data.getParcelableExtra(ImportKeysActivity.EXTRA_RESULT);
|
||||
if (result != null) {
|
||||
result.displayToast(this);
|
||||
result.displayNotify(this);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -6,7 +6,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/notification_area"/>
|
||||
<include layout="@layout/notify_area"/>
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/decrypt_pager"
|
||||
|
@ -4,11 +4,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/card_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
<include layout="@layout/notify_area"/>
|
||||
|
||||
<org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout
|
||||
android:id="@+id/import_sliding_tab_layout"
|
||||
|
Loading…
Reference in New Issue
Block a user