-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3e60c7e
commit 8af3037
Showing
18 changed files
with
15,873 additions
and
2,428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
...src/main/kotlin/com/dergoogler/mmrl/ui/activity/webui/interfaces/mmrl/VersionInterface.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.dergoogler.mmrl.ui.activity.webui.interfaces.mmrl | ||
|
||
import android.content.Context | ||
import android.webkit.JavascriptInterface | ||
import android.webkit.WebView | ||
import android.widget.Toast | ||
import com.dergoogler.mmrl.BuildConfig | ||
import com.dergoogler.mmrl.viewmodel.WebUIViewModel | ||
|
||
class VersionInterface( | ||
private val context: Context, | ||
private val webView: WebView, | ||
private val viewModel: WebUIViewModel, | ||
) { | ||
inner class BuildConfigDetails { | ||
@get:JavascriptInterface | ||
val applicationId = BuildConfig.APPLICATION_ID | ||
|
||
@get:JavascriptInterface | ||
val buildType = BuildConfig.BUILD_TYPE | ||
|
||
@get:JavascriptInterface | ||
val versionCode = BuildConfig.VERSION_CODE | ||
|
||
@get:JavascriptInterface | ||
val versionName = BuildConfig.VERSION_NAME | ||
|
||
@get:JavascriptInterface | ||
val isDevVersion: Boolean = BuildConfig.IS_DEV_VERSION | ||
|
||
@get:JavascriptInterface | ||
val isGooglePlayBuild: Boolean = BuildConfig.IS_GOOGLE_PLAY_BUILD | ||
} | ||
|
||
inner class RootConfigDetails { | ||
@get:JavascriptInterface | ||
val platform = viewModel.platform.current | ||
|
||
@get:JavascriptInterface | ||
val versionName = viewModel.versionName | ||
|
||
@get:JavascriptInterface | ||
val versionCode = viewModel.versionCode | ||
} | ||
|
||
@get:JavascriptInterface | ||
val buildConfig get() = BuildConfigDetails() | ||
|
||
@get:JavascriptInterface | ||
val rootConfig get() = RootConfigDetails() | ||
|
||
inner class ToastBuilderInterface { | ||
private val toast = Toast(context) | ||
|
||
@JavascriptInterface | ||
fun setText(msg: String) { | ||
toast.setText(msg) | ||
} | ||
|
||
@JavascriptInterface | ||
fun show() { | ||
webView.post { | ||
toast.show() | ||
} | ||
} | ||
|
||
@JavascriptInterface | ||
fun cancel() { | ||
webView.post { | ||
toast.cancel() | ||
} | ||
} | ||
|
||
@JavascriptInterface | ||
fun setDuration(duration: Int) { | ||
toast.duration = duration | ||
} | ||
} | ||
|
||
@JavascriptInterface | ||
fun toastBuilder(): ToastBuilderInterface { | ||
return ToastBuilderInterface() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"plugins": [ | ||
["@babel/plugin-proposal-decorators", { "legacy": true }], | ||
"@babel/plugin-proposal-class-properties" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Dependency directories | ||
node_modules/ | ||
.parcel-cache/ | ||
|
||
src/ | ||
test/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "@parcel/config-default", | ||
"bundler": "@parcel/bundler-library" | ||
} |
Binary file not shown.
Oops, something went wrong.