diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/GroupFragment.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/GroupFragment.java index 2de634e..dcec588 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/GroupFragment.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/fragment/GroupFragment.java @@ -162,7 +162,7 @@ public class GroupFragment extends NamedFragment { OTPListItem vh = (OTPListItem) binding.itemList.findViewHolderForAdapterPosition(i); if(vh == null) continue; try { - vh.getBinding().otpCode.setText(vh.getOTPData().getPin()); + vh.getBinding().otpCode.setText(OTPListItem.formatCode(vh.getOTPData().getPin())); } catch (OTPException e) { DialogUtil.showErrorDialog(requireContext(), e.getMessage() == null ? "An error occurred while refreshing the code" : e.getMessage()); } diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/otplist/OTPListAdapter.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/otplist/OTPListAdapter.java index 519dfac..8ac328d 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/otplist/OTPListAdapter.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/otplist/OTPListAdapter.java @@ -68,7 +68,7 @@ public class OTPListAdapter extends RecyclerView.Adapter { data.incrementCounter(); try { - holder.getBinding().otpCode.setText(data.getPin()); + holder.getBinding().otpCode.setText(OTPListItem.formatCode(data.getPin())); }catch(OTPException e) { DialogUtil.showErrorDialog(context, context.getString(R.string.otp_add_error, e.getMessage() != null ? e.getMessage() : e.toString())); return; diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/otplist/OTPListItem.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/otplist/OTPListItem.java index d02b3ba..25a7c13 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/otplist/OTPListItem.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/otplist/OTPListItem.java @@ -29,4 +29,18 @@ public class OTPListItem extends RecyclerView.ViewHolder { return otpData; } + public static String formatCode(String code) { + // TODO: add setting for group size (and enable/disable grouping) + StringBuilder b = new StringBuilder(); + for(int i = 0; i < code.length(); i++) { + if(i != 0 && i % 3 == 0) { + b.append(' '); + } + + char c = code.charAt(i); + b.append(c); + } + return b.toString(); + } + }