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
24f60243
Commit
24f60243
authored
Aug 09, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More homescreen UI improvements
parent
15b12159
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
136 additions
and
192 deletions
+136
-192
DeveloperItem.kt
...n/java/com/topjohnwu/magisk/model/entity/DeveloperItem.kt
+84
-0
HomeItems.kt
...a/com/topjohnwu/magisk/model/entity/recycler/HomeItems.kt
+0
-116
CompatHelpers.kt
...c/main/java/com/topjohnwu/magisk/ui/base/CompatHelpers.kt
+2
-1
HomeViewModel.kt
...c/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt
+2
-7
DataBindingAdapters.kt
...in/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt
+2
-2
fragment_home_md2.xml
app/src/main/res/layout/fragment_home_md2.xml
+16
-16
item_developer.xml
app/src/main/res/layout/item_developer.xml
+27
-47
item_icon_link.xml
app/src/main/res/layout/item_icon_link.xml
+3
-3
No files found.
app/src/main/java/com/topjohnwu/magisk/model/entity/DeveloperItem.kt
0 → 100644
View file @
24f60243
package
com.topjohnwu.magisk.model.entity
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.core.Const
import
com.topjohnwu.magisk.databinding.RvItem
sealed
class
DeveloperItem
{
abstract
val
items
:
List
<
IconLink
>
abstract
val
name
:
Int
object
Main
:
DeveloperItem
()
{
override
val
items
=
listOf
(
IconLink
.
Twitter
.
Main
,
IconLink
.
Patreon
,
IconLink
.
PayPal
.
Main
,
IconLink
.
Github
)
override
val
name
get
()
=
R
.
string
.
topjohnwu
}
object
App
:
DeveloperItem
()
{
override
val
items
=
listOf
<
IconLink
>(
IconLink
.
Twitter
.
App
,
IconLink
.
PayPal
.
App
)
override
val
name
get
()
=
R
.
string
.
diareuse
}
}
private
interface
Dev
{
val
name
:
String
}
private
interface
MainDev
:
Dev
{
override
val
name
get
()
=
"topjohnwu"
}
private
interface
AppDev
:
Dev
{
override
val
name
get
()
=
"diareuse"
}
sealed
class
IconLink
:
RvItem
()
{
abstract
val
icon
:
Int
abstract
val
title
:
Int
abstract
val
link
:
String
override
val
layoutRes
get
()
=
R
.
layout
.
item_icon_link
sealed
class
PayPal
:
IconLink
(),
Dev
{
override
val
icon
get
()
=
R
.
drawable
.
ic_paypal
override
val
title
get
()
=
R
.
string
.
paypal
override
val
link
get
()
=
"https://paypal.me/$name"
object
App
:
PayPal
(),
AppDev
object
Main
:
PayPal
(),
MainDev
}
object
Patreon
:
IconLink
()
{
override
val
icon
get
()
=
R
.
drawable
.
ic_patreon
override
val
title
get
()
=
R
.
string
.
patreon
override
val
link
get
()
=
Const
.
Url
.
PATREON_URL
}
sealed
class
Twitter
:
IconLink
(),
Dev
{
override
val
icon
get
()
=
R
.
drawable
.
ic_twitter
override
val
title
get
()
=
R
.
string
.
twitter
override
val
link
get
()
=
"https://twitter.com/$name"
object
App
:
Twitter
(),
AppDev
object
Main
:
Twitter
(),
MainDev
}
object
Github
:
IconLink
()
{
override
val
icon
get
()
=
R
.
drawable
.
ic_github
override
val
title
get
()
=
R
.
string
.
home_item_source
override
val
link
get
()
=
Const
.
Url
.
SOURCE_CODE_URL
}
}
app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/HomeItems.kt
deleted
100644 → 0
View file @
15b12159
package
com.topjohnwu.magisk.model.entity.recycler
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.core.Const
import
com.topjohnwu.magisk.databinding.ComparableRvItem
sealed
class
HomeItem
:
ComparableRvItem
<
HomeItem
>()
{
abstract
val
icon
:
Int
abstract
val
title
:
Int
abstract
val
link
:
String
override
val
layoutRes
=
R
.
layout
.
item_developer_link
override
fun
contentSameAs
(
other
:
HomeItem
)
=
itemSameAs
(
other
)
override
fun
itemSameAs
(
other
:
HomeItem
)
=
this
==
other
override
fun
equals
(
other
:
Any
?):
Boolean
{
if
(
other
!
is
HomeItem
)
return
false
return
icon
==
other
.
icon
&&
title
==
other
.
title
&&
link
==
other
.
link
}
override
fun
hashCode
()
=
icon
.
hashCode
()
+
title
.
hashCode
()
+
link
.
hashCode
()
+
layoutRes
.
hashCode
()
// region Children
sealed
class
PayPal
:
HomeItem
()
{
override
val
icon
=
R
.
drawable
.
ic_paypal
override
val
title
=
R
.
string
.
paypal
override
val
link
=
"https://paypal.me/%s"
// region Children
object
App
:
PayPal
()
{
override
val
link
=
super
.
link
.
format
(
"diareuse"
)
}
object
Mainline
:
PayPal
()
{
override
val
link
=
super
.
link
.
format
(
"topjohnwu"
)
}
// endregion
}
object
Patreon
:
HomeItem
()
{
override
val
icon
=
R
.
drawable
.
ic_patreon
override
val
title
=
R
.
string
.
patreon
override
val
link
=
Const
.
Url
.
PATREON_URL
}
sealed
class
Twitter
:
HomeItem
()
{
override
val
icon
=
R
.
drawable
.
ic_twitter
override
val
title
=
R
.
string
.
twitter
override
val
link
=
"https://twitter.com/%s"
// region Children
object
App
:
Twitter
()
{
override
val
link
=
super
.
link
.
format
(
"diareuse"
)
}
object
Mainline
:
Twitter
()
{
override
val
link
=
super
.
link
.
format
(
"topjohnwu"
)
}
// endregion
}
object
Github
:
HomeItem
()
{
override
val
icon
=
R
.
drawable
.
ic_github
override
val
title
=
R
.
string
.
home_item_source
override
val
link
=
Const
.
Url
.
SOURCE_CODE_URL
}
object
Xda
:
HomeItem
()
{
override
val
icon
=
R
.
drawable
.
ic_xda
override
val
title
=
R
.
string
.
xda
override
val
link
=
Const
.
Url
.
XDA_THREAD
}
// endregion
}
sealed
class
DeveloperItem
:
ComparableRvItem
<
DeveloperItem
>()
{
abstract
val
items
:
List
<
HomeItem
>
abstract
val
name
:
Int
override
val
layoutRes
=
R
.
layout
.
item_developer
override
fun
contentSameAs
(
other
:
DeveloperItem
)
=
itemSameAs
(
other
)
override
fun
itemSameAs
(
other
:
DeveloperItem
)
=
this
==
other
override
fun
equals
(
other
:
Any
?):
Boolean
{
if
(
other
!
is
DeveloperItem
)
return
false
return
name
==
other
.
name
&&
items
==
other
.
items
}
override
fun
hashCode
()
=
name
.
hashCode
()
+
items
.
hashCode
()
+
layoutRes
.
hashCode
()
//region Children
object
Mainline
:
DeveloperItem
()
{
override
val
items
=
listOf
(
HomeItem
.
PayPal
.
Mainline
,
HomeItem
.
Patreon
,
HomeItem
.
Twitter
.
Mainline
)
override
val
name
=
R
.
string
.
topjohnwu
}
object
App
:
DeveloperItem
()
{
override
val
items
=
listOf
(
HomeItem
.
PayPal
.
App
,
HomeItem
.
Twitter
.
App
)
override
val
name
=
R
.
string
.
diareuse
}
object
Project
:
DeveloperItem
()
{
override
val
items
=
listOf
(
HomeItem
.
Github
,
HomeItem
.
Xda
)
override
val
name
=
R
.
string
.
home_links_project
}
//endregion
}
app/src/main/java/com/topjohnwu/magisk/ui/base/CompatHelpers.kt
View file @
24f60243
...
...
@@ -2,6 +2,7 @@ package com.topjohnwu.magisk.ui.base
import
androidx.databinding.ViewDataBinding
import
com.topjohnwu.magisk.databinding.ComparableRvItem
import
com.topjohnwu.magisk.databinding.RvItem
import
com.topjohnwu.magisk.utils.DiffObservableList
import
com.topjohnwu.magisk.utils.FilterableDiffObservableList
import
me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter
...
...
@@ -39,7 +40,7 @@ fun <T : ComparableRvItem<*>> adapterOf() = object : BindingRecyclerViewAdapter<
}
}
inline
fun
<
T
:
ComparableRvItem
<*
>
>
itemBindingOf
(
inline
fun
<
T
:
RvItem
>
itemBindingOf
(
crossinline
body
:
(
ItemBinding
<*>)
->
Unit
=
{}
)
=
OnItemBind
<
T
>
{
itemBinding
,
_
,
item
->
item
.
bind
(
itemBinding
)
...
...
app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt
View file @
24f60243
...
...
@@ -15,9 +15,8 @@ import com.topjohnwu.magisk.data.repository.MagiskRepository
import
com.topjohnwu.magisk.ktx.await
import
com.topjohnwu.magisk.ktx.packageName
import
com.topjohnwu.magisk.ktx.res
import
com.topjohnwu.magisk.model.entity.IconLink
import
com.topjohnwu.magisk.model.entity.internal.DownloadSubject.Manager
import
com.topjohnwu.magisk.model.entity.recycler.DeveloperItem
import
com.topjohnwu.magisk.model.entity.recycler.HomeItem
import
com.topjohnwu.magisk.model.events.ActivityExecutor
import
com.topjohnwu.magisk.model.events.OpenInappLinkEvent
import
com.topjohnwu.magisk.model.events.ViewEvent
...
...
@@ -77,11 +76,7 @@ class HomeViewModel(
val
showUninstall
get
()
=
Info
.
env
.
magiskVersionCode
>
0
&&
stateMagisk
!=
MagiskState
.
LOADING
&&
isConnected
.
get
()
val
items
=
listOf
(
DeveloperItem
.
Mainline
,
DeveloperItem
.
App
,
DeveloperItem
.
Project
)
val
itemBinding
=
itemBindingOf
<
HomeItem
>
{
it
.
bindExtra
(
BR
.
viewModel
,
this
)
}
val
itemDeveloperBinding
=
itemBindingOf
<
DeveloperItem
>
{
val
itemBinding
=
itemBindingOf
<
IconLink
>
{
it
.
bindExtra
(
BR
.
viewModel
,
this
)
}
...
...
app/src/main/java/com/topjohnwu/magisk/utils/DataBindingAdapters.kt
View file @
24f60243
...
...
@@ -6,11 +6,11 @@ import android.graphics.drawable.Drawable
import
android.view.ContextThemeWrapper
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.PopupMenu
import
android.widget.ProgressBar
import
android.widget.TextView
import
androidx.annotation.DrawableRes
import
androidx.appcompat.widget.AppCompatImageView
import
androidx.appcompat.widget.Toolbar
import
androidx.core.view.updateLayoutParams
import
androidx.databinding.BindingAdapter
...
...
@@ -33,7 +33,7 @@ fun setOnNavigationClickedListener(view: Toolbar, listener: View.OnClickListener
}
@BindingAdapter
(
"srcCompat"
)
fun
setImageResource
(
view
:
AppCompat
ImageView
,
@DrawableRes
resId
:
Int
)
{
fun
setImageResource
(
view
:
ImageView
,
@DrawableRes
resId
:
Int
)
{
view
.
setImageResource
(
resId
)
}
...
...
app/src/main/res/layout/fragment_home_md2.xml
View file @
24f60243
...
...
@@ -9,6 +9,8 @@
<import
type=
"com.topjohnwu.magisk.ui.home.MagiskState"
/>
<import
type=
"com.topjohnwu.magisk.model.entity.DeveloperItem"
/>
<variable
name=
"viewModel"
type=
"com.topjohnwu.magisk.ui.home.HomeViewModel"
/>
...
...
@@ -166,23 +168,21 @@
android:text=
"@string/home_support_content"
android:textAppearance=
"@style/AppearanceFoundation.Caption.Variant"
/>
<androidx.recyclerview.widget.RecyclerView
dividerHorizontal=
"@{@drawable/divider_l1}"
dividerVertical=
"@{@drawable/divider_l1}"
itemBinding=
"@{viewModel.itemDeveloperBinding}"
items=
"@{viewModel.items}"
android:layout_width=
"match_parent"
<include
layout=
"@layout/item_developer"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/l_50"
viewModel=
"@{viewModel}"
item=
"@{DeveloperItem.Main.INSTANCE}"
/>
<include
layout=
"@layout/item_developer"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/l1"
android:clipToPadding=
"false"
android:nestedScrollingEnabled=
"false"
android:orientation=
"horizontal"
android:overScrollMode=
"ifContentScrolls"
android:paddingStart=
"@dimen/l1"
app:layoutManager=
"androidx.recyclerview.widget.StaggeredGridLayoutManager"
app:spanCount=
"2"
tools:itemCount=
"3"
tools:listitem=
"@layout/item_developer"
/>
android:layout_marginTop=
"@dimen/l_50"
viewModel=
"@{viewModel}"
item=
"@{DeveloperItem.App.INSTANCE}"
/>
</LinearLayout>
...
...
app/src/main/res/layout/item_developer.xml
View file @
24f60243
...
...
@@ -7,7 +7,7 @@
<variable
name=
"item"
type=
"com.topjohnwu.magisk.model.entity.
recycler.
DeveloperItem"
/>
type=
"com.topjohnwu.magisk.model.entity.DeveloperItem"
/>
<variable
name=
"viewModel"
...
...
@@ -15,55 +15,35 @@
</data>
<
androidx.constraintlayout.widget.Constraint
Layout
android:layout_width=
"
wrap_cont
ent"
<
Linear
Layout
android:layout_width=
"
match_par
ent"
android:layout_height=
"wrap_content"
tools:layout_gravity=
"center|start"
>
android:orientation=
"vertical"
android:padding=
"@dimen/l1"
>
<com.google.android.material.card.MaterialCardView
style=
"@style/WidgetFoundation.Card.Primary"
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
app:layout_constrainedWidth=
"true"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:padding=
"@dimen/l1"
>
<androidx.appcompat.widget.AppCompatTextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"@{item.name}"
android:textAppearance=
"@style/AppearanceFoundation.Caption.OnPrimary"
android:textStyle=
"bold"
tools:text=
"\@topjohnwu"
/>
<androidx.recyclerview.widget.RecyclerView
itemBinding=
"@{viewModel.itemBinding}"
items=
"@{item.items}"
nestedScrollingEnabled=
"@{false}"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:clipToPadding=
"false"
android:fadingEdgeLength=
"@dimen/l1"
android:orientation=
"horizontal"
android:paddingTop=
"@dimen/l_50"
android:requiresFadingEdge=
"horizontal"
app:layoutManager=
"androidx.recyclerview.widget.LinearLayoutManager"
tools:itemCount=
"3"
tools:listitem=
"@layout/item_developer_link"
/>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
android:text=
"@{item.name}"
android:textAppearance=
"@style/AppearanceFoundation.Caption"
android:textStyle=
"bold"
tools:text=
"\@topjohnwu"
/>
<androidx.recyclerview.widget.RecyclerView
itemBinding=
"@{viewModel.itemBinding}"
items=
"@{item.items}"
nestedScrollingEnabled=
"@{false}"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:clipToPadding=
"false"
android:fadingEdgeLength=
"@dimen/l1"
android:orientation=
"horizontal"
android:paddingTop=
"@dimen/l_50"
android:requiresFadingEdge=
"horizontal"
app:layoutManager=
"androidx.recyclerview.widget.LinearLayoutManager"
tools:itemCount=
"3"
tools:listitem=
"@layout/item_icon_link"
/>
</LinearLayout>
</layout>
app/src/main/res/layout/item_
developer
_link.xml
→
app/src/main/res/layout/item_
icon
_link.xml
View file @
24f60243
...
...
@@ -7,7 +7,7 @@
<variable
name=
"item"
type=
"com.topjohnwu.magisk.model.entity.
recycler.HomeItem
"
/>
type=
"com.topjohnwu.magisk.model.entity.
IconLink
"
/>
<variable
name=
"viewModel"
...
...
@@ -24,12 +24,12 @@
android:padding=
"@dimen/l_50"
tools:layout_gravity=
"center"
>
<
androidx.appcompat.widget.AppCompat
ImageView
<ImageView
android:id=
"@+id/developer_link"
style=
"@style/WidgetFoundation.Image.Small"
android:layout_gravity=
"center"
app:srcCompat=
"@{item.icon}"
app:tint=
"?colorOn
Primary
"
app:tint=
"?colorOn
Surface
"
tools:srcCompat=
"@drawable/ic_paypal"
/>
</FrameLayout>
...
...
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