Commit 4a411408 authored by Nastuzzi Samy's avatar Nastuzzi Samy
Browse files

Enter key manually

Allow new key by simple input (need to press a long time on "not registered application"
parent 67c09a8e
......@@ -63,6 +63,16 @@ public class MainActivity extends NFCActivity {
AppRegisteredText = findViewById(R.id.text_app_registered);
usernameButton = findViewById(R.id.button_username);
AppRegisteredText.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (!nemopaySession.isRegistered())
addKeyDialog();
return false;
}
});
usernameButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -342,4 +352,22 @@ public class MainActivity extends NFCActivity {
dialog.createDialog(alertDialogBuilder, nameInput);
}
protected void addKeyDialog() {
final View keyView = getLayoutInflater().inflate(R.layout.dialog_key_force, null);
final EditText keyInput = keyView.findViewById(R.id.input_key);
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this);
alertDialogBuilder
.setTitle(R.string.key_dialog)
.setView(keyView)
.setCancelable(false)
.setPositiveButton(R.string.register, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int id) {
setKey(keyInput.getText().toString());
}
});
dialog.createDialog(alertDialogBuilder);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/text_key_explication"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:text="@string/key_add_explication"
android:layout_marginBottom="10dp" />
<EditText
android:id="@+id/input_key"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:inputType="text|textEmailAddress"
android:hint="@string/key" />
</LinearLayout>
\ No newline at end of file
......@@ -40,9 +40,11 @@
<string name="nemopay_registering">Enregistrement de l\'application</string>
<string name="nemopay_already_registered">Application déjà authentifiée</string>
<string name="nemopay_error_registering">Application non enregistrée</string>
<string name="key">Clé d\'application</string>
<string name="key_dialog">Enregistrement de l\'appareil</string>
<string name="key_explication">Pour pouvoir fonctionner, l\'application a besoin d\'être enregistrée sous un nom précis et daté (date automatiquement ajoutée si non détectée). Ceci permettra par la suite de donner des droits à cet appareil</string>
<string name="key_name">Nom - Date</string>
<string name="key_description">Description</string>
<string name="key_name_required">Nom requis !</string>
<string name="key_add_explication">Il est possible d\'ajouter directement une clé d\'application si celle-ci est connue</string>
</resources>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment