Loading packages/OsuLogin/Android.mk +1 −0 Original line number Original line Diff line number Diff line Loading @@ -3,6 +3,7 @@ include $(CLEAR_VARS) LOCAL_MODULE_TAGS := optional LOCAL_MODULE_TAGS := optional LOCAL_USE_AAPT2 := true LOCAL_USE_AAPT2 := true LOCAL_STATIC_ANDROID_LIBRARIES := androidx.legacy_legacy-support-v4 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_SRC_FILES := $(call all-java-files-under, src) Loading packages/OsuLogin/AndroidManifest.xml +8 −5 Original line number Original line Diff line number Diff line Loading @@ -28,7 +28,10 @@ android:label="@string/app_name" android:label="@string/app_name" android:configChanges="keyboardHidden|orientation|screenSize" android:configChanges="keyboardHidden|orientation|screenSize" android:supportsRtl="true"> android:supportsRtl="true"> <activity android:name="com.android.hotspot2.osu.OsuLoginActivity"> <activity android:name="com.android.hotspot2.osu.OsuLoginActivity" android:label="@string/action_bar_label" android:theme="@style/AppTheme" android:configChanges="keyboardHidden|orientation|screenSize"> <intent-filter> <intent-filter> <action android:name="android.net.wifi.action.PASSPOINT_LAUNCH_OSU_VIEW"/> <action android:name="android.net.wifi.action.PASSPOINT_LAUNCH_OSU_VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT"/> Loading packages/OsuLogin/res/layout/osu_web_view.xml +33 −8 Original line number Original line Diff line number Diff line Loading @@ -2,12 +2,37 @@ xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" android:id="@+id/container" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.android.hotspot2.osu.OsuLoginActivity"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <FrameLayout android:layout_width="match_parent" android:layout_height="4dp"> <!-- Eliminates ProgressBar padding by boxing it into a 4dp high container --> <ProgressBar android:id="@+id/progress_bar" style="@android:style/Widget.Material.Light.ProgressBar.Horizontal" android:indeterminate="false" android:max="100" android:progress="0" android:layout_gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content"/> </FrameLayout> <androidx.swiperefreshlayout.widget.SwipeRefreshLayout android:id="@+id/swipe_refresh" android:layout_width="match_parent" android:layout_height="match_parent"> android:layout_height="match_parent"> <WebView <WebView android:id="@+id/webview" android:id="@+id/webview" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_height="match_parent" android:layout_alignParentBottom="true" android:layout_alignParentBottom="false" android:layout_alignParentRight="true" /> android:layout_alignParentRight="false"/> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </LinearLayout> </FrameLayout> </FrameLayout> packages/OsuLogin/res/values/strings.xml +2 −0 Original line number Original line Diff line number Diff line <resources> <resources> <!-- application name [CHAR LIMIT=32] --> <!-- application name [CHAR LIMIT=32] --> <string name="app_name">OsuLogin</string> <string name="app_name">OsuLogin</string> <!-- action bar label [CHAR LIMIT=32] --> <string name="action_bar_label">Online Sign Up</string> </resources> </resources> packages/OsuLogin/src/com/android/hotspot2/osu/OsuLoginActivity.java +50 −2 Original line number Original line Diff line number Diff line Loading @@ -16,9 +16,12 @@ package com.android.hotspot2.osu; package com.android.hotspot2.osu; import static android.net.NetworkCapabilities.NET_CAPABILITY_TRUSTED; import android.annotation.Nullable; import android.annotation.Nullable; import android.app.Activity; import android.app.Activity; import android.content.Context; import android.content.Context; import android.graphics.Bitmap; import android.net.ConnectivityManager; import android.net.ConnectivityManager; import android.net.Network; import android.net.Network; import android.net.NetworkCapabilities; import android.net.NetworkCapabilities; Loading @@ -27,17 +30,22 @@ import android.net.wifi.WifiManager; import android.os.Bundle; import android.os.Bundle; import android.util.Log; import android.util.Log; import android.view.KeyEvent; import android.view.KeyEvent; import android.view.View; import android.webkit.WebChromeClient; import android.webkit.WebResourceError; import android.webkit.WebResourceError; import android.webkit.WebResourceRequest; import android.webkit.WebResourceRequest; import android.webkit.WebSettings; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebView; import android.webkit.WebViewClient; import android.webkit.WebViewClient; import android.widget.ProgressBar; import com.android.hotspot2.R; import com.android.hotspot2.R; import java.net.MalformedURLException; import java.net.MalformedURLException; import java.net.URL; import java.net.URL; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; /** /** * Online Sign Up Login Web View launched during Provision Process of Hotspot 2.0 rel2. * Online Sign Up Login Web View launched during Provision Process of Hotspot 2.0 rel2. */ */ Loading @@ -52,6 +60,8 @@ public class OsuLoginActivity extends Activity { private ConnectivityManager.NetworkCallback mNetworkCallback; private ConnectivityManager.NetworkCallback mNetworkCallback; private WifiManager mWifiManager; private WifiManager mWifiManager; private WebView mWebView; private WebView mWebView; private SwipeRefreshLayout mSwipeRefreshLayout; private ProgressBar mProgressBar; @Override @Override protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) { Loading Loading @@ -117,6 +127,9 @@ public class OsuLoginActivity extends Activity { } } getActionBar().setDisplayShowHomeEnabled(false); getActionBar().setDisplayShowHomeEnabled(false); getActionBar().setElevation(0); // remove shadow getActionBar().setTitle(getString(R.string.action_bar_label)); getActionBar().setSubtitle(""); setContentView(R.layout.osu_web_view); setContentView(R.layout.osu_web_view); // Exit this app if network disappeared. // Exit this app if network disappeared. Loading @@ -134,7 +147,8 @@ public class OsuLoginActivity extends Activity { mCm.registerNetworkCallback( mCm.registerNetworkCallback( new NetworkRequest.Builder().addTransportType( new NetworkRequest.Builder().addTransportType( NetworkCapabilities.TRANSPORT_WIFI).build(), NetworkCapabilities.TRANSPORT_WIFI).removeCapability( NET_CAPABILITY_TRUSTED).build(), mNetworkCallback); mNetworkCallback); mWebView = findViewById(R.id.webview); mWebView = findViewById(R.id.webview); Loading @@ -147,12 +161,25 @@ public class OsuLoginActivity extends Activity { webSettings.setSupportZoom(true); webSettings.setSupportZoom(true); webSettings.setBuiltInZoomControls(true); webSettings.setBuiltInZoomControls(true); webSettings.setDisplayZoomControls(false); webSettings.setDisplayZoomControls(false); mProgressBar = findViewById(R.id.progress_bar); mWebView.setWebViewClient(new OsuWebViewClient()); mWebView.setWebViewClient(new OsuWebViewClient()); mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { mProgressBar.setProgress(newProgress); } }); if (DBG) { if (DBG) { Log.d(TAG, "OSU Web View to " + mUrl); Log.d(TAG, "OSU Web View to " + mUrl); } } mWebView.loadUrl(mUrl); mWebView.loadUrl(mUrl); mSwipeRefreshLayout = findViewById(R.id.swipe_refresh); mSwipeRefreshLayout.setOnRefreshListener(() -> { mWebView.reload(); mSwipeRefreshLayout.setRefreshing(true); }); } } @Override @Override Loading Loading @@ -191,11 +218,31 @@ public class OsuLoginActivity extends Activity { return null; return null; } } private String getHeaderSubtitle(String urlString) { try { URL url = new URL(urlString); return url.getProtocol() + "://" + url.getHost(); } catch (MalformedURLException e) { Log.e(TAG, "Invalid URL " + urlString); } return ""; } private class OsuWebViewClient extends WebViewClient { private class OsuWebViewClient extends WebViewClient { boolean mPageError = false; boolean mPageError = false; @Override public void onPageStarted(WebView view, String urlString, Bitmap favicon) { String subtitle = getHeaderSubtitle(urlString); getActionBar().setSubtitle(subtitle); mProgressBar.setVisibility(View.VISIBLE); } @Override @Override public void onPageFinished(WebView view, String url) { public void onPageFinished(WebView view, String url) { mProgressBar.setVisibility(View.INVISIBLE); mSwipeRefreshLayout.setRefreshing(false); // Do not show the page error on UI. // Do not show the page error on UI. if (mPageError) { if (mPageError) { finishAndRemoveTask(); finishAndRemoveTask(); Loading @@ -213,4 +260,5 @@ public class OsuLoginActivity extends Activity { } } } } } } } } Loading
packages/OsuLogin/Android.mk +1 −0 Original line number Original line Diff line number Diff line Loading @@ -3,6 +3,7 @@ include $(CLEAR_VARS) LOCAL_MODULE_TAGS := optional LOCAL_MODULE_TAGS := optional LOCAL_USE_AAPT2 := true LOCAL_USE_AAPT2 := true LOCAL_STATIC_ANDROID_LIBRARIES := androidx.legacy_legacy-support-v4 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_SRC_FILES := $(call all-java-files-under, src) Loading
packages/OsuLogin/AndroidManifest.xml +8 −5 Original line number Original line Diff line number Diff line Loading @@ -28,7 +28,10 @@ android:label="@string/app_name" android:label="@string/app_name" android:configChanges="keyboardHidden|orientation|screenSize" android:configChanges="keyboardHidden|orientation|screenSize" android:supportsRtl="true"> android:supportsRtl="true"> <activity android:name="com.android.hotspot2.osu.OsuLoginActivity"> <activity android:name="com.android.hotspot2.osu.OsuLoginActivity" android:label="@string/action_bar_label" android:theme="@style/AppTheme" android:configChanges="keyboardHidden|orientation|screenSize"> <intent-filter> <intent-filter> <action android:name="android.net.wifi.action.PASSPOINT_LAUNCH_OSU_VIEW"/> <action android:name="android.net.wifi.action.PASSPOINT_LAUNCH_OSU_VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.DEFAULT"/> Loading
packages/OsuLogin/res/layout/osu_web_view.xml +33 −8 Original line number Original line Diff line number Diff line Loading @@ -2,12 +2,37 @@ xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" android:id="@+id/container" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.android.hotspot2.osu.OsuLoginActivity"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <FrameLayout android:layout_width="match_parent" android:layout_height="4dp"> <!-- Eliminates ProgressBar padding by boxing it into a 4dp high container --> <ProgressBar android:id="@+id/progress_bar" style="@android:style/Widget.Material.Light.ProgressBar.Horizontal" android:indeterminate="false" android:max="100" android:progress="0" android:layout_gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content"/> </FrameLayout> <androidx.swiperefreshlayout.widget.SwipeRefreshLayout android:id="@+id/swipe_refresh" android:layout_width="match_parent" android:layout_height="match_parent"> android:layout_height="match_parent"> <WebView <WebView android:id="@+id/webview" android:id="@+id/webview" android:layout_width="match_parent" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_height="match_parent" android:layout_alignParentBottom="true" android:layout_alignParentBottom="false" android:layout_alignParentRight="true" /> android:layout_alignParentRight="false"/> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </LinearLayout> </FrameLayout> </FrameLayout>
packages/OsuLogin/res/values/strings.xml +2 −0 Original line number Original line Diff line number Diff line <resources> <resources> <!-- application name [CHAR LIMIT=32] --> <!-- application name [CHAR LIMIT=32] --> <string name="app_name">OsuLogin</string> <string name="app_name">OsuLogin</string> <!-- action bar label [CHAR LIMIT=32] --> <string name="action_bar_label">Online Sign Up</string> </resources> </resources>
packages/OsuLogin/src/com/android/hotspot2/osu/OsuLoginActivity.java +50 −2 Original line number Original line Diff line number Diff line Loading @@ -16,9 +16,12 @@ package com.android.hotspot2.osu; package com.android.hotspot2.osu; import static android.net.NetworkCapabilities.NET_CAPABILITY_TRUSTED; import android.annotation.Nullable; import android.annotation.Nullable; import android.app.Activity; import android.app.Activity; import android.content.Context; import android.content.Context; import android.graphics.Bitmap; import android.net.ConnectivityManager; import android.net.ConnectivityManager; import android.net.Network; import android.net.Network; import android.net.NetworkCapabilities; import android.net.NetworkCapabilities; Loading @@ -27,17 +30,22 @@ import android.net.wifi.WifiManager; import android.os.Bundle; import android.os.Bundle; import android.util.Log; import android.util.Log; import android.view.KeyEvent; import android.view.KeyEvent; import android.view.View; import android.webkit.WebChromeClient; import android.webkit.WebResourceError; import android.webkit.WebResourceError; import android.webkit.WebResourceRequest; import android.webkit.WebResourceRequest; import android.webkit.WebSettings; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebView; import android.webkit.WebViewClient; import android.webkit.WebViewClient; import android.widget.ProgressBar; import com.android.hotspot2.R; import com.android.hotspot2.R; import java.net.MalformedURLException; import java.net.MalformedURLException; import java.net.URL; import java.net.URL; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; /** /** * Online Sign Up Login Web View launched during Provision Process of Hotspot 2.0 rel2. * Online Sign Up Login Web View launched during Provision Process of Hotspot 2.0 rel2. */ */ Loading @@ -52,6 +60,8 @@ public class OsuLoginActivity extends Activity { private ConnectivityManager.NetworkCallback mNetworkCallback; private ConnectivityManager.NetworkCallback mNetworkCallback; private WifiManager mWifiManager; private WifiManager mWifiManager; private WebView mWebView; private WebView mWebView; private SwipeRefreshLayout mSwipeRefreshLayout; private ProgressBar mProgressBar; @Override @Override protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) { Loading Loading @@ -117,6 +127,9 @@ public class OsuLoginActivity extends Activity { } } getActionBar().setDisplayShowHomeEnabled(false); getActionBar().setDisplayShowHomeEnabled(false); getActionBar().setElevation(0); // remove shadow getActionBar().setTitle(getString(R.string.action_bar_label)); getActionBar().setSubtitle(""); setContentView(R.layout.osu_web_view); setContentView(R.layout.osu_web_view); // Exit this app if network disappeared. // Exit this app if network disappeared. Loading @@ -134,7 +147,8 @@ public class OsuLoginActivity extends Activity { mCm.registerNetworkCallback( mCm.registerNetworkCallback( new NetworkRequest.Builder().addTransportType( new NetworkRequest.Builder().addTransportType( NetworkCapabilities.TRANSPORT_WIFI).build(), NetworkCapabilities.TRANSPORT_WIFI).removeCapability( NET_CAPABILITY_TRUSTED).build(), mNetworkCallback); mNetworkCallback); mWebView = findViewById(R.id.webview); mWebView = findViewById(R.id.webview); Loading @@ -147,12 +161,25 @@ public class OsuLoginActivity extends Activity { webSettings.setSupportZoom(true); webSettings.setSupportZoom(true); webSettings.setBuiltInZoomControls(true); webSettings.setBuiltInZoomControls(true); webSettings.setDisplayZoomControls(false); webSettings.setDisplayZoomControls(false); mProgressBar = findViewById(R.id.progress_bar); mWebView.setWebViewClient(new OsuWebViewClient()); mWebView.setWebViewClient(new OsuWebViewClient()); mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { mProgressBar.setProgress(newProgress); } }); if (DBG) { if (DBG) { Log.d(TAG, "OSU Web View to " + mUrl); Log.d(TAG, "OSU Web View to " + mUrl); } } mWebView.loadUrl(mUrl); mWebView.loadUrl(mUrl); mSwipeRefreshLayout = findViewById(R.id.swipe_refresh); mSwipeRefreshLayout.setOnRefreshListener(() -> { mWebView.reload(); mSwipeRefreshLayout.setRefreshing(true); }); } } @Override @Override Loading Loading @@ -191,11 +218,31 @@ public class OsuLoginActivity extends Activity { return null; return null; } } private String getHeaderSubtitle(String urlString) { try { URL url = new URL(urlString); return url.getProtocol() + "://" + url.getHost(); } catch (MalformedURLException e) { Log.e(TAG, "Invalid URL " + urlString); } return ""; } private class OsuWebViewClient extends WebViewClient { private class OsuWebViewClient extends WebViewClient { boolean mPageError = false; boolean mPageError = false; @Override public void onPageStarted(WebView view, String urlString, Bitmap favicon) { String subtitle = getHeaderSubtitle(urlString); getActionBar().setSubtitle(subtitle); mProgressBar.setVisibility(View.VISIBLE); } @Override @Override public void onPageFinished(WebView view, String url) { public void onPageFinished(WebView view, String url) { mProgressBar.setVisibility(View.INVISIBLE); mSwipeRefreshLayout.setRefreshing(false); // Do not show the page error on UI. // Do not show the page error on UI. if (mPageError) { if (mPageError) { finishAndRemoveTask(); finishAndRemoveTask(); Loading @@ -213,4 +260,5 @@ public class OsuLoginActivity extends Activity { } } } } } } } }