Increase timeout for remote user requests. Wrap long pre lines in markdown display.

This commit is contained in:
Akinwale Ariwodola 2020-05-25 20:08:24 +01:00
parent d2ec0e2aa1
commit 82307c9f98
3 changed files with 11 additions and 6 deletions

View file

@ -1725,6 +1725,7 @@ public class FileViewFragment extends BaseFragment implements
" <style type=\"text/css\">\n" +
" body { font-family: 'Inter', sans-serif; margin: 16px }\n" +
" img { width: 100%; }\n" +
" pre { white-space: pre-wrap; word-wrap: break-word }\n" +
" </style>\n" +
" </head>\n" +
" <body>\n" +

View file

@ -8,7 +8,7 @@ import com.google.firebase.analytics.FirebaseAnalytics;
public class LbryAnalytics {
public static final String EVENT_APP_EXCEPTION = "app_exception";
public static final String EVENT_APP_ERROR = "app_error";
public static final String EVENT_APP_LAUNCH = "app_launch";
public static final String EVENT_EMAIL_ADDED = "email_added";
public static final String EVENT_EMAIL_VERIFIED = "email_verified";
@ -56,10 +56,10 @@ public class LbryAnalytics {
}
}
public static void logException(String message, String exceptionName) {
public static void logError(String message, String exceptionName) {
Bundle bundle = new Bundle();
bundle.putString("message", message);
bundle.putString("name", exceptionName);
logEvent("app_exception", bundle);
logEvent(EVENT_APP_ERROR, bundle);
}
}

View file

@ -12,7 +12,6 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@ -24,6 +23,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import io.lbry.browser.MainActivity;
import io.lbry.browser.exceptions.LbryioRequestException;
@ -102,7 +102,10 @@ public final class Lbryio {
}
Request request = builder.build();
OkHttpClient client = new OkHttpClient();
OkHttpClient client = new OkHttpClient.Builder().
writeTimeout(120, TimeUnit.SECONDS).
readTimeout(120, TimeUnit.SECONDS).
build();
try {
return client.newCall(request).execute();
} catch (IOException ex) {
@ -154,6 +157,7 @@ public final class Lbryio {
AUTH_TOKEN = json.getString(AUTH_TOKEN_PARAM);
broadcastAuthTokenGenerated(context);
} catch (JSONException | ClassCastException ex) {
LbryAnalytics.logError(String.format("/user/new failed: %s", ex.getMessage()), ex.getClass().getName());
throw new LbryioResponseException("auth_token was not set in the response", ex);
} finally {
generatingAuthToken = false;
@ -193,7 +197,7 @@ public final class Lbryio {
User user = gson.fromJson(object.toString(), type);
return user;
} catch (LbryioRequestException | LbryioResponseException | ClassCastException | IllegalStateException ex) {
LbryAnalytics.logException(String.format("/user/me failed: %s", ex.getMessage()), ex.getClass().getName());
LbryAnalytics.logError(String.format("/user/me failed: %s", ex.getMessage()), ex.getClass().getName());
android.util.Log.e(TAG, "Could not retrieve the current user", ex);
return null;
}