Make AndroidPolyfill completely static
This commit is contained in:
parent
9b7052767a
commit
700599140e
3 changed files with 8 additions and 7 deletions
File diff suppressed because one or more lines are too long
|
@ -25,7 +25,7 @@ const DatabridgePluginSingleton = registerPlugin<DatabridgePlugin>("Databridge",
|
|||
})
|
||||
|
||||
export class AndroidPolyfill {
|
||||
private readonly databridgePlugin: DatabridgePlugin = DatabridgePluginSingleton
|
||||
private static readonly databridgePlugin: DatabridgePlugin = DatabridgePluginSingleton
|
||||
private static readonly _inAndroid: UIEventSource<boolean> = new UIEventSource<boolean>(false)
|
||||
public static readonly inAndroid: Store<boolean> = AndroidPolyfill._inAndroid
|
||||
private static readonly _geolocationPermission: UIEventSource<"granted" | "denied" | "prompt"> = new UIEventSource("prompt")
|
||||
|
@ -35,7 +35,7 @@ export class AndroidPolyfill {
|
|||
* Registers 'navigator.'
|
||||
* @private
|
||||
*/
|
||||
private backfillGeolocation(databridgePlugin: DatabridgePlugin) {
|
||||
private static backfillGeolocation(databridgePlugin: DatabridgePlugin) {
|
||||
const src = UIEventSource.FromPromise(databridgePlugin.request({ key: "location:has-permission" }))
|
||||
src.addCallbackAndRunD(permission => {
|
||||
console.log("> Checking geopermission gave: ", JSON.stringify(permission), permission.value)
|
||||
|
@ -48,16 +48,16 @@ export class AndroidPolyfill {
|
|||
return DatabridgePluginSingleton.request({ key: "location:request-permission" })
|
||||
}
|
||||
|
||||
public async init() {
|
||||
public static async init() {
|
||||
console.log("Sniffing shell version")
|
||||
const shell = await this.databridgePlugin.request({ key: "meta" })
|
||||
const shell = await AndroidPolyfill.databridgePlugin.request({ key: "meta" })
|
||||
if (shell.value === "web") {
|
||||
console.log("Not initing Android polyfill as not in a shell; web detected")
|
||||
return
|
||||
}
|
||||
AndroidPolyfill._inAndroid.set(true)
|
||||
console.log("Detected shell:", shell.value)
|
||||
this.backfillGeolocation(this.databridgePlugin)
|
||||
AndroidPolyfill.backfillGeolocation(AndroidPolyfill.databridgePlugin)
|
||||
}
|
||||
|
||||
public static async requestLoginCodes() {
|
||||
|
|
|
@ -12,6 +12,7 @@ import { UIEventSource } from "../Logic/UIEventSource"
|
|||
import { WithSearchState } from "../Models/ThemeViewState/WithSearchState"
|
||||
import { ThemeConfigJson } from "../Models/ThemeConfig/Json/ThemeConfigJson"
|
||||
import ThemeConfig from "../Models/ThemeConfig/ThemeConfig"
|
||||
import { AndroidPolyfill } from "../Logic/Web/AndroidPolyfill"
|
||||
|
||||
function webgl_support() {
|
||||
try {
|
||||
|
@ -46,7 +47,7 @@ async function getAvailableLayers(): Promise<Set<string>> {
|
|||
}
|
||||
|
||||
export let theme: ThemeConfig
|
||||
|
||||
AndroidPolyfill.init()
|
||||
let webgl_supported = webgl_support()
|
||||
|
||||
let availableLayers = UIEventSource.FromPromise(getAvailableLayers())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue