22
33import android .content .Intent ;
44import android .os .Bundle ;
5- import android .util .Log ;
65import android .webkit .JavascriptInterface ;
6+ import android .webkit .WebSettings ;
77import android .webkit .WebView ;
88
99import com .getcapacitor .BridgeActivity ;
1010import com .getcapacitor .BridgeWebViewClient ;
11- import com .getcapacitor .Plugin ;
12- import com .getcapacitor .PluginHandle ;
1311
14- import ee .forgr .capacitor .social .login .GoogleProvider ;
15- import ee .forgr .capacitor .social .login .ModifiedMainActivityForSocialLoginPlugin ;
16- import ee .forgr .capacitor .social .login .SocialLoginPlugin ;
17-
18- public class MainActivity extends BridgeActivity implements ModifiedMainActivityForSocialLoginPlugin {
12+ public class MainActivity extends BridgeActivity {
1913 public class NativeBridge {
2014 @ JavascriptInterface
2115 public boolean isNativeApp () {
2216 return true ;
2317 }
2418 }
2519
26- private static final String LOCAL_URL = "file:///android_asset/public/server/pages" ;
27- private static final String REMOTE_URL = "https://www.compassmeet.com" ;
20+ // private static final String LOCAL_URL = "file:///android_asset/public/server/pages";
21+ // private static final String REMOTE_URL = "https://www.compassmeet.com";
2822
2923 // Optional helper for future use
30- public void loadLocalContent () {
31- Log .i ("CompassApp" , "Loading local assets..." );
32- this .bridge .getWebView ().loadUrl (LOCAL_URL );
33- }
24+ // public void loadLocalContent() {
25+ // Log.i("CompassApp", "Loading local assets...");
26+ // this.bridge.getWebView().loadUrl(LOCAL_URL);
27+ // }
28+ //
29+ // public void loadRemoteContent() {
30+ // Log.i("CompassApp", "Loading remote content...");
31+ // this.bridge.getWebView().loadUrl(REMOTE_URL);
32+ // }
33+
34+ @ Override
35+ protected void onNewIntent (Intent intent ) {
36+ super .onNewIntent (intent );
3437
35- public void loadRemoteContent () {
36- Log .i ("CompassApp" , "Loading remote content..." );
37- this .bridge .getWebView ().loadUrl (REMOTE_URL );
38+ String data = intent .getDataString ();
39+ if (data != null && data .startsWith ("com.compassmeet:/auth" )) {
40+ bridge .triggerWindowJSEvent ("oauthRedirect" , data );
41+ }
3842 }
3943
4044 @ Override
@@ -47,11 +51,10 @@ public void onCreate(Bundle savedInstanceState) {
4751 WebView .setWebContentsDebuggingEnabled (true );
4852
4953 // Set a recognizable User-Agent (always reliable)
50- webView .getSettings ().setUserAgentString (
51- webView .getSettings ().getUserAgentString () + " CompassAppWebView"
52- );
54+ WebSettings settings = webView .getSettings ();
55+ settings .setUserAgentString (settings .getUserAgentString () + " CompassAppWebView" );
5356
54- webView . getSettings () .setJavaScriptEnabled (true );
57+ settings .setJavaScriptEnabled (true );
5558 webView .addJavascriptInterface (new NativeBridge (), "AndroidBridge" );
5659
5760 // Allow remote URLs to still have access to Capacitor bridge
@@ -70,31 +73,31 @@ public void onCreate(Bundle savedInstanceState) {
7073// this.bridge.getWebView().loadUrl("https://www.compassmeet.com");
7174 }
7275
73- @ Override
74- public void onActivityResult (int requestCode , int resultCode , Intent data ) {
75- super .onActivityResult (requestCode , resultCode , data );
76-
77- Log .i ("Google Activity Result" , "onActivityResult called with requestCode: " + requestCode + data );
78-
79- if (requestCode >= GoogleProvider .REQUEST_AUTHORIZE_GOOGLE_MIN && requestCode < GoogleProvider .REQUEST_AUTHORIZE_GOOGLE_MAX ) {
80- PluginHandle pluginHandle = getBridge ().getPlugin ("SocialLogin" );
81- if (pluginHandle == null ) {
82- Log .i ("Google Activity Result" , "SocialLogin login handle is null" );
83- return ;
84- }
85- Plugin plugin = pluginHandle .getInstance ();
86- if (!(plugin instanceof SocialLoginPlugin )) {
87- Log .i ("Google Activity Result" , "SocialLogin plugin instance is not SocialLoginPlugin" );
88- return ;
89- }
90- Log .i ("Google Activity Result" , "Handling Google login intent" );
91- ((SocialLoginPlugin ) plugin ).handleGoogleLoginIntent (requestCode , data );
92- }
93- }
76+ // @Override
77+ // public void onActivityResult(int requestCode, int resultCode, Intent data) {
78+ // super.onActivityResult(requestCode, resultCode, data);
79+ //
80+ // Log.i("Google Activity Result", "onActivityResult called with requestCode: " + requestCode + data);
81+ //
82+ // if (requestCode >= GoogleProvider.REQUEST_AUTHORIZE_GOOGLE_MIN && requestCode < GoogleProvider.REQUEST_AUTHORIZE_GOOGLE_MAX) {
83+ // PluginHandle pluginHandle = getBridge().getPlugin("SocialLogin");
84+ // if (pluginHandle == null) {
85+ // Log.i("Google Activity Result", "SocialLogin login handle is null");
86+ // return;
87+ // }
88+ // Plugin plugin = pluginHandle.getInstance();
89+ // if (!(plugin instanceof SocialLoginPlugin)) {
90+ // Log.i("Google Activity Result", "SocialLogin plugin instance is not SocialLoginPlugin");
91+ // return;
92+ // }
93+ // Log.i("Google Activity Result", "Handling Google login intent");
94+ // ((SocialLoginPlugin) plugin).handleGoogleLoginIntent(requestCode, data);
95+ // }
96+ // }
9497
9598 // This function will never be called, leave it empty
96- @ Override
97- public void IHaveModifiedTheMainActivityForTheUseWithSocialLoginPlugin () {
98- }
99+ // @Override
100+ // public void IHaveModifiedTheMainActivityForTheUseWithSocialLoginPlugin() {
101+ // }
99102}
100103
0 commit comments