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
f1dcecc6
Commit
f1dcecc6
authored
Oct 05, 2019
by
Viktor De Pasquale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added link opening on homepage
parent
fe1ce08a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
1 deletion
+34
-1
OpenInappLinkEvent.kt
...a/com/topjohnwu/magisk/model/events/OpenInappLinkEvent.kt
+32
-0
HomeViewModel.kt
.../java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt
+2
-1
No files found.
app/src/main/java/com/topjohnwu/magisk/model/events/OpenInappLinkEvent.kt
0 → 100644
View file @
f1dcecc6
package
com.topjohnwu.magisk.model.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.skoumal.teanity.viewevents.ViewEvent
import
com.topjohnwu.magisk.R
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
)
}
}
\ No newline at end of file
app/src/main/java/com/topjohnwu/magisk/redesign/home/HomeViewModel.kt
View file @
f1dcecc6
...
...
@@ -12,6 +12,7 @@ import com.topjohnwu.magisk.model.entity.MagiskJson
import
com.topjohnwu.magisk.model.entity.ManagerJson
import
com.topjohnwu.magisk.model.entity.UpdateInfo
import
com.topjohnwu.magisk.model.entity.recycler.HomeItem
import
com.topjohnwu.magisk.model.events.OpenInappLinkEvent
import
com.topjohnwu.magisk.model.observer.Observer
import
com.topjohnwu.magisk.redesign.compat.CompatViewModel
import
com.topjohnwu.magisk.ui.home.MagiskState
...
...
@@ -70,7 +71,7 @@ class HomeViewModel(
}
fun
onDeletePressed
()
{}
fun
onLinkPressed
(
link
:
String
)
{}
fun
onLinkPressed
(
link
:
String
)
=
OpenInappLinkEvent
(
link
).
publish
()
}
...
...
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