Add custom user agent

This commit is contained in:
Thomas 2023-09-04 11:02:40 +02:00
parent 5204974688
commit b8c96e872f
26 changed files with 45 additions and 172 deletions

View file

@ -1107,12 +1107,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
}
//If the attached account is null, the app will fetch remote instance to get up-to-date values
if (currentAccount != null && currentAccount.mastodon_account == null) {
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + (MainActivity.currentInstance != null ? IDN.toASCII(MainActivity.currentInstance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))

View file

@ -29,7 +29,6 @@ import java.net.IDN;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -62,12 +61,7 @@ public class Nitter implements Serializable {
public static MastodonTimelinesService initInstanceXMLOnly(Context context, String instance) {
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(context))
.build();
OkHttpClient okHttpClient = Helper.myOkHttpClient(context);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null))
.addConverterFactory(SimpleXmlConverterFactory.create())

View file

@ -34,7 +34,6 @@ import java.io.IOException;
import java.net.IDN;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.BaseMainActivity;
import app.fedilab.android.R;
@ -260,11 +259,7 @@ public class CrossActionHelper {
private static MastodonSearchService init(Context context, String instance) {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(context))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(context);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v2/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))

View file

@ -140,6 +140,7 @@ import java.util.Random;
import java.util.Set;
import java.util.TimeZone;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -168,6 +169,8 @@ import app.fedilab.android.mastodon.watermark.androidwm.bean.WatermarkText;
import es.dmoral.toasty.Toasty;
import okhttp3.MediaType;
import okhttp3.MultipartBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
public class Helper {
@ -2080,4 +2083,20 @@ public class Helper {
return false;
}
}
public static OkHttpClient myOkHttpClient(Context context) {
return new OkHttpClient.Builder()
.addInterceptor(chain -> {
Request originalRequest = chain.request();
Request requestWithUserAgent = originalRequest.newBuilder()
.header("User-Agent", context.getString(R.string.app_name) + "/" + BuildConfig.VERSION_NAME + "/" + BuildConfig.VERSION_CODE)
.build();
return chain.proceed(requestWithUserAgent);
})
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(context))
.build();
}
}

View file

@ -41,7 +41,6 @@ import java.net.IDN;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.BaseMainActivity;
import app.fedilab.android.R;
@ -137,11 +136,7 @@ public class NotificationsHelper {
private static MastodonNotificationsService init(Context context, String instance) {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(context))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(context);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))

View file

@ -24,7 +24,6 @@ import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
import java.net.IDN;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.R;
import app.fedilab.android.mastodon.client.endpoints.MastodonNotificationsService;
@ -132,11 +131,7 @@ public class PushNotifications {
}
private static MastodonNotificationsService init(@NonNull Context context, String instance) {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(context.getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(context);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v1/")
.addConverterFactory(GsonConverterFactory.create(Helper.getDateBuilder()))

View file

@ -33,7 +33,6 @@ import java.net.IDN;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -56,11 +55,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class TimelineHelper {
private static MastodonFiltersService initv2(Context context) {
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(context))
.build();
OkHttpClient okHttpClient = Helper.myOkHttpClient(context);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + (MainActivity.currentInstance != null ? IDN.toASCII(MainActivity.currentInstance, IDN.ALLOW_UNASSIGNED) : null) + "/api/v2/")
.addConverterFactory(GsonConverterFactory.create())

View file

@ -64,12 +64,7 @@ public class FetchHomeWorker extends Worker {
private static final int FETCH_HOME_CHANNEL_ID = 5;
private static final String CHANNEL_ID = "fedilab_home";
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplicationContext().getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplicationContext());
private final NotificationManager notificationManager;

View file

@ -27,7 +27,6 @@ import androidx.lifecycle.MutableLiveData;
import java.net.IDN;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.R;
import app.fedilab.android.activities.MainActivity;
@ -69,12 +68,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class AccountsVM extends AndroidViewModel {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
private MutableLiveData<Account> accountMutableLiveData;

View file

@ -25,7 +25,6 @@ import androidx.lifecycle.MutableLiveData;
import java.net.IDN;
import java.util.List;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.mastodon.client.endpoints.MastodonAdminService;
import app.fedilab.android.mastodon.client.entities.api.admin.AdminAccount;
@ -44,12 +43,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class AdminVM extends AndroidViewModel {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
private MutableLiveData<AdminAccount> adminAccountMutableLiveData;
private MutableLiveData<AdminAccounts> adminAccountsListMutableLiveData;
private MutableLiveData<AdminReport> adminReportMutableLiveData;

View file

@ -25,7 +25,6 @@ import androidx.lifecycle.MutableLiveData;
import java.net.IDN;
import java.util.List;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.mastodon.client.endpoints.MastodonAnnouncementsService;
import app.fedilab.android.mastodon.client.entities.api.Announcement;
@ -38,12 +37,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class AnnouncementsVM extends AndroidViewModel {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
private MutableLiveData<Announcement> announcementMutableLiveData;
private MutableLiveData<List<Announcement>> announcementListMutableLiveData;

View file

@ -27,7 +27,6 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.net.IDN;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.mastodon.client.endpoints.MastodonAppsService;
import app.fedilab.android.mastodon.client.entities.api.App;
@ -40,12 +39,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class AppsVM extends AndroidViewModel {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
private MutableLiveData<App> appMutableLiveData;

View file

@ -26,7 +26,6 @@ import androidx.lifecycle.MutableLiveData;
import java.net.IDN;
import java.util.List;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.BaseMainActivity;
import app.fedilab.android.mastodon.client.endpoints.MastodonFiltersService;
@ -41,12 +40,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class FiltersVM extends AndroidViewModel {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
private MutableLiveData<Filter> filterMutableLiveData;

View file

@ -23,7 +23,6 @@ import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.MutableLiveData;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.mastodon.client.entities.app.InstanceSocial;
import app.fedilab.android.mastodon.helper.Helper;
@ -36,12 +35,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class InstanceSocialVM extends AndroidViewModel {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
private final InstancesSocialService instancesSocialService;
private MutableLiveData<InstanceSocial> instanceSocialMutableLiveData;

View file

@ -29,7 +29,6 @@ import com.google.gson.GsonBuilder;
import java.net.IDN;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.BaseMainActivity;
import app.fedilab.android.mastodon.client.endpoints.MastodonInstanceService;
@ -48,12 +47,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class InstancesVM extends AndroidViewModel {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
private MutableLiveData<EmojiInstance> emojiInstanceMutableLiveData;
private MutableLiveData<InstanceInfo> instanceInfoMutableLiveData;

View file

@ -24,7 +24,6 @@ import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import java.util.List;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.mastodon.client.endpoints.JoinMastodonService;
import app.fedilab.android.mastodon.client.entities.api.JoinMastodonInstance;
@ -37,12 +36,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class JoinInstancesVM extends AndroidViewModel {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
private final String base_url;
private final JoinMastodonService joinMastodonService;
private MutableLiveData<List<JoinMastodonInstance>> joiListMutableLiveData;

View file

@ -25,7 +25,6 @@ import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import java.net.IDN;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.mastodon.client.NodeInfoService;
import app.fedilab.android.mastodon.client.entities.app.WellKnownNodeinfo;
@ -38,11 +37,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class NodeInfoVM extends AndroidViewModel {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(5, TimeUnit.SECONDS)
.connectTimeout(5, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
private MutableLiveData<WellKnownNodeinfo.NodeInfo> nodeInfoMutableLiveData;

View file

@ -27,7 +27,6 @@ import java.net.IDN;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.mastodon.client.endpoints.MastodonNotificationsService;
import app.fedilab.android.mastodon.client.entities.api.Notification;
@ -49,12 +48,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class NotificationsVM extends AndroidViewModel {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
private MutableLiveData<Notifications> notificationsMutableLiveData;

View file

@ -27,7 +27,6 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.net.IDN;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.mastodon.client.endpoints.MastodonAppsService;
import app.fedilab.android.mastodon.client.entities.api.Token;
@ -40,12 +39,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class OauthVM extends AndroidViewModel {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
private MutableLiveData<Token> tokenMutableLiveData;
private MutableLiveData<Void> voidMutableLiveData;

View file

@ -20,7 +20,6 @@ import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import java.net.IDN;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.mastodon.client.endpoints.MastodonOembedService;
import app.fedilab.android.mastodon.helper.Helper;
@ -30,12 +29,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class OembedVM extends AndroidViewModel {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
public OembedVM(@NonNull Application application) {
super(application);

View file

@ -29,7 +29,6 @@ import androidx.preference.PreferenceManager;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.R;
import app.fedilab.android.mastodon.client.endpoints.MastodonSearchService;
@ -48,12 +47,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class ReorderVM extends AndroidViewModel {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
private MutableLiveData<Results> resultsMutableLiveData;
private MutableLiveData<Pinned> pinnedMutableLiveData;
private MutableLiveData<BottomMenu> bottomMenuMutableLiveData;

View file

@ -29,7 +29,6 @@ import com.google.gson.GsonBuilder;
import java.net.IDN;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.mastodon.client.endpoints.MastodonSearchService;
import app.fedilab.android.mastodon.client.entities.api.Results;
@ -45,12 +44,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class SearchVM extends AndroidViewModel {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
private MutableLiveData<Results> resultsMutableLiveData;
public SearchVM(@NonNull Application application) {

View file

@ -25,7 +25,6 @@ import androidx.lifecycle.MutableLiveData;
import java.net.IDN;
import java.util.List;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.mastodon.client.endpoints.MastodonTagService;
import app.fedilab.android.mastodon.client.entities.api.Pagination;
@ -42,12 +41,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class TagVM extends AndroidViewModel {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
private MutableLiveData<Tags> tagsMutableLiveData;
private MutableLiveData<Tag> tagMutableLiveData;

View file

@ -35,7 +35,6 @@ import java.net.IDN;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.R;
import app.fedilab.android.activities.MainActivity;
@ -71,12 +70,7 @@ import retrofit2.converter.simplexml.SimpleXmlConverterFactory;
public class TimelinesVM extends AndroidViewModel {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
private MutableLiveData<List<Account>> accountListMutableLiveData;

View file

@ -22,7 +22,6 @@ import androidx.lifecycle.MutableLiveData;
import java.net.IDN;
import java.util.List;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.mastodon.client.endpoints.PleromaAPI;
import app.fedilab.android.mastodon.client.entities.api.Announcement;
@ -34,12 +33,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
public class ActionsVM extends AndroidViewModel {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.callTimeout(60, TimeUnit.SECONDS)
.proxy(Helper.getProxy(getApplication().getApplicationContext()))
.build();
final OkHttpClient okHttpClient = Helper.myOkHttpClient(getApplication().getApplicationContext());
private MutableLiveData<Announcement> announcementMutableLiveData;
private MutableLiveData<List<Announcement>> announcementListMutableLiveData;

View file

@ -54,7 +54,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import app.fedilab.android.BaseMainActivity;
import app.fedilab.android.R;
@ -226,11 +225,7 @@ public class RetrofitPeertubeAPI {
}
private PeertubeService init() {
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.proxy(app.fedilab.android.mastodon.helper.Helper.getProxy(_context.getApplicationContext()))
.build();
final OkHttpClient okHttpClient = app.fedilab.android.mastodon.helper.Helper.myOkHttpClient(_context);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(finalUrl)
.addConverterFactory(GsonConverterFactory.create())
@ -248,11 +243,7 @@ public class RetrofitPeertubeAPI {
if (!URLUtil.isValidUrl("https://" + instance)) {
return null;
}
final OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(60, TimeUnit.SECONDS)
.connectTimeout(60, TimeUnit.SECONDS)
.proxy(app.fedilab.android.mastodon.helper.Helper.getProxy(_context.getApplicationContext()))
.build();
final OkHttpClient okHttpClient = app.fedilab.android.mastodon.helper.Helper.myOkHttpClient(_context);
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://" + (instance != null ? IDN.toASCII(instance, IDN.ALLOW_UNASSIGNED) : null))
.addConverterFactory(GsonConverterFactory.create())