Why do we need to access the property like this? LoginActivity.this.password.getText().toString().trim();
Why not just: password.getText().toString().trim();
Why do we need to access the property like this? LoginActivity.this.password.getText().toString().trim();
Why not just: password.getText().toString().trim();
The UI shouldn’t have a tunnel object either. It should have only the end results that it needs. Like methods isVPNConnected, if it listens to an interface then it should just get the interface. All the logic should be connected with UI only.
The UI shouldn't have a tunnel object either. It should have only the end results that it needs. Like methods isVPNConnected, if it listens to an interface then it should just get the interface. All the logic should be connected with UI only.
Encapsulate this code in a method: setConnectionStateUI(boolean state){
if (state) {
Toast.makeText(MainActivity.this, getString(R.string.connected_bubble), Toast.LENGTH_SHORT).show();
bubbleStatus.setText(getString(R.string.connected_bubble));
connectButton.setText(getString(R.string.disconnect));
} else {
Toast.makeText(MainActivity.this, getString(R.string.not_connected_bubble), Toast.LENGTH_SHORT).show();
bubbleStatus.setText(getString(R.string.not_connected_bubble));
connectButton.setText(getString(R.string.connect));
}
}
After this, you can reuse this method.
Encapsulate this code in a method: setConnectionStateUI(boolean state){
if (state) {
Toast.makeText(MainActivity.this, getString(R.string.connected_bubble), Toast.LENGTH_SHORT).show();
bubbleStatus.setText(getString(R.string.connected_bubble));
connectButton.setText(getString(R.string.disconnect));
} else {
Toast.makeText(MainActivity.this, getString(R.string.not_connected_bubble), Toast.LENGTH_SHORT).show();
bubbleStatus.setText(getString(R.string.not_connected_bubble));
connectButton.setText(getString(R.string.connect));
}
}
After this, you can reuse this method.
rename to BASE_URL_PREFIX
Rename to BASE_URL_SUFFIX
Make a validity check on the URL format, if it’s not valid, return error
Why do we need to access the property like this?
LoginActivity.this.password
local variable have same name
Why do we set a connection flag to true when state is down?
if it does not work, turn it on and set the flag to true
This is not connected with the API, it should be located in another class.
The connection state should not be saved manually by the app but taken from the tunnel every time when needed.
Why do we need to access the property like this? LoginActivity.this.password.getText().toString().trim();
Why not just: password.getText().toString().trim();
password is a local variable i have be use this + that is anonym class use LoginActivity.this
Then just rename String username to usernameInput, and password to passwordInput.
The string is hardcoded. Put in the string resources.
The UI shouldn’t have a tunnel object either. It should have only the end results that it needs. Like methods isVPNConnected, if it listens to an interface then it should just get the interface. All the logic should be connected with UI only.
This logic should not happen in the LoginActivity. The login activity should directly receive an encoded certificate just to put it in the intent.
Handle errors and exception catches correctly. Return an error, otherwise, during errors, we will get an infinite loading dialog.
Encapsulate this code in a method: setConnectionStateUI(boolean state){
if (state) {
Toast.makeText(MainActivity.this, getString(R.string.connected_bubble), Toast.LENGTH_SHORT).show();
bubbleStatus.setText(getString(R.string.connected_bubble));
connectButton.setText(getString(R.string.disconnect));
} else {
Toast.makeText(MainActivity.this, getString(R.string.not_connected_bubble), Toast.LENGTH_SHORT).show();
bubbleStatus.setText(getString(R.string.not_connected_bubble));
connectButton.setText(getString(R.string.connect));
}
}
After this, you can reuse this method.
use the setConnectionState(false)
Reviewers
ee7304b9f3
.