Merge branch 'ssl_tor_onion' into develop

This commit is contained in:
tom79 2019-05-23 19:05:32 +02:00
commit 29f10a594e
20 changed files with 218 additions and 187 deletions

View File

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

View File

@ -149,7 +149,7 @@ public class LoginActivity extends BaseActivity {
@Override
public void run() {
try {
final String response = new HttpsConnection(LoginActivity.this).post(Helper.instanceWithProtocol(instance) + action, 30, parameters, null);
final String response = new HttpsConnection(LoginActivity.this, instance).post(Helper.instanceWithProtocol(instance) + action, 30, parameters, null);
JSONObject resobj;
try {
resobj = new JSONObject(response);
@ -354,7 +354,7 @@ public class LoginActivity extends BaseActivity {
@Override
public void run() {
try {
final String response = new HttpsConnection(LoginActivity.this).get("https://instances.social/api/1.0" + action, 30, parameters, Helper.THEKINRAR_SECRET_TOKEN);
final String response = new HttpsConnection(LoginActivity.this, instance).get("https://instances.social/api/1.0" + action, 30, parameters, Helper.THEKINRAR_SECRET_TOKEN);
runOnUiThread(new Runnable() {
public void run() {
isLoadingInstance = false;
@ -542,9 +542,9 @@ public class LoginActivity extends BaseActivity {
try {
String response;
if( socialNetwork == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
response = new HttpsConnection(LoginActivity.this).get(Helper.instanceWithProtocol(instance) + actionToken, 30, parameters, null );
response = new HttpsConnection(LoginActivity.this, instance).get(Helper.instanceWithProtocol(instance) + actionToken, 30, parameters, null );
else
response = new HttpsConnection(LoginActivity.this).post(Helper.instanceWithProtocol(instance) + actionToken, 30, parameters, null );
response = new HttpsConnection(LoginActivity.this, instance).post(Helper.instanceWithProtocol(instance) + actionToken, 30, parameters, null );
runOnUiThread(new Runnable() {
public void run() {
JSONObject resobj;
@ -647,9 +647,9 @@ public class LoginActivity extends BaseActivity {
try {
String response;
if( socialNetwork != UpdateAccountInfoAsyncTask.SOCIAL.GNU)
response = new HttpsConnection(LoginActivity.this).post(Helper.instanceWithProtocol(instance) + finalOauthUrl, 30, parameters, null );
response = new HttpsConnection(LoginActivity.this, instance).post(Helper.instanceWithProtocol(instance) + finalOauthUrl, 30, parameters, null );
else {
response = new HttpsConnection(LoginActivity.this).get(Helper.instanceWithProtocol(instance) + finalOauthUrl, 30, null, basicAuth);
response = new HttpsConnection(LoginActivity.this, instance).get(Helper.instanceWithProtocol(instance) + finalOauthUrl, 30, null, basicAuth);
}
runOnUiThread(new Runnable() {
public void run() {

View File

@ -115,6 +115,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
private boolean scheduleHidden, scheduleHiddenDescription;
private SimpleExoPlayer player;
private boolean isSHaring;
private String instance;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -146,6 +147,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
}
}
});
instance = Helper.getLiveInstance(MediaActivity.this);
mSwipeBackLayout.attachToActivity(this);
attachments = getIntent().getParcelableArrayListExtra("mediaArray");
if( getIntent().getExtras() != null)
@ -177,7 +179,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
if( attachment != null ) {
progress.setText("0 %");
progress.setVisibility(View.VISIBLE);
new HttpsConnection(MediaActivity.this).download(attachment.getUrl(), MediaActivity.this);
new HttpsConnection(MediaActivity.this, instance).download(attachment.getUrl(), MediaActivity.this);
}
}else {
if (Build.VERSION.SDK_INT >= 23) {
@ -200,7 +202,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
if( attachment != null ) {
progress.setText("0 %");
progress.setVisibility(View.VISIBLE);
new HttpsConnection(MediaActivity.this).download(attachment.getUrl(), MediaActivity.this);
new HttpsConnection(MediaActivity.this, instance).download(attachment.getUrl(), MediaActivity.this);
}
}else {
if (Build.VERSION.SDK_INT >= 23) {
@ -441,7 +443,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
pbar_inf.setIndeterminate(false);
pbar_inf.setScaleY(3f);
try {
HttpsURLConnection.setDefaultSSLSocketFactory(new TLSSocketFactory());
HttpsURLConnection.setDefaultSSLSocketFactory(new TLSSocketFactory(instance));
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {

View File

@ -134,7 +134,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
private ImageView my_pp, send;
private TextView add_comment_read;
private EditText add_comment_write;
private String instance;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -206,7 +206,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
});
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
Helper.loadGiF(getApplicationContext(), account.getAvatar(), my_pp);
Bundle b = getIntent().getExtras();
@ -544,7 +544,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
}
try {
HttpsURLConnection.setDefaultSSLSocketFactory(new TLSSocketFactory());
HttpsURLConnection.setDefaultSSLSocketFactory(new TLSSocketFactory(instance));
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {

View File

@ -94,6 +94,7 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
private boolean isLoadingInstance;
private String oldSearch;
private int theme;
private String instance;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -124,6 +125,7 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
style = R.style.Dialog;
}
if( getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ActionBar actionBar = getSupportActionBar();
@ -170,15 +172,15 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
public void run() {
try {
if(radioGroup.getCheckedRadioButtonId() == R.id.mastodon_instance)
new HttpsConnection(ReorderTimelinesActivity.this).get("https://" + instanceName + "/api/v1/timelines/public?local=true", 10, null, null);
new HttpsConnection(ReorderTimelinesActivity.this, null).get("https://" + instanceName + "/api/v1/timelines/public?local=true", 10, null, null);
else if( radioGroup.getCheckedRadioButtonId() == R.id.peertube_instance)
new HttpsConnection(ReorderTimelinesActivity.this).get("https://" + instanceName + "/api/v1/videos/", 10, null, null);
new HttpsConnection(ReorderTimelinesActivity.this, null).get("https://" + instanceName + "/api/v1/videos/", 10, null, null);
else if( radioGroup.getCheckedRadioButtonId() == R.id.pixelfed_instance) {
new HttpsConnection(ReorderTimelinesActivity.this).get("https://" + instanceName + "/api/v1/timelines/public", 10, null, null);
new HttpsConnection(ReorderTimelinesActivity.this, null).get("https://" + instanceName + "/api/v1/timelines/public", 10, null, null);
}else if( radioGroup.getCheckedRadioButtonId() == R.id.misskey_instance) {
new HttpsConnection(ReorderTimelinesActivity.this).post("https://" + instanceName + "/api/notes/local-timeline", 10, null, null);
new HttpsConnection(ReorderTimelinesActivity.this, null).post("https://" + instanceName + "/api/notes/local-timeline", 10, null, null);
}else if( radioGroup.getCheckedRadioButtonId() == R.id.gnu_instance) {
new HttpsConnection(ReorderTimelinesActivity.this).get("https://" + instanceName + "/api/statuses/public_timeline.json", 10, null, null);
new HttpsConnection(ReorderTimelinesActivity.this, null).get("https://" + instanceName + "/api/statuses/public_timeline.json", 10, null, null);
}
runOnUiThread(new Runnable() {
@ -277,7 +279,7 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
@Override
public void run() {
try {
final String response = new HttpsConnection(ReorderTimelinesActivity.this).get("https://instances.social/api/1.0" + action, 30, parameters, Helper.THEKINRAR_SECRET_TOKEN);
final String response = new HttpsConnection(ReorderTimelinesActivity.this, null).get("https://instances.social/api/1.0" + action, 30, parameters, Helper.THEKINRAR_SECRET_TOKEN);
runOnUiThread(new Runnable() {
public void run() {
isLoadingInstance = false;

View File

@ -1099,14 +1099,14 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
if( !peertubeAccount) {
//Here we can't know if the instance is a Mastodon one or not
try { //Testing Mastodon
new HttpsConnection(ShowAccountActivity.this).get("https://" + finalInstanceName + "/api/v1/timelines/public?local=true", 10, null, null);
new HttpsConnection(ShowAccountActivity.this, null).get("https://" + finalInstanceName + "/api/v1/timelines/public?local=true", 10, null, null);
}catch (Exception ignored){
new HttpsConnection(ShowAccountActivity.this).get("https://" + finalInstanceName + "/api/v1/videos/", 10, null, null);
new HttpsConnection(ShowAccountActivity.this, null).get("https://" + finalInstanceName + "/api/v1/videos/", 10, null, null);
peertubeAccount = true;
}
}
else
new HttpsConnection(ShowAccountActivity.this).get("https://" + finalInstanceName + "/api/v1/videos/", 10, null, null);
new HttpsConnection(ShowAccountActivity.this, null).get("https://" + finalInstanceName + "/api/v1/videos/", 10, null, null);
runOnUiThread(new Runnable() {
public void run() {

View File

@ -199,7 +199,8 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
private AlertDialog alertDialogEmoji;
private String mentionAccount;
private Status idRedirect;
private String userId, instance;
private String userId;
private static String instance;
private Account account;
private ArrayList<String> splitToot;
private int stepSpliToot;
@ -467,7 +468,7 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
picture_scrollview.setVisibility(View.VISIBLE);
toot_picture.setEnabled(false);
toot_it.setEnabled(false);
new HttpsConnection(TootActivity.this).upload(bs, fileMention, accountReply!=null?accountReply.getToken():null, TootActivity.this);
new HttpsConnection(TootActivity.this, instance).upload(bs, fileMention, accountReply!=null?accountReply.getToken():null, TootActivity.this);
}
});
@ -513,7 +514,7 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
toot_space_left.setText(String.valueOf(toot_content.length()));
}
if (image != null) {
new HttpsConnection(TootActivity.this).download(image, TootActivity.this);
new HttpsConnection(TootActivity.this, instance).download(image, TootActivity.this);
}
int selectionBefore = toot_content.getSelectionStart();
toot_content.setText(String.format("\n%s", sharedContent));
@ -894,7 +895,7 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
String mime = cr.getType(data.getData());
if(mime != null && (mime.toLowerCase().contains("video") || mime.toLowerCase().contains("gif")) ) {
InputStream inputStream = getContentResolver().openInputStream(data.getData());
new HttpsConnection(TootActivity.this).upload(inputStream, filename, accountReply!=null?accountReply.getToken():null, TootActivity.this);
new HttpsConnection(TootActivity.this, instance).upload(inputStream, filename, accountReply!=null?accountReply.getToken():null, TootActivity.this);
} else if(mime != null && mime.toLowerCase().contains("image")) {
new asyncPicture(TootActivity.this, accountReply, data.getData()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}else {
@ -979,7 +980,7 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
toot_it.setEnabled(false);
String filename = Helper.getFileName(this.activityWeakReference.get(), uriFile);
filesMap.put(filename, uriFile);
new HttpsConnection(this.activityWeakReference.get()).upload(bs, filename, accountReply != null ? accountReply.getToken() : null, (TootActivity) this.activityWeakReference.get());
new HttpsConnection(this.activityWeakReference.get(), instance).upload(bs, filename, accountReply != null ? accountReply.getToken() : null, (TootActivity) this.activityWeakReference.get());
}
}
}
@ -1002,7 +1003,7 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
String mime = cr.getType(imageUri);
if(mime != null && (mime.toLowerCase().contains("video") || mime.toLowerCase().contains("gif")) ) {
InputStream inputStream = getContentResolver().openInputStream(imageUri);
new HttpsConnection(TootActivity.this).upload(inputStream, filename, accountReply!=null?accountReply.getToken():null, TootActivity.this);
new HttpsConnection(TootActivity.this, instance).upload(inputStream, filename, accountReply!=null?accountReply.getToken():null, TootActivity.this);
} else if(mime != null && mime.toLowerCase().contains("image")) {
new asyncPicture(TootActivity.this, accountReply, intent.getData()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}else {
@ -1797,7 +1798,7 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
toot_picture_container.setVisibility(View.VISIBLE);
toot_picture.setEnabled(false);
toot_it.setEnabled(false);
new HttpsConnection(TootActivity.this).upload(bs, filename, accountReply!=null?accountReply.getToken():null, TootActivity.this);
new HttpsConnection(TootActivity.this, instance).upload(bs, filename, accountReply!=null?accountReply.getToken():null, TootActivity.this);
}
}

View File

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

View File

@ -89,7 +89,7 @@ public class RetrieveMetaDataAsyncTask extends AsyncTask<Void, Void, Void> {
Pattern descriptionPattern = Pattern.compile("meta[ a-zA-Z=\"'-]+property=[\"']og:description[\"']\\s+content=[\"']([^>]*)[\"']");
Pattern imagePattern = Pattern.compile("meta[ a-zA-Z=\"'-]+property=[\"']og:image[\"']\\s+content=[\"']([^>]*)[\"']");
try {
String response = new HttpsConnection(this.contextWeakReference.get()).get(potentialUrl);
String response = new HttpsConnection(this.contextWeakReference.get(), null).get(potentialUrl);
Matcher matcherTitle = titlePattern.matcher(response);
Matcher matcherDescription = descriptionPattern.matcher(response);
Matcher matcherImage = imagePattern.matcher(response);

View File

@ -182,7 +182,7 @@ public class API {
String response;
InstanceNodeInfo instanceNodeInfo = new InstanceNodeInfo();
try {
response = new HttpsConnection(context).get("https://" + domain + "/.well-known/nodeinfo", 30, null, null);
response = new HttpsConnection(context, this.instance).get("https://" + domain + "/.well-known/nodeinfo", 30, null, null);
JSONArray jsonArray = new JSONObject(response).getJSONArray("links");
ArrayList<NodeInfo> nodeInfos = new ArrayList<>();
try {
@ -198,7 +198,7 @@ public class API {
}
if( nodeInfos.size() > 0){
NodeInfo nodeInfo = nodeInfos.get(0);
response = new HttpsConnection(context).get(nodeInfo.getHref(), 30, null, null);
response = new HttpsConnection(context, this.instance).get(nodeInfo.getHref(), 30, null, null);
JSONObject resobj = new JSONObject(response);
JSONObject jsonObject = resobj.getJSONObject("software");
String name = jsonObject.getString("name").toUpperCase();
@ -229,7 +229,7 @@ public class API {
e.printStackTrace();
} catch (HttpsConnection.HttpsConnectionException e) {
try {
response = new HttpsConnection(context).get("https://" + domain + "/api/v1/instance", 30, null, null);
response = new HttpsConnection(context, this.instance).get("https://" + domain + "/api/v1/instance", 30, null, null);
JSONObject jsonObject = new JSONObject(response);
instanceNodeInfo.setName("MASTODON");
instanceNodeInfo.setVersion(jsonObject.getString("version"));
@ -288,7 +288,7 @@ public class API {
*/
public APIResponse getInstance() {
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl("/instance"), 30, null, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/instance"), 30, null, prefKeyOauthTokenT);
Instance instanceEntity = parseInstance(new JSONObject(response));
apiResponse.setInstance(instanceEntity);
} catch (HttpsConnection.HttpsConnectionException e) {
@ -343,7 +343,7 @@ public class API {
requestParams.put("source[sensitive]", String.valueOf(sensitive));
}
try {
new HttpsConnection(context).patch(getAbsoluteUrl("/accounts/update_credentials"), 60, requestParams, avatar, avatarName, header, headerName, prefKeyOauthTokenT);
new HttpsConnection(context, this.instance).patch(getAbsoluteUrl("/accounts/update_credentials"), 60, requestParams, avatar, avatarName, header, headerName, prefKeyOauthTokenT);
} catch (HttpsConnection.HttpsConnectionException e) {
e.printStackTrace();
setError(e.getStatusCode(), e);
@ -368,7 +368,7 @@ public class API {
setError(500, new Throwable("An error occured!"));
return null;
}
String response = new HttpsConnection(context).get(getAbsoluteUrl("/accounts/verify_credentials"), 60, null, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/accounts/verify_credentials"), 60, null, prefKeyOauthTokenT);
account = parseAccountResponse(context, new JSONObject(response));
if( account.getSocial().equals("PLEROMA")){
isPleromaAdmin(account.getAcct());
@ -396,7 +396,7 @@ public class API {
new AccountDAO(context, db).updateAccountCredential(targetedAccount);
String response;
try {
response = new HttpsConnection(context).get(getAbsoluteUrl("/accounts/verify_credentials"), 60, null, targetedAccount.getToken());
response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/accounts/verify_credentials"), 60, null, targetedAccount.getToken());
account = parseAccountResponse(context, new JSONObject(response));
if( account.getSocial().equals("PLEROMA")){
isPleromaAdmin(account.getAcct());
@ -440,7 +440,7 @@ public class API {
params.put("client_secret", client_secret);
params.put("refresh_token", refresh_token);
try {
String response = new HttpsConnection(context).post(getAbsoluteUrl("/oauth/token"), 60, params, null);
String response = new HttpsConnection(context, this.instance).post(getAbsoluteUrl("/oauth/token"), 60, params, null);
JSONObject resobj = new JSONObject(response);
String token = resobj.get("access_token").toString();
if( resobj.has("refresh_token"))
@ -472,7 +472,7 @@ public class API {
account = new Account();
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl(String.format("/accounts/%s",accountId)), 60, null, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl(String.format("/accounts/%s",accountId)), 60, null, prefKeyOauthTokenT);
account = parseAccountResponse(context, new JSONObject(response));
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
@ -506,7 +506,7 @@ public class API {
HashMap<String, String> params = new HashMap<>();
params.put("id",accountId);
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl("/accounts/relationships"), 60, params, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/accounts/relationships"), 60, params, prefKeyOauthTokenT);
relationships = parseRelationshipResponse(new JSONArray(response));
if( relationships != null && relationships.size() > 0)
relationship = relationships.get(0);
@ -543,7 +543,7 @@ public class API {
params.put("id[]", parameters.toString());
List<Relationship> relationships = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/accounts/relationships"), 60, params, prefKeyOauthTokenT);
relationships = parseRelationshipResponse(new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id());
@ -654,7 +654,7 @@ public class API {
}
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/accounts/%s/statuses", accountId)), 60, params, prefKeyOauthTokenT);
statuses = parseStatuses(context, new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id());
@ -693,7 +693,7 @@ public class API {
params.put("limit", "80");
accounts = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/statuses/%s/reblogged_by", statusId)), 60, params, prefKeyOauthTokenT);
accounts = parseAccountResponse(new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id());
@ -731,7 +731,7 @@ public class API {
params.put("limit", "80");
accounts = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/statuses/%s/favourited_by", statusId)), 60, params, prefKeyOauthTokenT);
accounts = parseAccountResponse(new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id());
@ -763,7 +763,7 @@ public class API {
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/statuses/%s", statusId)), 60, null, prefKeyOauthTokenT);
Status status = parseStatuses(context, new JSONObject(response));
statuses.add(status);
@ -791,7 +791,7 @@ public class API {
public APIResponse getStatusbyIdAndCache(String statusId) {
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/statuses/%s", statusId)), 60, null, prefKeyOauthTokenT);
Status status = parseStatuses(context, new JSONObject(response));
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
@ -821,7 +821,7 @@ public class API {
public app.fedilab.android.client.Entities.Context getStatusContext(String statusId) {
app.fedilab.android.client.Entities.Context statusContext = new app.fedilab.android.client.Entities.Context();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/statuses/%s/context", statusId)), 60, null, prefKeyOauthTokenT);
statusContext = parseContext(new JSONObject(response));
} catch (HttpsConnection.HttpsConnectionException e) {
@ -884,7 +884,7 @@ public class API {
params.put("limit",String.valueOf(limit));
conversations = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/conversations"), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id());
@ -931,7 +931,7 @@ public class API {
params.put("limit",String.valueOf(limit));
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/timelines/direct"), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id());
@ -1045,7 +1045,7 @@ public class API {
params.put("limit",String.valueOf(limit));
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/timelines/home"), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id());
@ -1080,7 +1080,7 @@ public class API {
params.put("max_id", max_id);
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get("https://"+remoteInstance+"/api/statuses/public_timeline.json", 60, params, prefKeyOauthTokenT);
statuses = GNUAPI.parseStatuses(context, new JSONArray(response));
if( statuses.size() > 0) {
@ -1115,7 +1115,7 @@ public class API {
params.put("page", max_id);
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrlRemote(remoteInstance, "/timelines/public/"), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id());
@ -1142,7 +1142,7 @@ public class API {
List<Account> accounts = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(String.format("https://"+instance+"/api/v1/accounts/%s/video-channels", name), 60, null, null);
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
accounts = parseAccountResponsePeertube(context, instance, jsonArray);
@ -1170,7 +1170,7 @@ public class API {
List<Peertube> peertubes = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(String.format("https://"+instance+"/api/v1/video-channels/%s/videos", name), 60, null, null);
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
peertubes = parsePeertube(instance, jsonArray);
@ -1205,7 +1205,7 @@ public class API {
params.put("count", "20");
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get("https://"+instance+"/api/v1/videos", 60, params, null);
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
peertubes = parsePeertube(instance, jsonArray);
@ -1233,7 +1233,7 @@ public class API {
Peertube peertube = null;
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(String.format("https://"+instance+"/api/v1/videos/%s", videoId), 60, null, null);
JSONObject jsonObject = new JSONObject(response);
peertube = parseSinglePeertube(context, instance, jsonObject);
@ -1270,7 +1270,7 @@ public class API {
}
List<Peertube> peertubes = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get("https://"+instance+"/api/v1/search/videos", 60, params, null);
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
peertubes = parsePeertube(instance, jsonArray);
@ -1296,7 +1296,7 @@ public class API {
public APIResponse getSinglePeertubeComments(String instance, String videoId) {
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(String.format("https://"+instance+"/api/v1/videos/%s/comment-threads", videoId), 60, null, null);
JSONObject jsonObject = new JSONObject(response);
statuses = parseSinglePeertubeComments(context, instance, jsonObject);
@ -1323,7 +1323,7 @@ public class API {
List<HowToVideo> howToVideos = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get("https://peertube.social/api/v1/video-channels/mastalab_channel/videos", 60, null, null);
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
howToVideos = parseHowTos(jsonArray);
@ -1364,7 +1364,7 @@ public class API {
try {
statuses = new ArrayList<>();
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.postMisskey("https://"+instance+"/api/notes", 60, params, null);
statuses = parseNotes(context, instance, new JSONArray(response));
if( statuses != null && statuses.size() > 0){
@ -1447,7 +1447,7 @@ public class API {
params.put("limit",String.valueOf(limit));
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String url;
if( instanceName == null)
url = getAbsoluteUrl("/timelines/public");
@ -1506,7 +1506,7 @@ public class API {
params.put("limit",String.valueOf(limit));
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String url;
url = getAbsoluteUr2l("/discover/posts");
String response = httpsConnection.get(url, 60, params, prefKeyOauthTokenT);
@ -1665,7 +1665,7 @@ public class API {
return null;
try {
String query = tag.trim();
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
try {
query = URLEncoder.encode(query, "UTF-8");
@ -1750,7 +1750,7 @@ public class API {
params.put("limit",String.valueOf(limit));
accounts = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id());
@ -1786,7 +1786,7 @@ public class API {
results = new Results();
accounts = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get("https://opencollective.com/mastalab/members/all.json", 60, null, prefKeyOauthTokenT);
accounts = parseOpencollectiveAccountResponse(context, type, new JSONArray(response));
} catch (HttpsConnection.HttpsConnectionException e) {
@ -1820,7 +1820,7 @@ public class API {
params.put("limit","80");
domains = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/domain_blocks"), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id());
@ -1853,7 +1853,7 @@ public class API {
domains = new ArrayList<>();
HttpsConnection httpsConnection;
try {
httpsConnection = new HttpsConnection(context);
httpsConnection = new HttpsConnection(context, this.instance);
httpsConnection.delete(getAbsoluteUrl("/domain_blocks"), 60, params, prefKeyOauthTokenT);
actionCode = httpsConnection.getActionCode();
} catch (HttpsConnection.HttpsConnectionException e) {
@ -1896,7 +1896,7 @@ public class API {
params.put("limit",String.valueOf(limit));
accounts = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/follow_requests"), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id());
@ -1945,7 +1945,7 @@ public class API {
params.put("limit",String.valueOf(limit));
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/favourites"), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id());
@ -1987,7 +1987,7 @@ public class API {
HashMap<String, String> params = new HashMap<>();
params.put("notifications", Boolean.toString(muteNotifications));
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
httpsConnection.post(getAbsoluteUrl(String.format("/accounts/%s/mute", targetedId)), 60, params, prefKeyOauthTokenT);
actionCode = httpsConnection.getActionCode();
} catch (HttpsConnection.HttpsConnectionException e) {
@ -2142,7 +2142,7 @@ public class API {
}
if(statusAction != StatusAction.UNSTATUS ) {
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String resp = httpsConnection.post(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT);
actionCode = httpsConnection.getActionCode();
if( statusAction == StatusAction.REBLOG || statusAction == StatusAction.UNREBLOG || statusAction == StatusAction.FAVOURITE || statusAction == StatusAction.UNFAVOURITE) {
@ -2168,7 +2168,7 @@ public class API {
}
}else{
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
httpsConnection.delete(getAbsoluteUrl(action), 60, null, prefKeyOauthTokenT);
actionCode = httpsConnection.getActionCode();
SQLiteDatabase db = Sqlite.getInstance(context, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
@ -2206,7 +2206,7 @@ public class API {
}
List<StoredStatus> storedStatus = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = null;
int responseCode = -1;
if( call.equals("GET"))
@ -2282,7 +2282,7 @@ public class API {
}
jsonObject.add("choices",jchoices);
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.postJson(getAbsoluteUrl(String.format("/polls/%s/votes", pollId)), 60, jsonObject, prefKeyOauthTokenT);
return parsePoll(context, new JSONObject(response));
} catch (HttpsConnection.HttpsConnectionException e) {
@ -2308,7 +2308,7 @@ public class API {
public Poll getPoll(Status status){
try {
Poll _p = (status.getReblog() != null)?status.getReblog().getPoll():status.getPoll();
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/polls/%s", _p.getId())), 60, null, prefKeyOauthTokenT);
Poll poll = parsePoll(context, new JSONObject(response));
Bundle b = new Bundle();
@ -2379,7 +2379,7 @@ public class API {
jsonObject.addProperty("visibility", status.getVisibility());
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.postJson(getAbsoluteUrl("/statuses"), 60, jsonObject, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id());
@ -2418,7 +2418,7 @@ public class API {
action = "/notifications/dismiss";
}
try {
new HttpsConnection(context).post(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT);
new HttpsConnection(context, this.instance).post(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT);
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
} catch (NoSuchAlgorithmException e) {
@ -2558,7 +2558,7 @@ public class API {
List<Notification> notifications = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/notifications"), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id());
@ -2597,7 +2597,7 @@ public class API {
params.put("description", description);
}
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.put(getAbsoluteUrl(String.format("/media/%s", mediaId)), 240, params, prefKeyOauthTokenT);
attachment = parseAttachmentResponse(new JSONObject(response));
} catch (HttpsConnection.HttpsConnectionException e) {
@ -2633,7 +2633,7 @@ public class API {
params.put("q", query);
}
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/search"), 60, params, prefKeyOauthTokenT);
results = parseResultsResponse(new JSONObject(response));
apiResponse.setResults(results);
@ -2685,7 +2685,7 @@ public class API {
}
params.put("limit", "20");
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUr2l("/search"), 60, params, prefKeyOauthTokenT);
results = parseResultsResponse(new JSONObject(response));
apiResponse.setSince_id(httpsConnection.getSince_id());
@ -2738,7 +2738,7 @@ public class API {
params.put("limit", String.valueOf(count));
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/accounts/search"), 60, params, prefKeyOauthTokenT);
accounts = parseAccountResponse(new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id());
@ -2769,7 +2769,7 @@ public class API {
public APIResponse getCustomEmoji() {
List<Emojis> emojis = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/custom_emojis"), 60, null, prefKeyOauthTokenT);
emojis = parseEmojis(new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id());
@ -2804,7 +2804,7 @@ public class API {
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean isAdmin;
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(String.format(Helper.getLiveInstanceWithProtocol(context)+"/api/pleroma/admin/permission_group/%s/admin",nickname), 60, null, prefKeyOauthTokenT);
//Call didn't return a 404, so the account is admin
isAdmin = true;
@ -2824,7 +2824,7 @@ public class API {
public APIResponse getCustomPleromaEmoji() {
List<Emojis> emojis = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(Helper.getLiveInstanceWithProtocol(context)+"/api/pleroma/emoji", 60, null, prefKeyOauthTokenT);
emojis = parsePleromaEmojis(new JSONObject(response));
@ -2851,7 +2851,7 @@ public class API {
List<Filters> filters = null;
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl("/filters"), 60, null, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/filters"), 60, null, prefKeyOauthTokenT);
filters = parseFilters(new JSONArray(response));
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
@ -2878,7 +2878,7 @@ public class API {
List<Filters> filters = new ArrayList<>();
Filters filter;
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl(String.format("/filters/%s", filterId)), 60, null, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl(String.format("/filters/%s", filterId)), 60, null, prefKeyOauthTokenT);
filter = parseFilter(new JSONObject(response));
filters.add(filter);
} catch (HttpsConnection.HttpsConnectionException e) {
@ -2917,7 +2917,7 @@ public class API {
params.put("expires_in", String.valueOf(filter.getExpires_in()));
ArrayList<Filters> filters = new ArrayList<>();
try {
String response = new HttpsConnection(context).post(getAbsoluteUrl("/filters"), 60, params, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).post(getAbsoluteUrl("/filters"), 60, params, prefKeyOauthTokenT);
Filters resfilter = parseFilter(new JSONObject(response));
filters.add(resfilter);
} catch (HttpsConnection.HttpsConnectionException e) {
@ -2943,7 +2943,7 @@ public class API {
public int deleteFilters(Filters filter){
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
httpsConnection.delete(getAbsoluteUrl(String.format("/filters/%s", filter.getId())), 60, null, prefKeyOauthTokenT);
actionCode = httpsConnection.getActionCode();
} catch (HttpsConnection.HttpsConnectionException e) {
@ -2978,7 +2978,7 @@ public class API {
params.put("expires_in", String.valueOf(filter.getExpires_in()));
ArrayList<Filters> filters = new ArrayList<>();
try {
String response = new HttpsConnection(context).put(getAbsoluteUrl(String.format("/filters/%s", filter.getId())), 60, params, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).put(getAbsoluteUrl(String.format("/filters/%s", filter.getId())), 60, params, prefKeyOauthTokenT);
Filters resfilter = parseFilter(new JSONObject(response));
filters.add(resfilter);
} catch (HttpsConnection.HttpsConnectionException e) {
@ -3004,7 +3004,7 @@ public class API {
apiResponse = new APIResponse();
List<app.fedilab.android.client.Entities.List> lists = new ArrayList<>();
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl("/lists"), 60, null, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/lists"), 60, null, prefKeyOauthTokenT);
lists = parseLists(new JSONArray(response));
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
@ -3031,7 +3031,7 @@ public class API {
List<app.fedilab.android.client.Entities.List> lists = new ArrayList<>();
app.fedilab.android.client.Entities.List list;
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl(String.format("/accounts/%s/lists", userId)), 60, null, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl(String.format("/accounts/%s/lists", userId)), 60, null, prefKeyOauthTokenT);
list = parseList(new JSONObject(response));
lists.add(list);
} catch (HttpsConnection.HttpsConnectionException e) {
@ -3069,7 +3069,7 @@ public class API {
params.put("limit",String.valueOf(limit));
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/timelines/list/%s",list_id)), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id());
@ -3107,7 +3107,7 @@ public class API {
limit = 50;
params.put("limit",String.valueOf(limit));
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/lists/%s/accounts", listId)), 60, params, prefKeyOauthTokenT);
accounts = parseAccountResponse(new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id());
@ -3140,7 +3140,7 @@ public class API {
List<app.fedilab.android.client.Entities.List> lists = new ArrayList<>();
app.fedilab.android.client.Entities.List list;
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl(String.format("/lists/%s",id)), 60, null, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl(String.format("/lists/%s",id)), 60, null, prefKeyOauthTokenT);
list = parseList(new JSONObject(response));
lists.add(list);
} catch (HttpsConnection.HttpsConnectionException e) {
@ -3178,7 +3178,7 @@ public class API {
params.put("account_ids[]", parameters.toString());
}
try {
new HttpsConnection(context).post(getAbsoluteUrl(String.format("/lists/%s/accounts", id)), 60, params, prefKeyOauthTokenT);
new HttpsConnection(context, this.instance).post(getAbsoluteUrl(String.format("/lists/%s/accounts", id)), 60, params, prefKeyOauthTokenT);
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
} catch (NoSuchAlgorithmException e) {
@ -3199,7 +3199,7 @@ public class API {
*/
public int deleteAccountFromList(String id, String[] account_ids){
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
StringBuilder parameters = new StringBuilder();
HashMap<String, String> params = new HashMap<>();
for(String val: account_ids)
@ -3235,7 +3235,7 @@ public class API {
List<app.fedilab.android.client.Entities.List> lists = new ArrayList<>();
app.fedilab.android.client.Entities.List list;
try {
String response = new HttpsConnection(context).post(getAbsoluteUrl("/lists"), 60, params, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).post(getAbsoluteUrl("/lists"), 60, params, prefKeyOauthTokenT);
list = parseList(new JSONObject(response));
lists.add(list);
} catch (HttpsConnection.HttpsConnectionException e) {
@ -3268,7 +3268,7 @@ public class API {
List<app.fedilab.android.client.Entities.List> lists = new ArrayList<>();
app.fedilab.android.client.Entities.List list;
try {
String response = new HttpsConnection(context).put(getAbsoluteUrl(String.format("/lists/%s", id)), 60, params, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).put(getAbsoluteUrl(String.format("/lists/%s", id)), 60, params, prefKeyOauthTokenT);
list = parseList(new JSONObject(response));
lists.add(list);
} catch (HttpsConnection.HttpsConnectionException e) {
@ -3294,7 +3294,7 @@ public class API {
*/
public int deleteList(String id){
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
httpsConnection.delete(getAbsoluteUrl(String.format("/lists/%s", id)), 60, null, prefKeyOauthTokenT);
actionCode = httpsConnection.getActionCode();
} catch (HttpsConnection.HttpsConnectionException e) {
@ -3314,7 +3314,7 @@ public class API {
public ArrayList<String> getCommunitywikiList() {
ArrayList<String> list = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrlCommunitywiki("/list"), 60, null, prefKeyOauthTokenT);
JSONArray jsonArray = new JSONArray(response);
@ -3344,7 +3344,7 @@ public class API {
public ArrayList<String> getCommunitywikiList(String name) {
ArrayList<String> list = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrlCommunitywiki(String.format("/list/%s", name)), 60, null, prefKeyOauthTokenT);
JSONArray jsonArray = new JSONArray(response);

View File

@ -56,7 +56,7 @@ public class CustomSharing {
public CustomSharingResponse customShare(String encodedCustomSharingURL) {
String HTTPResponse = "";
try {
HTTPResponse = new HttpsConnection(context).get(encodedCustomSharingURL);
HTTPResponse = new HttpsConnection(context, null).get(encodedCustomSharingURL);
} catch (HttpsConnection.HttpsConnectionException e) {
e.printStackTrace();
setError(e.getStatusCode(), e);

View File

@ -159,9 +159,9 @@ public class GNUAPI {
requestParams.put("locked",privacy== accountPrivacy.LOCKED?"true":"false");
try {
if( requestParams.size() > 0)
new HttpsConnection(context).patch(getAbsoluteUrl("/accounts/update_profile"), 60, requestParams, avatar, null, null, null, prefKeyOauthTokenT);
new HttpsConnection(context, this.instance).patch(getAbsoluteUrl("/accounts/update_profile"), 60, requestParams, avatar, null, null, null, prefKeyOauthTokenT);
if( avatar!= null && avatarName != null)
new HttpsConnection(context).patch(getAbsoluteUrl("/accounts/update_profile_image"), 60, null, avatar, avatarName, null, null, prefKeyOauthTokenT);
new HttpsConnection(context, this.instance).patch(getAbsoluteUrl("/accounts/update_profile_image"), 60, null, avatar, avatarName, null, null, prefKeyOauthTokenT);
} catch (HttpsConnection.HttpsConnectionException e) {
e.printStackTrace();
@ -183,7 +183,7 @@ public class GNUAPI {
public Account verifyCredentials() {
account = new Account();
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl("/account/verify_credentials.json"), 60, null, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/account/verify_credentials.json"), 60, null, prefKeyOauthTokenT);
account = parseAccountResponse(context, new JSONObject(response));
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
@ -211,7 +211,7 @@ public class GNUAPI {
HashMap<String, String> params = new HashMap<>();
params.put("user_id",accountId);
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl("/users/show.json"), 60, params, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/users/show.json"), 60, params, prefKeyOauthTokenT);
account = parseAccountResponse(context, new JSONObject(response));
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
@ -244,11 +244,11 @@ public class GNUAPI {
String response;
if(MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.GNU) {
params.put("target_id",accountId);
response = new HttpsConnection(context).get(getAbsoluteUrl("/friendships/show.json"), 60, params, prefKeyOauthTokenT);
response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/friendships/show.json"), 60, params, prefKeyOauthTokenT);
relationship = parseRelationshipResponse(new JSONObject(response));
}else if(MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
params.put("user_id",accountId);
response = new HttpsConnection(context).get(getAbsoluteUrl("/users/show.json"), 60, params, prefKeyOauthTokenT);
response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/users/show.json"), 60, params, prefKeyOauthTokenT);
JSONObject resobj = new JSONObject(response);
try {
relationship = new Relationship();
@ -307,7 +307,7 @@ public class GNUAPI {
params.put("target_id[]", parameters.toString());
List<Relationship> relationships = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/friendships/show.json"), 60, params, prefKeyOauthTokenT);
relationships = parseRelationshipResponse(new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id());
@ -409,7 +409,7 @@ public class GNUAPI {
params.put("count", String.valueOf(limit));
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/statuses/user_timeline.json"), 60, params, prefKeyOauthTokenT);
statuses = parseStatuses(context, new JSONArray(response));
if( statuses.size() > 0) {
@ -450,7 +450,7 @@ public class GNUAPI {
params.put("limit", "80");
accounts = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/statuses/%s/reblogged_by", statusId)), 60, params, prefKeyOauthTokenT);
accounts = parseAccountResponse(new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id());
@ -488,7 +488,7 @@ public class GNUAPI {
params.put("limit", "80");
accounts = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/statuses/%s/favourited_by", statusId)), 60, params, prefKeyOauthTokenT);
accounts = parseAccountResponse(new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id());
@ -520,7 +520,7 @@ public class GNUAPI {
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/statuses/%s", statusId)), 60, null, prefKeyOauthTokenT);
Status status = parseStatuses(context, new JSONObject(response));
statuses.add(status);
@ -548,7 +548,7 @@ public class GNUAPI {
public app.fedilab.android.client.Entities.Context getStatusContext(String statusId, boolean directtimeline) {
app.fedilab.android.client.Entities.Context statusContext = new app.fedilab.android.client.Entities.Context();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response;
if( !directtimeline)
response = httpsConnection.get(getAbsoluteUrl(String.format("/statusnet/conversation/%s.json", statusId)), 60, null, prefKeyOauthTokenT);
@ -625,7 +625,7 @@ public class GNUAPI {
params.put("limit",String.valueOf(limit));
List<Conversation> conversations = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/direct_messages.json"), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id());
@ -672,7 +672,7 @@ public class GNUAPI {
params.put("count",String.valueOf(limit));
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/direct_messages.json"), 60, params, prefKeyOauthTokenT);
statuses = parseStatuses(context, new JSONArray(response));
if( statuses.size() > 0) {
@ -745,7 +745,7 @@ public class GNUAPI {
//Current user
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/statuses/home_timeline.json"), 60, params, prefKeyOauthTokenT);
statuses = parseStatuses(context, new JSONArray(response));
if( statuses.size() > 0) {
@ -834,7 +834,7 @@ public class GNUAPI {
params.put("count",String.valueOf(limit));
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String url;
if(local)
url = getAbsoluteUrl("/statuses/public_timeline.json");
@ -987,7 +987,7 @@ public class GNUAPI {
return null;
try {
String query = tag.trim();
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
if( MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
try {
query = URLEncoder.encode(query, "UTF-8");
@ -1075,7 +1075,7 @@ public class GNUAPI {
params.put("user_id",targetedId);
accounts = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id());
@ -1132,7 +1132,7 @@ public class GNUAPI {
params.put("limit",String.valueOf(limit));
accounts = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/follow_requests"), 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id());
@ -1181,7 +1181,7 @@ public class GNUAPI {
params.put("count",String.valueOf(limit));
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/favorites.json"), 60, params, prefKeyOauthTokenT);
statuses = parseStatuses(context, new JSONArray(response));
if( statuses.size() > 0) {
@ -1225,7 +1225,7 @@ public class GNUAPI {
HashMap<String, String> params = new HashMap<>();
params.put("notifications", Boolean.toString(muteNotifications));
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
httpsConnection.post(getAbsoluteUrl(String.format("/accounts/%s/mute", targetedId)), 60, params, prefKeyOauthTokenT);
actionCode = httpsConnection.getActionCode();
} catch (HttpsConnection.HttpsConnectionException e) {
@ -1382,7 +1382,7 @@ public class GNUAPI {
}
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String resp = httpsConnection.post(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT);
actionCode = httpsConnection.getActionCode();
if( statusAction == API.StatusAction.REBLOG || statusAction == API.StatusAction.UNREBLOG || statusAction == API.StatusAction.FAVOURITE || statusAction == API.StatusAction.UNFAVOURITE) {
@ -1463,7 +1463,7 @@ public class GNUAPI {
params.put("possibly_sensitive", Boolean.toString(status.isSensitive()));
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response;
if( !status.getVisibility().equals("direct"))
response = httpsConnection.post(getAbsoluteUrl("/statuses/update.json"), 60, params, prefKeyOauthTokenT);
@ -1565,7 +1565,7 @@ public class GNUAPI {
return apiResponse;
}
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(url, 60, params, prefKeyOauthTokenT);
apiResponse.setSince_id(httpsConnection.getSince_id());
apiResponse.setMax_id(httpsConnection.getMax_id());
@ -1628,7 +1628,7 @@ public class GNUAPI {
params.put("description", description);
}
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.put(getAbsoluteUrl(String.format("/media/%s", mediaId)), 240, params, prefKeyOauthTokenT);
attachment = parseAttachmentResponse(new JSONObject(response));
} catch (HttpsConnection.HttpsConnectionException e) {
@ -1665,7 +1665,7 @@ public class GNUAPI {
params.put("q", query);
}
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/users/search.json"), 60, params, prefKeyOauthTokenT);
List<Account> accounts = parseAccountResponse(new JSONArray(response));
results.setAccounts(accounts);
@ -1700,7 +1700,7 @@ public class GNUAPI {
if (max_id != null)
params.put("max_id", max_id);
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/statusnet/tags/timeline/"+query.trim().toLowerCase().replaceAll("\\#","")+".json"), 60, params, null);
List<Status> statuses = parseStatuses(context, new JSONArray(response));
if( statuses.size() > 0) {
@ -1755,7 +1755,7 @@ public class GNUAPI {
params.put("limit", String.valueOf(count));
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/accounts/search"), 60, params, prefKeyOauthTokenT);
accounts = parseAccountResponse(new JSONArray(response));
apiResponse.setSince_id(httpsConnection.getSince_id());

View File

@ -12,6 +12,7 @@ import java.io.InputStream;
import java.lang.ref.WeakReference;
import app.fedilab.android.client.HttpsConnection;
import app.fedilab.android.helper.Helper;
/**
* Created by Thomas on 13/12/2017.
@ -30,7 +31,8 @@ public class CustomStreamFetcher implements DataFetcher<InputStream> {
@Override
public void loadData(@NonNull Priority priority, @NonNull DataCallback<? super InputStream> callback) {
callback.onDataReady(new HttpsConnection(this.contextWeakReference.get()).getPicture(url.toStringUrl()));
String instance = Helper.getLiveInstance(this.contextWeakReference.get());
callback.onDataReady(new HttpsConnection(this.contextWeakReference.get(), instance).getPicture(url.toStringUrl()));
}
@Override

View File

@ -88,9 +88,10 @@ public class HttpsConnection {
private int CHUNK_SIZE = 4096;
private SharedPreferences sharedpreferences;
private Proxy proxy;
private String instance;
public HttpsConnection(Context context){
public HttpsConnection(Context context, String instance){
this.instance = instance;
this.context = context;
sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
boolean proxyEnabled = sharedpreferences.getBoolean(Helper.SET_PROXY_ENABLED, false);
@ -155,7 +156,7 @@ public class HttpsConnection {
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
httpsURLConnection.setRequestProperty("Content-Type", "application/json");
httpsURLConnection.setRequestProperty("Accept", "application/json");
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
if (token != null && !token.startsWith("Basic "))
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token);
else if( token != null && token.startsWith("Basic "))
@ -250,7 +251,7 @@ public class HttpsConnection {
httpsURLConnection.setRequestProperty("Content-Type", "application/json");
httpsURLConnection.setRequestProperty("Accept", "application/json");
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.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
httpsURLConnection.setRequestMethod("GET");
String response;
if (httpsURLConnection.getResponseCode() >= 200 && httpsURLConnection.getResponseCode() < 400) {
@ -338,7 +339,7 @@ public class HttpsConnection {
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
httpsURLConnection.setConnectTimeout(timeout * 1000);
httpsURLConnection.setDoOutput(true);
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
httpsURLConnection.setRequestMethod("POST");
if (token != null && !token.startsWith("Basic "))
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token);
@ -444,7 +445,7 @@ public class HttpsConnection {
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
httpsURLConnection.setConnectTimeout(timeout * 1000);
httpsURLConnection.setDoOutput(true);
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
httpsURLConnection.setRequestProperty("Content-Type", "application/json");
httpsURLConnection.setRequestProperty("Accept", "application/json");
httpsURLConnection.setRequestMethod("POST");
@ -534,7 +535,7 @@ public class HttpsConnection {
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
httpsURLConnection.setConnectTimeout(timeout * 1000);
httpsURLConnection.setDoOutput(true);
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
httpsURLConnection.setRequestMethod("POST");
if (token != null && !token.startsWith("Basic "))
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token);
@ -772,7 +773,7 @@ public class HttpsConnection {
httpsURLConnection = (HttpsURLConnection) url.openConnection(proxy);
else
httpsURLConnection = (HttpsURLConnection) url.openConnection();
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
int responseCode = httpsURLConnection.getResponseCode();
// always check HTTP response code first
@ -867,7 +868,7 @@ public class HttpsConnection {
httpsURLConnection = (HttpsURLConnection) url.openConnection();
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
httpsURLConnection.setConnectTimeout(timeout * 1000);
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
httpsURLConnection.setDoInput(true);
httpsURLConnection.setDoOutput(true);
httpsURLConnection.setUseCaches(false);
@ -1085,7 +1086,7 @@ public class HttpsConnection {
httpsURLConnection = (HttpsURLConnection) url.openConnection();
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
httpsURLConnection.setConnectTimeout(timeout * 1000);
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
if( Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT ){
httpsURLConnection.setRequestMethod("PATCH");
}else {
@ -1266,7 +1267,7 @@ public class HttpsConnection {
httpsURLConnection.setFixedLengthStreamingMode(lengthSent);
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(instance));
httpsURLConnection.setDoInput(true);
httpsURLConnection.setDoOutput(true);
httpsURLConnection.setUseCaches(false);
@ -1571,7 +1572,7 @@ public class HttpsConnection {
httpsURLConnection = (HttpsURLConnection) url.openConnection();
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
httpsURLConnection.setConnectTimeout(timeout * 1000);
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
if (token != null && !token.startsWith("Basic "))
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token);
else if( token != null && token.startsWith("Basic "))
@ -1699,7 +1700,7 @@ public class HttpsConnection {
else
httpsURLConnection = (HttpsURLConnection) url.openConnection();
httpsURLConnection.setRequestProperty("User-Agent", Helper.USER_AGENT);
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory());
httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory(this.instance));
if (token != null && !token.startsWith("Basic "))
httpsURLConnection.setRequestProperty("Authorization", "Bearer " + token);
else if( token != null && token.startsWith("Basic "))

View File

@ -143,7 +143,7 @@ public class PeertubeAPI {
*/
public APIResponse getInstance() {
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl("/instance"), 30, null, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/instance"), 30, null, prefKeyOauthTokenT);
Instance instanceEntity = parseInstance(new JSONObject(response));
apiResponse.setInstance(instanceEntity);
} catch (HttpsConnection.HttpsConnectionException e) {
@ -213,7 +213,7 @@ public class PeertubeAPI {
params.put("scheduleUpdate","null");
List<Peertube> peertubes = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
httpsConnection.put(getAbsoluteUrl(String.format("/videos/%s", peertube.getId())), 60, params, prefKeyOauthTokenT);
peertubes.add(peertube);
} catch (HttpsConnection.HttpsConnectionException e) {
@ -264,7 +264,7 @@ public class PeertubeAPI {
}
}
try {
new HttpsConnection(context).patch(getAbsoluteUrl("/accounts/update_credentials"), 60, requestParams, avatar, avatarName, header, headerName, prefKeyOauthTokenT);
new HttpsConnection(context, this.instance).patch(getAbsoluteUrl("/accounts/update_credentials"), 60, requestParams, avatar, avatarName, header, headerName, prefKeyOauthTokenT);
} catch (HttpsConnection.HttpsConnectionException e) {
e.printStackTrace();
setError(e.getStatusCode(), e);
@ -288,7 +288,7 @@ public class PeertubeAPI {
PeertubeInformation peertubeInformation = new PeertubeInformation();
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl("/videos/categories"), 60, null, null);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/videos/categories"), 60, null, null);
JSONObject categories = new JSONObject(response);
LinkedHashMap<Integer, String> _pcategories = new LinkedHashMap<>();
for( int i = 1 ; i <= categories.length() ; i++){
@ -297,7 +297,7 @@ public class PeertubeAPI {
}
peertubeInformation.setCategories(_pcategories);
response = new HttpsConnection(context).get(getAbsoluteUrl("/videos/languages"), 60, null, null);
response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/videos/languages"), 60, null, null);
JSONObject languages = new JSONObject(response);
LinkedHashMap<String, String> _languages = new LinkedHashMap<>();
Iterator<String> iter = languages.keys();
@ -309,7 +309,7 @@ public class PeertubeAPI {
}
peertubeInformation.setLanguages(_languages);
response = new HttpsConnection(context).get(getAbsoluteUrl("/videos/privacies"), 60, null, null);
response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/videos/privacies"), 60, null, null);
JSONObject privacies = new JSONObject(response);
LinkedHashMap<Integer, String> _pprivacies = new LinkedHashMap<>();
for( int i = 1 ; i <= privacies.length() ; i++){
@ -319,7 +319,7 @@ public class PeertubeAPI {
peertubeInformation.setPrivacies(_pprivacies);
response = new HttpsConnection(context).get(getAbsoluteUrl("/videos/licences"), 60, null, null);
response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/videos/licences"), 60, null, null);
JSONObject licences = new JSONObject(response);
LinkedHashMap<Integer, String> _plicences = new LinkedHashMap<>();
for( int i = 1 ; i <= licences.length() ; i++){
@ -335,7 +335,7 @@ public class PeertubeAPI {
lang = PeertubeInformation.langueMapped.get(Locale.getDefault().getLanguage());
if( lang != null && !lang.startsWith("en")) {
response = new HttpsConnection(context).get(String.format("https://" + instance + "/client/locales/%s/server.json", lang), 60, null, null);
response = new HttpsConnection(context, this.instance).get(String.format("https://" + instance + "/client/locales/%s/server.json", lang), 60, null, null);
JSONObject translations = new JSONObject(response);
LinkedHashMap<String, String> _translations = new LinkedHashMap<>();
Iterator<String> itertrans = translations.keys();
@ -368,7 +368,7 @@ public class PeertubeAPI {
public Account verifyCredentials() {
account = new Account();
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl("/users/me"), 60, null, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/users/me"), 60, null, prefKeyOauthTokenT);
JSONObject accountObject = new JSONObject(response).getJSONObject("account");
account = parseAccountResponsePeertube(context, accountObject);
} catch (NoSuchAlgorithmException e) {
@ -399,7 +399,7 @@ public class PeertubeAPI {
new AccountDAO(context, db).updateAccount(targetedAccount);
String response;
try {
response = new HttpsConnection(context).get(getAbsoluteUrl("/users/me"), 60, null, targetedAccount.getToken());
response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/users/me"), 60, null, targetedAccount.getToken());
JSONObject accountObject = new JSONObject(response).getJSONObject("account");
account = parseAccountResponsePeertube(context, accountObject);
} catch (IOException e1) {
@ -433,7 +433,7 @@ public class PeertubeAPI {
params.put("client_secret", client_secret);
params.put("refresh_token", refresh_token);
try {
String response = new HttpsConnection(context).post(getAbsoluteUrl("/users/token"), 60, params, null);
String response = new HttpsConnection(context, this.instance).post(getAbsoluteUrl("/users/token"), 60, params, null);
JSONObject resobj = new JSONObject(response);
String token = resobj.get("access_token").toString();
if( resobj.has("refresh_token"))
@ -465,7 +465,7 @@ public class PeertubeAPI {
account = new Account();
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl(String.format("/accounts/%s",accountId)), 60, null, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl(String.format("/accounts/%s",accountId)), 60, null, prefKeyOauthTokenT);
account = parseAccountResponsePeertube(context, new JSONObject(response));
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
@ -494,7 +494,7 @@ public class PeertubeAPI {
params.put("uris", uri);
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/users/me/subscriptions/exist"), 60, params, prefKeyOauthTokenT);
return new JSONObject(response).getBoolean(uri);
} catch (HttpsConnection.HttpsConnectionException e) {
@ -558,7 +558,7 @@ public class PeertubeAPI {
List<Peertube> peertubes = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/users/me/videos"), 60, params, prefKeyOauthTokenT);
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
@ -581,7 +581,7 @@ public class PeertubeAPI {
account.setRefresh_token(refresh_token);
new AccountDAO(context, db).updateAccount(account);
}
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response;
try {
response = httpsConnection.get(getAbsoluteUrl("/users/me/videos"), 60, params, prefKeyOauthTokenT);
@ -637,7 +637,7 @@ public class PeertubeAPI {
params.put("count", String.valueOf(limit));
List<Peertube> peertubes = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/accounts/%s/videos", acct)), 60, params, prefKeyOauthTokenT);
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
peertubes = parsePeertube(jsonArray);
@ -699,7 +699,7 @@ public class PeertubeAPI {
params.put("count", String.valueOf(limit));
List<PeertubeNotification> peertubeNotifications = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl("/users/me/notifications"), 60, params, prefKeyOauthTokenT);
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
peertubeNotifications = parsePeertubeNotifications(jsonArray);
@ -754,7 +754,7 @@ public class PeertubeAPI {
List<Peertube> peertubes = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/video-channels/%s/videos", acct)), 60, params, prefKeyOauthTokenT);
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
@ -871,7 +871,7 @@ public class PeertubeAPI {
params.put("nsfw", String.valueOf(nsfw));
List<Peertube> peertubes = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT);
if( !action.equals("/overviews/videos")) {
JSONArray values = new JSONObject(response).getJSONArray("data");
@ -955,7 +955,7 @@ public class PeertubeAPI {
List<Account> accounts = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/accounts/%s/video-channels", name)), 60, null, null);
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
accounts = parseAccountResponsePeertube(context, instance, jsonArray);
@ -983,7 +983,7 @@ public class PeertubeAPI {
List<Peertube> peertubes = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(String.format("https://"+instance+"/api/v1/video-channels/%s/videos", name), 60, null, null);
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
peertubes = parsePeertube(jsonArray);
@ -1015,7 +1015,7 @@ public class PeertubeAPI {
params.put("start", max_id);
params.put("count", "50");
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get("https://"+instance+"/api/v1/videos", 60, params, null);
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
peertubes = parsePeertube(jsonArray);
@ -1042,7 +1042,7 @@ public class PeertubeAPI {
Peertube peertube = null;
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(String.format("https://"+instance+"/api/v1/videos/%s", videoId), 60, null, token);
JSONObject jsonObject = new JSONObject(response);
peertube = parseSinglePeertube(context, instance, jsonObject);
@ -1079,7 +1079,7 @@ public class PeertubeAPI {
}
List<Peertube> peertubes = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get("https://"+instance+"/api/v1/search/videos", 60, params, null);
JSONArray jsonArray = new JSONObject(response).getJSONArray("data");
peertubes = parsePeertube(jsonArray);
@ -1105,7 +1105,7 @@ public class PeertubeAPI {
public APIResponse getSinglePeertubeComments(String instance, String videoId) {
statuses = new ArrayList<>();
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(String.format("https://"+instance+"/api/v1/videos/%s/comment-threads", videoId), 60, null, null);
JSONObject jsonObject = new JSONObject(response);
statuses = parseSinglePeertubeComments(context, instance, jsonObject);
@ -1136,7 +1136,7 @@ public class PeertubeAPI {
@SuppressWarnings("SameParameterValue")
public String getRating(String id){
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.get(getAbsoluteUrl(String.format("/users/me/videos/%s/rating",id)), 60, null, prefKeyOauthTokenT);
return new JSONObject(response).get("rating").toString();
} catch (HttpsConnection.HttpsConnectionException e) {
@ -1235,7 +1235,7 @@ public class PeertubeAPI {
return -1;
}
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
if( actionCall.equals("POST"))
httpsConnection.post(getAbsoluteUrl(action), 60, params, prefKeyOauthTokenT);
else if( actionCall.equals("DELETE"))
@ -1273,7 +1273,7 @@ public class PeertubeAPI {
params.put("description", description);
}
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
String response = httpsConnection.put(getAbsoluteUrl(String.format("/media/%s", mediaId)), 240, params, prefKeyOauthTokenT);
attachment = parseAttachmentResponse(new JSONObject(response));
} catch (HttpsConnection.HttpsConnectionException e) {
@ -1301,7 +1301,7 @@ public class PeertubeAPI {
List<Filters> filters = null;
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl("/filters"), 60, null, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/filters"), 60, null, prefKeyOauthTokenT);
filters = parseFilters(new JSONArray(response));
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
@ -1328,7 +1328,7 @@ public class PeertubeAPI {
List<Filters> filters = new ArrayList<>();
Filters filter;
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl(String.format("/filters/%s", filterId)), 60, null, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl(String.format("/filters/%s", filterId)), 60, null, prefKeyOauthTokenT);
filter = parseFilter(new JSONObject(response));
filters.add(filter);
} catch (HttpsConnection.HttpsConnectionException e) {
@ -1367,7 +1367,7 @@ public class PeertubeAPI {
params.put("expires_in", String.valueOf(filter.getExpires_in()));
ArrayList<Filters> filters = new ArrayList<>();
try {
String response = new HttpsConnection(context).post(getAbsoluteUrl("/filters"), 60, params, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).post(getAbsoluteUrl("/filters"), 60, params, prefKeyOauthTokenT);
Filters resfilter = parseFilter(new JSONObject(response));
filters.add(resfilter);
} catch (HttpsConnection.HttpsConnectionException e) {
@ -1393,7 +1393,7 @@ public class PeertubeAPI {
public int deleteFilters(Filters filter){
try {
HttpsConnection httpsConnection = new HttpsConnection(context);
HttpsConnection httpsConnection = new HttpsConnection(context, this.instance);
httpsConnection.delete(getAbsoluteUrl(String.format("/filters/%s", filter.getId())), 60, null, prefKeyOauthTokenT);
actionCode = httpsConnection.getActionCode();
} catch (HttpsConnection.HttpsConnectionException e) {
@ -1428,7 +1428,7 @@ public class PeertubeAPI {
params.put("expires_in", String.valueOf(filter.getExpires_in()));
ArrayList<Filters> filters = new ArrayList<>();
try {
String response = new HttpsConnection(context).put(getAbsoluteUrl(String.format("/filters/%s", filter.getId())), 60, params, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).put(getAbsoluteUrl(String.format("/filters/%s", filter.getId())), 60, params, prefKeyOauthTokenT);
Filters resfilter = parseFilter(new JSONObject(response));
filters.add(resfilter);
} catch (HttpsConnection.HttpsConnectionException e) {
@ -1454,7 +1454,7 @@ public class PeertubeAPI {
List<app.fedilab.android.client.Entities.List> lists = new ArrayList<>();
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl("/lists"), 60, null, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl("/lists"), 60, null, prefKeyOauthTokenT);
lists = parseLists(new JSONArray(response));
} catch (HttpsConnection.HttpsConnectionException e) {
setError(e.getStatusCode(), e);
@ -1481,7 +1481,7 @@ public class PeertubeAPI {
List<app.fedilab.android.client.Entities.List> lists = new ArrayList<>();
app.fedilab.android.client.Entities.List list;
try {
String response = new HttpsConnection(context).get(getAbsoluteUrl(String.format("/accounts/%s/lists", userId)), 60, null, prefKeyOauthTokenT);
String response = new HttpsConnection(context, this.instance).get(getAbsoluteUrl(String.format("/accounts/%s/lists", userId)), 60, null, prefKeyOauthTokenT);
list = parseList(new JSONObject(response));
lists.add(list);
} catch (HttpsConnection.HttpsConnectionException e) {

View File

@ -1,6 +1,7 @@
package app.fedilab.android.client;
import android.annotation.SuppressLint;
import android.content.SharedPreferences;
import java.io.IOException;
@ -8,11 +9,15 @@ import java.net.InetAddress;
import java.net.Socket;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import app.fedilab.android.activities.MainApplication;
import app.fedilab.android.helper.Helper;
@ -26,11 +31,29 @@ public class TLSSocketFactory extends SSLSocketFactory {
private SSLSocketFactory sSLSocketFactory;
private SSLContext sslContext;
private String instance;
public TLSSocketFactory() throws KeyManagementException, NoSuchAlgorithmException {
public TLSSocketFactory(String instance) throws KeyManagementException, NoSuchAlgorithmException {
sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, null, null);
if( instance == null || !instance.endsWith(".onion")) {
sslContext.init(null, null, null);
}else{
TrustManager tm = new X509TrustManager() {
@SuppressLint("TrustAllX509TrustManager")
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
@SuppressLint("TrustAllX509TrustManager")
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
sslContext.init(null, new TrustManager[] { tm }, null);
}
sSLSocketFactory = sslContext.getSocketFactory();
}

View File

@ -228,7 +228,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece
}
if( Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT ) {
try {
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setSSLContext(new TLSSocketFactory().getSSLContext());
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setSSLContext(new TLSSocketFactory(account.getInstance()).getSSLContext());
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setConnectAllAddresses(true);
} catch (KeyManagementException e) {
e.printStackTrace();

View File

@ -109,7 +109,7 @@ public class StreamingFederatedTimelineService extends IntentService {
Account finalAccountStream = accountStream;
if( Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT ) {
try {
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setSSLContext(new TLSSocketFactory().getSSLContext());
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setSSLContext(new TLSSocketFactory(accountStream.getInstance()).getSSLContext());
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setConnectAllAddresses(true);
} catch (KeyManagementException e) {
e.printStackTrace();

View File

@ -109,7 +109,7 @@ public class StreamingHomeTimelineService extends IntentService {
Account finalAccountStream = accountStream;
if( Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT ) {
try {
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setSSLContext(new TLSSocketFactory().getSSLContext());
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setSSLContext(new TLSSocketFactory(accountStream.getInstance()).getSSLContext());
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setConnectAllAddresses(true);
} catch (KeyManagementException e) {
e.printStackTrace();

View File

@ -110,7 +110,7 @@ public class StreamingLocalTimelineService extends IntentService {
Account finalAccountStream = accountStream;
if( Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT ) {
try {
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setSSLContext(new TLSSocketFactory().getSSLContext());
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setSSLContext(new TLSSocketFactory(accountStream.getInstance()).getSSLContext());
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setConnectAllAddresses(true);
} catch (KeyManagementException e) {
e.printStackTrace();