work on edit key
This commit is contained in:
@@ -80,7 +80,7 @@ public abstract class OperationResults {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public void displayToast(final Activity activity) {
|
public void displayNotify(final Activity activity) {
|
||||||
|
|
||||||
int resultType = getResult();
|
int resultType = getResult();
|
||||||
|
|
||||||
@@ -130,6 +130,7 @@ public abstract class OperationResults {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: externalize into Notify class?
|
||||||
boolean button = getLog() != null && !getLog().isEmpty();
|
boolean button = getLog() != null && !getLog().isEmpty();
|
||||||
SuperCardToast toast = new SuperCardToast(activity,
|
SuperCardToast toast = new SuperCardToast(activity,
|
||||||
button ? SuperToast.Type.BUTTON : SuperToast.Type.STANDARD,
|
button ? SuperToast.Type.BUTTON : SuperToast.Type.STANDARD,
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
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.CursorLoader;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
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.pgp.WrappedSecretKeyRing;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
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.service.SaveKeyringParcel;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.UserIdsArrayAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.UserIdsArrayAdapter;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.AddUserIdDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.AddUserIdDialogFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.EditUserIdDialogFragment;
|
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.ui.dialog.SetPassphraseDialogFragment;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
@@ -260,8 +266,6 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
String newPassphrase = data
|
String newPassphrase = data
|
||||||
.getString(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE);
|
.getString(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE);
|
||||||
|
|
||||||
// updatePassphraseButtonText();
|
|
||||||
// somethingChanged();
|
|
||||||
mSaveKeyringParcel.newPassphrase = newPassphrase;
|
mSaveKeyringParcel.newPassphrase = newPassphrase;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -270,14 +274,6 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
// Create a new Messenger for the communication back
|
// Create a new Messenger for the communication back
|
||||||
Messenger messenger = new Messenger(returnHandler);
|
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(
|
SetPassphraseDialogFragment setPassphraseDialog = SetPassphraseDialogFragment.newInstance(
|
||||||
messenger, R.string.title_change_passphrase);
|
messenger, R.string.title_change_passphrase);
|
||||||
|
|
||||||
@@ -356,8 +352,73 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void save() {
|
private void save() {
|
||||||
getActivity().finish();
|
String passphrase = PassphraseCacheService.getCachedPassphrase(getActivity(),
|
||||||
// TODO
|
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;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@@ -37,11 +36,6 @@ import android.view.View;
|
|||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
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.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.helper.OtherHelper;
|
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.adapter.PagerTabStripAdapter;
|
||||||
import org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout;
|
import org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
import org.sufficientlysecure.keychain.util.Notify;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -382,11 +377,7 @@ public class ImportKeysActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
private boolean isFingerprintValid(String fingerprint) {
|
private boolean isFingerprintValid(String fingerprint) {
|
||||||
if (fingerprint == null || fingerprint.length() < 40) {
|
if (fingerprint == null || fingerprint.length() < 40) {
|
||||||
SuperCardToast toast = SuperCardToast.create(this,
|
Notify.showNotify(this, R.string.import_qr_code_too_short_fingerprint, Notify.Style.ERROR);
|
||||||
getString(R.string.import_qr_code_too_short_fingerprint),
|
|
||||||
SuperToast.Duration.LONG);
|
|
||||||
toast.setBackground(SuperToast.Background.RED);
|
|
||||||
toast.show();
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
@@ -460,7 +451,7 @@ public class ImportKeysActivity extends ActionBarActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.displayToast(ImportKeysActivity.this);
|
result.displayNotify(ImportKeysActivity.this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -546,11 +537,7 @@ public class ImportKeysActivity extends ActionBarActivity {
|
|||||||
startService(intent);
|
startService(intent);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SuperCardToast toast = SuperCardToast.create(this,
|
Notify.showNotify(this, R.string.error_nothing_import, Notify.Style.ERROR);
|
||||||
getString(R.string.error_nothing_import),
|
|
||||||
SuperToast.Duration.LONG);
|
|
||||||
toast.setBackground(SuperToast.Background.RED);
|
|
||||||
toast.show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui;
|
|||||||
|
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@@ -358,7 +357,7 @@ public class ViewKeyActivity extends ActionBarActivity implements
|
|||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
ImportResult result = data.getParcelableExtra(ImportKeysActivity.EXTRA_RESULT);
|
ImportResult result = data.getParcelableExtra(ImportKeysActivity.EXTRA_RESULT);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
result.displayToast(this);
|
result.displayNotify(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include layout="@layout/notification_area"/>
|
<include layout="@layout/notify_area"/>
|
||||||
|
|
||||||
<android.support.v4.view.ViewPager
|
<android.support.v4.view.ViewPager
|
||||||
android:id="@+id/decrypt_pager"
|
android:id="@+id/decrypt_pager"
|
||||||
|
|||||||
@@ -4,11 +4,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<include layout="@layout/notify_area"/>
|
||||||
android:id="@+id/card_container"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical" />
|
|
||||||
|
|
||||||
<org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout
|
<org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout
|
||||||
android:id="@+id/import_sliding_tab_layout"
|
android:id="@+id/import_sliding_tab_layout"
|
||||||
|
|||||||
Reference in New Issue
Block a user