Skip to content

Commit

Permalink
better mouse support
Browse files Browse the repository at this point in the history
  • Loading branch information
truefedex committed Sep 30, 2020
1 parent e7aec76 commit f2fb898
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
6 changes: 3 additions & 3 deletions app/src/main/assets/pages/new-tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@
{"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": "Amazon", "url":"https://www.amazon.com"},
{"title": "Netflix", "url":"https://www.netflix.com"},
{"title": "BBC", "url":"https://www.bbc.com"},
{"title": "AliExpress", "url":"https://aliexpress.com"}];
{"title": "Prime Video", "url":"https://www.primevideo.com/"}];
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"}];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import android.transition.TransitionManager
import android.util.Log
import android.util.Patterns
import android.view.KeyEvent
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.view.animation.AccelerateInterpolator
Expand Down Expand Up @@ -153,6 +154,7 @@ class MainActivity : AppCompatActivity() {
etUrl.setOnKeyListener(etUrlKeyListener)

llBottomPanel.childs.forEach {
it.setOnTouchListener(bottomButtonsOnTouchListener)
it.onFocusChangeListener = bottomButtonsFocusListener
it.setOnKeyListener(bottomButtonsKeyListener)
}
Expand Down Expand Up @@ -284,6 +286,20 @@ class MainActivity : AppCompatActivity() {
}
}

private val bottomButtonsOnTouchListener = View.OnTouchListener{ v, e ->
when (e.action) {
MotionEvent.ACTION_DOWN -> {
return@OnTouchListener true
}
MotionEvent.ACTION_UP -> {
hideMenuOverlay(false)
v.performClick()
return@OnTouchListener true
}
else -> return@OnTouchListener false
}
}

private val bottomButtonsFocusListener = View.OnFocusChangeListener { view, hasFocus ->
if (hasFocus) {
hideMenuOverlay(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class TitlesView @JvmOverloads constructor(context: Context, attrs: AttributeSet
postInvalidate()
}
private val paint = TextPaint(Paint.ANTI_ALIAS_FLAG)
private lateinit var gDetector: GestureDetectorCompat
private var gDetector: GestureDetectorCompat
var animationVector = 0
var animationStartTime = 0L
private val emptyTitle: String
Expand All @@ -49,8 +49,12 @@ class TitlesView @JvmOverloads constructor(context: Context, attrs: AttributeSet
listener?.onTitleOptions(current)
}

override fun onSingleTapConfirmed(e: MotionEvent?): Boolean {
listener?.onTitleSelected(current)
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
if (e.x < width / 3) {
moveLeft()
} else if (e.x > width / 3 * 2) {
moveRight()
} else listener?.onTitleSelected(current)
return true
}
}
Expand Down

0 comments on commit f2fb898

Please sign in to comment.