Skip to content

Commit

Permalink
v1.4.5 bugfix (by crashlogs)
Browse files Browse the repository at this point in the history
  • Loading branch information
truefedex committed May 30, 2019
1 parent 4d1e3c7 commit db0e0f6
Show file tree
Hide file tree
Showing 11 changed files with 56 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 @@ -21,8 +21,8 @@ android {
applicationId "com.phlox.tvwebbrowser"
minSdkVersion 21
targetSdkVersion 28
versionCode 31
versionName "1.4.4"
versionCode 32
versionName "1.4.5"
}
signingConfigs {
release {
Expand Down Expand Up @@ -75,5 +75,5 @@ dependencies {
implementation 'de.halfbit:pinned-section-listview:1.0.0'

crashlyticsImplementation 'com.google.firebase:firebase-core:16.0.9'
crashlyticsImplementation 'com.crashlytics.sdk.android:crashlytics:2.10.0'
crashlyticsImplementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
}
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<uses-feature
android:name="android.hardware.touchscreen"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ class DownloadsActivity : AppCompatActivity(), AdapterView.OnItemClickListener,

companion object {
const val REQUEST_CODE_UNKNOWN_APP_SOURCES = 10007
const val REQUEST_CODE_INSTALL_PACKAGE = 10008

internal fun getFileExtension(filePath: String): String? {
var result = ""
Expand All @@ -291,7 +292,7 @@ class DownloadsActivity : AppCompatActivity(), AdapterView.OnItemClickListener,
install.setDataAndType(apkURI, mimeType)
install.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
try {
activity.startActivityForResult(install, 1001011)//we are not using result for now
activity.startActivityForResult(install, REQUEST_CODE_INSTALL_PACKAGE)//we are not using result for now
} catch (e: ActivityNotFoundException) {
Toast.makeText(activity, R.string.error, Toast.LENGTH_SHORT).show()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import android.view.animation.Animation
import android.view.animation.AnimationUtils
import android.view.inputmethod.InputMethodManager
import android.webkit.*
import android.widget.Toast
import com.phlox.tvwebbrowser.R
import com.phlox.tvwebbrowser.TVBro
import com.phlox.tvwebbrowser.activity.downloads.DownloadsActivity
Expand Down Expand Up @@ -145,7 +146,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
override fun onFavoriteChoosen(item: FavoriteItem?) {
navigate(item!!.url!!)
}
}, currentPageTitle!!, currentPageUrl!!).show()
}, currentPageTitle, currentPageUrl).show()
hideMenuOverlay()
}

Expand Down Expand Up @@ -387,7 +388,9 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
}
val tab = WebTabState()
tab.currentOriginalUrl = url
createWebView(tab)
if (!createWebView(tab)) {
return
}
viewModel.tabsStates.add(0, tab)
changeTab(tab)
navigate(url)
Expand Down Expand Up @@ -428,7 +431,9 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
lvTabs.setSelection(viewModel.tabsStates.indexOf(newTab))
}
if (viewModel.currentTab.value!!.webView == null) {
createWebView(viewModel.currentTab.value!!)
if (!createWebView(viewModel.currentTab.value!!)) {
return
}
viewModel.currentTab.value!!.restoreWebView()
flWebViewContainer!!.addView(viewModel.currentTab.value!!.webView)
} else {
Expand All @@ -443,8 +448,24 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
}

@SuppressLint("SetJavaScriptEnabled")
private fun createWebView(tab: WebTabState) {
tab.webView = WebViewEx(this)
private fun createWebView(tab: WebTabState): Boolean {
try {
tab.webView = WebViewEx(this)
} catch (e: UnsatisfiedLinkError) {
e.printStackTrace()
Toast.makeText(this,
getString(R.string.err_webview_can_not_link),
Toast.LENGTH_LONG).show()
finish()
return false
} catch (e: PackageManager.NameNotFoundException) {
e.printStackTrace()
Toast.makeText(this,
getString(R.string.err_webview_can_not_link),
Toast.LENGTH_LONG).show()
finish()
return false
}

if (settingsViewModel.uaString.value == null || settingsViewModel.uaString.value == "") {
settingsViewModel.saveUAString("TV Bro/1.0 " + tab.webView!!.settings.userAgentString.replace("Mobile Safari", "Safari"))
Expand Down Expand Up @@ -560,17 +581,13 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
}

if (!neededPermissions.isEmpty()) {
val permissionsArr = arrayOfNulls<String>(neededPermissions.size)
neededPermissions.toTypedArray()
requestPermissions(permissionsArr,
requestPermissions(neededPermissions.toTypedArray(),
MY_PERMISSIONS_REQUEST_WEB_PAGE_PERMISSIONS)
} else {
if (reuestedResourcesForAlreadyGrantedPermissions!!.isEmpty()) {
webPermissionsRequest.deny()
} else {
val grantedResourcesArr = arrayOfNulls<String>(reuestedResourcesForAlreadyGrantedPermissions!!.size)
reuestedResourcesForAlreadyGrantedPermissions!!.toTypedArray()
webPermissionsRequest.grant(grantedResourcesArr)
webPermissionsRequest.grant(reuestedResourcesForAlreadyGrantedPermissions!!.toTypedArray())
}
}
} else {
Expand Down Expand Up @@ -750,6 +767,8 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
onDownloadRequested(url, DownloadUtils.guessFileName(url, contentDisposition, mimetype), userAgent
?: tab.webView?.settings?.userAgentString)
}

return true
}

private fun showCertificateErrorHint(error: SslError) {
Expand Down Expand Up @@ -787,6 +806,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {

override fun onRequestPermissionsResult(requestCode: Int,
permissions: Array<String>, grantResults: IntArray) {
if (grantResults.isEmpty()) return
when (requestCode) {
MY_PERMISSIONS_REQUEST_WEB_PAGE_PERMISSIONS -> {
if (webPermissionsRequest == null) {
Expand All @@ -807,9 +827,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
if (resources.isEmpty()) {
webPermissionsRequest!!.deny()
} else {
val resourcesArr = arrayOfNulls<String>(resources.size)
resources.toTypedArray()
webPermissionsRequest!!.grant(resourcesArr)
webPermissionsRequest!!.grant(resources.toTypedArray())
}
webPermissionsRequest = null
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.util.ArrayList
/**
* Created by PDT on 09.09.2016.
*/
class FavoritesDialog(context: Context, private val callback: Callback, private val currentPageTitle: String, private val currentPageUrl: String) : Dialog(context), FavoriteItemView.Listener {
class FavoritesDialog(context: Context, private val callback: Callback, private val currentPageTitle: String?, private val currentPageUrl: String?) : Dialog(context), FavoriteItemView.Listener {
private var items: MutableList<FavoriteItem> = ArrayList()
private val adapter: FavoritesListAdapter = FavoritesListAdapter(items, this)
private val asql: ASQL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ class DownloadService : Service() {
super.onDestroy()
}

override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
if (intent == null) return START_STICKY
val download = intent.getSerializableExtra("download") as Download
val userAgent = intent.getStringExtra("userAgent")
try {
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/view_favorite_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
android:padding="6dp"
android:gravity="center_vertical"
android:layout_weight="1"
android:id="@+id/llContent"
android:background="@drawable/favorite_item_view_bg_selector">
android:id="@+id/llContent">

<TextView
android:layout_width="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@
<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>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@
<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>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,5 @@
<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>
</resources>
17 changes: 11 additions & 6 deletions latest_version.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@
"channels": [
{
"name": "release",
"latestVersionName": "v1.3.0",
"latestVersionCode": 25,
"url": "https://github.com/truefedex/tv-bro/releases/download/v1.3.0-alpha/tvbro1.3.0alpha.apk"
"latestVersionName": "v1.4.5",
"latestVersionCode": 32,
"url": "https://github.com/truefedex/tv-bro/releases/download/v1.4.5/tvbro1.4.5.apk"
},
{
"name": "beta",
"latestVersionName": "v1.4.4",
"latestVersionCode": 31,
"url": "https://github.com/truefedex/tv-bro/releases/download/v1.4.4/tvbro1.4.4.apk"
"latestVersionName": "v1.4.5",
"latestVersionCode": 32,
"url": "https://github.com/truefedex/tv-bro/releases/download/v1.4.5/tvbro1.4.5.apk"
}
],

"changelog": [
{
"versionCode": 32,
"versionName": "v1.4.5",
"changes": "-Fixed several bugs"
},
{
"versionCode": 31,
"versionName": "v1.4.4",
Expand Down

0 comments on commit db0e0f6

Please sign in to comment.