Skip to content

Commit

Permalink
fixed several layout bugs
Browse files Browse the repository at this point in the history
updated homepage (default recommendations added)
fixed ERR_CLEARTEXT_NOT_PERMITTED problem
  • Loading branch information
truefedex committed May 24, 2019
1 parent 76d47e0 commit 4d1e3c7
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 70 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 30
versionName "1.4.3"
versionCode 31
versionName "1.4.4"
}
signingConfigs {
release {
Expand Down Expand Up @@ -74,6 +74,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:16.0.8'
crashlyticsImplementation 'com.google.firebase:firebase-core:16.0.9'
crashlyticsImplementation 'com.crashlytics.sdk.android:crashlytics:2.10.0'
}
5 changes: 2 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:usesCleartextTraffic="true"
android:screenOrientation="sensor"
android:theme="@style/AppTheme">
<activity
android:name=".activity.main.MainActivity"
Expand All @@ -49,7 +51,6 @@
android:label="@string/app_name_short"
android:launchMode="singleTop"
android:logo="@drawable/banner"
android:screenOrientation="sensorLandscape"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -74,12 +75,10 @@
<activity
android:name=".activity.history.HistoryActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:screenOrientation="sensorLandscape"
android:windowSoftInputMode="adjustResize" />

<activity android:name=".activity.downloads.DownloadsActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:screenOrientation="sensorLandscape"
android:windowSoftInputMode="adjustResize" />

<meta-data
Expand Down
27 changes: 24 additions & 3 deletions app/src/main/assets/pages/new-tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,48 @@
var suggs = undefined;
function renderSuggestions() {
if (suggs) return;
var recommendations = [
{"title": "YouTube", "url":"https://www.youtube.com"},
{"title": "Facebook", "url":"https://www.facebook.com"},
{"title": "Twitter", "url":"https://twitter.com"},
{"title": "Twitch", "url":"https://www.twitch.tv"},
{"title": "Amazon", "url":"https://www.amazon.com/video"},
{"title": "Deezer", "url":"https://www.deezer.com"},
{"title": "BBC", "url":"https://www.bbc.com"},
{"title": "AliExpress", "url":"https://aliexpress.comi"}];
var suggsStr = TVBro.suggestions();
suggs = JSON.parse(suggsStr);
//suggs = [{"title": "test", "url":"http://google.com"}, {"title": "test", "url":"http://googlewerqwerqwerwqerqwerdfasdfaserfwsderfwerqwerqwerwqdfasdfawsefWEFefWEFwaefAWSF.com"}, {"title": "test", "url":"http://google.com"}, {"title": "test", "url":"http://google.com"}, {"title": "test", "url":"http://google.com"}, {"title": "test", "url":"http://google.com"}, {"title": "test", "url":"http://google.com"}];
var i = 0;
while (suggs.length < 8) {
suggs.push(recommendations[i++]);
}
suggs.map(function(c, i, arr){
if (!c.favicon) {
c.favicon = 'file:///android_asset/pages/ic_web.png'
const url = new URL(c.url);
c.favicon = url.origin + "/favicon.ico";
}
return c;
})
//suggs = [{"title": "test", "url":"http://google.com"}, {"title": "test", "url":"http://googlewerqwerqwerwqerqwerdfasdfaserfwsderfwerqwerqwerwqdfasdfawsefWEFefWEFwaefAWSF.com"}, {"title": "test", "url":"http://google.com"}, {"title": "test", "url":"http://google.com"}, {"title": "test", "url":"http://google.com"}, {"title": "test", "url":"http://google.com"}, {"title": "test", "url":"http://google.com"}];
var container = document.getElementById('suggestions');
var html = "";
for (var i = 0; i < suggs.length; i++) {
if (!(i % 2)) html += '<tr>';
html += '<td onclick="onSuggestionClicked(' + i + ');"><div class="sugg" style="margin-left: 0;">'+
'<img src="' + suggs[i].favicon + '" /><div class="sugg-title">' +
'<img src="' + suggs[i].favicon + '" onerror="onfavloaderror(this);" /><div class="sugg-title">' +
suggs[i].title + '</div><div class="sugg-desk">' + suggs[i].url + '</div></div></td>';
if ((i % 2) || i == (suggs.length - 1)) html += '</tr>';
}
container.innerHTML = html;
container.style.top = window.innerHeight / 2 - container.clientHeight / 2 + "px";
}

function onfavloaderror(source) {
//source.src = 'ic_web.png';
source.src = 'file:///android_asset/pages/ic_web.png';
return true;
}
renderSuggestions();
</script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
if (focused) {
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.showSoftInput(etUrl, InputMethodManager.SHOW_FORCED)
uiHandler!!.postDelayed(//workaround an android TV bug
uiHandler.postDelayed(//workaround an android TV bug
{
etUrl.selectAll()
}, 500)
Expand Down Expand Up @@ -365,6 +365,10 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
}
})
} else {
if (viewModel.currentTab.value == null ||
viewModel.currentTab.value!!.currentOriginalUrl == WebViewEx.HOME_URL) {
showMenuOverlay()
}
if (settingsViewModel.needAutockeckUpdates &&
settingsViewModel.updateChecker.versionCheckResult == null &&
!settingsViewModel.lastUpdateNotificationTime.sameDay(Calendar.getInstance())) {
Expand Down Expand Up @@ -477,8 +481,9 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {

override fun onShowCustomView(view: View, callback: WebChromeClient.CustomViewCallback) {
tab.webView?.visibility = View.GONE
flFullscreenContainer!!.visibility = View.VISIBLE
flFullscreenContainer!!.addView(view)
flFullscreenContainer.visibility = View.VISIBLE
flFullscreenContainer.addView(view)
flFullscreenContainer.cursorPosition.set(flWebViewContainer.cursorPosition)

fullScreenView = view
fullscreenViewCallback = callback
Expand All @@ -490,8 +495,9 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
fullScreenView = null
}

fullscreenViewCallback!!.onCustomViewHidden()
fullscreenViewCallback?.onCustomViewHidden()

flWebViewContainer.cursorPosition.set(flFullscreenContainer.cursorPosition)
flFullscreenContainer.visibility = View.GONE
tab.webView?.visibility = View.VISIBLE
}
Expand All @@ -503,11 +509,11 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
} else {
progressBar.progress = newProgress
}
uiHandler!!.removeCallbacks(progressBarHideRunnable)
uiHandler.removeCallbacks(progressBarHideRunnable)
if (newProgress == 100) {
uiHandler!!.postDelayed(progressBarHideRunnable, 1000)
uiHandler.postDelayed(progressBarHideRunnable, 1000)
} else {
uiHandler!!.postDelayed(progressBarHideRunnable, 5000)
uiHandler.postDelayed(progressBarHideRunnable, 5000)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class MainActivityViewModel: ViewModel() {

try {
val frequentlyUsedUrls = asql.queryAll<HistoryItem>(HistoryItem::class.java,
"SELECT title, url, favicon, count(url) as cnt , max(time) as time FROM history GROUP BY title, url, favicon ORDER BY cnt DESC, time DESC LIMIT 6")
"SELECT title, url, favicon, count(url) as cnt , max(time) as time FROM history GROUP BY title, url, favicon ORDER BY cnt DESC, time DESC LIMIT 8")
jsInterface.setSuggestions(TVBro.instance, frequentlyUsedUrls)
} catch (e: Exception) {
e.printStackTrace()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CursorLayout : FrameLayout {
private var USE_SCROLL_HACK = true
private val SCROLL_HACK_PADDING = 300
private val cursorDirection = Point(0, 0)
private val cursorPosition = PointF(0f, 0f)
public val cursorPosition = PointF(0f, 0f)
private val cursorSpeed = PointF(0f, 0f)
private val paint = Paint()
private var lastCursorUpdate = System.currentTimeMillis()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import android.widget.TextView

import com.phlox.tvwebbrowser.R
import com.phlox.tvwebbrowser.model.WebTabState
import kotlinx.android.synthetic.main.view_tab_item.view.*

/**
* Created by PDT on 24.08.2016.
Expand All @@ -21,11 +22,6 @@ class WebTabItemView(context: Context) : FrameLayout(context) {
private var tabState: WebTabState? = null
private var listener: Listener? = null

private val tvTitle: TextView
private val ivThumbnail: ImageView
private val llContainer: LinearLayout
private val btnClose: Button

interface Listener {
fun onTabSelected(tab: WebTabState)
fun onTabDeleteClicked(tab: WebTabState)
Expand All @@ -34,13 +30,8 @@ class WebTabItemView(context: Context) : FrameLayout(context) {

init {
LayoutInflater.from(context).inflate(R.layout.view_tab_item, this)
tvTitle = findViewById<View>(R.id.tvTitle) as TextView
ivThumbnail = findViewById<View>(R.id.ivThumbnail) as ImageView
llContainer = findViewById<View>(R.id.llContainer) as LinearLayout
btnClose = findViewById<View>(R.id.btnClose) as Button

llContainer.setOnClickListener { listener!!.onTabSelected(tabState!!) }

btnClose.setOnClickListener { listener!!.onTabDeleteClicked(tabState!!) }
}

Expand All @@ -59,14 +50,11 @@ class WebTabItemView(context: Context) : FrameLayout(context) {
} else {
ivThumbnail.setImageResource(android.R.color.transparent)
}
llContainer.setBackgroundResource(if (tabState.selected)
R.drawable.selected_tab_button_bg_selector
else
R.drawable.tab_button_bg_selector)
llContainer.isActivated = tabState.selected
}

public override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
val calculatedHeightSpec = View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(widthMeasureSpec) * 4 / 5, View.MeasureSpec.getMode(widthMeasureSpec))
val calculatedHeightSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec) * 4 / 5, View.MeasureSpec.getMode(widthMeasureSpec))
super.onMeasure(widthMeasureSpec, calculatedHeightSpec)
}

Expand Down
28 changes: 0 additions & 28 deletions app/src/main/res/drawable/selected_tab_button_bg_selector.xml

This file was deleted.

10 changes: 9 additions & 1 deletion app/src/main/res/drawable/tab_button_bg_selector.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@
<padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
</shape>
</item>
<item android:state_activated="true">
<shape android:shape="rectangle">
<corners android:topLeftRadius="5dp" android:topRightRadius="5dp" />
<solid android:color="#acf" />
<stroke android:color="#777" android:width="1dp" />
<padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<corners android:topLeftRadius="5dp" android:topRightRadius="5dp" />
<solid android:color="#C2C2C2" />
<solid android:color="#E6E6E6" />
<stroke android:color="#afafaf" android:width="1dp" />
<padding android:bottom="4dp" android:left="4dp" android:right="4dp" android:top="4dp" />
</shape>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@

<com.phlox.tvwebbrowser.activity.main.view.CursorLayout
android:id="@+id/flFullscreenContainer"
android:background="#000"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/view_tab_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:background="@drawable/tab_button_bg_selector"
android:id="@+id/llContainer">

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath 'com.android.tools.build:gradle:3.4.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
classpath 'io.fabric.tools:gradle:1.27.1'
Expand Down
12 changes: 6 additions & 6 deletions latest_version.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
},
{
"name": "beta",
"latestVersionName": "v1.4.3",
"latestVersionCode": 30,
"url": "https://github.com/truefedex/tv-bro/releases/download/v1.4.3/tvbro1.4.3.apk"
"latestVersionName": "v1.4.4",
"latestVersionCode": 31,
"url": "https://github.com/truefedex/tv-bro/releases/download/v1.4.4/tvbro1.4.4.apk"
}
],

"changelog": [
{
"versionCode": 30,
"versionName": "v1.4.3",
"changes": "-Fixed several layout problems and bugs\n-Auto update function (experimental)\n-New settings screen\n-Sites with self-signed certificated now displayed (with warning)"
"versionCode": 31,
"versionName": "v1.4.4",
"changes": "-Fixed several layout problems and bugs\n-Updated homepage\n-Auto update function (experimental)\n-New settings screen\n-Sites with self-signed certificates now displayed (with warning)"
},
{
"versionCode": 25,
Expand Down

0 comments on commit 4d1e3c7

Please sign in to comment.