Prepares proxy

This commit is contained in:
stom79 2018-01-19 18:59:30 +01:00
parent d252ebf585
commit 72b15d3893
9 changed files with 120 additions and 59 deletions

View File

@ -1096,7 +1096,7 @@ public abstract class BaseMainActivity extends BaseActivity
if(matchStart < matchEnd && sharedText.length() >= matchEnd) if(matchStart < matchEnd && sharedText.length() >= matchEnd)
sharedText = sharedText.substring(matchStart, matchEnd); sharedText = sharedText.substring(matchStart, matchEnd);
} }
new RetrieveMetaDataAsyncTask(sharedText, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new RetrieveMetaDataAsyncTask(BaseMainActivity.this, sharedText, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
Intent intentToot = new Intent(getApplicationContext(), TootActivity.class); Intent intentToot = new Intent(getApplicationContext(), TootActivity.class);
Bundle b = new Bundle(); Bundle b = new Bundle();
b.putString("sharedSubject", sharedSubject); b.putString("sharedSubject", sharedSubject);

View File

@ -140,7 +140,7 @@ public class InstanceHealthActivity extends BaseActivity {
try { try {
HashMap<String, String> parameters = new HashMap<>(); HashMap<String, String> parameters = new HashMap<>();
parameters.put("name", instance.trim()); parameters.put("name", instance.trim());
final String response = new HttpsConnection().get("https://instances.social/api/1.0/instances/show", 30, parameters, Helper.THEKINRAR_SECRET_TOKEN ); final String response = new HttpsConnection(InstanceHealthActivity.this).get("https://instances.social/api/1.0/instances/show", 30, parameters, Helper.THEKINRAR_SECRET_TOKEN );
if( response != null) if( response != null)
instanceSocial = API.parseInstanceSocialResponse(getApplicationContext(), new JSONObject(response)); instanceSocial = API.parseInstanceSocialResponse(getApplicationContext(), new JSONObject(response));
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {

View File

@ -125,7 +125,7 @@ public class LoginActivity extends BaseActivity {
@Override @Override
public void run() { public void run() {
try { try {
final String response = new HttpsConnection().get("https://instances.social/api/1.0" + action, 30, parameters, Helper.THEKINRAR_SECRET_TOKEN ); final String response = new HttpsConnection(LoginActivity.this).get("https://instances.social/api/1.0" + action, 30, parameters, Helper.THEKINRAR_SECRET_TOKEN );
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
isLoadingInstance = false; isLoadingInstance = false;
@ -252,7 +252,7 @@ public class LoginActivity extends BaseActivity {
@Override @Override
public void run() { public void run() {
try { try {
final String response = new HttpsConnection().post("https://" + instance + action, 30, parameters, null ); final String response = new HttpsConnection(LoginActivity.this).post("https://" + instance + action, 30, parameters, null );
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
JSONObject resobj; JSONObject resobj;
@ -326,7 +326,7 @@ public class LoginActivity extends BaseActivity {
@Override @Override
public void run() { public void run() {
try { try {
final String response = new HttpsConnection().post("https://" + instance + "/oauth/token", 30, parameters, null ); final String response = new HttpsConnection(LoginActivity.this).post("https://" + instance + "/oauth/token", 30, parameters, null );
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
JSONObject resobj; JSONObject resobj;

View File

@ -184,7 +184,7 @@ public class RemoteFollowActivity extends BaseActivity implements OnRetrieveRemo
@Override @Override
public void run() { public void run() {
try { try {
final String response = new HttpsConnection().get("https://instances.social/api/1.0" + action, 30, parameters, Helper.THEKINRAR_SECRET_TOKEN ); final String response = new HttpsConnection(RemoteFollowActivity.this).get("https://instances.social/api/1.0" + action, 30, parameters, Helper.THEKINRAR_SECRET_TOKEN );
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
public void run() { public void run() {
isLoadingInstance = false; isLoadingInstance = false;

View File

@ -119,7 +119,7 @@ public class WebviewConnectActivity extends BaseActivity {
@Override @Override
public void run() { public void run() {
try { try {
final String response = new HttpsConnection().post("https://" + instance + action, 30, parameters, null); final String response = new HttpsConnection(WebviewConnectActivity.this).post("https://" + instance + action, 30, parameters, null);
JSONObject resobj; JSONObject resobj;
try { try {
resobj = new JSONObject(response); resobj = new JSONObject(response);

View File

@ -14,16 +14,17 @@
* see <http://www.gnu.org/licenses>. */ * see <http://www.gnu.org/licenses>. */
package fr.gouv.etalab.mastodon.asynctasks; package fr.gouv.etalab.mastodon.asynctasks;
import android.content.Context;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
import android.util.Patterns; import android.util.Patterns;
import java.io.IOException; import java.io.IOException;
import java.lang.ref.WeakReference;
import java.security.KeyManagementException; import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import fr.gouv.etalab.mastodon.client.HttpsConnection; import fr.gouv.etalab.mastodon.client.HttpsConnection;
import fr.gouv.etalab.mastodon.helper.Helper; import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveMetaDataInterface; import fr.gouv.etalab.mastodon.interfaces.OnRetrieveMetaDataInterface;
@ -40,10 +41,12 @@ public class RetrieveMetaDataAsyncTask extends AsyncTask<Void, Void, Void> {
private String url; private String url;
private boolean error = false; private boolean error = false;
private String image, title, description; private String image, title, description;
private WeakReference<Context> contextWeakReference;
public RetrieveMetaDataAsyncTask(String url, OnRetrieveMetaDataInterface onRetrieveRemoteAccountInterface){ public RetrieveMetaDataAsyncTask(Context context, String url, OnRetrieveMetaDataInterface onRetrieveRemoteAccountInterface){
this.url = url; this.url = url;
this.listener = onRetrieveRemoteAccountInterface; this.listener = onRetrieveRemoteAccountInterface;
this.contextWeakReference = new WeakReference<>(context);
} }
@Override @Override
@ -70,7 +73,7 @@ public class RetrieveMetaDataAsyncTask extends AsyncTask<Void, Void, Void> {
Pattern descriptionPattern = Pattern.compile("meta\\s+property=[\"']og:description[\"']\\s+content=[\"'](.*)[\"']"); Pattern descriptionPattern = Pattern.compile("meta\\s+property=[\"']og:description[\"']\\s+content=[\"'](.*)[\"']");
Pattern imagePattern = Pattern.compile("meta\\s+property=[\"']og:image[\"']\\s+content=[\"'](.*)[\"']"); Pattern imagePattern = Pattern.compile("meta\\s+property=[\"']og:image[\"']\\s+content=[\"'](.*)[\"']");
try { try {
String response = new HttpsConnection().get(potentialUrl); String response = new HttpsConnection(this.contextWeakReference.get()).get(potentialUrl);
Matcher matcherTitle = titlePattern.matcher(response); Matcher matcherTitle = titlePattern.matcher(response);
Matcher matcherDescription = descriptionPattern.matcher(response); Matcher matcherDescription = descriptionPattern.matcher(response);
Matcher matcherImage = imagePattern.matcher(response); Matcher matcherImage = imagePattern.matcher(response);

View File

@ -123,7 +123,7 @@ public class API {
*/ */
public APIResponse getInstance() { public APIResponse getInstance() {
try { try {
String response = new HttpsConnection().get(getAbsoluteUrl("/instance"), 30, null, prefKeyOauthTokenT); String response = new HttpsConnection(context).get(getAbsoluteUrl("/instance"), 30, null, prefKeyOauthTokenT);
Instance instanceEntity = parseInstance(new JSONObject(response)); Instance instanceEntity = parseInstance(new JSONObject(response));
apiResponse.setInstance(instanceEntity); apiResponse.setInstance(instanceEntity);
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
@ -166,7 +166,7 @@ public class API {
requestParams.put("header",header); requestParams.put("header",header);
} }
try { try {
new HttpsConnection().patch(getAbsoluteUrl("/accounts/update_credentials"), 60, requestParams, prefKeyOauthTokenT); new HttpsConnection(context).patch(getAbsoluteUrl("/accounts/update_credentials"), 60, requestParams, prefKeyOauthTokenT);
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
e.printStackTrace(); e.printStackTrace();
setError(e.getStatusCode(), e); setError(e.getStatusCode(), e);
@ -185,7 +185,7 @@ public class API {
public Account verifyCredentials() { public Account verifyCredentials() {
account = new Account(); account = new Account();
try { try {
String response = new HttpsConnection().get(getAbsoluteUrl("/accounts/verify_credentials"), 60, null, prefKeyOauthTokenT); String response = new HttpsConnection(context).get(getAbsoluteUrl("/accounts/verify_credentials"), 60, null, prefKeyOauthTokenT);
account = parseAccountResponse(context, new JSONObject(response)); account = parseAccountResponse(context, new JSONObject(response));
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e); setError(e.getStatusCode(), e);
@ -204,7 +204,7 @@ public class API {
account = new Account(); account = new Account();
try { try {
String response = new HttpsConnection().get(getAbsoluteUrl(String.format("/accounts/%s",accountId)), 60, null, prefKeyOauthTokenT); String response = new HttpsConnection(context).get(getAbsoluteUrl(String.format("/accounts/%s",accountId)), 60, null, prefKeyOauthTokenT);
account = parseAccountResponse(context, new JSONObject(response)); account = parseAccountResponse(context, new JSONObject(response));
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e); setError(e.getStatusCode(), e);
@ -227,7 +227,7 @@ public class API {
HashMap<String, String> params = new HashMap<>(); HashMap<String, String> params = new HashMap<>();
params.put("id",accountId); params.put("id",accountId);
try { try {
String response = new HttpsConnection().get(getAbsoluteUrl("/accounts/relationships"), 60, params, prefKeyOauthTokenT); String response = new HttpsConnection(context).get(getAbsoluteUrl("/accounts/relationships"), 60, params, prefKeyOauthTokenT);
relationships = parseRelationshipResponse(new JSONArray(response)); relationships = parseRelationshipResponse(new JSONArray(response));
if( relationships != null && relationships.size() > 0) if( relationships != null && relationships.size() > 0)
relationship = relationships.get(0); relationship = relationships.get(0);
@ -259,7 +259,7 @@ public class API {
} }
List<Relationship> relationships = new ArrayList<>(); List<Relationship> relationships = new ArrayList<>();
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(getAbsoluteUrl("/accounts/relationships"), 60, params, prefKeyOauthTokenT); String response = httpsConnection.get(getAbsoluteUrl("/accounts/relationships"), 60, params, prefKeyOauthTokenT);
relationships = parseRelationshipResponse(new JSONArray(response)); relationships = parseRelationshipResponse(new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id()); apiResponse.setSince_id(httpsConnection.getSince_id());
@ -348,7 +348,7 @@ public class API {
statuses = new ArrayList<>(); statuses = new ArrayList<>();
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/accounts/%s/statuses", accountId)), 60, params, prefKeyOauthTokenT); String response = httpsConnection.get(getAbsoluteUrl(String.format("/accounts/%s/statuses", accountId)), 60, params, prefKeyOauthTokenT);
statuses = parseStatuses(new JSONArray(response)); statuses = parseStatuses(new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id()); apiResponse.setSince_id(httpsConnection.getSince_id());
@ -375,7 +375,7 @@ public class API {
statuses = new ArrayList<>(); statuses = new ArrayList<>();
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/statuses/%s", statusId)), 60, null, prefKeyOauthTokenT); String response = httpsConnection.get(getAbsoluteUrl(String.format("/statuses/%s", statusId)), 60, null, prefKeyOauthTokenT);
Status status = parseStatuses(context, new JSONObject(response)); Status status = parseStatuses(context, new JSONObject(response));
statuses.add(status); statuses.add(status);
@ -397,7 +397,7 @@ public class API {
public fr.gouv.etalab.mastodon.client.Entities.Context getStatusContext(String statusId) { public fr.gouv.etalab.mastodon.client.Entities.Context getStatusContext(String statusId) {
fr.gouv.etalab.mastodon.client.Entities.Context statusContext = new fr.gouv.etalab.mastodon.client.Entities.Context(); fr.gouv.etalab.mastodon.client.Entities.Context statusContext = new fr.gouv.etalab.mastodon.client.Entities.Context();
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/statuses/%s/context", statusId)), 60, null, prefKeyOauthTokenT); String response = httpsConnection.get(getAbsoluteUrl(String.format("/statuses/%s/context", statusId)), 60, null, prefKeyOauthTokenT);
statusContext = parseContext(new JSONObject(response)); statusContext = parseContext(new JSONObject(response));
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
@ -448,7 +448,7 @@ public class API {
params.put("limit",String.valueOf(limit)); params.put("limit",String.valueOf(limit));
statuses = new ArrayList<>(); statuses = new ArrayList<>();
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(getAbsoluteUrl("/timelines/home"), 60, params, prefKeyOauthTokenT); String response = httpsConnection.get(getAbsoluteUrl("/timelines/home"), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id()); apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id()); apiResponse.setMax_id(httpsConnection.getMax_id());
@ -507,7 +507,7 @@ public class API {
params.put("limit",String.valueOf(limit)); params.put("limit",String.valueOf(limit));
statuses = new ArrayList<>(); statuses = new ArrayList<>();
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(getAbsoluteUrl("/timelines/public"), 60, params, prefKeyOauthTokenT); String response = httpsConnection.get(getAbsoluteUrl("/timelines/public"), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id()); apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id()); apiResponse.setMax_id(httpsConnection.getMax_id());
@ -556,7 +556,7 @@ public class API {
params.put("limit",String.valueOf(limit)); params.put("limit",String.valueOf(limit));
statuses = new ArrayList<>(); statuses = new ArrayList<>();
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/timelines/tag/%s",tag.trim())), 60, params, prefKeyOauthTokenT); String response = httpsConnection.get(getAbsoluteUrl(String.format("/timelines/tag/%s",tag.trim())), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id()); apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id()); apiResponse.setMax_id(httpsConnection.getMax_id());
@ -630,7 +630,7 @@ public class API {
params.put("limit",String.valueOf(limit)); params.put("limit",String.valueOf(limit));
accounts = new ArrayList<>(); accounts = new ArrayList<>();
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT); String response = httpsConnection.get(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id()); apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id()); apiResponse.setMax_id(httpsConnection.getMax_id());
@ -673,7 +673,7 @@ public class API {
params.put("limit",String.valueOf(limit)); params.put("limit",String.valueOf(limit));
accounts = new ArrayList<>(); accounts = new ArrayList<>();
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(getAbsoluteUrl("/follow_requests"), 60, params, prefKeyOauthTokenT); String response = httpsConnection.get(getAbsoluteUrl("/follow_requests"), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id()); apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id()); apiResponse.setMax_id(httpsConnection.getMax_id());
@ -716,7 +716,7 @@ public class API {
params.put("limit",String.valueOf(limit)); params.put("limit",String.valueOf(limit));
statuses = new ArrayList<>(); statuses = new ArrayList<>();
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(getAbsoluteUrl("/favourites"), 60, params, prefKeyOauthTokenT); String response = httpsConnection.get(getAbsoluteUrl("/favourites"), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id()); apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id()); apiResponse.setMax_id(httpsConnection.getMax_id());
@ -752,7 +752,7 @@ public class API {
HashMap<String, String> params = new HashMap<>(); HashMap<String, String> params = new HashMap<>();
params.put("notifications", Boolean.toString(muteNotifications)); params.put("notifications", Boolean.toString(muteNotifications));
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
httpsConnection.post(getAbsoluteUrl(String.format("/accounts/%s/mute", targetedId)), 60, params, prefKeyOauthTokenT); httpsConnection.post(getAbsoluteUrl(String.format("/accounts/%s/mute", targetedId)), 60, params, prefKeyOauthTokenT);
actionCode = httpsConnection.getActionCode(); actionCode = httpsConnection.getActionCode();
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
@ -882,7 +882,7 @@ public class API {
if(statusAction != StatusAction.UNSTATUS ) { if(statusAction != StatusAction.UNSTATUS ) {
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
httpsConnection.post(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT); httpsConnection.post(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT);
actionCode = httpsConnection.getActionCode(); actionCode = httpsConnection.getActionCode();
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
@ -892,7 +892,7 @@ public class API {
} }
}else{ }else{
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
httpsConnection.delete(getAbsoluteUrl(action), 60, null, prefKeyOauthTokenT); httpsConnection.delete(getAbsoluteUrl(action), 60, null, prefKeyOauthTokenT);
actionCode = httpsConnection.getActionCode(); actionCode = httpsConnection.getActionCode();
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
@ -939,7 +939,7 @@ public class API {
statuses = new ArrayList<>(); statuses = new ArrayList<>();
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.post(getAbsoluteUrl("/statuses"), 60, params, prefKeyOauthTokenT); String response = httpsConnection.post(getAbsoluteUrl("/statuses"), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id()); apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id()); apiResponse.setMax_id(httpsConnection.getMax_id());
@ -971,7 +971,7 @@ public class API {
action = "/notifications/dismiss"; action = "/notifications/dismiss";
} }
try { try {
new HttpsConnection().post(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT); new HttpsConnection(context).post(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT);
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e); setError(e.getStatusCode(), e);
}catch (Exception e) { }catch (Exception e) {
@ -1060,7 +1060,7 @@ public class API {
List<Notification> notifications = new ArrayList<>(); List<Notification> notifications = new ArrayList<>();
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(getAbsoluteUrl("/notifications"), 60, params, prefKeyOauthTokenT); String response = httpsConnection.get(getAbsoluteUrl("/notifications"), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id()); apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id()); apiResponse.setMax_id(httpsConnection.getMax_id());
@ -1092,7 +1092,7 @@ public class API {
params.put("description", description); params.put("description", description);
} }
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.put(getAbsoluteUrl(String.format("/media/%s", mediaId)), 240, params, prefKeyOauthTokenT); String response = httpsConnection.put(getAbsoluteUrl(String.format("/media/%s", mediaId)), 240, params, prefKeyOauthTokenT);
attachment = parseAttachmentResponse(new JSONObject(response)); attachment = parseAttachmentResponse(new JSONObject(response));
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
@ -1114,7 +1114,7 @@ public class API {
HashMap<String, String> params = new HashMap<>(); HashMap<String, String> params = new HashMap<>();
params.put("q", query); params.put("q", query);
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(getAbsoluteUrl("/search"), 60, params, prefKeyOauthTokenT); String response = httpsConnection.get(getAbsoluteUrl("/search"), 60, params, prefKeyOauthTokenT);
results = parseResultsResponse(new JSONObject(response)); results = parseResultsResponse(new JSONObject(response));
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
@ -1158,7 +1158,7 @@ public class API {
params.put("limit", String.valueOf(count)); params.put("limit", String.valueOf(count));
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(getAbsoluteUrl("/accounts/search"), 60, params, prefKeyOauthTokenT); String response = httpsConnection.get(getAbsoluteUrl("/accounts/search"), 60, params, prefKeyOauthTokenT);
accounts = parseAccountResponse(new JSONArray(response)); accounts = parseAccountResponse(new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id()); apiResponse.setSince_id(httpsConnection.getSince_id());
@ -1184,7 +1184,7 @@ public class API {
public APIResponse getCustomEmoji() { public APIResponse getCustomEmoji() {
List<Emojis> emojis = new ArrayList<>(); List<Emojis> emojis = new ArrayList<>();
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(getAbsoluteUrl("/custom_emojis"), 60, null, prefKeyOauthTokenT); String response = httpsConnection.get(getAbsoluteUrl("/custom_emojis"), 60, null, prefKeyOauthTokenT);
emojis = parseEmojis(new JSONArray(response)); emojis = parseEmojis(new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id()); apiResponse.setSince_id(httpsConnection.getSince_id());
@ -1209,7 +1209,7 @@ public class API {
List<fr.gouv.etalab.mastodon.client.Entities.List> lists = new ArrayList<>(); List<fr.gouv.etalab.mastodon.client.Entities.List> lists = new ArrayList<>();
try { try {
String response = new HttpsConnection().get(getAbsoluteUrl("/lists"), 60, null, prefKeyOauthTokenT); String response = new HttpsConnection(context).get(getAbsoluteUrl("/lists"), 60, null, prefKeyOauthTokenT);
lists = parseLists(new JSONArray(response)); lists = parseLists(new JSONArray(response));
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e); setError(e.getStatusCode(), e);
@ -1229,7 +1229,7 @@ public class API {
List<fr.gouv.etalab.mastodon.client.Entities.List> lists = new ArrayList<>(); List<fr.gouv.etalab.mastodon.client.Entities.List> lists = new ArrayList<>();
fr.gouv.etalab.mastodon.client.Entities.List list; fr.gouv.etalab.mastodon.client.Entities.List list;
try { try {
String response = new HttpsConnection().get(getAbsoluteUrl(String.format("/accounts/%s/lists", userId)), 60, null, prefKeyOauthTokenT); String response = new HttpsConnection(context).get(getAbsoluteUrl(String.format("/accounts/%s/lists", userId)), 60, null, prefKeyOauthTokenT);
list = parseList(new JSONObject(response)); list = parseList(new JSONObject(response));
lists.add(list); lists.add(list);
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
@ -1261,7 +1261,7 @@ public class API {
params.put("limit",String.valueOf(limit)); params.put("limit",String.valueOf(limit));
statuses = new ArrayList<>(); statuses = new ArrayList<>();
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/timelines/list/%s",list_id)), 60, params, prefKeyOauthTokenT); String response = httpsConnection.get(getAbsoluteUrl(String.format("/timelines/list/%s",list_id)), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id()); apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id()); apiResponse.setMax_id(httpsConnection.getMax_id());
@ -1295,7 +1295,7 @@ public class API {
limit = 50; limit = 50;
params.put("limit",String.valueOf(limit)); params.put("limit",String.valueOf(limit));
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/lists/%s/accounts", listId)), 60, params, prefKeyOauthTokenT); String response = httpsConnection.get(getAbsoluteUrl(String.format("/lists/%s/accounts", listId)), 60, params, prefKeyOauthTokenT);
accounts = parseAccountResponse(new JSONArray(response)); accounts = parseAccountResponse(new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id()); apiResponse.setSince_id(httpsConnection.getSince_id());
@ -1321,7 +1321,7 @@ public class API {
List<fr.gouv.etalab.mastodon.client.Entities.List> lists = new ArrayList<>(); List<fr.gouv.etalab.mastodon.client.Entities.List> lists = new ArrayList<>();
fr.gouv.etalab.mastodon.client.Entities.List list; fr.gouv.etalab.mastodon.client.Entities.List list;
try { try {
String response = new HttpsConnection().get(getAbsoluteUrl(String.format("/lists/%s",id)), 60, null, prefKeyOauthTokenT); String response = new HttpsConnection(context).get(getAbsoluteUrl(String.format("/lists/%s",id)), 60, null, prefKeyOauthTokenT);
list = parseList(new JSONObject(response)); list = parseList(new JSONObject(response));
lists.add(list); lists.add(list);
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
@ -1355,7 +1355,7 @@ public class API {
List<fr.gouv.etalab.mastodon.client.Entities.List> lists = new ArrayList<>(); List<fr.gouv.etalab.mastodon.client.Entities.List> lists = new ArrayList<>();
fr.gouv.etalab.mastodon.client.Entities.List list; fr.gouv.etalab.mastodon.client.Entities.List list;
try { try {
new HttpsConnection().post(getAbsoluteUrl(String.format("/lists/%s/accounts", id)), 60, params, prefKeyOauthTokenT); new HttpsConnection(context).post(getAbsoluteUrl(String.format("/lists/%s/accounts", id)), 60, params, prefKeyOauthTokenT);
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e); setError(e.getStatusCode(), e);
}catch (Exception e) { }catch (Exception e) {
@ -1372,7 +1372,7 @@ public class API {
*/ */
public int deleteAccountFromList(String id, String[] account_ids){ public int deleteAccountFromList(String id, String[] account_ids){
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
StringBuilder parameters = new StringBuilder(); StringBuilder parameters = new StringBuilder();
HashMap<String, String> params = new HashMap<>(); HashMap<String, String> params = new HashMap<>();
for(String val: account_ids) for(String val: account_ids)
@ -1405,7 +1405,7 @@ public class API {
List<fr.gouv.etalab.mastodon.client.Entities.List> lists = new ArrayList<>(); List<fr.gouv.etalab.mastodon.client.Entities.List> lists = new ArrayList<>();
fr.gouv.etalab.mastodon.client.Entities.List list; fr.gouv.etalab.mastodon.client.Entities.List list;
try { try {
String response = new HttpsConnection().post(getAbsoluteUrl("/lists"), 60, params, prefKeyOauthTokenT); String response = new HttpsConnection(context).post(getAbsoluteUrl("/lists"), 60, params, prefKeyOauthTokenT);
list = parseList(new JSONObject(response)); list = parseList(new JSONObject(response));
lists.add(list); lists.add(list);
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
@ -1427,7 +1427,7 @@ public class API {
Card card = null; Card card = null;
try { try {
String response = new HttpsConnection().get(getAbsoluteUrl(String.format("/statuses/%s/card", statusId)), 60, null, prefKeyOauthTokenT); String response = new HttpsConnection(context).get(getAbsoluteUrl(String.format("/statuses/%s/card", statusId)), 60, null, prefKeyOauthTokenT);
card = parseCardResponse(new JSONObject(response)); card = parseCardResponse(new JSONObject(response));
}catch (Exception ignored) {ignored.printStackTrace();} }catch (Exception ignored) {ignored.printStackTrace();}
return card; return card;
@ -1446,7 +1446,7 @@ public class API {
List<fr.gouv.etalab.mastodon.client.Entities.List> lists = new ArrayList<>(); List<fr.gouv.etalab.mastodon.client.Entities.List> lists = new ArrayList<>();
fr.gouv.etalab.mastodon.client.Entities.List list; fr.gouv.etalab.mastodon.client.Entities.List list;
try { try {
String response = new HttpsConnection().put(getAbsoluteUrl(String.format("/lists/%s", id)), 60, params, prefKeyOauthTokenT); String response = new HttpsConnection(context).put(getAbsoluteUrl(String.format("/lists/%s", id)), 60, params, prefKeyOauthTokenT);
list = parseList(new JSONObject(response)); list = parseList(new JSONObject(response));
lists.add(list); lists.add(list);
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {
@ -1466,7 +1466,7 @@ public class API {
*/ */
public int deleteList(String id){ public int deleteList(String id){
try { try {
HttpsConnection httpsConnection = new HttpsConnection(); HttpsConnection httpsConnection = new HttpsConnection(context);
httpsConnection.delete(getAbsoluteUrl(String.format("/lists/%s", id)), 60, null, prefKeyOauthTokenT); httpsConnection.delete(getAbsoluteUrl(String.format("/lists/%s", id)), 60, null, prefKeyOauthTokenT);
actionCode = httpsConnection.getActionCode(); actionCode = httpsConnection.getActionCode();
} catch (HttpsConnection.HttpsConnectionException e) { } catch (HttpsConnection.HttpsConnectionException e) {

View File

@ -31,7 +31,11 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.Authenticator;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.net.URL; import java.net.URL;
import java.security.KeyManagementException; import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
@ -66,11 +70,32 @@ public class HttpsConnection {
private String since_id, max_id; private String since_id, max_id;
private Context context; private Context context;
private int CHUNK_SIZE = 4096; private int CHUNK_SIZE = 4096;
private SharedPreferences sharedpreferences;
private Proxy proxy;
public HttpsConnection(){}
public HttpsConnection(Context context){ public HttpsConnection(Context context){
this.context = context; this.context = context;
sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean proxyEnabled = sharedpreferences.getBoolean(Helper.SET_PROXY_ENABLED, false);
proxy = null;
if( proxyEnabled ){
String host = sharedpreferences.getString(Helper.SET_PROXY_HOST, "127.0.0.1");
int port = sharedpreferences.getInt(Helper.SET_PROXY_PORT, 8118);
proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(host, port));
final String login = sharedpreferences.getString(Helper.SET_PROXY_LOGIN, null);
final String pwd = sharedpreferences.getString(Helper.SET_PROXY_PASSWORD, null);
if( login != null) {
Authenticator authenticator = new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
assert pwd != null;
return (new PasswordAuthentication(login,
pwd.toCharArray()));
}
};
Authenticator.setDefault(authenticator);
}
}
} }
@ -95,7 +120,10 @@ public class HttpsConnection {
postData.append(String.valueOf(param.getValue())); postData.append(String.valueOf(param.getValue()));
} }
URL url = new URL(urlConnection + "?" + postData); URL url = new URL(urlConnection + "?" + postData);
httpsURLConnection = (HttpsURLConnection)url.openConnection(); if( proxy !=null )
httpsURLConnection = (HttpsURLConnection)url.openConnection(proxy);
else
httpsURLConnection = (HttpsURLConnection)url.openConnection();
httpsURLConnection.setConnectTimeout(timeout * 1000); httpsURLConnection.setConnectTimeout(timeout * 1000);
httpsURLConnection.setRequestProperty("http.keepAlive", "false"); httpsURLConnection.setRequestProperty("http.keepAlive", "false");
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT); httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
@ -124,7 +152,10 @@ public class HttpsConnection {
HttpURLConnection httpURLConnection; HttpURLConnection httpURLConnection;
if( urlConnection.startsWith("https://")) { if( urlConnection.startsWith("https://")) {
URL url = new URL(urlConnection); URL url = new URL(urlConnection);
httpsURLConnection = (HttpsURLConnection) url.openConnection(); if( proxy !=null )
httpsURLConnection = (HttpsURLConnection)url.openConnection(proxy);
else
httpsURLConnection = (HttpsURLConnection)url.openConnection();
httpsURLConnection.setConnectTimeout(30 * 1000); httpsURLConnection.setConnectTimeout(30 * 1000);
httpsURLConnection.setRequestProperty("http.keepAlive", "false"); httpsURLConnection.setRequestProperty("http.keepAlive", "false");
httpsURLConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"); httpsURLConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36");
@ -145,7 +176,10 @@ public class HttpsConnection {
return response; return response;
}else{ }else{
URL url = new URL(urlConnection); URL url = new URL(urlConnection);
httpURLConnection = (HttpURLConnection) url.openConnection(); if( proxy !=null )
httpURLConnection = (HttpURLConnection)url.openConnection(proxy);
else
httpURLConnection = (HttpURLConnection)url.openConnection();
httpURLConnection.setConnectTimeout(30 * 1000); httpURLConnection.setConnectTimeout(30 * 1000);
httpURLConnection.setRequestProperty("http.keepAlive", "false"); httpURLConnection.setRequestProperty("http.keepAlive", "false");
httpURLConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"); httpURLConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36");
@ -188,7 +222,10 @@ public class HttpsConnection {
} }
byte[] postDataBytes = postData.toString().getBytes("UTF-8"); byte[] postDataBytes = postData.toString().getBytes("UTF-8");
httpsURLConnection = (HttpsURLConnection)url.openConnection(); if( proxy !=null )
httpsURLConnection = (HttpsURLConnection)url.openConnection(proxy);
else
httpsURLConnection = (HttpsURLConnection)url.openConnection();
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT); httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
httpsURLConnection.setConnectTimeout(timeout * 1000); httpsURLConnection.setConnectTimeout(timeout * 1000);
httpsURLConnection.setDoOutput(true); httpsURLConnection.setDoOutput(true);
@ -231,7 +268,10 @@ public class HttpsConnection {
if (downloadUrl.startsWith("https://")) { if (downloadUrl.startsWith("https://")) {
try { try {
url = new URL(downloadUrl); url = new URL(downloadUrl);
httpsURLConnection = (HttpsURLConnection) url.openConnection(); if( proxy !=null )
httpsURLConnection = (HttpsURLConnection)url.openConnection(proxy);
else
httpsURLConnection = (HttpsURLConnection)url.openConnection();
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT); httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
int responseCode = httpsURLConnection.getResponseCode(); int responseCode = httpsURLConnection.getResponseCode();
@ -318,7 +358,10 @@ public class HttpsConnection {
} else { } else {
try { try {
url = new URL(downloadUrl); url = new URL(downloadUrl);
httpURLConnection = (HttpURLConnection) url.openConnection(); if( proxy !=null )
httpURLConnection = (HttpURLConnection)url.openConnection(proxy);
else
httpURLConnection = (HttpURLConnection)url.openConnection();
httpURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT); httpURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
int responseCode = httpURLConnection.getResponseCode(); int responseCode = httpURLConnection.getResponseCode();
@ -412,7 +455,10 @@ public class HttpsConnection {
public InputStream getPicture(final String downloadUrl) { public InputStream getPicture(final String downloadUrl) {
try { try {
URL url = new URL(downloadUrl); URL url = new URL(downloadUrl);
httpsURLConnection = (HttpsURLConnection) url.openConnection(); if( proxy !=null )
httpsURLConnection = (HttpsURLConnection)url.openConnection(proxy);
else
httpsURLConnection = (HttpsURLConnection)url.openConnection();
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory()); httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT); httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
int responseCode = httpsURLConnection.getResponseCode(); int responseCode = httpsURLConnection.getResponseCode();
@ -449,7 +495,6 @@ public class HttpsConnection {
String boundary = "*****" + Long.toString(System.currentTimeMillis()) + "*****"; String boundary = "*****" + Long.toString(System.currentTimeMillis()) + "*****";
String lineEnd = "\r\n"; String lineEnd = "\r\n";
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null); String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
final URL url = new URL("https://"+Helper.getLiveInstance(context)+"/api/v1/media"); final URL url = new URL("https://"+Helper.getLiveInstance(context)+"/api/v1/media");
ByteArrayOutputStream ous = null; ByteArrayOutputStream ous = null;
@ -475,7 +520,10 @@ public class HttpsConnection {
lengthSent += ("Content-Disposition: form-data; name=\"file\";filename=\"picture.png\"" + lineEnd).getBytes().length; lengthSent += ("Content-Disposition: form-data; name=\"file\";filename=\"picture.png\"" + lineEnd).getBytes().length;
lengthSent += 2 * (lineEnd).getBytes().length; lengthSent += 2 * (lineEnd).getBytes().length;
httpsURLConnection = (HttpsURLConnection) url.openConnection(); if( proxy !=null )
httpsURLConnection = (HttpsURLConnection)url.openConnection(proxy);
else
httpsURLConnection = (HttpsURLConnection)url.openConnection();
httpsURLConnection.setFixedLengthStreamingMode(lengthSent); httpsURLConnection.setFixedLengthStreamingMode(lengthSent);
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT); httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
@ -599,7 +647,10 @@ public class HttpsConnection {
} }
byte[] postDataBytes = postData.toString().getBytes("UTF-8"); byte[] postDataBytes = postData.toString().getBytes("UTF-8");
httpsURLConnection = (HttpsURLConnection)url.openConnection(); if( proxy !=null )
httpsURLConnection = (HttpsURLConnection)url.openConnection(proxy);
else
httpsURLConnection = (HttpsURLConnection)url.openConnection();
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT); httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
httpsURLConnection.setConnectTimeout(timeout * 1000); httpsURLConnection.setConnectTimeout(timeout * 1000);
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory()); httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
@ -650,7 +701,10 @@ public class HttpsConnection {
} }
byte[] postDataBytes = postData.toString().getBytes("UTF-8"); byte[] postDataBytes = postData.toString().getBytes("UTF-8");
httpsURLConnection = (HttpsURLConnection)url.openConnection(); if( proxy !=null )
httpsURLConnection = (HttpsURLConnection)url.openConnection(proxy);
else
httpsURLConnection = (HttpsURLConnection)url.openConnection();
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT); httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
httpsURLConnection.setConnectTimeout(timeout * 1000); httpsURLConnection.setConnectTimeout(timeout * 1000);
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory()); httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
@ -699,7 +753,10 @@ public class HttpsConnection {
} }
byte[] postDataBytes = postData.toString().getBytes("UTF-8"); byte[] postDataBytes = postData.toString().getBytes("UTF-8");
httpsURLConnection = (HttpsURLConnection)url.openConnection(); if( proxy !=null )
httpsURLConnection = (HttpsURLConnection)url.openConnection(proxy);
else
httpsURLConnection = (HttpsURLConnection)url.openConnection();
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT); httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory()); httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
if( token != null) if( token != null)

View File

@ -270,6 +270,7 @@ public class Helper {
//Proxy //Proxy
public static final String SET_PROXY_ENABLED = "set_proxy_enabled";
public static final String SET_PROXY_HOST = "set_proxy_host"; public static final String SET_PROXY_HOST = "set_proxy_host";
public static final String SET_PROXY_PORT = "set_proxy_port"; public static final String SET_PROXY_PORT = "set_proxy_port";
public static final String SET_PROXY_LOGIN = "set_proxy_login"; public static final String SET_PROXY_LOGIN = "set_proxy_login";