Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
074b1f8c
Commit
074b1f8c
authored
Jun 12, 2019
by
Viktor De Pasquale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added one-click scroll to the bottom
parent
326eee8c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
11 deletions
+76
-11
LogViewModel.kt
...src/main/java/com/topjohnwu/magisk/ui/log/LogViewModel.kt
+6
-0
DataBindingAdapters.kt
...in/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt
+31
-1
ic_arrow_down.xml
app/src/main/res/drawable/ic_arrow_down.xml
+10
-0
item_page_magisk_log.xml
app/src/main/res/layout/item_page_magisk_log.xml
+29
-10
No files found.
app/src/main/java/com/topjohnwu/magisk/ui/log/LogViewModel.kt
View file @
074b1f8c
...
@@ -43,6 +43,8 @@ class LogViewModel(
...
@@ -43,6 +43,8 @@ class LogViewModel(
private
val
logItem
get
()
=
items
[
0
]
as
LogRvItem
private
val
logItem
get
()
=
items
[
0
]
as
LogRvItem
private
val
magiskLogItem
get
()
=
items
[
1
]
as
MagiskLogRvItem
private
val
magiskLogItem
get
()
=
items
[
1
]
as
MagiskLogRvItem
val
scrollPosition
=
KObservableField
(
0
)
init
{
init
{
currentPage
.
addOnPropertyChangedCallback
{
currentPage
.
addOnPropertyChangedCallback
{
it
?:
return
@addOnPropertyChangedCallback
it
?:
return
@addOnPropertyChangedCallback
...
@@ -59,6 +61,10 @@ class LogViewModel(
...
@@ -59,6 +61,10 @@ class LogViewModel(
else
->
""
else
->
""
}
}
fun
scrollDownPressed
()
{
scrollPosition
.
value
=
magiskLogItem
.
items
.
size
-
1
}
fun
refresh
()
{
fun
refresh
()
{
fetchLogs
().
subscribeK
{
logItem
.
update
(
it
)
}
fetchLogs
().
subscribeK
{
logItem
.
update
(
it
)
}
fetchMagiskLog
().
subscribeK
{
magiskLogItem
.
update
(
it
)
}
fetchMagiskLog
().
subscribeK
{
magiskLogItem
.
update
(
it
)
}
...
...
app/src/main/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt
View file @
074b1f8c
...
@@ -11,8 +11,10 @@ import androidx.databinding.InverseBindingAdapter
...
@@ -11,8 +11,10 @@ import androidx.databinding.InverseBindingAdapter
import
androidx.databinding.InverseBindingListener
import
androidx.databinding.InverseBindingListener
import
androidx.drawerlayout.widget.DrawerLayout
import
androidx.drawerlayout.widget.DrawerLayout
import
androidx.interpolator.view.animation.FastOutSlowInInterpolator
import
androidx.interpolator.view.animation.FastOutSlowInInterpolator
import
androidx.recyclerview.widget.LinearLayoutManager
import
androidx.recyclerview.widget.RecyclerView
import
androidx.recyclerview.widget.RecyclerView
import
androidx.viewpager.widget.ViewPager
import
androidx.viewpager.widget.ViewPager
import
com.google.android.material.floatingactionbutton.FloatingActionButton
import
com.google.android.material.navigation.NavigationView
import
com.google.android.material.navigation.NavigationView
import
com.skoumal.teanity.extensions.subscribeK
import
com.skoumal.teanity.extensions.subscribeK
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.R
...
@@ -176,4 +178,32 @@ fun setScrollToLast(view: RecyclerView, shouldScrollToLast: Boolean) {
...
@@ -176,4 +178,32 @@ fun setScrollToLast(view: RecyclerView, shouldScrollToLast: Boolean) {
}
else
{
}
else
{
view
.
adapter
?.
removeListener
()
view
.
adapter
?.
removeListener
()
}
}
}
}
\ No newline at end of file
@BindingAdapter
(
"hide"
)
fun
setHidden
(
view
:
FloatingActionButton
,
hide
:
Boolean
)
{
if
(
hide
)
view
.
hide
()
else
view
.
show
()
}
@BindingAdapter
(
"scrollPosition"
,
"scrollPositionSmooth"
,
requireAll
=
false
)
fun
setScrollPosition
(
view
:
RecyclerView
,
position
:
Int
,
smoothScroll
:
Boolean
)
=
when
{
smoothScroll
->
view
.
smoothScrollToPosition
(
position
)
else
->
view
.
scrollToPosition
(
position
)
}
@BindingAdapter
(
"recyclerScrollEvent"
)
fun
setScrollListener
(
view
:
RecyclerView
,
listener
:
InverseBindingListener
)
{
view
.
addOnScrollListener
(
object
:
RecyclerView
.
OnScrollListener
()
{
override
fun
onScrollStateChanged
(
recyclerView
:
RecyclerView
,
newState
:
Int
)
{
// don't change this or the recycler will stop at every line, effectively disabling smooth scroll
if
(
newState
==
RecyclerView
.
SCROLL_STATE_IDLE
)
{
listener
.
onChange
()
}
}
})
}
@InverseBindingAdapter
(
attribute
=
"scrollPosition"
,
event
=
"recyclerScrollEvent"
)
fun
getScrollPosition
(
view
:
RecyclerView
)
=
(
view
.
layoutManager
as
?
LinearLayoutManager
)
?.
findLastCompletelyVisibleItemPosition
()
?:
-
1
\ No newline at end of file
app/src/main/res/drawable/ic_arrow_down.xml
0 → 100644
View file @
074b1f8c
<?xml version="1.0" encoding="utf-8"?>
<vector
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:width=
"24dp"
android:height=
"24dp"
android:viewportWidth=
"24"
android:viewportHeight=
"24"
>
<path
android:fillColor=
"#000"
android:pathData=
"M16.59,5.59L18,7L12,13L6,7L7.41,5.59L12,10.17L16.59,5.59M16.59,11.59L18,13L12,19L6,13L7.41,11.59L12,16.17L16.59,11.59Z"
/>
</vector>
\ No newline at end of file
app/src/main/res/layout/item_page_magisk_log.xml
View file @
074b1f8c
...
@@ -15,20 +15,39 @@
...
@@ -15,20 +15,39 @@
</data>
</data>
<
HorizontalScrollView
<
FrameLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
android:layout_height=
"match_parent"
>
<androidx.recyclerview.widget.RecyclerView
<HorizontalScrollView
adapter=
"@{viewModel.itemsAdapter}"
android:layout_width=
"match_parent"
itemBinding=
"@{viewModel.itemBinding}"
android:layout_height=
"match_parent"
>
items=
"@{item.items}"
<androidx.recyclerview.widget.RecyclerView
adapter=
"@{viewModel.itemsAdapter}"
itemBinding=
"@{viewModel.itemBinding}"
items=
"@{item.items}"
scrollPosition=
"@={viewModel.scrollPosition}"
scrollPositionSmooth=
"@{true}"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
app:layoutManager=
"androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem=
"@layout/item_console"
/>
</HorizontalScrollView>
<com.google.android.material.floatingactionbutton.FloatingActionButton
hide=
"@{viewModel.scrollPosition == item.items.size - 1}"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:layout_gravity=
"bottom|end"
app:layoutManager=
"androidx.recyclerview.widget.LinearLayoutManager"
android:layout_margin=
"@dimen/margin_generic"
tools:listitem=
"@layout/item_console"
/>
android:onClick=
"@{() -> viewModel.scrollDownPressed()}"
app:srcCompat=
"@drawable/ic_arrow_down"
app:tint=
"@color/colorTextInverse"
/>
</FrameLayout>
</HorizontalScrollView>
</layout>
</layout>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment