Merge branch 'master' of https://git.cringe-studios.com/CringeStudios/Cringe-Authenticator
This commit is contained in:
commit
e6db8ba5d9
@ -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());
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class OTPListAdapter extends RecyclerView.Adapter<OTPListItem> {
|
||||
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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user