fix #100 where passwords were not copied if we didn't show them
This commit is contained in:
parent
608f61b605
commit
eb65c2283f
1 changed files with 56 additions and 45 deletions
|
@ -213,9 +213,20 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
|
|||
|
||||
public class DelayShow extends AsyncTask<Void, Integer, Boolean> {
|
||||
ProgressBar pb;
|
||||
int current, SHOW_TIME;
|
||||
boolean showPassword;
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
try {
|
||||
SHOW_TIME = Integer.parseInt(settings.getString("general_show_time", "45"));
|
||||
} catch (NumberFormatException e) {
|
||||
SHOW_TIME = 45;
|
||||
}
|
||||
current = 0;
|
||||
|
||||
showPassword = settings.getBoolean("show_password", true);
|
||||
if (showPassword) {
|
||||
LinearLayout container = (LinearLayout) findViewById(R.id.crypto_container);
|
||||
container.setVisibility(View.VISIBLE);
|
||||
|
||||
|
@ -225,34 +236,27 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
|
|||
((LinearLayout) findViewById(R.id.crypto_extra_show_layout)).setVisibility(View.VISIBLE);
|
||||
|
||||
this.pb = (ProgressBar) findViewById(R.id.pbLoading);
|
||||
|
||||
// Make Show Time a user preference
|
||||
// kLeZ: Changed to match the default for pass
|
||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(container.getContext());
|
||||
int SHOW_TIME;
|
||||
try {
|
||||
SHOW_TIME = Integer.parseInt(settings.getString("general_show_time", "45"));
|
||||
} catch (NumberFormatException e) {
|
||||
SHOW_TIME = 45;
|
||||
}
|
||||
this.pb.setMax(SHOW_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
while (this.pb.getProgress() < this.pb.getMax()) {
|
||||
while (current < SHOW_TIME) {
|
||||
SystemClock.sleep(1000);
|
||||
publishProgress(this.pb.getProgress() + 1);
|
||||
current++;
|
||||
if (showPassword) {
|
||||
publishProgress(current);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean b) {
|
||||
|
||||
ClipData clip = ClipData.newPlainText("pgp_handler_result_pm", "MyPasswordIsDaBest!");
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
if (showPassword) {
|
||||
//clear password
|
||||
((TextView) findViewById(R.id.crypto_password_show)).setText("");
|
||||
((TextView) findViewById(R.id.crypto_extra_show)).setText("");
|
||||
|
@ -261,12 +265,15 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
|
|||
activity.setResult(RESULT_CANCELED);
|
||||
activity.finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onProgressUpdate(Integer... values) {
|
||||
if (showPassword) {
|
||||
this.pb.setProgress(values[0]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -327,6 +334,8 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
|
|||
|
||||
if (showPassword) {
|
||||
findViewById(R.id.crypto_container).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
Typeface monoTypeface = Typeface.createFromAsset(getAssets(), "fonts/sourcecodepro.ttf");
|
||||
String[] passContent = os.toString("UTF-8").split("\n");
|
||||
((TextView) findViewById(R.id.crypto_password_show))
|
||||
|
@ -341,14 +350,16 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
|
|||
((TextView) findViewById(R.id.crypto_extra_show))
|
||||
.setText(extraContent);
|
||||
}
|
||||
new DelayShow().execute();
|
||||
} else {
|
||||
activity.setResult(RESULT_CANCELED);
|
||||
activity.finish();
|
||||
}
|
||||
|
||||
if (settings.getBoolean("copy_on_decrypt", true)) {
|
||||
copyToClipBoard();
|
||||
}
|
||||
|
||||
new DelayShow().execute();
|
||||
if (!showPassword) {
|
||||
activity.setResult(RESULT_CANCELED);
|
||||
activity.finish();
|
||||
}
|
||||
} else {
|
||||
Log.d("PGPHANDLER", "Error message after decrypt : " + os.toString());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue