mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-29 13:27:46 +00:00
fix #100 where passwords were not copied if we didn't show them
This commit is contained in:
parent
608f61b605
commit
eb65c2283f
@ -213,59 +213,66 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
|
|||||||
|
|
||||||
public class DelayShow extends AsyncTask<Void, Integer, Boolean> {
|
public class DelayShow extends AsyncTask<Void, Integer, Boolean> {
|
||||||
ProgressBar pb;
|
ProgressBar pb;
|
||||||
|
int current, SHOW_TIME;
|
||||||
|
boolean showPassword;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
LinearLayout container = (LinearLayout) findViewById(R.id.crypto_container);
|
|
||||||
container.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
TextView extraText = (TextView) findViewById(R.id.crypto_extra_show);
|
|
||||||
|
|
||||||
if (extraText.getText().length() != 0)
|
|
||||||
((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 {
|
try {
|
||||||
SHOW_TIME = Integer.parseInt(settings.getString("general_show_time", "45"));
|
SHOW_TIME = Integer.parseInt(settings.getString("general_show_time", "45"));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
SHOW_TIME = 45;
|
SHOW_TIME = 45;
|
||||||
}
|
}
|
||||||
this.pb.setMax(SHOW_TIME);
|
current = 0;
|
||||||
|
|
||||||
|
showPassword = settings.getBoolean("show_password", true);
|
||||||
|
if (showPassword) {
|
||||||
|
LinearLayout container = (LinearLayout) findViewById(R.id.crypto_container);
|
||||||
|
container.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
TextView extraText = (TextView) findViewById(R.id.crypto_extra_show);
|
||||||
|
|
||||||
|
if (extraText.getText().length() != 0)
|
||||||
|
((LinearLayout) findViewById(R.id.crypto_extra_show_layout)).setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
this.pb = (ProgressBar) findViewById(R.id.pbLoading);
|
||||||
|
this.pb.setMax(SHOW_TIME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean doInBackground(Void... params) {
|
protected Boolean doInBackground(Void... params) {
|
||||||
while (this.pb.getProgress() < this.pb.getMax()) {
|
while (current < SHOW_TIME) {
|
||||||
SystemClock.sleep(1000);
|
SystemClock.sleep(1000);
|
||||||
publishProgress(this.pb.getProgress() + 1);
|
current++;
|
||||||
|
if (showPassword) {
|
||||||
|
publishProgress(current);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Boolean b) {
|
protected void onPostExecute(Boolean b) {
|
||||||
|
|
||||||
ClipData clip = ClipData.newPlainText("pgp_handler_result_pm", "MyPasswordIsDaBest!");
|
ClipData clip = ClipData.newPlainText("pgp_handler_result_pm", "MyPasswordIsDaBest!");
|
||||||
clipboard.setPrimaryClip(clip);
|
clipboard.setPrimaryClip(clip);
|
||||||
|
if (showPassword) {
|
||||||
//clear password
|
//clear password
|
||||||
((TextView) findViewById(R.id.crypto_password_show)).setText("");
|
((TextView) findViewById(R.id.crypto_password_show)).setText("");
|
||||||
((TextView) findViewById(R.id.crypto_extra_show)).setText("");
|
((TextView) findViewById(R.id.crypto_extra_show)).setText("");
|
||||||
findViewById(R.id.crypto_extra_show_layout).setVisibility(View.INVISIBLE);
|
findViewById(R.id.crypto_extra_show_layout).setVisibility(View.INVISIBLE);
|
||||||
findViewById(R.id.crypto_container).setVisibility(View.INVISIBLE);
|
findViewById(R.id.crypto_container).setVisibility(View.INVISIBLE);
|
||||||
activity.setResult(RESULT_CANCELED);
|
activity.setResult(RESULT_CANCELED);
|
||||||
activity.finish();
|
activity.finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onProgressUpdate(Integer... values) {
|
protected void onProgressUpdate(Integer... values) {
|
||||||
this.pb.setProgress(values[0]);
|
if (showPassword) {
|
||||||
|
this.pb.setProgress(values[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -327,28 +334,32 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
|
|||||||
|
|
||||||
if (showPassword) {
|
if (showPassword) {
|
||||||
findViewById(R.id.crypto_container).setVisibility(View.VISIBLE);
|
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))
|
|
||||||
.setTypeface(monoTypeface);
|
|
||||||
((TextView) findViewById(R.id.crypto_password_show))
|
|
||||||
.setText(passContent[0]);
|
|
||||||
|
|
||||||
String extraContent = os.toString("UTF-8").replaceFirst(".*\n", "");
|
|
||||||
if (extraContent.length() != 0) {
|
|
||||||
((TextView) findViewById(R.id.crypto_extra_show))
|
|
||||||
.setTypeface(monoTypeface);
|
|
||||||
((TextView) findViewById(R.id.crypto_extra_show))
|
|
||||||
.setText(extraContent);
|
|
||||||
}
|
|
||||||
new DelayShow().execute();
|
|
||||||
} else {
|
|
||||||
activity.setResult(RESULT_CANCELED);
|
|
||||||
activity.finish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Typeface monoTypeface = Typeface.createFromAsset(getAssets(), "fonts/sourcecodepro.ttf");
|
||||||
|
String[] passContent = os.toString("UTF-8").split("\n");
|
||||||
|
((TextView) findViewById(R.id.crypto_password_show))
|
||||||
|
.setTypeface(monoTypeface);
|
||||||
|
((TextView) findViewById(R.id.crypto_password_show))
|
||||||
|
.setText(passContent[0]);
|
||||||
|
|
||||||
|
String extraContent = os.toString("UTF-8").replaceFirst(".*\n", "");
|
||||||
|
if (extraContent.length() != 0) {
|
||||||
|
((TextView) findViewById(R.id.crypto_extra_show))
|
||||||
|
.setTypeface(monoTypeface);
|
||||||
|
((TextView) findViewById(R.id.crypto_extra_show))
|
||||||
|
.setText(extraContent);
|
||||||
|
}
|
||||||
|
|
||||||
if (settings.getBoolean("copy_on_decrypt", true)) {
|
if (settings.getBoolean("copy_on_decrypt", true)) {
|
||||||
copyToClipBoard();
|
copyToClipBoard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new DelayShow().execute();
|
||||||
|
if (!showPassword) {
|
||||||
|
activity.setResult(RESULT_CANCELED);
|
||||||
|
activity.finish();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.d("PGPHANDLER", "Error message after decrypt : " + os.toString());
|
Log.d("PGPHANDLER", "Error message after decrypt : " + os.toString());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user