Skip to content

Commit

Permalink
Account Settings: Take product name into MyActivity page (#2491)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaVinci9196 authored Sep 28, 2024
1 parent 2fba42b commit f2479fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package org.microg.gms.accountsettings.ui
import android.accounts.Account
import android.accounts.AccountManager
import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import android.view.View
import android.webkit.WebView
Expand Down Expand Up @@ -132,6 +133,8 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)

val screenId = intent?.getIntExtra(EXTRA_SCREEN_ID, -1).takeIf { it != -1 } ?: ACTION_TO_SCREEN_ID[intent.action] ?: 1
val product = intent?.getStringExtra(EXTRA_SCREEN_MY_ACTIVITY_PRODUCT)

val screenOptions = intent.extras?.keySet().orEmpty()
.filter { it.startsWith(EXTRA_SCREEN_OPTIONS_PREFIX) }
.map { it.substring(EXTRA_SCREEN_OPTIONS_PREFIX.length) to intent.getStringExtra(it) }
Expand All @@ -151,6 +154,7 @@ class MainActivity : AppCompatActivity() {
}

if (screenId in SCREEN_ID_TO_URL) {
val screenUrl = SCREEN_ID_TO_URL[screenId]?.run { if (screenId == 547 && !product.isNullOrEmpty()) { replace("search", product) } else { this } }
val layout = RelativeLayout(this)
layout.addView(ProgressBar(this).apply {
layoutParams = RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT).apply {
Expand All @@ -165,7 +169,7 @@ class MainActivity : AppCompatActivity() {
}
layout.addView(webView)
setContentView(layout)
WebViewHelper(this, webView, ALLOWED_WEB_PREFIXES).openWebView(SCREEN_ID_TO_URL[screenId], accountName)
WebViewHelper(this, webView, ALLOWED_WEB_PREFIXES).openWebView(screenUrl, accountName)
setResult(RESULT_OK)
} else {
Log.w(TAG, "Unknown screen id, can't open corresponding web page")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ const val EXTRA_SCREEN_OPTIONS_PREFIX = "extra.screen."
const val EXTRA_FALLBACK_URL = "extra.fallbackUrl"
const val EXTRA_FALLBACK_AUTH = "extra.fallbackAuth"
const val EXTRA_THEME_CHOICE = "extra.themeChoice"
const val EXTRA_SCREEN_MY_ACTIVITY_PRODUCT = "extra.screen.myactivityProduct"

const val OPTION_SCREEN_FLAVOR = "screenFlavor"

0 comments on commit f2479fe

Please sign in to comment.