Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release/1.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Amab committed Jul 25, 2016
2 parents 249d0b7 + 10ded0f commit 259d1bf
Show file tree
Hide file tree
Showing 8 changed files with 222 additions and 213 deletions.
4 changes: 2 additions & 2 deletions SWADroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ android {
}

dependencies {
compile 'com.android.support:support-v4:24.0.0'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.android.support:support-v4:24.1.1'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.google.android.gms:play-services-analytics:9.2.1'
compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.1'
compile 'commons-io:commons-io:2.5'
Expand Down
311 changes: 154 additions & 157 deletions SWADroid/src/main/java/es/ugr/swad/swadroid/SWADMain.java

Large diffs are not rendered by default.

27 changes: 26 additions & 1 deletion SWADroid/src/main/java/es/ugr/swad/swadroid/modules/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

import org.ksoap2.SoapFault;
import org.ksoap2.transport.HttpResponseException;
import org.kxml2.kdom.Element;
import org.kxml2.kdom.Node;
import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;
Expand Down Expand Up @@ -358,7 +360,7 @@ protected void onPostExecute(Void unused) {
errorMsg = getString(R.string.errorBadAppKeyMsg);
break;
default:
errorMsg = "Server error: " + es.getMessage();
errorMsg = getSoapErrorMessage(es);
break;
}
} else if ((e.getClass() == TimeoutException.class) || (e.getClass() == SocketTimeoutException.class)) {
Expand Down Expand Up @@ -408,4 +410,27 @@ protected void onPostExecute(Void unused) {
}
}
}



/**
* Method to retrieve the errorMessage from the given SoapFault.
* @param soapFault
* @return String representing the errorMessage found in the given SoapFault.
*/
private static String getSoapErrorMessage(SoapFault soapFault) {
String errorMessage;

try {
Node detailNode = soapFault.detail;
Element faultDetailElement = (Element)detailNode.getElement(0);
errorMessage = faultDetailElement.getText(0);
}
catch (Exception e) {
errorMessage = "Could not determine soap error.";
Log.e(TAG, errorMessage, e);
}

return errorMessage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,17 @@
package es.ugr.swad.swadroid.modules.marks;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import org.ksoap2.SoapFault;
import org.ksoap2.serialization.SoapObject;

import es.ugr.swad.swadroid.Constants;
import es.ugr.swad.swadroid.R;
import es.ugr.swad.swadroid.analytics.SWADroidTracker;
import es.ugr.swad.swadroid.gui.DialogFactory;
import es.ugr.swad.swadroid.model.User;
import es.ugr.swad.swadroid.modules.login.Login;
import es.ugr.swad.swadroid.modules.Module;
import es.ugr.swad.swadroid.modules.login.Login;
import es.ugr.swad.swadroid.webservices.SOAPClient;

/**
Expand All @@ -51,7 +46,6 @@ public class GetMarks extends Module {

private static String marks;
private long fileCode;
private boolean hasError;

@Override
protected void runConnection() {
Expand Down Expand Up @@ -81,9 +75,7 @@ protected void onStart() {

SWADroidTracker.sendScreenView(getApplicationContext(), TAG);

//fileCode = this.getIntent().getLongExtra("fileCode", 0);
fileCode = 0;
hasError = false;
fileCode = this.getIntent().getLongExtra("fileCode", 0);

runConnection();
}
Expand All @@ -105,8 +97,6 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
*/
@Override
protected void connect() {
String progressDescription = getString(R.string.marksProgressDescription);

startConnection();
}

Expand All @@ -117,30 +107,24 @@ protected void connect() {
protected void requestService()
throws Exception {

try {
//Creates webservice request, adds required params and sends request to webservice
createRequest(SOAPClient.CLIENT_TYPE);
addParam("wsKey", Login.getLoggedUser().getWsKey());
addParam("fileCode", fileCode);
sendRequest(User.class, true);

if (result != null) {
//Stores courses data returned by webservice response
SoapObject soap = (SoapObject) result;
marks = soap.getProperty("content").toString();

Log.i(TAG, "Retrieved marks [user=" + Login.getLoggedUser().getUserNickname()
+ ", fileCode=" + fileCode + "]");

//Request finalized without errors
setResult(RESULT_OK);
} else {
setResult(RESULT_CANCELED);
}
} catch(SoapFault e) {
if (e.faultstring.equals("Bad file code")) {
hasError = true;
}
//Creates webservice request, adds required params and sends request to webservice
createRequest(SOAPClient.CLIENT_TYPE);
addParam("wsKey", Login.getLoggedUser().getWsKey());
addParam("fileCode", fileCode);
sendRequest(User.class, true);

if (result != null) {
//Stores courses data returned by webservice response
SoapObject soap = (SoapObject) result;
marks = soap.getProperty("content").toString();

Log.i(TAG, "Retrieved marks [user=" + Login.getLoggedUser().getUserNickname()
+ ", fileCode=" + fileCode + "]");

//Request finalized without errors
setResult(RESULT_OK);
} else {
setResult(RESULT_CANCELED);
}
}

Expand All @@ -149,21 +133,7 @@ protected void requestService()
*/
@Override
protected void postConnect() {
AlertDialog errorDialog;
String errorMsg = getString(R.string.errorBadFileCodeMsg);
if(hasError) {
errorDialog = DialogFactory.createErrorDialog(this, TAG,
errorMsg, null, false, false, new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
errorDialog.show();
} else {
finish();
}
finish();
}

/* (non-Javadoc)
Expand Down
10 changes: 10 additions & 0 deletions SWADroid/src/main/res/raw-es/changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
</head>

<body bgcolor="white">
<h4>1.4.0 (2016-07-25)</h4>
<ul>
<lh class="new">[NOVEDADES]</lh>
<li type="disc"><strong>Men&uacute; principal&#58;</strong> A&ntilde;adido men&uacute; para
usuarios que no tienen ninguna asignatura</li>
</ul>
<ul>
<lh class="fix">[CORRECCIONES]</lh>
<li type="disc"><strong>Calificaciones&#58;</strong> Corregida consulta de calificaciones desde el rol estudiante</li>
</ul>
<h4>1.3.4 (2016-07-17)</h4>
<ul>
<lh class="update">[ACTUALIZACIONES]</lh>
Expand Down
9 changes: 9 additions & 0 deletions SWADroid/src/main/res/raw/changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
</head>

<body bgcolor="white">
<h4>1.4.0 (2016-07-25)</h4>
<ul>
<lh class="new">[NEW]</lh>
<li type="disc"><strong>Main menu&#58;</strong> Added menu for users who have no course</li>
</ul>
<ul>
<lh class="fix">[FIXES]</lh>
<li type="disc"><strong>Marks&#58;</strong> Fixed consultation of marks from the student role</li>
</ul>
<h4>1.3.4 (2016-07-17)</h4>
<ul>
<lh class="update">[UPDATES]</lh>
Expand Down
1 change: 0 additions & 1 deletion SWADroid/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@
<string name="marksModuleLabel">Calificaciones</string>
<string name="marksProgressTitle">Calificaciones</string>
<string name="marksProgressDescription">Obteniendo calificaciones…\nPor favor, espere…</string>
<string name="errorBadFileCodeMsg">Usted no puede consultar calificaciones en este fichero</string>
<string name="createAccountModuleLabel">Crear cuenta</string>
<string name="nickName">\@apodo</string>
<string name="email">Correo electrónico</string>
Expand Down
1 change: 0 additions & 1 deletion SWADroid/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@
<string name="marksModuleLabel">Marks</string>
<string name="marksProgressTitle">Marks</string>
<string name="marksProgressDescription">Getting marks…\nWait, please…</string>
<string name="errorBadFileCodeMsg">You can not get marks from this file</string>
<string name="createAccountModuleLabel">Create account</string>
<string name="nickName">\@nickname</string>
<string name="email">Email</string>
Expand Down

0 comments on commit 259d1bf

Please sign in to comment.