Commit 64ad7083 authored by Ricki Hirner's avatar Ricki Hirner 🐑

Use untranslated User-Agent string

* refactoring: don't use global string variables
parent d4e38644
Pipeline #7838810 passed with stage
in 15 minutes and 35 seconds
......@@ -58,9 +58,6 @@ public class App extends Application {
public static final String OVERRIDE_PROXY_HOST_DEFAULT = "localhost";
public static final int OVERRIDE_PROXY_PORT_DEFAULT = 8118;
@Getter
private static String appName, homepageUrl;
@Getter
private CustomCertManager certManager;
......@@ -89,9 +86,6 @@ public class App extends Application {
public void onCreate() {
super.onCreate();
appName = getString(R.string.app_name);
homepageUrl = getString(R.string.homepage_url);
reinitCertManager();
reinitLogger();
......
......@@ -42,7 +42,7 @@ public class HttpClient {
private static final String userAgent;
static {
String date = new SimpleDateFormat("yyyy/MM/dd", Locale.US).format(new Date(BuildConfig.buildTime));
userAgent = App.getAppName() + "/" + BuildConfig.VERSION_NAME + " (" + date + "; dav4android; okhttp3) Android/" + Build.VERSION.RELEASE;
userAgent = "DAVdroid/" + BuildConfig.VERSION_NAME + " (" + date + "; dav4android; okhttp3) Android/" + Build.VERSION.RELEASE;
}
private HttpClient() {
......
......@@ -31,7 +31,6 @@ import android.view.ViewGroup;
import android.widget.TextView;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.io.IOException;
import java.io.InputStream;
......@@ -46,33 +45,22 @@ import lombok.RequiredArgsConstructor;
public class AboutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
setSupportActionBar((Toolbar)findViewById(R.id.toolbar));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ViewPager viewPager = (ViewPager)findViewById(R.id.viewpager);
viewPager.setAdapter(new TabsAdapter(getSupportFragmentManager()));
TabLayout tabLayout = (TabLayout)findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
}
@RequiredArgsConstructor
private static class ComponentInfo {
final String title, version, website, copyright;
final int licenseInfo;
final String licenseTextFile;
}
private static ComponentInfo components[];
private final static ComponentInfo components[] = {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
components = new ComponentInfo[] {
new ComponentInfo(
App.getAppName(), BuildConfig.VERSION_NAME, App.getHomepageUrl(),
DateFormatUtils.format(BuildConfig.buildTime, "yyyy") + " Ricki Hirner, Bernhard Stockmann (bitfire web engineering)",
getString(R.string.app_name), BuildConfig.VERSION_NAME, getString(R.string.homepage_url),
"Ricki Hirner, Bernhard Stockmann (bitfire web engineering)",
R.string.about_license_info_no_warranty, "gpl-3.0-standalone.html"
), new ComponentInfo(
"AmbilWarna", null, "https://github.com/yukuku/ambilwarna",
......@@ -96,7 +84,19 @@ public class AboutActivity extends AppCompatActivity {
"Project Lombok", null, "https://projectlombok.org/",
"The Project Lombok Authors", R.string.about_license_info_no_warranty, "mit.html"
)
};
};
setContentView(R.layout.activity_about);
setSupportActionBar((Toolbar)findViewById(R.id.toolbar));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ViewPager viewPager = (ViewPager)findViewById(R.id.viewpager);
viewPager.setAdapter(new TabsAdapter(getSupportFragmentManager()));
TabLayout tabLayout = (TabLayout)findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
}
private static class TabsAdapter extends FragmentPagerAdapter {
......@@ -137,7 +137,7 @@ public class AboutActivity extends AppCompatActivity {
@Override
@SuppressLint("SetTextI18n")
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
ComponentInfo info = components[getArguments().getInt(KEY_POSITION)];
ComponentInfo info = ((AboutActivity)getActivity()).components[getArguments().getInt(KEY_POSITION)];
View v = inflater.inflate(R.layout.about_component, container, false);
......
......@@ -130,16 +130,18 @@ public class AccountsActivity extends AppCompatActivity implements NavigationVie
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://twitter.com/davdroidapp")));
break;
case R.id.nav_website:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(App.getHomepageUrl())));
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.homepage_url))));
break;
case R.id.nav_faq:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.navigation_drawer_faq_url))));
break;
case R.id.nav_forums:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(App.getHomepageUrl()).buildUpon().appendEncodedPath("forums/").build()));
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.homepage_url))
.buildUpon().appendEncodedPath("forums/").build()));
break;
case R.id.nav_donate:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(App.getHomepageUrl()).buildUpon().appendEncodedPath("donate/").build()));
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.homepage_url))
.buildUpon().appendEncodedPath("donate/").build()));
break;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment