@Override protected Call enqueue(Request request, com.squareup.okhttp.Callback requestCallback) { Context context = PopcornApplication.getAppContext(); PackageInfo pInfo; String versionName = "0.0.0"; try { pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); versionName = pInfo.versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } request = request .newBuilder() .removeHeader("User-Agent") .addHeader( "User-Agent", String.format( "Mozilla/5.0 (Linux; U; Android %s; %s; %s Build/%s) AppleWebkit/534.30 (KHTML, like Gecko) PT/%s", Build.VERSION.RELEASE, LocaleUtils.getCurrent(), Build.MODEL, Build.DISPLAY, versionName)) .build(); return super.enqueue(request, requestCallback); }
private void onSubtitleLanguageSelected(String language) { mSelectedSubtitleLanguage = language; if (!language.equals("no-subs")) { final Locale locale = LocaleUtils.toLocale(language); ThreadUtils.runOnUiThread( new Runnable() { @Override public void run() { mSubtitles.setText(StringUtils.uppercaseFirst(locale.getDisplayName(locale))); } }); } else { ThreadUtils.runOnUiThread( new Runnable() { @Override public void run() { mSubtitles.setText(R.string.no_subs); } }); } }
private GuidedAction generateAction(long id, PrefItem item) { GuidedAction.Builder builder = new GuidedAction.Builder() .id(id) .hasNext(item.hasNext()) .enabled(item.isClickable()) .infoOnly(item.isTitle() || !item.isClickable()) .title( item.isTitle() ? item.getTitle().toUpperCase(LocaleUtils.getCurrent()) : item.getTitle()); if (!item.isTitle()) { builder.description(item.getSubtitle()); if (item.getDefaultValue() instanceof Boolean) { builder.checked((Boolean) item.getValue()); } } return builder.build(); }