Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intentando resolver issue #28 #29

Closed
wants to merge 8 commits into from
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,11 @@ Para cambiar a cualquier login JWT, se deben cambiar algunos parametros en login
- url: Esta debe apuntar al servidor que se desea consultar. Ubicado en app/src/main/res/values/strings.xml como jwt_URL.
- jsonRequest: Debe contener los datos necesarios para el servidor. En este caso se utilizaron solo 2 campos, username y password.
- listener y errorListener: Aca se definen las acciones a tomar ya sea esperando una respuesta positiva, negativa o un error.

## Configurar Entorno de Desarrollo

Configurar el nombre de servidor en los siguientes archivos:

app/src/main/res/xml/network_security_config.xml ( etiqueta: domain )

app/src/debug/res/values/strings.xml (host_name)
4 changes: 4 additions & 0 deletions app/src/debug/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesante recurso @GonzaloGaleano , es una buena opción para cierto tipo de constantes.
Solemos usar el build.gradle para definir variables dependientes del buildType.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

si, utilizo mucho este recurso también para tener distintos iconos para la versión dev + agregando sufix a appname en build.gradle entonces poder tener debug y release instalados en el mismo teléfono y diferenciados

<resources>
<string name="host_name">http://192.168.0.33:8080</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ private void loginJWT(LoginRequest loginRequest) {

// Instanciar el RequestQueue.
RequestQueue queue = Volley.newRequestQueue(this);
String url = getString(R.string.jwt_URL);
String host_name = getString(R.string.host_name);
String end_point = getString(R.string.jwt_URL);
String url = host_name + end_point;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sobre variable host_name :

  1. El proyecto tiene su larga data, no obstante nuevas contribuciones tratamos de que mantengan el Coding Style de Android, como se menciona en el README
  2. Su valor debería venir de un input text en la pantalla del login. Esta funcionalidad es la más buscada del ejercicio. El objetivo es que un tester o developer, pueda ingresar un nuevo server en runtime

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si, suelo utilizar camelCase donde se puede, aquí se me pasó. Voy a estar repasando más Android Coding Style.


Map<String, String> params = new HashMap();
params.put("username", loginRequest.getUsername());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ private void initializeUI(){

private void otpValid(View view){
RequestQueue queue = Volley.newRequestQueue(this);
String url = getString(R.string.user_acces_URL);

String host_name = getString(R.string.host_name);
String end_point = getString(R.string.user_acces_URL);
String url = host_name + end_point;

final Context ctx = view.getContext();
Intent intent = new Intent(ctx, HomeActivity.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ public void onClick(View v) {
private void saveSeed(Token token){
RequestQueue queue = Volley.newRequestQueue(this);

String url = getString(R.string.user_acces_URL); //<--saveseed_URL url to request, change values/strings.xml
// saveseed_URL url to request, change values/strings.xml
String host_name = getString(R.string.host_name);
String end_point = getString(R.string.user_acces_URL);
String url = host_name + end_point;

//Creates parameters
Map<String, String> params = new HashMap();
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
<string name="settings_pwd_too_short">New password must have at least 8 characters</string>
<string name="eula_warning_body">Ud. no aceptó aún los términos de uso de la aplicación. Por favor lea hasta el final y marque la casilla de aceptación si está de acuerdo con las condiciones</string>
<string name="eula_URL">http://example.com/</string>
<string name="jwt_URL">http://192.168.0.33:8080/api/login</string>
<string name="user_acces_URL">http://192.168.0.33:8080/api/token/user-access</string>
<string name="jwt_URL">/api/login</string>
<string name="user_acces_URL">/api/token/user-access</string>
<string name="rest_URL">https://restcountries.eu/rest/v2/all?fields=name;alpha2Code</string>
<string name="eula_warning_title"></string>
<string name="eula_title">Aviso Legal de Responsabilidades</string>
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="false" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asegurarse de que una vez resuelto el input text para el hostname, al ingresar un nuevo hostname en runtime; se pueda conectar a un puerto plain text.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En este caso lo resolví con un archivo solo para la versión DEBUG con base-config cleartextTrafficPermitted=true y false para la versión release. Ahí fue el siguiente pull request.

<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">sodep.com.py</domain>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">192.168.0.33</domain>
</domain-config>
<domain includeSubdomains="true">192.168.0.33</domain>
</domain-config>
</network-security-config>
4 changes: 4 additions & 0 deletions app/src/release/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="host_name">http://192.168.0.33:8080</string>
</resources>