Skip to content

Commit

Permalink
Open via browser
Browse files Browse the repository at this point in the history
  • Loading branch information
DaVinci9196 committed Sep 12, 2024
1 parent 8ef7a44 commit a88a2fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 37 deletions.
2 changes: 1 addition & 1 deletion play-services-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@
<activity
android:name="org.microg.gms.googlehelp.ui.GoogleHelpRedirectActivity"
android:process=":ui"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:theme="@style/Theme.App.Translucent"
android:exported="true">
<intent-filter>
<action android:name="com.google.android.gms.googlehelp.HELP" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.microg.gms.googlehelp.ui

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.os.Parcel
import android.os.Parcelable.Creator
Expand Down Expand Up @@ -42,8 +43,6 @@ private const val HELP_URL = "https://www.google.com/tools/feedback/mobile/help-

class GoogleHelpRedirectActivity : AppCompatActivity() {

private lateinit var webView: WebView

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Log.d(TAG, "onCreate begin")
Expand All @@ -59,43 +58,16 @@ class GoogleHelpRedirectActivity : AppCompatActivity() {
if (googleHelp == null) {
inProductHelp = getParcelableFromIntent<InProductHelp>(intent, PRODUCT_HELP_KEY, InProductHelp.CREATOR)
}
Log.d(TAG, "onCreate: googleHelp: ${googleHelp ?: inProductHelp?.googleHelp}")

val layout = RelativeLayout(this)
layout.addView(ProgressBar(this).apply {
layoutParams = RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT).apply {
addRule(RelativeLayout.CENTER_HORIZONTAL)
addRule(RelativeLayout.CENTER_VERTICAL)
}
isIndeterminate = true
})
webView = WebView(this).apply {
layoutParams = RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)
visibility = View.INVISIBLE
}
layout.addView(webView)
setContentView(layout)

lifecycleScope.launchWhenCreated {
val account = googleHelp?.account ?: inProductHelp?.googleHelp?.account
Log.d(TAG, "onCreate: googleHelp: ${googleHelp ?: inProductHelp?.googleHelp}")
val searchId = googleHelp?.appContext ?: inProductHelp?.googleHelp?.appContext
Log.d(TAG, "loadHelpUrl: searchId: $searchId")
val answerUrl = requestHelpLink(callingPackage, searchId).content?.info?.answerUrl
Log.d(TAG, "answerUrl: $answerUrl")
val url = googleHelp?.uri?.toString() ?: inProductHelp?.googleHelp?.uri?.toString() ?: answerUrl
Log.d(TAG, "loadUrl: $url")
if (answerUrl != null) {
WebViewHelper(this@GoogleHelpRedirectActivity, webView).openWebView(url, account?.name)
setResult(RESULT_OK)
} else finish()
}
}

override fun onBackPressed() {
if (this::webView.isInitialized && webView.canGoBack()) {
webView.goBack()
} else {
super.onBackPressed()
val answerUrl = runCatching { requestHelpLink(callingPackage, searchId).content?.info?.answerUrl }.getOrNull()
Log.d(TAG, "requestHelpLink answerUrl: $answerUrl")
val url = answerUrl ?: googleHelp?.uri?.toString() ?: inProductHelp?.googleHelp?.uri?.toString() ?: return@launchWhenCreated finish()
Log.d(TAG, "Open $url for $callingPackage in Browser")
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))

Check failure on line 69 in play-services-core/src/main/kotlin/org/microg/gms/googlehelp/ui/GoogleHelpRedirectActivity.kt

View workflow job for this annotation

GitHub Actions / Gradle build

The intent action android.intent.action.VIEW (used to start an activity) matches the intent filter of a non-exported component org.microg.gms.ui.MainSettingsActivity from a manifest. If you are trying to invoke this specific component via the action then you should make the intent explicit by calling Intent.set{Component,Class,ClassName}. [UnsafeImplicitIntentLaunch]

Check failure on line 69 in play-services-core/src/main/kotlin/org/microg/gms/googlehelp/ui/GoogleHelpRedirectActivity.kt

View workflow job for this annotation

GitHub Actions / Gradle build

The intent action android.intent.action.VIEW (used to start an activity) matches the intent filter of a non-exported component org.microg.gms.ui.MainSettingsActivity from a manifest. If you are trying to invoke this specific component via the action then you should make the intent explicit by calling Intent.set{Component,Class,ClassName}. [UnsafeImplicitIntentLaunch]
finish()
}
}

Expand Down

0 comments on commit a88a2fd

Please sign in to comment.