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
2954eb4b
Commit
2954eb4b
authored
Oct 04, 2021
by
vvb2060
Committed by
John Wu
Oct 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove CustomTab
parent
e08de916
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
45 deletions
+11
-45
OpenInappLinkEvent.kt
...in/java/com/topjohnwu/magisk/events/OpenInappLinkEvent.kt
+0
-33
HomeViewModel.kt
...c/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt
+7
-6
Utils.kt
app/src/main/java/com/topjohnwu/magisk/utils/Utils.kt
+4
-6
No files found.
app/src/main/java/com/topjohnwu/magisk/events/OpenInappLinkEvent.kt
deleted
100644 → 0
View file @
e08de916
package
com.topjohnwu.magisk.events
import
android.content.Context
import
android.content.res.Resources
import
android.util.TypedValue
import
androidx.annotation.AttrRes
import
androidx.browser.customtabs.CustomTabsIntent
import
androidx.core.net.toUri
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.arch.ContextExecutor
import
com.topjohnwu.magisk.arch.ViewEvent
data class
OpenInappLinkEvent
(
private
val
link
:
String
)
:
ViewEvent
(),
ContextExecutor
{
// todo find app that can open the link and as a fallback open custom tabs! it shouldn't be the default
override
fun
invoke
(
context
:
Context
)
=
CustomTabsIntent
.
Builder
()
.
setShowTitle
(
true
)
.
setToolbarColor
(
context
.
themedColor
(
R
.
attr
.
colorSurface
))
.
enableUrlBarHiding
()
.
build
()
.
launchUrl
(
context
,
link
.
toUri
())
private
fun
Context
.
themedColor
(
@AttrRes
attribute
:
Int
)
=
theme
.
resolveAttribute
(
attribute
).
data
private
fun
Resources
.
Theme
.
resolveAttribute
(
@AttrRes
attribute
:
Int
,
resolveRefs
:
Boolean
=
true
)
=
TypedValue
().
also
{
resolveAttribute
(
attribute
,
it
,
resolveRefs
)
}
}
app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt
View file @
2954eb4b
package
com.topjohnwu.magisk.ui.home
package
com.topjohnwu.magisk.ui.home
import
android.content.Context
import
androidx.core.net.toUri
import
androidx.databinding.Bindable
import
androidx.databinding.Bindable
import
androidx.lifecycle.viewModelScope
import
androidx.lifecycle.viewModelScope
import
com.topjohnwu.magisk.BuildConfig
import
com.topjohnwu.magisk.BuildConfig
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.R
import
com.topjohnwu.magisk.arch.ActivityExecutor
import
com.topjohnwu.magisk.arch.*
import
com.topjohnwu.magisk.arch.BaseUIActivity
import
com.topjohnwu.magisk.arch.BaseViewModel
import
com.topjohnwu.magisk.arch.ViewEvent
import
com.topjohnwu.magisk.core.Config
import
com.topjohnwu.magisk.core.Config
import
com.topjohnwu.magisk.core.Info
import
com.topjohnwu.magisk.core.Info
import
com.topjohnwu.magisk.core.download.Subject
import
com.topjohnwu.magisk.core.download.Subject
...
@@ -15,12 +14,12 @@ import com.topjohnwu.magisk.core.download.Subject.Manager
...
@@ -15,12 +14,12 @@ import com.topjohnwu.magisk.core.download.Subject.Manager
import
com.topjohnwu.magisk.data.repository.NetworkService
import
com.topjohnwu.magisk.data.repository.NetworkService
import
com.topjohnwu.magisk.databinding.itemBindingOf
import
com.topjohnwu.magisk.databinding.itemBindingOf
import
com.topjohnwu.magisk.databinding.set
import
com.topjohnwu.magisk.databinding.set
import
com.topjohnwu.magisk.events.OpenInappLinkEvent
import
com.topjohnwu.magisk.events.SnackbarEvent
import
com.topjohnwu.magisk.events.SnackbarEvent
import
com.topjohnwu.magisk.events.dialog.EnvFixDialog
import
com.topjohnwu.magisk.events.dialog.EnvFixDialog
import
com.topjohnwu.magisk.events.dialog.ManagerInstallDialog
import
com.topjohnwu.magisk.events.dialog.ManagerInstallDialog
import
com.topjohnwu.magisk.events.dialog.UninstallDialog
import
com.topjohnwu.magisk.events.dialog.UninstallDialog
import
com.topjohnwu.magisk.ktx.await
import
com.topjohnwu.magisk.ktx.await
import
com.topjohnwu.magisk.utils.Utils
import
com.topjohnwu.magisk.utils.asText
import
com.topjohnwu.magisk.utils.asText
import
com.topjohnwu.superuser.Shell
import
com.topjohnwu.superuser.Shell
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
...
@@ -116,7 +115,9 @@ class HomeViewModel(
...
@@ -116,7 +115,9 @@ class HomeViewModel(
stateManagerProgress
=
progress
.
times
(
100f
).
roundToInt
()
stateManagerProgress
=
progress
.
times
(
100f
).
roundToInt
()
}
}
fun
onLinkPressed
(
link
:
String
)
=
OpenInappLinkEvent
(
link
).
publish
()
fun
onLinkPressed
(
link
:
String
)
=
object
:
ViewEvent
(),
ContextExecutor
{
override
fun
invoke
(
context
:
Context
)
=
Utils
.
openLink
(
context
,
link
.
toUri
())
}.
publish
()
fun
onDeletePressed
()
=
UninstallDialog
().
publish
()
fun
onDeletePressed
()
=
UninstallDialog
().
publish
()
...
...
app/src/main/java/com/topjohnwu/magisk/utils/Utils.kt
View file @
2954eb4b
package
com.topjohnwu.magisk.utils
package
com.topjohnwu.magisk.utils
import
android.content.ActivityNotFoundException
import
android.content.Context
import
android.content.Context
import
android.content.Intent
import
android.content.Intent
import
android.net.Uri
import
android.net.Uri
...
@@ -29,13 +30,10 @@ object Utils {
...
@@ -29,13 +30,10 @@ object Utils {
fun
openLink
(
context
:
Context
,
link
:
Uri
)
{
fun
openLink
(
context
:
Context
,
link
:
Uri
)
{
val
intent
=
Intent
(
Intent
.
ACTION_VIEW
,
link
)
val
intent
=
Intent
(
Intent
.
ACTION_VIEW
,
link
)
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
if
(
intent
.
resolveActivity
(
context
.
packageManager
)
!=
null
)
{
try
{
context
.
startActivity
(
intent
)
context
.
startActivity
(
intent
)
}
else
{
}
catch
(
e
:
ActivityNotFoundException
)
{
toast
(
toast
(
R
.
string
.
open_link_failed_toast
,
Toast
.
LENGTH_SHORT
)
R
.
string
.
open_link_failed_toast
,
Toast
.
LENGTH_SHORT
)
}
}
}
}
}
}
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