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
706eba32
Commit
706eba32
authored
Jul 04, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add release notes to the install fragment
parent
f6a2b1c8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
12 deletions
+43
-12
ViewModelsModule.kt
...src/main/java/com/topjohnwu/magisk/di/ViewModelsModule.kt
+1
-1
InstallViewModel.kt
.../java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt
+17
-5
fragment_install_md2.xml
app/src/main/res/layout/fragment_install_md2.xml
+25
-6
No files found.
app/src/main/java/com/topjohnwu/magisk/di/ViewModelsModule.kt
View file @
706eba32
...
...
@@ -25,7 +25,7 @@ val viewModelModules = module {
viewModel
{
SettingsViewModel
(
get
())
}
viewModel
{
SuperuserViewModel
(
get
(),
get
(),
get
())
}
viewModel
{
ThemeViewModel
()
}
viewModel
{
InstallViewModel
()
}
viewModel
{
InstallViewModel
(
get
(),
get
()
)
}
viewModel
{
MainViewModel
()
}
// Legacy
...
...
app/src/main/java/com/topjohnwu/magisk/ui/install/InstallViewModel.kt
View file @
706eba32
package
com.topjohnwu.magisk.ui.install
import
android.net.Uri
import
android.text.SpannableString
import
android.text.Spanned
import
android.widget.Toast
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.core.Info
import
com.topjohnwu.magisk.core.download.DownloadService
import
com.topjohnwu.magisk.core.download.RemoteFileService
import
com.topjohnwu.magisk.core.utils.Utils
import
com.topjohnwu.magisk.data.repository.StringRepository
import
com.topjohnwu.magisk.extensions.addOnPropertyChangedCallback
import
com.topjohnwu.magisk.extensions.subscribeK
import
com.topjohnwu.magisk.model.entity.internal.Configuration
import
com.topjohnwu.magisk.model.entity.internal.DownloadSubject
import
com.topjohnwu.magisk.model.events.RequestFileEvent
...
...
@@ -15,20 +19,23 @@ import com.topjohnwu.magisk.model.events.dialog.SecondSlotWarningDialog
import
com.topjohnwu.magisk.ui.base.BaseViewModel
import
com.topjohnwu.magisk.utils.KObservableField
import
com.topjohnwu.superuser.Shell
import
io.noties.markwon.Markwon
import
org.koin.core.get
import
kotlin.math.roundToInt
class
InstallViewModel
:
BaseViewModel
(
State
.
LOADED
)
{
class
InstallViewModel
(
stringRepo
:
StringRepository
,
markwon
:
Markwon
)
:
BaseViewModel
(
State
.
LOADED
)
{
val
isRooted
get
()
=
Shell
.
rootAccess
()
val
isAB
get
()
=
Info
.
isAB
val
step
=
KObservableField
(
0
)
val
method
=
KObservableField
(-
1
)
val
progress
=
KObservableField
(
0
)
va
r
data
=
KObservableField
<
Uri
?>(
null
)
val
data
=
KObservableField
<
Uri
?>(
null
)
va
l
notes
=
KObservableField
<
Spanned
>(
SpannableString
(
""
)
)
init
{
RemoteFileService
.
reset
()
...
...
@@ -42,8 +49,13 @@ class InstallViewModel : BaseViewModel(State.LOADED) {
state
=
State
.
LOADED
}
}
stringRepo
.
getString
(
Info
.
remote
.
magisk
.
note
).
map
{
markwon
.
toMarkdown
(
it
)
}.
subscribeK
{
notes
.
value
=
it
}
method
.
addOnPropertyChangedCallback
{
when
(
method
.
value
)
{
when
(
it
!!
)
{
R
.
id
.
method_patch
->
{
Utils
.
toast
(
R
.
string
.
patch_file_msg
,
Toast
.
LENGTH_LONG
)
RequestFileEvent
().
publish
()
...
...
app/src/main/res/layout/fragment_install_md2.xml
View file @
706eba32
...
...
@@ -50,7 +50,7 @@
android:layout_height=
"wrap_content"
android:minHeight=
"?listPreferredItemHeightSmall"
>
<
androidx.appcompat.widget.AppCompat
ImageView
<ImageView
android:id=
"@+id/install_step_options_icon"
style=
"@style/WidgetFoundation.Icon"
isSelected=
"@{viewModel.step > 0}"
...
...
@@ -60,7 +60,7 @@
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/ic_check_circle_md2"
/>
<
androidx.appcompat.widget.AppCompat
TextView
<TextView
android:id=
"@+id/install_step_options_title"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
...
...
@@ -129,7 +129,7 @@
android:layout_height=
"wrap_content"
android:minHeight=
"?listPreferredItemHeightSmall"
>
<
androidx.appcompat.widget.AppCompat
ImageView
<ImageView
android:id=
"@+id/install_step_method_icon"
style=
"@style/WidgetFoundation.Icon"
isSelected=
"@{viewModel.step > 1}"
...
...
@@ -139,7 +139,7 @@
app:layout_constraintTop_toTopOf=
"parent"
app:srcCompat=
"@drawable/ic_check_circle_md2"
/>
<
androidx.appcompat.widget.AppCompat
TextView
<TextView
android:id=
"@+id/install_step_method_title"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
...
...
@@ -217,6 +217,25 @@
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.card.MaterialCardView
style=
"@style/WidgetFoundation.Card.Variant"
gone=
"@{viewModel.step != 0}"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/l1"
android:layout_marginStart=
"@dimen/l1"
android:layout_marginEnd=
"@dimen/l1"
app:strokeWidth=
"@{viewModel.step != 0 ? 0f : @dimen/l_125}"
>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"15dp"
android:textAppearance=
"@style/AppearanceFoundation.Caption"
android:text=
"@{viewModel.notes}"
/>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.button.MaterialButton
style=
"@style/WidgetFoundation.Button.Text"
gone=
"@{viewModel.step != 2}"
...
...
@@ -241,7 +260,7 @@
android:gravity=
"center"
android:orientation=
"vertical"
>
<
androidx.appcompat.widget.AppCompat
TextView
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"center"
...
...
@@ -279,7 +298,7 @@
android:gravity=
"center"
android:orientation=
"vertical"
>
<
androidx.appcompat.widget.AppCompat
TextView
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:gravity=
"center"
...
...
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