Add OTP error message
This commit is contained in:
parent
bf3ea5231f
commit
6c9d6550a4
@ -141,13 +141,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
|
||||||
|
|
||||||
/*if(NavigationUtil.getCurrentFragment(this) instanceof DynamicFragment) { TODO: vs. fabs?
|
|
||||||
getMenuInflater().inflate(R.menu.menu_dynamic, menu);
|
|
||||||
return true;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if(NavigationUtil.getCurrentFragment(this) instanceof MenuFragment) {
|
if(NavigationUtil.getCurrentFragment(this) instanceof MenuFragment) {
|
||||||
getMenuInflater().inflate(R.menu.menu_groups, menu);
|
getMenuInflater().inflate(R.menu.menu_groups, menu);
|
||||||
return true;
|
return true;
|
||||||
|
@ -15,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
import com.cringe_studios.cringe_authenticator.R;
|
import com.cringe_studios.cringe_authenticator.R;
|
||||||
import com.cringe_studios.cringe_authenticator.databinding.OtpCodeBinding;
|
import com.cringe_studios.cringe_authenticator.databinding.OtpCodeBinding;
|
||||||
import com.cringe_studios.cringe_authenticator.model.OTPData;
|
import com.cringe_studios.cringe_authenticator.model.OTPData;
|
||||||
|
import com.cringe_studios.cringe_authenticator.util.DialogUtil;
|
||||||
import com.cringe_studios.cringe_authenticator_library.OTPException;
|
import com.cringe_studios.cringe_authenticator_library.OTPException;
|
||||||
import com.cringe_studios.cringe_authenticator_library.OTPType;
|
import com.cringe_studios.cringe_authenticator_library.OTPType;
|
||||||
|
|
||||||
@ -23,6 +24,8 @@ import java.util.List;
|
|||||||
|
|
||||||
public class OTPListAdapter extends RecyclerView.Adapter<OTPListItem> {
|
public class OTPListAdapter extends RecyclerView.Adapter<OTPListItem> {
|
||||||
|
|
||||||
|
private Context context;
|
||||||
|
|
||||||
private LayoutInflater inflater;
|
private LayoutInflater inflater;
|
||||||
|
|
||||||
private List<OTPData> items;
|
private List<OTPData> items;
|
||||||
@ -32,6 +35,7 @@ public class OTPListAdapter extends RecyclerView.Adapter<OTPListItem> {
|
|||||||
private Consumer<OTPData> showMenuCallback;
|
private Consumer<OTPData> showMenuCallback;
|
||||||
|
|
||||||
public OTPListAdapter(Context context, Consumer<OTPData> showMenuCallback) {
|
public OTPListAdapter(Context context, Consumer<OTPData> showMenuCallback) {
|
||||||
|
this.context = context;
|
||||||
this.inflater = LayoutInflater.from(context);
|
this.inflater = LayoutInflater.from(context);
|
||||||
this.items = new ArrayList<>();
|
this.items = new ArrayList<>();
|
||||||
this.handler = new Handler(Looper.getMainLooper());
|
this.handler = new Handler(Looper.getMainLooper());
|
||||||
@ -58,16 +62,17 @@ public class OTPListAdapter extends RecyclerView.Adapter<OTPListItem> {
|
|||||||
|
|
||||||
// Click delay for HOTP
|
// Click delay for HOTP
|
||||||
view.setClickable(false);
|
view.setClickable(false);
|
||||||
Toast.makeText(view.getContext(), R.string.hotp_generated_new_code, Toast.LENGTH_SHORT).show();
|
|
||||||
data.incrementCounter();
|
data.incrementCounter();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
holder.getBinding().otpCode.setText(data.getPin());
|
holder.getBinding().otpCode.setText(data.getPin());
|
||||||
}catch(OTPException e) {
|
}catch(OTPException e) {
|
||||||
// TODO: show user an error message
|
DialogUtil.showErrorDialog(context, context.getString(R.string.otp_add_error, e.getMessage() != null ? e.getMessage() : e.toString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Toast.makeText(view.getContext(), R.string.hotp_generated_new_code, Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
handler.postDelayed(() -> view.setClickable(true), 5000);
|
handler.postDelayed(() -> view.setClickable(true), 5000);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
<string name="otp_add_secret">Geheimnis</string>
|
<string name="otp_add_secret">Geheimnis</string>
|
||||||
<string name="otp_add_name">Name</string>
|
<string name="otp_add_name">Name</string>
|
||||||
<string name="otp_add_period">Intervall</string>
|
<string name="otp_add_period">Intervall</string>
|
||||||
|
<string name="otp_add_error">Hinzufügen des OTP-Codes fehlgeschlagen: %s</string>
|
||||||
<string-array name="view_edit_delete">
|
<string-array name="view_edit_delete">
|
||||||
<item>Anzeigen</item>
|
<item>Anzeigen</item>
|
||||||
<item>Bearbeiten</item>
|
<item>Bearbeiten</item>
|
||||||
|
@ -84,6 +84,7 @@
|
|||||||
<string name="otp_add_secret">Secret</string>
|
<string name="otp_add_secret">Secret</string>
|
||||||
<string name="otp_add_name">Name</string>
|
<string name="otp_add_name">Name</string>
|
||||||
<string name="otp_add_period">Period</string>
|
<string name="otp_add_period">Period</string>
|
||||||
|
<string name="otp_add_error">Failed to update OTP: %s</string>
|
||||||
<string-array name="view_edit_delete">
|
<string-array name="view_edit_delete">
|
||||||
<item>View</item>
|
<item>View</item>
|
||||||
<item>Edit</item>
|
<item>Edit</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user