Skip to content

Commit

Permalink
localizations added
Browse files Browse the repository at this point in the history
  • Loading branch information
truefedex committed Jul 20, 2020
1 parent 976faac commit c5ef576
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 28 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId "com.phlox.tvwebbrowser"
minSdkVersion 21
targetSdkVersion 28
versionCode 33
versionName "1.5.0"
versionCode 34
versionName "1.5.1"

javaCompileOptions {
annotationProcessorOptions {
Expand Down Expand Up @@ -80,6 +80,6 @@ dependencies {
implementation 'com.github.truefedex:segmented-button:v1.0.0'
implementation 'de.halfbit:pinned-section-listview:1.0.0'

crashlyticsImplementation 'com.google.firebase:firebase-core:17.4.3'
crashlyticsImplementation 'com.google.firebase:firebase-core:17.4.4'
crashlyticsImplementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
}
25 changes: 17 additions & 8 deletions app/src/main/assets/pages/warning-certificate.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,36 @@
}
</style>
</head>
<body onload="showErrorDesk();">
<body onload="onLoad();">
<div class="interstitial-wrapper">
<div>
<img src="file:///android_asset/pages/ic_warning.svg">
<!--<img src="ic_warning.svg">-->
<h1 style="margin-bottom: 28px;">Connection is not secure</h1>
<p><b>Hostname: </b><span id="hostname"></span></p>
<p><b>Error description: </b><span id="error"></span></p>
<p><b>Details: </b><br><span id="error-details"></span></p>
<h1 id="caption" style="margin-bottom: 28px;"></h1>
<p><b id="hostnameLabel"></b> <span id="hostname"></span></p>
<p><b id="errorDeskr"></b> <span id="error"></span></p>
<p><b id="details"></b><br> <span id="error-details"></span></p>

<div id="certErrorAndCaptivePortalButtonContainer">
<button id="returnButton" onclick="TVBro.navigateBack();">Back to safety</button>
<button id="goForwardButton" onclick="TVBro.reloadWithSslTrust();">Go. I am aware of the risk</button>
<button id="returnButton" onclick="TVBro.navigateBack();"></button>
<button id="goForwardButton" onclick="TVBro.reloadWithSslTrust();"></button>
</div>
</div>
</div>
<script>
function onSuggestionClicked(index) {
TVBro.navigate(suggs[index].url);
}
function showErrorDesk() {
function onLoad() {
//translate captions first
document.getElementById("caption").innerHTML = TVBro.getStringByName('connection_isnt_secure');
document.getElementById("hostnameLabel").innerHTML = TVBro.getStringByName('hostname');
document.getElementById("errorDeskr").innerHTML = TVBro.getStringByName('err_desk');
document.getElementById("details").innerHTML = TVBro.getStringByName('details');
document.getElementById("returnButton").innerHTML = TVBro.getStringByName('back_to_safety');
document.getElementById("goForwardButton").innerHTML = TVBro.getStringByName('go_im_aware');

//show error info
let url = new URL(TVBro.currentUrl());
document.getElementById("hostname").innerHTML = url.hostname;
let error = TVBro.lastSSLError(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,26 +459,25 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
}

private fun changeTab(newTab: WebTabState) {
if (viewModel.currentTab.value != null) {
viewModel.currentTab.value!!.selected = false
viewModel.currentTab.value!!.webView?.onPause()
flWebViewContainer!!.removeView(viewModel.currentTab.value!!.webView)
viewModel.currentTab.value?.webView?.apply {
onPause()
flWebViewContainer.removeView(this)
}

newTab.selected = true
viewModel.currentTab.value = newTab
vTitles.current = viewModel.tabsStates.indexOf(newTab)
if (viewModel.currentTab.value!!.webView == null) {
if (!createWebView(viewModel.currentTab.value!!)) {
if (newTab.webView == null) {
if (!createWebView(newTab)) {
return
}
viewModel.currentTab.value!!.restoreWebView()
flWebViewContainer!!.addView(viewModel.currentTab.value!!.webView)
newTab.restoreWebView()
flWebViewContainer.addView(newTab.webView)
} else {
flWebViewContainer!!.addView(viewModel.currentTab.value!!.webView)
viewModel.currentTab.value!!.webView?.onResume()
flWebViewContainer.addView(newTab.webView)
newTab.webView!!.onResume()
}
viewModel.currentTab.value!!.webView?.setNetworkAvailable(Utils.isNetworkConnected(this))
newTab.webView!!.setNetworkAvailable(Utils.isNetworkConnected(this))

etUrl.setText(newTab.currentOriginalUrl)
ibBack.isEnabled = newTab.webView?.canGoBack() == true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import org.json.JSONArray
import org.json.JSONException
import org.json.JSONObject

/**
* Created by fedex on 11.12.16.
*/

class AndroidJSInterface(private val mainActivityViewModel: MainActivityViewModel) {
private var activity: MainActivity? = null
private var suggestions = "[]"
Expand Down Expand Up @@ -50,6 +48,13 @@ class AndroidJSInterface(private val mainActivityViewModel: MainActivityViewMode
}
}

@JavascriptInterface
fun getStringByName(name: String): String {
val ctx = TVBro.instance
val resId = ctx.resources.getIdentifier(name, "string", ctx.packageName)
return ctx.getString(resId)
}

@JavascriptInterface
fun suggestions(): String {
return suggestions
Expand Down
15 changes: 14 additions & 1 deletion app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,18 @@
<string name="warning">Предупреждение</string>
<string name="web_browser_optimized_for_tvs_https_github_com_truefedex_tv_bro">Веб-браузер, оптимизированный для телевизоров (https://github.com/truefedex/tv-bro)</string>
<string name="new_version_available_s">Доступна новая версия: %s</string>
<string name="err_webview_can_not_link">Не могу найти WebView компонент. Попробуйте сперва установить Chrome (или другую версию Chrome, если уже стоит).</string>
<string name="err_webview_can_not_link">Не могу найти WebView компонент. Попробуйте сперва установить Android System WebView</string>
<string name="new_tab_title">[НОВАЯ ВКЛ.]</string>
<string name="open_a_new_tab_here">Открыть новую вкладку тут</string>
<string name="tabs">Вкладки</string>
<string name="ssl_expired">Срок действия сертификата истек</string>
<string name="ssl_idmismatch">Несоответствие имени хоста</string>
<string name="ssl_date_invalid">Дата сертификата недействительна</string>
<string name="ssl_invalid">Произошла общая ошибка</string>
<string name="back_to_safety">Вернуться к безопасности</string>
<string name="go_im_aware">Вперёд. Я осознаю риск</string>
<string name="connection_isnt_secure">Соединение не защищено</string>
<string name="hostname">Имя хоста:</string>
<string name="err_desk">Описание ошибки:</string>
<string name="details">Подробности:</string>
</resources>
15 changes: 14 additions & 1 deletion app/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,18 @@
<string name="warning">Увага</string>
<string name="web_browser_optimized_for_tvs_https_github_com_truefedex_tv_bro">Веб-браузер, оптимізований для телевізорів (https://github.com/truefedex/tv-bro)</string>
<string name="new_version_available_s">Доступна нова версія: %s</string>
<string name="err_webview_can_not_link">Не можу знайти WebView компонент. Спробуйте спочатку встановити Chrome (або новішу версію Chrome, якщо вже є).</string>
<string name="err_webview_can_not_link">Не можу знайти WebView компонент. Спробуйте спочатку встановити Android System WebView</string>
<string name="new_tab_title">[НОВА ВКЛ.]</string>
<string name="open_a_new_tab_here">Відкрити нову вкладку тут</string>
<string name="tabs">Вкладки</string>
<string name="ssl_expired">Термін дії сертифікату минув</string>
<string name="ssl_idmismatch">Невідповідність імені хоста</string>
<string name="ssl_date_invalid">Дата сертифіката недійсна</string>
<string name="ssl_invalid">Виникла загальна помилка</string>
<string name="back_to_safety">Повернення до безпеки</string>
<string name="go_im_aware">Вперед. Я знаю про ризик</string>
<string name="connection_isnt_secure">Підключення не захищено</string>
<string name="hostname">Ім\'я хоста:</string>
<string name="err_desk">Опис помилки:</string>
<string name="details">Деталі:</string>
</resources>
8 changes: 7 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<string name="web_browser_optimized_for_tvs_https_github_com_truefedex_tv_bro">Web browser optimized for TVs ( https://github.com/truefedex/tv-bro )</string>
<string name="warning">Warning</string>
<string name="unprotected_connection">Unprotected connection</string>
<string name="err_webview_can_not_link">Can not link to WebView component. Try to install chrome (or other version of chrome if already).</string>
<string name="err_webview_can_not_link">Can not link to WebView component. Try to install Android System WebView component first.</string>
<string name="new_tab_title">[NEW TAB]</string>
<string name="open_a_new_tab_here">Open a new tab here</string>
<string name="tabs">Tabs</string>
Expand All @@ -94,4 +94,10 @@
<string name="ssl_idmismatch">Hostname mismatch</string>
<string name="ssl_date_invalid">The date of the certificate is invalid</string>
<string name="ssl_invalid">A generic error occurred</string>
<string name="back_to_safety">Back to safety</string>
<string name="go_im_aware">Go. I am aware of the risk</string>
<string name="connection_isnt_secure">Connection is not secure</string>
<string name="hostname">Hostname:</string>
<string name="err_desk">Error description:</string>
<string name="details">Details:</string>
</resources>

0 comments on commit c5ef576

Please sign in to comment.