Skip to content

Commit

Permalink
Android text cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jrandiny committed Jul 26, 2018
1 parent 45f7000 commit 9c8687e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ public void onDecryptionSuccess(@NotNull String messageDecrypted) {

@Override
public void onDecryptionFailed() {
status.setText("Decryption failed");
status.setText(R.string.statusFailDecryption);
failAuth();
}

@Override
public void onFingerprintNotRecognized() {
status.setText("Fingerprint not recognized");
status.setText(R.string.statusFailNotRecognized);
authButton.setEnabled(true);
}

Expand All @@ -111,13 +111,13 @@ public void onAuthenticationFailedWithHelp(@Nullable String help) {

@Override
public void onFingerprintNotAvailable() {
status.setText("Fingerprint not available");
status.setText(R.string.statusFailNotAvailable);
failAuth();
}

@Override
public void onCancelled() {
status.setText("Cancelled");
status.setText(R.string.statusCanceled);
authButton.setEnabled(true);
}
}, getSupportFragmentManager());
Expand All @@ -139,7 +139,7 @@ private void returnToServer(){
}

private void failAuth(){
Toast.makeText(this,"Fail to get encrypted data, have you run setup?",Toast.LENGTH_LONG).show();
Toast.makeText(this, R.string.toastFailGetEncrypted,Toast.LENGTH_LONG).show();
returnToServer();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistent
private void startServer(){
String ip;

setupButton.setEnabled(false);

statusText.setText(getString(R.string.statusStarting));

startService(serverIntent);
Expand All @@ -74,10 +76,12 @@ private void startServer(){
WifiManager wm = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress());

statusText.setText(getString(R.string.statusStarted) + ip + "(port : " + port +")");
statusText.setText(String.format(getString(R.string.statusStarted), ip, port));
}

private void stopServer(){
setupButton.setEnabled(true);

stopService(serverIntent);
fab.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_play_arrow_white_24dp));
serverStatus = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ public class MyHTTPD extends NanoHTTPD {
public static final Object syncToken = new Object();
private int port;
private Context context;
private String testString = "test";

public MyHTTPD(Context context,Integer port) throws IOException {
super(port);
this.port = port;
this.context = context;
}

public int getPort(){
return port;
}

@Override
public Response serve(IHTTPSession session) {
String uri = session.getUri();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ public void onEncryptionSuccess(@NotNull String messageEncrypted) {

@Override
public void onEncryptionFailed() {
status.setText("Encryption failed");
status.setText(R.string.statusFailEncryption);
failFatal();
}

@Override
public void onFingerprintNotRecognized() {
status.setText("Fingerprint not recognized");
status.setText(R.string.statusFailNotRecognized);
retryBtn.setEnabled(true);
}

Expand All @@ -106,13 +106,13 @@ public void onAuthenticationFailedWithHelp(@Nullable String help) {

@Override
public void onFingerprintNotAvailable() {
status.setText("Fingerprint not available");
status.setText(R.string.statusFailNotAvailable);
failFatal();
}

@Override
public void onCancelled() {
status.setText("Operation cancelled by user");
status.setText(R.string.statusCanceled);
retryBtn.setEnabled(true);
}
}, getSupportFragmentManager());
Expand All @@ -135,7 +135,7 @@ public void onClick(View view) {
}

private void failFatal(){
Toast.makeText(this,"Fatal error",Toast.LENGTH_LONG).show();
Toast.makeText(this, R.string.toastFailFatal,Toast.LENGTH_LONG).show();
returnToServer();
}

Expand Down
9 changes: 8 additions & 1 deletion Android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
<resources>
<string name="app_name">Fingerprint Authenticator</string>
<string name="statusStarting">Starting up</string>
<string name="statusStarted">Started on </string>
<string name="statusStarted">Started on %s (port : %d)</string>
<string name="statusStopped">Stopped</string>
<string name="authRetry">Retry</string>
<string name="authStatusWaiting">Waiting auth</string>
<string name="portBtn">Port</string>
<string name="setupStatus">Processing</string>
<string name="setupRetry">Retry</string>
<string name="statusFailDecryption">Decryption failed</string>
<string name="statusFailNotRecognized">Fingerprint not recognized</string>
<string name="statusFailNotAvailable">Fingerprint not available</string>
<string name="statusCanceled">Cancelled</string>
<string name="toastFailGetEncrypted">Fail to get encrypted data, have you run setup?</string>
<string name="statusFailEncryption">Encryption failed</string>
<string name="toastFailFatal">Fatal error</string>
</resources>

0 comments on commit 9c8687e

Please sign in to comment.