show toast on copy and dismiss dialog if error on openkeychain

This commit is contained in:
knuthy 2014-09-29 22:04:47 +02:00
parent 2c929441a7
commit 2fd688bd27
2 changed files with 13 additions and 1 deletions

View file

@ -147,6 +147,9 @@ public class PgpHandler extends Activity implements OpenPgpServiceConnection.OnB
case R.id.copy_password: case R.id.copy_password:
ClipData clip = ClipData.newPlainText("pgp_handler_result_pm", ((TextView) findViewById(R.id.crypto_password_show)).getText()); ClipData clip = ClipData.newPlainText("pgp_handler_result_pm", ((TextView) findViewById(R.id.crypto_password_show)).getText());
clipboard.setPrimaryClip(clip); clipboard.setPrimaryClip(clip);
showToast("Password copied to clipboard, you have "
+ Integer.parseInt(settings.getString("general_show_time", "45"))
+ " seconds to paste it somewhere.");
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -387,10 +390,19 @@ public class PgpHandler extends Activity implements OpenPgpServiceConnection.OnB
break; break;
} }
case OpenPgpApi.RESULT_CODE_ERROR: { case OpenPgpApi.RESULT_CODE_ERROR: {
// TODO show what kind of error it is
/* For example:
* No suitable key found -> no key in OpenKeyChain
*
* Check in open-pgp-lib how their definitions and error code
*/
showToast("ERROR"); showToast("ERROR");
OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR); OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
handleError(error); handleError(error);
// close the dialog
bindingDialog.dismiss();
break; break;
} }

View file

@ -77,7 +77,7 @@
<ProgressBar <ProgressBar
android:id="@+id/pbLoading" android:id="@+id/pbLoading"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="2dp" android:layout_height="8dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
style="?android:attr/progressBarStyleHorizontal" style="?android:attr/progressBarStyleHorizontal"