forked from mirror/monocles_chat
Add User-Agent to all HTTP calls
This commit is contained in:
parent
ffdfa951cd
commit
37c29e4176
31 changed files with 60 additions and 38 deletions
|
@ -124,14 +124,15 @@ android {
|
|||
applicationId "de.monocles.chat"
|
||||
multiDexEnabled true
|
||||
|
||||
buildConfigField("String", "LOGTAG", '"monocles_chat"')
|
||||
buildConfigField("String", "DOMAIN_LOCK", 'null')
|
||||
buildConfigField("String", "MAGIC_CREATE_DOMAIN", '"monocles.de"')
|
||||
buildConfigField("boolean", "SHOW_INTRO", 'true')
|
||||
buildConfigField("String", "UPDATE_URL", '"https://monocles.de/chat/update/"')
|
||||
resValue "string", "applicationId", applicationId
|
||||
resValue "string", "app_name", "monocles chat"
|
||||
signingConfig signingConfigs.'monocles chat'
|
||||
def appName = "monocles chat"
|
||||
resValue "string", "app_name", appName
|
||||
buildConfigField "String", "APP_NAME", "\"$appName\"";
|
||||
}
|
||||
|
||||
dataBinding {
|
||||
|
|
|
@ -51,7 +51,7 @@ public final class Config {
|
|||
}
|
||||
}
|
||||
|
||||
public static final String LOGTAG = BuildConfig.LOGTAG;
|
||||
public static final String LOGTAG = BuildConfig.APP_NAME.toLowerCase(Locale.US);
|
||||
|
||||
public static final Jid BUG_REPORTS = Jid.of("support@monocles.de");
|
||||
public static final Uri HELP = Uri.parse("https://help.conversations.im");
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.List;
|
|||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import eu.siacs.conversations.BuildConfig;
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
||||
|
@ -66,7 +67,6 @@ public abstract class AbstractGenerator {
|
|||
};
|
||||
|
||||
protected XmppConnectionService mXmppConnectionService;
|
||||
private String mVersion = null;
|
||||
|
||||
AbstractGenerator(XmppConnectionService service) {
|
||||
this.mXmppConnectionService = service;
|
||||
|
@ -78,18 +78,11 @@ public abstract class AbstractGenerator {
|
|||
}
|
||||
|
||||
String getIdentityVersion() {
|
||||
if (mVersion == null) {
|
||||
this.mVersion = PhoneHelper.getVersionName(mXmppConnectionService);
|
||||
}
|
||||
return this.mVersion;
|
||||
return BuildConfig.VERSION_NAME;
|
||||
}
|
||||
|
||||
public String getIdentityName() {
|
||||
return mXmppConnectionService.getString(R.string.app_name) + ' ' + getIdentityVersion();
|
||||
}
|
||||
|
||||
public String getUserAgent() {
|
||||
return System.getProperty("http.agent");
|
||||
return BuildConfig.APP_NAME;
|
||||
}
|
||||
|
||||
String getIdentityType() {
|
||||
|
|
|
@ -19,10 +19,10 @@ import java.util.concurrent.Executor;
|
|||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import eu.siacs.conversations.BuildConfig;
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Message;
|
||||
|
@ -41,8 +41,24 @@ public class HttpConnectionManager extends AbstractConnectionManager {
|
|||
|
||||
public static final Executor FileTransferExecutor = Executors.newFixedThreadPool(4);
|
||||
|
||||
private static final OkHttpClient OK_HTTP_CLIENT = new OkHttpClient();
|
||||
public static final OkHttpClient OK_HTTP_CLIENT;
|
||||
|
||||
static {
|
||||
OK_HTTP_CLIENT = new OkHttpClient.Builder()
|
||||
.addInterceptor(chain -> {
|
||||
final Request original = chain.request();
|
||||
final Request modified = original.newBuilder()
|
||||
.header("User-Agent", getUserAgent())
|
||||
.build();
|
||||
return chain.proceed(modified);
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
public static String getUserAgent() {
|
||||
return String.format("%s/%s", BuildConfig.APP_NAME, BuildConfig.VERSION_NAME);
|
||||
}
|
||||
public HttpConnectionManager(XmppConnectionService service) {
|
||||
super(service);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class ChannelDiscoveryService {
|
|||
}
|
||||
|
||||
void initializeMuclumbusService() {
|
||||
final OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
||||
final OkHttpClient.Builder builder = HttpConnectionManager.OK_HTTP_CLIENT.newBuilder();
|
||||
if (service.useTorToConnect()) {
|
||||
builder.proxy(HttpConnectionManager.getProxy());
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ public class AboutActivity extends XmppActivity {
|
|||
setContentView(R.layout.activity_about);
|
||||
setSupportActionBar(findViewById(R.id.toolbar));
|
||||
configureActionBar(getSupportActionBar());
|
||||
setTitle(getString(R.string.title_activity_about_x, getString(R.string.app_name)));
|
||||
aboutmessage = findViewById(R.id.aboutmessage);
|
||||
libraries = findViewById(R.id.libraries);
|
||||
Button privacyButton = findViewById(R.id.show_privacy_policy);
|
||||
|
|
|
@ -5,18 +5,23 @@ import android.content.Intent;
|
|||
import android.preference.Preference;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import eu.siacs.conversations.BuildConfig;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.utils.PhoneHelper;
|
||||
|
||||
public class AboutPreference extends Preference {
|
||||
public AboutPreference(final Context context, final AttributeSet attrs, final int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
setSummary();
|
||||
setSummaryAndTitle(context);
|
||||
}
|
||||
|
||||
public AboutPreference(final Context context, final AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setSummary();
|
||||
setSummaryAndTitle(context);
|
||||
}
|
||||
private void setSummaryAndTitle(final Context context) {
|
||||
setSummary(String.format("%s %s", BuildConfig.APP_NAME, BuildConfig.VERSION_NAME));
|
||||
setTitle(context.getString(R.string.title_activity_about_x, BuildConfig.APP_NAME));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,9 +30,5 @@ public class AboutPreference extends Preference {
|
|||
final Intent intent = new Intent(getContext(), AboutActivity.class);
|
||||
getContext().startActivity(intent);
|
||||
}
|
||||
|
||||
private void setSummary() {
|
||||
setSummary(getContext().getString(R.string.app_name) + ' ' + PhoneHelper.getVersionName(getContext()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,20 +37,6 @@ public class PhoneHelper {
|
|||
return uri == null ? null : Uri.parse(uri);
|
||||
}
|
||||
|
||||
public static String getVersionName(Context context) {
|
||||
final String packageName = context == null ? null : context.getPackageName();
|
||||
if (packageName != null) {
|
||||
try {
|
||||
return context.getPackageManager().getPackageInfo(packageName, 0).versionName;
|
||||
} catch (final PackageManager.NameNotFoundException e) {
|
||||
return "unknown";
|
||||
} catch (final RuntimeException e) {
|
||||
return "unknown";
|
||||
}
|
||||
} else {
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
public static String getOSVersion(Context context) {
|
||||
return "Android/" + android.os.Build.MODEL + "/" + android.os.Build.VERSION.RELEASE;
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.net.URISyntaxException;
|
|||
import java.net.URLEncoder;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import eu.siacs.conversations.http.HttpConnectionManager;
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.services.XmppConnectionService;
|
||||
|
||||
|
@ -183,7 +184,7 @@ public class RichPreview {
|
|||
try {
|
||||
doc = Jsoup.connect(url)
|
||||
.timeout(Config.CONNECT_TIMEOUT * 1000)
|
||||
.userAgent(xmppConnectionService.getIqGenerator().getUserAgent())
|
||||
.userAgent(HttpConnectionManager.getUserAgent())
|
||||
.get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<string name="action_end_conversation">إنهاء هذه المحادثة</string>
|
||||
<string name="action_contact_details">بيانات المُراسِل</string>
|
||||
<string name="action_secure">محادثة آمنة</string>
|
||||
<string name="title_activity_about_x">عن %s</string>
|
||||
<string name="action_add_new_account">إضافة حساب جديد</string>
|
||||
<string name="action_add_phone_book">إضافة إلى دفتر العناوين</string>
|
||||
<string name="action_delete_contact">حذف من القائمة</string>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<string name="action_add_phone_book">Добавяне към адресната книга</string>
|
||||
<string name="action_delete_contact">Изтриване от любими</string>
|
||||
<string name="action_block_contact">Блокирай контакта</string>
|
||||
<string name="title_activity_about_x">Относно %s</string>
|
||||
<string name="action_unblock_contact">Разблокирай контакта</string>
|
||||
<string name="action_block_domain">Блокираи доминио</string>
|
||||
<string name="action_unblock_domain">Разблокираи доминио</string>
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<string name="action_secure">Conversa segura</string>
|
||||
<string name="action_add_new_account">Afegir nou compte</string>
|
||||
<string name="action_add_phone_book">Afegir a contactes</string>
|
||||
<string name="title_activity_about_x">Sobre 1%s</string>
|
||||
<string name="action_delete_contact">Eliminar de la llista de contactes</string>
|
||||
<string name="action_block_contact">Bloquejar contacte</string>
|
||||
<string name="action_unblock_contact">Desbloquejar contacte</string>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
<string name="action_block_contact">Zablokovat kontakt</string>
|
||||
<string name="action_unblock_contact">Odblokovat kontakt</string>
|
||||
<string name="action_block_domain">Zablokovat doménu</string>
|
||||
<string name="title_activity_about_x">O %s</string>
|
||||
<string name="action_unblock_domain">Odblokovat doménu</string>
|
||||
<string name="title_activity_settings">Nastavení</string>
|
||||
<string name="title_activity_block_list">Seznam blokovaných</string>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Generated by crowdin.com-->
|
||||
<resources></resources>
|
||||
<resources>
|
||||
<string name="title_activity_about_x">Om %s</string>
|
||||
</resources>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<string name="action_add_phone_book">Zu Adressbuch hinzufügen</string>
|
||||
<string name="action_delete_contact">Aus Kontaktliste entfernen</string>
|
||||
<string name="action_block_contact">Kontakt sperren</string>
|
||||
<string name="title_activity_about_x">Über %s</string>
|
||||
<string name="action_unblock_contact">Kontakt entsperren</string>
|
||||
<string name="action_block_domain">Domain sperren</string>
|
||||
<string name="action_unblock_domain">Domain entsperren</string>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<string name="action_block_domain">Αποκλεισμός τομέα</string>
|
||||
<string name="action_unblock_domain">Άρση αποκλεισμού τομέα</string>
|
||||
<string name="title_activity_settings">Ρυθμίσεις</string>
|
||||
<string name="title_activity_about_x">Περί %s</string>
|
||||
<string name="title_activity_block_list">Αποκλεισμός λίστας</string>
|
||||
<string name="just_now">μόλις τώρα</string>
|
||||
<string name="minute_ago">πριν από 1 λεπτό</string>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<string name="action_block_contact">Bloquear contacto</string>
|
||||
<string name="action_unblock_contact">Desbloquear contacto</string>
|
||||
<string name="action_block_domain">Bloquear dominio</string>
|
||||
<string name="title_activity_about_x">Acerca de %s</string>
|
||||
<string name="action_unblock_domain">Desbloquear dominio</string>
|
||||
<string name="title_activity_manage_accounts">Gestionar cuentas</string>
|
||||
<string name="title_activity_settings">Ajustes</string>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
<string name="action_unblock_domain">Domeinua desblokeatu</string>
|
||||
<string name="title_activity_manage_accounts">Kudeatu kontuak</string>
|
||||
<string name="title_activity_settings">Ezarpenak</string>
|
||||
<string name="title_activity_about_x">%s buruz</string>
|
||||
<string name="conference_details">Taldeko txataren xehetasunak</string>
|
||||
<string name="contact_details">Kontaktuaren xehetasunak</string>
|
||||
<string name="title_activity_sharewith">Elkarrizketarekin partekatu</string>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<string name="action_block_contact">Bloquer le contact</string>
|
||||
<string name="action_unblock_contact">Débloquer le contact</string>
|
||||
<string name="action_block_domain">Bloquer le domaine</string>
|
||||
<string name="title_activity_about_x">À propos de %s</string>
|
||||
<string name="action_unblock_domain">Débloquer le domaine</string>
|
||||
<string name="title_activity_manage_accounts">Gestion des comptes</string>
|
||||
<string name="title_activity_settings">Paramètres</string>
|
||||
|
|
|
@ -1120,6 +1120,7 @@
|
|||
<string name="images">imaxes</string>
|
||||
<string name="videos">vídeos</string>
|
||||
<string name="files">arquivos</string>
|
||||
<string name="title_activity_about_x">Acerca de %s</string>
|
||||
<string name="all_media_files">ficheiros multimedia</string>
|
||||
<string name="open_settings">Abrir axustes</string>
|
||||
<string name="oldAndroidVersion">Versión antiga de Android</string>
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<string name="action_unblock_contact">Sblocca contatto</string>
|
||||
<string name="action_block_domain">Blocca dominio</string>
|
||||
<string name="action_unblock_domain">Sblocca dominio</string>
|
||||
<string name="title_activity_about_x">Informazioni su %s</string>
|
||||
<string name="title_activity_manage_accounts">Gestisci account</string>
|
||||
<string name="title_activity_settings">Impostazioni</string>
|
||||
<string name="conference_details">Dettagli della conversazione di gruppo</string>
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<string name="action_unblock_contact">Contact deblokkeren</string>
|
||||
<string name="action_block_domain">Domein blokkeren</string>
|
||||
<string name="action_unblock_domain">Domein deblokkeren</string>
|
||||
<string name="title_activity_about_x">Over %s</string>
|
||||
<string name="title_activity_manage_accounts">Accounts beheren</string>
|
||||
<string name="title_activity_settings">Instellingen</string>
|
||||
<string name="conference_details">Gespreksgegevens</string>
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<string name="action_unblock_contact">Odblokuj kontakt</string>
|
||||
<string name="action_block_domain">Zablokuj domenę</string>
|
||||
<string name="action_unblock_domain">Odblokuj domenę</string>
|
||||
<string name="title_activity_about_x">O %s</string>
|
||||
<string name="title_activity_manage_accounts">Zarządzaj kontami</string>
|
||||
<string name="title_activity_settings">Ustawienia</string>
|
||||
<string name="conference_details">Szczegóły czatu grupowego</string>
|
||||
|
|
|
@ -353,6 +353,7 @@
|
|||
<string name="no_application_to_share_uri">Não foi encontrada nenhuma aplicação para partilhar o URI</string>
|
||||
<string name="share_uri_with">Partilhar URI com...</string>
|
||||
<string name="create_account">Criar conta</string>
|
||||
<string name="title_activity_about_x">Sobre o %s</string>
|
||||
<string name="create_monocles_account"><a href="https://ocean.monocles.de/apps/registration/">Get a monocles account!</a></string>
|
||||
<string name="contact_is_typing">%s está a escrever...</string>
|
||||
<string name="pref_use_tor">Conectar via TOR</string>
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
<string name="title_activity_settings">Setări</string>
|
||||
<string name="conference_details">Detalii discuție de grup</string>
|
||||
<string name="contact_details">Detalii contact</string>
|
||||
<string name="title_activity_about_x">%s</string>
|
||||
<string name="title_activity_sharewith">Partajează într-o conversație</string>
|
||||
<string name="title_activity_start_conversation">Pornește o conversație</string>
|
||||
<string name="title_activity_choose_contact">Alegeți contact</string>
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
<string name="title_activity_settings">Настройки</string>
|
||||
<string name="conference_details">Детали группового чата</string>
|
||||
<string name="contact_details">Детали контакта</string>
|
||||
<string name="title_activity_about_x">О %s</string>
|
||||
<string name="title_activity_sharewith">Поделиться с разговором</string>
|
||||
<string name="title_activity_start_conversation">Начать беседу</string>
|
||||
<string name="title_activity_choose_contact">Выбрать контакт</string>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
<string name="title_activity_settings">Inställningar</string>
|
||||
<string name="title_activity_block_list">Blockeringslista</string>
|
||||
<string name="just_now">just nu</string>
|
||||
<string name="title_activity_about_x">Om %s</string>
|
||||
<string name="minute_ago">1 min sedan</string>
|
||||
<string name="minutes_ago">%d min sedan</string>
|
||||
<string name="sending">skickar…</string>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<string name="action_block_contact">Kişiyi engelle</string>
|
||||
<string name="action_unblock_contact">Kişinin engelini kaldır</string>
|
||||
<string name="action_block_domain">Domaini engelle</string>
|
||||
<string name="title_activity_about_x">%sHakkında</string>
|
||||
<string name="action_unblock_domain">Domainin engelini kaldır</string>
|
||||
<string name="title_activity_manage_accounts">Hesapları yönet</string>
|
||||
<string name="title_activity_settings">Ayarlar</string>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<string name="title_activity_manage_accounts">Мої облікові записи</string>
|
||||
<string name="title_activity_settings">Налаштування</string>
|
||||
<string name="conference_details">Деталі групи</string>
|
||||
<string name="title_activity_about_x">Близько %s</string>
|
||||
<string name="contact_details">Переглянути деталі контакту</string>
|
||||
<string name="title_activity_sharewith">Поділитися розмовою</string>
|
||||
<string name="title_activity_start_conversation">Почати розмову</string>
|
||||
|
|
|
@ -908,6 +908,7 @@
|
|||
<string name="gp_short">短</string>
|
||||
<string name="gp_medium">中</string>
|
||||
<string name="gp_long">长</string>
|
||||
<string name="title_activity_about_x">关于%s</string>
|
||||
<string name="pref_theme_blue">蓝色</string>
|
||||
<string name="pref_theme_orange">橙色</string>
|
||||
<string name="pref_theme_color_options_summary">选择主题调色板</string>
|
||||
|
|
|
@ -144,6 +144,7 @@
|
|||
<string name="account_status_regis_not_sup">Server does not support registration</string>
|
||||
<string name="account_status_tls_error">TLS negotiation failed</string>
|
||||
<string name="account_status_tls_error_domain">Domain not verifiable</string>
|
||||
<string name="title_activity_about_x">About %s</string>
|
||||
<string name="account_status_policy_violation">Policy violation</string>
|
||||
<string name="account_status_incompatible_server">Incompatible server</string>
|
||||
<string name="account_status_stream_error">Stream error</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue