mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-09-03 15:55:14 +00:00
Password editing: action bar edit button replaces decrypt view with encrypt view
This commit is contained in:
@@ -56,6 +56,7 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
|
|||||||
SharedPreferences settings;
|
SharedPreferences settings;
|
||||||
private Activity activity;
|
private Activity activity;
|
||||||
ClipboardManager clipboard;
|
ClipboardManager clipboard;
|
||||||
|
AsyncTask delayShowTask;
|
||||||
|
|
||||||
private boolean registered;
|
private boolean registered;
|
||||||
|
|
||||||
@@ -137,10 +138,46 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
|
|||||||
return true;
|
return true;
|
||||||
case R.id.copy_password:
|
case R.id.copy_password:
|
||||||
copyToClipBoard();
|
copyToClipBoard();
|
||||||
|
break;
|
||||||
|
case R.id.edit_password:
|
||||||
|
editPassword();
|
||||||
|
if (delayShowTask != null) {
|
||||||
|
delayShowTask.cancel(true);
|
||||||
|
delayShowTask = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void editPassword() {
|
||||||
|
|
||||||
|
if (findViewById(R.id.crypto_container).getVisibility() != View.VISIBLE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CharSequence category = ((TextView) findViewById(R.id.crypto_password_category)).getText();
|
||||||
|
CharSequence file = ((TextView) findViewById(R.id.crypto_password_file)).getText();
|
||||||
|
CharSequence password = ((TextView) findViewById(R.id.crypto_password_show)).getText();
|
||||||
|
CharSequence extra = ((TextView) findViewById(R.id.crypto_extra_show)).getText();
|
||||||
|
|
||||||
|
setContentView(R.layout.encrypt_layout);
|
||||||
|
Typeface monoTypeface = Typeface.createFromAsset(getAssets(), "fonts/sourcecodepro.ttf");
|
||||||
|
((EditText) findViewById(R.id.crypto_password_edit)).setTypeface(monoTypeface);
|
||||||
|
((EditText) findViewById(R.id.crypto_extra_edit)).setTypeface(monoTypeface);
|
||||||
|
|
||||||
|
((TextView) findViewById(R.id.crypto_password_category)).setText(category);
|
||||||
|
((TextView) findViewById(R.id.crypto_password_file_edit)).setText(file);
|
||||||
|
((EditText) findViewById(R.id.crypto_password_edit)).setText(password);
|
||||||
|
((EditText) findViewById(R.id.crypto_extra_edit)).setText(extra);
|
||||||
|
|
||||||
|
// the original intent was to decrypt so FILE_PATH will have the file, not enclosing dir
|
||||||
|
// PgpCallback expects the dir when encrypting
|
||||||
|
String filePath = getIntent().getExtras().getString("FILE_PATH");
|
||||||
|
String directoryPath = filePath.substring(0, filePath.lastIndexOf(File.separator));
|
||||||
|
Intent intent = new Intent(this, PgpHandler.class);
|
||||||
|
intent.putExtra("FILE_PATH", directoryPath);
|
||||||
|
setIntent(intent);
|
||||||
|
}
|
||||||
|
|
||||||
public void copyToClipBoard() {
|
public void copyToClipBoard() {
|
||||||
|
|
||||||
if (findViewById(R.id.crypto_password_show) == null)
|
if (findViewById(R.id.crypto_password_show) == null)
|
||||||
@@ -248,6 +285,9 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
|
|||||||
if (showPassword) {
|
if (showPassword) {
|
||||||
publishProgress(current);
|
publishProgress(current);
|
||||||
}
|
}
|
||||||
|
if (isCancelled()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -361,7 +401,7 @@ public class PgpHandler extends AppCompatActivity implements OpenPgpServiceConne
|
|||||||
copyToClipBoard();
|
copyToClipBoard();
|
||||||
}
|
}
|
||||||
|
|
||||||
new DelayShow().execute();
|
delayShowTask = new DelayShow().execute();
|
||||||
if (!showPassword) {
|
if (!showPassword) {
|
||||||
activity.setResult(RESULT_CANCELED);
|
activity.setResult(RESULT_CANCELED);
|
||||||
activity.finish();
|
activity.finish();
|
||||||
|
BIN
app/src/main/res/drawable-hdpi/ic_action_edit.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_action_edit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 214 B |
BIN
app/src/main/res/drawable-mdpi/ic_action_edit.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_action_edit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 165 B |
BIN
app/src/main/res/drawable-xhdpi/ic_action_edit.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_action_edit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 241 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_action_edit.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_action_edit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 304 B |
@@ -7,4 +7,9 @@
|
|||||||
pwstore:showAsAction="ifRoom"
|
pwstore:showAsAction="ifRoom"
|
||||||
android:id="@+id/copy_password"
|
android:id="@+id/copy_password"
|
||||||
/>
|
/>
|
||||||
|
<item android:title="Edit password"
|
||||||
|
android:icon="@drawable/ic_action_edit"
|
||||||
|
pwstore:showAsAction="ifRoom"
|
||||||
|
android:id="@+id/edit_password"
|
||||||
|
/>
|
||||||
</menu>
|
</menu>
|
||||||
|
Reference in New Issue
Block a user