mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-23 06:12:20 -05:00
better state management in LinkedIdView, move confirm progress into card
This commit is contained in:
parent
f58ab3e439
commit
8d71a3fa92
@ -47,6 +47,7 @@ import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
||||
import org.sufficientlysecure.keychain.ui.PassphraseDialogActivity;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.LinkedIdsAdapter;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
|
||||
import org.sufficientlysecure.keychain.ui.linked.LinkedIdViewFragment.ViewHolder.VerifyState;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.State;
|
||||
import org.sufficientlysecure.keychain.ui.widget.CertListWidget;
|
||||
@ -242,7 +243,6 @@ public class LinkedIdViewFragment extends Fragment implements
|
||||
private final View vButtonBack;
|
||||
|
||||
private final ViewAnimator vProgress;
|
||||
private final ImageView vIcon;
|
||||
private final TextView vText;
|
||||
|
||||
ViewHolder(View root) {
|
||||
@ -261,12 +261,41 @@ public class LinkedIdViewFragment extends Fragment implements
|
||||
vVerifyingContainer = (ViewAnimator) root.findViewById(R.id.linked_verify_container);
|
||||
|
||||
vProgress = (ViewAnimator) root.findViewById(R.id.linked_cert_progress);
|
||||
vIcon = (ImageView) root.findViewById(R.id.linked_cert_icon);
|
||||
vText = (TextView) root.findViewById(R.id.linked_cert_text);
|
||||
}
|
||||
|
||||
void setShowProgress(boolean show) {
|
||||
vProgress.setDisplayedChild(show ? 0 : 1);
|
||||
enum VerifyState {
|
||||
VERIFYING, VERIFY_OK, VERIFY_ERROR, CERTIFYING
|
||||
}
|
||||
|
||||
void setVerifyingState(VerifyState state) {
|
||||
switch (state) {
|
||||
case VERIFYING:
|
||||
vProgress.setDisplayedChild(0);
|
||||
vText.setText("Verifying…");
|
||||
vKeySpinner.setVisibility(View.GONE);
|
||||
break;
|
||||
|
||||
case VERIFY_OK:
|
||||
showButton(2);
|
||||
vText.setText("Ok");
|
||||
vProgress.setDisplayedChild(1);
|
||||
vKeySpinner.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
|
||||
case VERIFY_ERROR:
|
||||
showButton(1);
|
||||
vProgress.setDisplayedChild(2);
|
||||
vText.setText("Error");
|
||||
vKeySpinner.setVisibility(View.GONE);
|
||||
break;
|
||||
|
||||
case CERTIFYING:
|
||||
vProgress.setDisplayedChild(0);
|
||||
vText.setText("Confirming…");
|
||||
vKeySpinner.setVisibility(View.GONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void showButton(int which) {
|
||||
@ -384,8 +413,7 @@ public class LinkedIdViewFragment extends Fragment implements
|
||||
setShowVerifying(true);
|
||||
|
||||
mViewHolder.vKeySpinner.setVisibility(View.GONE);
|
||||
mViewHolder.setShowProgress(true);
|
||||
mViewHolder.vText.setText("Verifying…");
|
||||
mViewHolder.setVerifyingState(VerifyState.VERIFYING);
|
||||
|
||||
mInProgress = new AsyncTask<Void,Void,LinkedVerifyResult>() {
|
||||
@Override
|
||||
@ -406,16 +434,13 @@ public class LinkedIdViewFragment extends Fragment implements
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(LinkedVerifyResult result) {
|
||||
mViewHolder.setShowProgress(false);
|
||||
if (isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (result.success()) {
|
||||
mViewHolder.vText.setText("Ok");
|
||||
setupForConfirmation();
|
||||
mViewHolder.setVerifyingState(VerifyState.VERIFY_OK);
|
||||
} else {
|
||||
mViewHolder.showButton(1);
|
||||
mViewHolder.vText.setText("Error");
|
||||
mViewHolder.setVerifyingState(VerifyState.VERIFY_ERROR);
|
||||
}
|
||||
mInProgress = null;
|
||||
}
|
||||
@ -423,15 +448,6 @@ public class LinkedIdViewFragment extends Fragment implements
|
||||
|
||||
}
|
||||
|
||||
void setupForConfirmation() {
|
||||
|
||||
// button is 'confirm'
|
||||
mViewHolder.showButton(2);
|
||||
|
||||
mViewHolder.vKeySpinner.setVisibility(View.VISIBLE);
|
||||
|
||||
}
|
||||
|
||||
private void initiateCertifying() {
|
||||
// get the user's passphrase for this key (if required)
|
||||
String passphrase;
|
||||
@ -478,6 +494,8 @@ public class LinkedIdViewFragment extends Fragment implements
|
||||
|
||||
private void certifyResource(long certifyKeyId, String passphrase) {
|
||||
|
||||
mViewHolder.setVerifyingState(VerifyState.CERTIFYING);
|
||||
|
||||
Bundle data = new Bundle();
|
||||
{
|
||||
|
||||
@ -502,16 +520,24 @@ public class LinkedIdViewFragment extends Fragment implements
|
||||
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
|
||||
|
||||
// Message is received after signing is done in KeychainIntentService
|
||||
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(getActivity(),
|
||||
getString(R.string.progress_certifying), ProgressDialog.STYLE_SPINNER, false) {
|
||||
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(getActivity()) {
|
||||
public void handleMessage(Message message) {
|
||||
// handle messages by standard KeychainIntentServiceHandler first
|
||||
super.handleMessage(message);
|
||||
|
||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
||||
Bundle data = message.getData();
|
||||
CertifyResult result = data.getParcelable(CertifyResult.EXTRA_RESULT);
|
||||
Bundle data = message.getData();
|
||||
|
||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_UPDATE_PROGRESS) {
|
||||
if (data.containsKey(DATA_MESSAGE)) {
|
||||
mViewHolder.vText.setText(data.getString(DATA_MESSAGE));
|
||||
} else if (data.containsKey(DATA_MESSAGE_ID)) {
|
||||
mViewHolder.vText.setText(data.getString(DATA_MESSAGE_ID));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
||||
CertifyResult result = data.getParcelable(CertifyResult.EXTRA_RESULT);
|
||||
result.createNotify(getActivity()).show();
|
||||
}
|
||||
}
|
||||
@ -521,9 +547,6 @@ public class LinkedIdViewFragment extends Fragment implements
|
||||
Messenger messenger = new Messenger(saveHandler);
|
||||
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
|
||||
|
||||
// show progress dialog
|
||||
saveHandler.showProgressDialog(getActivity());
|
||||
|
||||
// start service with intent
|
||||
getActivity().startService(intent);
|
||||
|
||||
|
@ -48,30 +48,11 @@
|
||||
android:orientation="horizontal"
|
||||
android:singleLine="true">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="0dip"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/linked_cert_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Verifying…"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ViewAnimator
|
||||
android:layout_width="22dp"
|
||||
android:layout_height="22dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_gravity="center"
|
||||
android:id="@+id/linked_cert_progress"
|
||||
android:inAnimation="@anim/fade_in"
|
||||
@ -86,11 +67,36 @@
|
||||
<ImageView
|
||||
android:layout_width="22dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/status_signature_unknown_cutout_24dp"
|
||||
android:id="@+id/linked_cert_icon"
|
||||
android:src="@drawable/status_signature_verified_cutout_24dp"
|
||||
/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="22dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/status_signature_unknown_cutout_24dp"
|
||||
/>
|
||||
|
||||
</ViewAnimator>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="0dip"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/linked_cert_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Verifying…"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ViewAnimator>
|
||||
|
Loading…
x
Reference in New Issue
Block a user