Increase timeout for remote user requests. Wrap long pre lines in markdown display.
This commit is contained in:
parent
d2ec0e2aa1
commit
82307c9f98
3 changed files with 11 additions and 6 deletions
|
@ -1725,6 +1725,7 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
" <style type=\"text/css\">\n" +
|
" <style type=\"text/css\">\n" +
|
||||||
" body { font-family: 'Inter', sans-serif; margin: 16px }\n" +
|
" body { font-family: 'Inter', sans-serif; margin: 16px }\n" +
|
||||||
" img { width: 100%; }\n" +
|
" img { width: 100%; }\n" +
|
||||||
|
" pre { white-space: pre-wrap; word-wrap: break-word }\n" +
|
||||||
" </style>\n" +
|
" </style>\n" +
|
||||||
" </head>\n" +
|
" </head>\n" +
|
||||||
" <body>\n" +
|
" <body>\n" +
|
||||||
|
|
|
@ -8,7 +8,7 @@ import com.google.firebase.analytics.FirebaseAnalytics;
|
||||||
|
|
||||||
public class LbryAnalytics {
|
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_APP_LAUNCH = "app_launch";
|
||||||
public static final String EVENT_EMAIL_ADDED = "email_added";
|
public static final String EVENT_EMAIL_ADDED = "email_added";
|
||||||
public static final String EVENT_EMAIL_VERIFIED = "email_verified";
|
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 bundle = new Bundle();
|
||||||
bundle.putString("message", message);
|
bundle.putString("message", message);
|
||||||
bundle.putString("name", exceptionName);
|
bundle.putString("name", exceptionName);
|
||||||
logEvent("app_exception", bundle);
|
logEvent(EVENT_APP_ERROR, bundle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
@ -24,6 +23,7 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import io.lbry.browser.MainActivity;
|
import io.lbry.browser.MainActivity;
|
||||||
import io.lbry.browser.exceptions.LbryioRequestException;
|
import io.lbry.browser.exceptions.LbryioRequestException;
|
||||||
|
@ -102,7 +102,10 @@ public final class Lbryio {
|
||||||
}
|
}
|
||||||
|
|
||||||
Request request = builder.build();
|
Request request = builder.build();
|
||||||
OkHttpClient client = new OkHttpClient();
|
OkHttpClient client = new OkHttpClient.Builder().
|
||||||
|
writeTimeout(120, TimeUnit.SECONDS).
|
||||||
|
readTimeout(120, TimeUnit.SECONDS).
|
||||||
|
build();
|
||||||
try {
|
try {
|
||||||
return client.newCall(request).execute();
|
return client.newCall(request).execute();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
@ -154,6 +157,7 @@ public final class Lbryio {
|
||||||
AUTH_TOKEN = json.getString(AUTH_TOKEN_PARAM);
|
AUTH_TOKEN = json.getString(AUTH_TOKEN_PARAM);
|
||||||
broadcastAuthTokenGenerated(context);
|
broadcastAuthTokenGenerated(context);
|
||||||
} catch (JSONException | ClassCastException ex) {
|
} 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);
|
throw new LbryioResponseException("auth_token was not set in the response", ex);
|
||||||
} finally {
|
} finally {
|
||||||
generatingAuthToken = false;
|
generatingAuthToken = false;
|
||||||
|
@ -193,7 +197,7 @@ public final class Lbryio {
|
||||||
User user = gson.fromJson(object.toString(), type);
|
User user = gson.fromJson(object.toString(), type);
|
||||||
return user;
|
return user;
|
||||||
} catch (LbryioRequestException | LbryioResponseException | ClassCastException | IllegalStateException ex) {
|
} 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);
|
android.util.Log.e(TAG, "Could not retrieve the current user", ex);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue