Allow moving codes to other groups, Show issuer

This commit is contained in:
MrLetsplay 2023-07-25 17:57:52 +02:00
parent 97e9e902f0
commit 94a8994d40
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
6 changed files with 16 additions and 7 deletions

View File

@ -77,7 +77,7 @@ public class GroupFragment extends NamedFragment {
private void showOTPDialog(OTPData data) { private void showOTPDialog(OTPData data) {
new StyledDialogBuilder(requireContext()) new StyledDialogBuilder(requireContext())
.setTitle(R.string.edit_otp_title) .setTitle(R.string.edit_otp_title)
.setItems(R.array.view_edit_delete, (dialog, which) -> { .setItems(R.array.view_edit_move_delete, (dialog, which) -> {
switch(which) { switch(which) {
case 0: case 0:
DialogUtil.showViewCodeDialog(getLayoutInflater(), data, () -> showOTPDialog(data)); DialogUtil.showViewCodeDialog(getLayoutInflater(), data, () -> showOTPDialog(data));
@ -89,6 +89,13 @@ public class GroupFragment extends NamedFragment {
}, () -> showOTPDialog(data)); }, () -> showOTPDialog(data));
break; break;
case 2: case 2:
DialogUtil.showChooseGroupDialog(requireContext(), group -> {
SettingsUtil.addOTP(requireContext(), group, data);
otpListAdapter.remove(data);
saveOTPs();
}, null);
break;
case 3:
new StyledDialogBuilder(requireContext()) new StyledDialogBuilder(requireContext())
.setTitle(R.string.otp_delete_title) .setTitle(R.string.otp_delete_title)
.setMessage(R.string.otp_delete_message) .setMessage(R.string.otp_delete_message)

View File

@ -54,8 +54,8 @@ public class OTPListAdapter extends RecyclerView.Adapter<OTPListItem> {
OTPData data = items.get(position); OTPData data = items.get(position);
holder.setOTPData(data); holder.setOTPData(data);
holder.getBinding().label.setText(holder.getOTPData().getName()); holder.getBinding().label.setText(String.format("%s%s", data.getIssuer() == null || data.getIssuer().isEmpty() ? "" : data.getIssuer() + ": ", data.getName()));
holder.getBinding().progress.setVisibility(holder.getOTPData().getType() == OTPType.TOTP ? View.VISIBLE : View.GONE); holder.getBinding().progress.setVisibility(data.getType() == OTPType.TOTP ? View.VISIBLE : View.GONE);
holder.getBinding().getRoot().setOnClickListener(view -> { holder.getBinding().getRoot().setOnClickListener(view -> {
if(data.getType() != OTPType.HOTP) return; if(data.getType() != OTPType.HOTP) return;

View File

@ -54,7 +54,7 @@ public class URIHandlerActivity extends AppCompatActivity {
} }
private void importCodes(OTPData... data) { private void importCodes(OTPData... data) {
DialogUtil.showImportCodeDialog(this, group -> { DialogUtil.showChooseGroupDialog(this, group -> {
for(OTPData d : data) SettingsUtil.addOTP(this, group, d); for(OTPData d : data) SettingsUtil.addOTP(this, group, d);
Toast.makeText(this, R.string.uri_handler_code_added, Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.uri_handler_code_added, Toast.LENGTH_SHORT).show();
}, this::finishAndRemoveTask); }, this::finishAndRemoveTask);

View File

@ -224,7 +224,7 @@ public class DialogUtil {
dialog.show(); dialog.show();
} }
public static void showImportCodeDialog(Context context, Consumer<String> callback, Runnable onDismiss) { public static void showChooseGroupDialog(Context context, Consumer<String> callback, Runnable onDismiss) {
List<String> groups = SettingsUtil.getGroups(context); List<String> groups = SettingsUtil.getGroups(context);
String[] groupNames = new String[groups.size() + 1]; String[] groupNames = new String[groups.size() + 1];

View File

@ -50,9 +50,10 @@
<string name="otp_add_missing_name">Name fehlt</string> <string name="otp_add_missing_name">Name fehlt</string>
<string name="qr_scanner_migration_title">OTP-Migration</string> <string name="qr_scanner_migration_title">OTP-Migration</string>
<string name="qr_scanner_migration_message">Du scheinst zu versuchen, Codes aus einer anderen App zu importieren. Willst du alle Codes in diese Gruppe importieren?</string> <string name="qr_scanner_migration_message">Du scheinst zu versuchen, Codes aus einer anderen App zu importieren. Willst du alle Codes in diese Gruppe importieren?</string>
<string-array name="view_edit_delete"> <string-array name="view_edit_move_delete">
<item>Anzeigen</item> <item>Anzeigen</item>
<item>Bearbeiten</item> <item>Bearbeiten</item>
<item>In andere Gruppe verschieben</item>
<item>Löschen</item> <item>Löschen</item>
</string-array> </string-array>
<string-array name="rename_delete"> <string-array name="rename_delete">

View File

@ -90,9 +90,10 @@
<string name="otp_add_missing_name">Missing name</string> <string name="otp_add_missing_name">Missing name</string>
<string name="qr_scanner_migration_title">OTP Migration</string> <string name="qr_scanner_migration_title">OTP Migration</string>
<string name="qr_scanner_migration_message">It seems like you\'re trying to import OTP codes from another app. Do you want to import all codes into this group?</string> <string name="qr_scanner_migration_message">It seems like you\'re trying to import OTP codes from another app. Do you want to import all codes into this group?</string>
<string-array name="view_edit_delete"> <string-array name="view_edit_move_delete">
<item>View</item> <item>View</item>
<item>Edit</item> <item>Edit</item>
<item>Move to other group</item>
<item>Delete</item> <item>Delete</item>
</string-array> </string-array>
<string-array name="rename_delete"> <string-array name="rename_delete">