Skip to content

Commit e3c7c81

Browse files
committed
added additional error messages
1 parent 372509e commit e3c7c81

File tree

5 files changed

+66
-24
lines changed

5 files changed

+66
-24
lines changed

AndroidManifest.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="org.pyload.android.client"
4-
android:versionCode="14"
5-
android:versionName="0.3.1">
4+
android:versionCode="15"
5+
android:versionName="0.3.2">
66

77
<uses-sdk android:minSdkVersion="7"
88
android:targetSdkVersion="17"/>
@@ -97,6 +97,5 @@
9797

9898
<activity android:name=".RemoteSettings" android:label="@string/remotesettings_activity"/>
9999

100-
101100
</application>
102101
</manifest>

Changelog.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
Changelog
2-
=========
1+
0.3.2:
2+
* More detailed error messages, when no connection can be established
3+
* TODO: Fixed refreshing of remote settings
4+
* TODO: Fixed reported crashes
35

4-
0.3.1
5-
-----
6-
- fixed captcha inputs
6+
0.3.1:
7+
* fixed captcha inputs
78

8-
0.3.0
9-
-----
10-
- Updated design to Holo theme
11-
- ActionBar for Android ICS and above
12-
- Allow to send links to pyLoad app
13-
- Improved performance, reduced footprint
9+
0.3.0:
10+
* Updated design to Holo theme
11+
* ActionBar for Android ICS and above
12+
* Allow to send links to pyLoad app
13+
* Improved performance, reduced footprint
1414

proguard-project.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@
2626
-keepclasseswithmembers class org.apache.commons.codec.binary.** {
2727
*;
2828
}
29+
30+
# java.lang.NoSuchMethodError: android.app.ActionBar.setHomeButtonEnabled
31+
# Derived from error reports, no clue how to reproduce it
32+
-keep class android.app.ActionBar {
33+
public void set*(...);
34+
}

res/values/strings.xml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@
5959
<string name="ssl">SSL Connection</string>
6060
<string name="ssl_desc">Establish a secure connection to the core if you activated SSL</string>
6161
<string name="ssl_validate">Validate SSL Certificate</string>
62-
<string name="ssl_validate_desc">If "SSL Connection" is enabled, check that the certificate presented by the core is signed by a CA known by Android</string>
62+
<string name="ssl_validate_desc">If "SSL Connection" is enabled, check that the certificate presented by the core is
63+
signed by a CA known by Android
64+
</string>
6365
<string name="old_server">Server version does not match, please use pyLoad %s.</string>
6466
<string name="choose_file">Container File</string>
6567
<string name="choose">Choose</string>
66-
<string name="current_dir">Current Dir: </string>
68+
<string name="current_dir">Current Dir:</string>
6769
<string name="folder">Folder</string>
68-
<string name="file_size">File Size: </string>
70+
<string name="file_size">File Size:</string>
6971
<string name="parent_dir">Parent Directory</string>
7072
<string name="eula_title">License</string>
7173
<string name="eula_accept">Accept</string>
@@ -89,4 +91,12 @@
8991
<string name="invalid">invalid</string>
9092
<string name="trafficleft">Traffic:</string>
9193
<string name="validuntil">Expires:</string>
94+
<string name="certificate_error">SSL certificate not accepted. Add it to android or disable validation.</string>
95+
<string name="connect_timeout">Connecting timed out. Please check that the server settings are correct.</string>
96+
<string name="socket_error">Could not connect to target host. Check the server settings, your network configuration
97+
or port forwarding.
98+
</string>
99+
<string name="connect_error">Could not connect to pyLoad. Check that pyLoad is running and server settings are
100+
correct.
101+
</string>
92102
</resources>

src/org/pyload/android/client/pyLoadApp.java

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
package org.pyload.android.client;
22

33
import java.io.IOException;
4+
import java.net.ConnectException;
5+
import java.net.SocketException;
6+
import java.net.SocketTimeoutException;
47
import java.security.KeyManagementException;
58
import java.security.KeyStore;
69
import java.security.KeyStoreException;
710
import java.security.NoSuchAlgorithmException;
811
import java.util.HashMap;
912

10-
import javax.net.ssl.SSLSocket;
11-
import javax.net.ssl.SSLContext;
12-
import javax.net.ssl.TrustManager;
13-
import javax.net.ssl.TrustManagerFactory;
13+
import javax.net.ssl.*;
1414

1515
import android.annotation.TargetApi;
1616
import android.content.Context;
@@ -176,7 +176,7 @@ public void run() {
176176

177177
public void onException() {
178178
client = null;
179-
Log.d("pyLoad", "Exception caught");
179+
// The task queue will log an error with exception
180180

181181
if (lastException instanceof TTransportException) {
182182
Toast t = Toast.makeText(this, R.string.lost_connection,
@@ -187,8 +187,20 @@ public void onException() {
187187
Toast.LENGTH_SHORT);
188188
t.show();
189189
} else if (lastException instanceof TException) {
190-
Toast t = Toast.makeText(this, R.string.no_connection,
191-
Toast.LENGTH_SHORT);
190+
Throwable tr = findException(lastException);
191+
192+
Toast t;
193+
if (tr instanceof SSLHandshakeException)
194+
t = Toast.makeText(this, R.string.certificate_error, Toast.LENGTH_SHORT);
195+
else if(tr instanceof SocketTimeoutException)
196+
t = Toast.makeText(this, R.string.connect_timeout, Toast.LENGTH_SHORT);
197+
else if(tr instanceof ConnectException)
198+
t = Toast.makeText(this, R.string.connect_error, Toast.LENGTH_SHORT);
199+
else if(tr instanceof SocketException)
200+
t = Toast.makeText(this, R.string.socket_error, Toast.LENGTH_SHORT);
201+
else
202+
t = Toast.makeText(this, R.string.no_connection, Toast.LENGTH_SHORT);
203+
192204
t.show();
193205
} else if (lastException instanceof WrongServer) {
194206
Toast t = Toast.makeText(this, String.format(
@@ -200,6 +212,21 @@ public void onException() {
200212
setProgress(false);
201213
}
202214

215+
/**
216+
* Retrieves first root exception on stack of several TExceptions.
217+
* @return the first exception not a TException or the last TException
218+
*/
219+
private Throwable findException(Throwable e) {
220+
// will not terminate when cycles occur, hopefully nobody cycle exception causes
221+
while (e instanceof TException) {
222+
if (e.getCause() == null) break;
223+
if (e.getCause() == e) break; // just to avoid loop
224+
e = e.getCause();
225+
}
226+
227+
return e;
228+
}
229+
203230
final public Runnable handleSuccess = new Runnable() {
204231
@Override
205232
public void run() {

0 commit comments

Comments
 (0)