diff --git a/app/src/main/assets/sync.html b/app/src/main/assets/sync.html deleted file mode 100644 index 7228b892..00000000 --- a/app/src/main/assets/sync.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - Memories - - - - -
- -

- Waiting for login to complete
- Keep this page open in the background -

- - - - -
- - - - diff --git a/app/src/main/assets/sync.js b/app/src/main/assets/sync.js deleted file mode 100644 index db9a977e..00000000 --- a/app/src/main/assets/sync.js +++ /dev/null @@ -1,51 +0,0 @@ -const main = document.getElementById("main"); -const waiting = document.getElementById("waiting"); -const sync = document.getElementById("sync"); -const localFolders = document.getElementById("local-folders"); - -// Waiting page => sync page -window.loggedIn = async () => { - waiting.classList.add("invisible"); - await new Promise((resolve) => setTimeout(resolve, 700)); - waiting.remove(); - sync.classList.remove("invisible"); -}; - -// Local list of folders -let localList = null; -async function openLocal() { - // Get the list of local folders for next screen - localList = JSON.parse(window.nativex?.configGetLocalFolders()); - - // Add HTML for folders list - document.getElementById("folder-list").innerHTML = localList - .map( - (folder) => ` -
- - -
- ` - ) - .join(""); - - // Show the folders list - sync.classList.add("invisible"); - await new Promise((resolve) => setTimeout(resolve, 700)); - sync.remove(); - localFolders.classList.remove("invisible"); -} - -// Open main app -async function start() { - // Mark all checked as enabled - if (localList) { - localList.forEach((f) => (f.enabled = document.getElementById(`folder-${f.id}`).checked)); - window.nativex?.configSetLocalFolders(JSON.stringify(localList)); - } - - // Start the app - main.classList.add("invisible"); - await new Promise((resolve) => setTimeout(resolve, 700)); - window.nativex?.reload(); -} diff --git a/app/src/main/assets/waiting.html b/app/src/main/assets/waiting.html new file mode 100644 index 00000000..24e801ca --- /dev/null +++ b/app/src/main/assets/waiting.html @@ -0,0 +1,18 @@ + + + + + Memories + + + + +
+ +

+ Waiting for login to complete
+ Keep this page open in the background +

+
+ + diff --git a/app/src/main/java/gallery/memories/service/AccountService.kt b/app/src/main/java/gallery/memories/service/AccountService.kt index b2e3d4e0..c239a1cf 100644 --- a/app/src/main/java/gallery/memories/service/AccountService.kt +++ b/app/src/main/java/gallery/memories/service/AccountService.kt @@ -56,7 +56,7 @@ class AccountService(private val mCtx: MainActivity, private val mHttp: HttpServ */ private fun pollLogin(pollUrl: String, pollToken: String, baseUrl: String) { mCtx.binding.webview.post { - mCtx.binding.webview.loadUrl("file:///android_asset/sync.html") + mCtx.binding.webview.loadUrl("file:///android_asset/waiting.html") } var pollCount = 0 @@ -84,7 +84,7 @@ class AccountService(private val mCtx: MainActivity, private val mHttp: HttpServ storeCredentials(baseUrl, loginName, appPassword) // Go to next screen - mCtx.binding.webview.evaluateJavascript("window.loggedIn()", {}) + mHttp.loadWebView(mCtx.binding.webview, "nxsetup") } return diff --git a/app/src/main/java/gallery/memories/service/HttpService.kt b/app/src/main/java/gallery/memories/service/HttpService.kt index 738759ee..4ef26b0b 100644 --- a/app/src/main/java/gallery/memories/service/HttpService.kt +++ b/app/src/main/java/gallery/memories/service/HttpService.kt @@ -51,16 +51,20 @@ class HttpService { /** * Load a webview at the default page * @param webView The webview to load + * @param subpath The subpath to load * @return Host URL if authenticated, null otherwise */ - fun loadWebView(webView: WebView): String? { + fun loadWebView(webView: WebView, subpath: String? = null): String? { // Load app interface if authenticated if (authHeader != null && memoriesUrl != null) { + var url = memoriesUrl + if (subpath != null) url += subpath + // Get host name - val host = Uri.parse(memoriesUrl).host + val host = Uri.parse(url).host // Set authorization header - webView.loadUrl(memoriesUrl!!, mapOf("Authorization" to authHeader)) + webView.loadUrl(url!!, mapOf("Authorization" to authHeader)) return host }