Methods Summary |
---|
private synchronized void | ensureViews()
if (mLayout == null) {
initializeViews();
}
|
private static java.lang.String | fillUrl(java.lang.String url, android.content.Context context)Fills the URL with the locale.
if (TextUtils.isEmpty(url)) {
return "";
}
/* We add another layer of indirection here to allow mcc's to fill
* in Locales for TOS. TODO - REMOVE when needed locales supported
* natively (when not shipping devices to country X without support
* for their locale).
*/
String localeReplacement = context.
getString(com.android.internal.R.string.locale_replacement);
if (localeReplacement != null && localeReplacement.length() != 0) {
url = String.format(url, localeReplacement);
}
Locale locale = Locale.getDefault();
String tmp = locale.getLanguage() + "_" + locale.getCountry().toLowerCase();
return String.format(url, tmp);
|
public android.view.ViewGroup | getLayout()Returns the layout containing the web view, progress bar, and text view.
This class takes care of setting each one's visibility based on current
state.
ensureViews();
return mLayout;
|
public boolean | handleKey(android.view.KeyEvent event)Helper to handle the back key. Returns true if the back key was handled,
otherwise returns false.
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK
&& event.getAction() == KeyEvent.ACTION_DOWN) {
if (mWebView.canGoBack()) {
mWebView.goBack();
return true;
}
}
return false;
|
private synchronized void | handleWebViewCompletion(boolean success)
if (mReceivedResponse) {
return;
} else {
mReceivedResponse = true;
}
// In both cases, remove the progress bar
((ViewGroup) mProgressBar.getParent()).removeView(mProgressBar);
// Remove the view that isn't relevant
View goneView = success ? mTextView : mWebView;
((ViewGroup) goneView.getParent()).removeView(goneView);
// Show the next view, which depends on success
View visibleView = success ? mWebView : mTextView;
visibleView.setVisibility(View.VISIBLE);
|
private void | initializeViews()
LayoutInflater inflater =
(LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mLayout = (ViewGroup) inflater.inflate(
com.android.internal.R.layout.google_web_content_helper_layout, null);
mWebView = (WebView) mLayout.findViewById(com.android.internal.R.id.web);
mWebView.setWebViewClient(new MyWebViewClient());
WebSettings settings = mWebView.getSettings();
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
mProgressBar = mLayout.findViewById(com.android.internal.R.id.progressContainer);
TextView message = (TextView) mProgressBar.findViewById(com.android.internal.R.id.message);
message.setText(com.android.internal.R.string.googlewebcontenthelper_loading);
mTextView = (TextView) mLayout.findViewById(com.android.internal.R.id.text);
mTextView.setText(mUnsuccessfulMessage);
|
public com.google.android.util.GoogleWebContentHelper | loadUrl()Begins loading the secure URL.
ensureViews();
mWebView.loadUrl(mSecureUrl);
return this;
|
public com.google.android.util.GoogleWebContentHelper | setUnsuccessfulMessage(java.lang.String message)Sets the message that will be shown if we are unable to load the page.
This should be called after {@link #setUrlsFromGservices(String, String)}
.
Locale locale = mContext.getResources().getConfiguration().locale;
mUnsuccessfulMessage = String.format(locale, message, mPrettyUrl);
return this;
|
public com.google.android.util.GoogleWebContentHelper | setUrls(java.lang.String secureUrl, java.lang.String prettyUrl)Fetch directly from provided urls.
mSecureUrl = fillUrl(secureUrl, mContext);
mPrettyUrl = fillUrl(prettyUrl, mContext);
return this;
|
public com.google.android.util.GoogleWebContentHelper | setUrlsFromGservices(java.lang.String secureSetting, java.lang.String prettySetting)Fetches the URLs from Gservices.
ContentResolver contentResolver = mContext.getContentResolver();
mSecureUrl = fillUrl(Settings.Gservices.getString(contentResolver, secureSetting),
mContext);
mPrettyUrl = fillUrl(Settings.Gservices.getString(contentResolver, prettySetting),
mContext);
return this;
|