From 4fc1d0aa1b77491fb90fe27cec5ee7919e09634d Mon Sep 17 00:00:00 2001 From: campbelg Date: Tue, 14 Jan 2014 16:07:07 -0500 Subject: [PATCH] Code review fixes, javadoc fixes, set width to 120 chars, moved 'missing params' message to a string file. --- res/values/strings.xml | 1 + .../android/AuthenticatingWebView.java | 114 ++++---- .../AuthenticatingWebViewCallbackMethods.java | 10 +- .../authentication/android/MainActivity.java | 256 ++++++++---------- 4 files changed, 166 insertions(+), 215 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 64b50a2..6d06605 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -9,5 +9,6 @@ Sign In Again Authenticating… Please Wait + Please set the authentication parameters in the authentication.xml file. diff --git a/src/org/oclc/mobile/authentication/android/AuthenticatingWebView.java b/src/org/oclc/mobile/authentication/android/AuthenticatingWebView.java index 70ee2d1..4d99824 100644 --- a/src/org/oclc/mobile/authentication/android/AuthenticatingWebView.java +++ b/src/org/oclc/mobile/authentication/android/AuthenticatingWebView.java @@ -1,7 +1,7 @@ package org.oclc.mobile.authentication.android; /******************************************************************************* - * Copyright (c) 2013 OCLC Inc. + * Copyright (c) 2014 OCLC Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of @@ -23,125 +23,111 @@ import android.webkit.WebViewClient; /** - * This class extends a generic webView to execute an Oauth2 authentication - * process to return a token and its associated parameters for use in calling - * OCLC web services. + * Extends a generic webView to execute an Oauth2 authentication. Returns a token and its associated parameters for use + * in calling OCLC web services. * * @see android.webkit.WebView */ public class AuthenticatingWebView { /** - * The parameters returned by a successful authentication + * Parameters returned by a successful authentication. */ private final HashMap authorizationReturnParameters = new HashMap(); /** - * A browser window used to perform authentication in + * Browser Window that hosts the authentication process. */ private final WebView webView; /** - * A listener for callbacks from webView + * Listener for callbacks from webView. */ private final AuthenticatingWebViewCallbackMethods listener; /** - * Class constructor. - *

- * Store the webview and call back listener into class instance variables - * for later use. + * Stores the webview and call back listener into class instance variables for later use. * - * @param webView the WebView that is handling the authentication - * interaction with the user - * @param listener handle to the callback methods to MainActivity.java + * @param webView the WebView that is handling the authentication interaction with the user. + * @param listener handle to the callback methods to MainActivity.java. */ - public AuthenticatingWebView(final WebView webView, - final AuthenticatingWebViewCallbackMethods listener) { + public AuthenticatingWebView(final WebView webView, final AuthenticatingWebViewCallbackMethods listener) { this.webView = webView; this.listener = listener; } /** - * Sets up the WebView to make a a HTTP GET to the OCLC Authentication - * server to retrieve an access token. + * Sets up the WebView to make a a HTTP GET to the OCLC Authentication server to retrieve an access token. *

* The request URL is of this form: *

- * {baseURL}/authorizeCode?client_id={wskey client - * ID}&authenticatingInstitutionId={Inst ID} &contextInstitutionId={Inst - * ID}&redirect_uri={redirect Url}&response_type={token} &scope={scope_1 - * scope_2 ...} + * {baseURL}/authorizeCode?client_id={wskey client ID}&authenticatingInstitutionId={Inst ID} + * &contextInstitutionId={Inst ID}&redirect_uri={redirect Url}&response_type={token} &scope={scope_1 scope_2 ...} * * @param requestUrl the request URL that initiates the token request */ @SuppressLint("SetJavaScriptEnabled") public final void makeRequest(final String requestUrl) { - /** - * Clear the webView, in case it is showing a previous authentication - * error. Make the webView visible, in case the last attempt succeeded - * and it is hidden. + /* + * Clear the webView, in case it is showing a previous authentication error. Make the webView visible, in case + * the last attempt succeeded and it is hidden. */ webView.loadUrl("about:blank"); webView.setVisibility(View.VISIBLE); - /** + /* * Enable javascript in the WebView (off by default). The annotation */ WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); - /** - * Set the callback function for the webview. Inspect the URL before - * loading to detect successful or failed loads. + /* + * Set the callback function for the webview. Inspect the URL before loading to detect successful or failed + * loads. */ webView.setWebViewClient(new MyCustomWebViewClient()); - /** + /* * Execute the token request */ webView.loadUrl(requestUrl); } /** - * This nested class handles callbacks from webView. + * Handles callbacks from the webView. */ private class MyCustomWebViewClient extends WebViewClient { /** - * Callback executes BEFORE the WebView makes the http request We - * examine the url to see if it contains the redirect URI, and if so - * intercept it, hide the webview and display the token. Note - if - * something goes wrong in the long OAuth2 dance, the user will end up - * with an error displayed on the webview. They can restart sign in by - * pushing the [Sign In Again] button. + * Callback executes BEFORE the WebView makes the http request We examine the url to see if it contains the + * redirect URI, and if so intercept it, hide the webview and display the token. Note - if something goes wrong + * in the long OAuth2 dance, the user will end up with an error displayed on the webview. They can restart sign + * in by pushing the [Sign In Again] button. * * @param view the WebView that executed the callback * @param url the URL that the WebView is about to load * @return returns true to permit the url to be loaded into the webview */ @Override - public boolean shouldOverrideUrlLoading(final WebView view, - final String url) { + public boolean shouldOverrideUrlLoading(final WebView view, final String url) { /* - * Is this the "redirect URI" that we are about to load? If so, - * parse it and don't load it. Parsing is based on the # and the & - * characters, so make sure they are present before accepting this - * as a valid redirect URI. + * Is this the "redirect URI" that we are about to load? If so, parse it and don't load it. Parsing is based + * on the # and the & characters, so make sure they are present before accepting this as a valid redirect + * URI. */ - if (url.indexOf("ncipapp://user_agent_flow#") == 0 - && url.indexOf("&") != -1) { + if (url.indexOf("ncipapp://user_agent_flow#") == 0 && url.indexOf("&") != -1) { parseRedirectURI(url); - /** - * Clear the webView and hide it */ + /* + * Clear the webView and hide it + */ view.loadUrl("about:blank"); webView.setVisibility(View.INVISIBLE); - /** + /* * Display all the parameters returned with the token */ listener.displayResults(authorizationReturnParameters); @@ -150,12 +136,10 @@ public boolean shouldOverrideUrlLoading(final WebView view, } else { - /** - * The url we are about to load is not the "redirect URI", so - * load it. Note that if anything goes wrong with the - * authentication, the last message in the webview, and - * listener.displayResults(authorizationReturnParameters) will - * never be called. + /* + * The url we are about to load is not the "redirect URI", so load it. Note that if anything goes wrong + * with the authentication, the last message in the webview, and + * listener.displayResults(authorizationReturnParameters) will never be called. */ view.loadUrl(url); return true; @@ -163,22 +147,19 @@ public boolean shouldOverrideUrlLoading(final WebView view, } /** - * Callback fires when page starts to load. Used to start the Progress - * Dialog. + * Callback fires when page starts to load. Used to start the Progress Dialog. * * @param view the webView referred to by this callback * @param url the URL that the webView started to load * @param favicon the favicon of the page being loaded */ @Override - public void onPageStarted(final WebView view, final String url, - final Bitmap favicon) { + public void onPageStarted(final WebView view, final String url, final Bitmap favicon) { listener.startProgressDialog(); } /** - * Callback fires when page finishes loading. We use it to turn off the - * Progress Dialog. + * Callback fires when page finishes loading. We use it to turn off the Progress Dialog. * * @param view the webView referred to by this callback * @param url the URL that this page is loading @@ -197,12 +178,13 @@ public void onPageFinished(final WebView view, final String url) { */ private void parseRedirectURI(final String redirectUrl) { - String[] strArr = redirectUrl.split("#")[1].split("&"); + String[] params = redirectUrl.split("#")[1].split("&"); - for (String parameter : strArr) { - if (parameter.indexOf("=") != -1) { - authorizationReturnParameters.put(parameter.split("=")[0], - parameter.split("=")[1]); + for (String parameter : params) { + if (parameter.contains("=")) { + authorizationReturnParameters.put(parameter.split("=")[0], parameter.split("=")[1]); + } else { + authorizationReturnParameters.put(parameter, ""); } } } diff --git a/src/org/oclc/mobile/authentication/android/AuthenticatingWebViewCallbackMethods.java b/src/org/oclc/mobile/authentication/android/AuthenticatingWebViewCallbackMethods.java index 74a93be..ac74302 100644 --- a/src/org/oclc/mobile/authentication/android/AuthenticatingWebViewCallbackMethods.java +++ b/src/org/oclc/mobile/authentication/android/AuthenticatingWebViewCallbackMethods.java @@ -1,7 +1,7 @@ package org.oclc.mobile.authentication.android; /******************************************************************************* - * Copyright (c) 2013 OCLC Inc. + * Copyright (c) 2014 OCLC Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of @@ -16,15 +16,13 @@ import java.util.HashMap; /** - * This interface defines the callback functions that AuthenticatingWebView.java - * will execute in MainActivity.java, since the MainActivity handles displaying - * results on the screen, and AuthenticatingWebView makes asynchronous http + * This interface defines the callback functions that AuthenticatingWebView.java will execute in MainActivity.java, + * since the MainActivity handles displaying results on the screen, and AuthenticatingWebView makes asynchronous http * requests. */ public interface AuthenticatingWebViewCallbackMethods { /** - * Method is called when it is time to display the progress spinner, for - * example when loading on the web view. + * Method is called when it is time to display the progress spinner, for example when loading on the web view. */ void startProgressDialog(); diff --git a/src/org/oclc/mobile/authentication/android/MainActivity.java b/src/org/oclc/mobile/authentication/android/MainActivity.java index 6785741..cac6275 100644 --- a/src/org/oclc/mobile/authentication/android/MainActivity.java +++ b/src/org/oclc/mobile/authentication/android/MainActivity.java @@ -1,7 +1,7 @@ package org.oclc.mobile.authentication.android; /******************************************************************************* - * Copyright (c) 2013 OCLC Inc. + * Copyright (c) 2014 OCLC Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of @@ -28,20 +28,18 @@ import android.widget.TextView; /** - * Displays the view for the application and handles UI interaction. The - * following resources are loaded into this Activity: + * Displays the view for the application and handles UI interaction. The following resources are loaded into this + * Activity: *

    *
  • res/layout/activity_main.xml - the view objects and their layout
  • *
  • /res/values/strings.xml - any strings that are displayed
  • - *
  • /res/values/authentication.xml - list of strings containing - * authentication parameters
  • + *
  • /res/values/authentication.xml - list of strings containing authentication parameters
  • *
*

- * This class calls an instance of AuthenticatingWebView to handle the actual - * sign in process with the OCLC Authentication servers. Call back methods are - * defined by interfaces in AuthenticatingWebViewCallbackMethods, so that the - * AuthenticatingWebView can turn an activity indicator on and off, and return - * the authentication results for display. + * This class calls an instance of AuthenticatingWebView to handle the actual sign in process with the OCLC + * Authentication servers. Call back methods are defined by interfaces in AuthenticatingWebViewCallbackMethods, so that + * the AuthenticatingWebView can turn an activity indicator on and off, and return the authentication results for + * display. *

* The request and result parameters are as follows: *

@@ -66,13 +64,12 @@ *

  • expires_at
  • * *

    - * The Cookie Manager, myCookieManager, gives access to this app's cookies so - * that we can clear them when restarting the sign-in activity from scratch. + * The Cookie Manager, myCookieManager, gives access to this app's cookies so that we can clear them when restarting the + * sign-in activity from scratch. * * @see android.app.Activity */ -public class MainActivity extends Activity implements -AuthenticatingWebViewCallbackMethods { +public class MainActivity extends Activity implements AuthenticatingWebViewCallbackMethods { /** * Multiplier to convert seconds to milliseconds @@ -80,14 +77,13 @@ public class MainActivity extends Activity implements private static final int SECONDS_TO_MILLISECONDS = 1000; /** - * An extension that is passed a webview and uses it to handle - * authentication + * An extension that is passed a webview and uses it to handle authentication */ private AuthenticatingWebView authenticatingWebView; /** - * Holds the context of MainActivity so it can be passed to the WebView. The - * WebView uses that context to call back to the MainActivity to + * Holds the context of MainActivity so it can be passed to the WebView. The WebView uses that context to call back + * to the MainActivity to *

      *
    • Start the activity spinner.
    • *
    • Stop the activity spinner.
    • @@ -102,14 +98,13 @@ public class MainActivity extends Activity implements private CookieManager myCookieManager; /** - * Timer activated when authentication token is received to decrement the - * seconds remaining until the authentication token expires. + * Timer activated when authentication token is received to decrement the seconds remaining until the authentication + * token expires. */ private CountDownTimer tokenCountDownTimer; /** - * A progress dialog to indicate to the user that the app is waiting for an - * http response + * A progress dialog to indicate to the user that the app is waiting for an http response */ private ProgressDialog myProgressDialog; @@ -124,17 +119,14 @@ public class MainActivity extends Activity implements private String requestUrl; /** - * This method initializes the class and only fires once - when the app - * loads into memory. Once an app is initialized, it stays in the run state - * until the client runs out of memory or shuts off, which could be for - * days. This method does not fire when the app returns from the background - * to the foreground. + * This method initializes the class and only fires once - when the app loads into memory. Once an app is + * initialized, it stays in the run state until the client runs out of memory or shuts off, which could be for days. + * This method does not fire when the app returns from the background to the foreground. *

      - * The method loads the layout from the xml file, instantiates an instance - * of the webview. A WebView is an embedded Chrome browser with no user - * controls, which we will use to handle OAuth2 authentication. Initially - * the webView is invisible. It is made visible to facilitate sign in, and - * hidden after a token is received so that the token can be displayed. + * The method loads the layout from the xml file, instantiates an instance of the webview. A WebView is an embedded + * Chrome browser with no user controls, which we will use to handle OAuth2 authentication. Initially the webView is + * invisible. It is made visible to facilitate sign in, and hidden after a token is received so that the token can + * be displayed. * * @param savedInstanceState state information for the app * @see android.app.Activity#onCreate(android.os.Bundle) @@ -142,67 +134,61 @@ public class MainActivity extends Activity implements @Override protected final void onCreate(final Bundle savedInstanceState) { - /** + /* * Set the context required for the progress dialog */ myContext = this; - /** - * Required for all Android apps to pass the savedInstanceState to the - * parent + /* + * Required for all Android apps to pass the savedInstanceState to the parent */ super.onCreate(savedInstanceState); - /** - * Loads the view elements from the xml file. R.layout.activity_main - * refers to res/layout/activity_main.xml + /* + * Loads the view elements from the xml file. R.layout.activity_main refers to res/layout/activity_main.xml */ setContentView(R.layout.activity_main); - /** - * Get a handle to the webView whose position and size is defined in - * activity_main.xml + /* + * Get a handle to the webView whose position and size is defined in activity_main.xml */ webView = (WebView) findViewById(R.id.webView); - /** - * Get a handle to the CookieManager, which is global for this app, and - * use it to enable cookies. + /* + * Get a handle to the CookieManager, which is global for this app, and use it to enable cookies. */ myCookieManager = CookieManager.getInstance(); myCookieManager.setAcceptCookie(true); - /** - * Build the request url by getting the request parameters from - * res/values/authentication.xml. + /* + * Build the request url by getting the request parameters from res/values/authentication.xml. */ - requestUrl = new StringBuffer() - .append(getString(R.string.authenticatingServerBaseUrl)) - .append("/authorizeCode?client_id=") - .append(getString(R.string.wskey)) - .append("&authenticatingInstitutionId=") - .append(getString(R.string.authenticatingInstitutionId)) - .append("&contextInstitutionId=") - .append(getString(R.string.contextInstitutionId)) - .append("&redirect_uri=") - .append(getString(R.string.redirectUrl)) - .append("&response_type=") - .append(getString(R.string.responseType)).append("&scope=") - .append(getString(R.string.scopes)).toString(); + requestUrl = (new StringBuffer()).append(getString(R.string.authenticatingServerBaseUrl)) + .append("/authorizeCode?client_id=") + .append(getString(R.string.wskey)) + .append("&authenticatingInstitutionId=") + .append(getString(R.string.authenticatingInstitutionId)) + .append("&contextInstitutionId=") + .append(getString(R.string.contextInstitutionId)) + .append("&redirect_uri=") + .append(getString(R.string.redirectUrl)) + .append("&response_type=") + .append(getString(R.string.responseType)) + .append("&scope=") + .append(getString(R.string.scopes)) + .toString(); if (getString(R.string.wskey).equals("")) { - // If the wskey is blank, then the user probably forgot to set the - // parameters in authentication.xml + /* + * If the wskey is blank, then the user probably forgot to set the parameters in authentication.xml + */ LinearLayout resultLayout = (LinearLayout) findViewById(R.id.resultLayout); resultLayout.setVisibility(View.VISIBLE); - - ((TextView) findViewById(R.id.access_token)) - .setText("You must set the authentication parameters in the authentication.xml properties file."); + ((TextView) findViewById(R.id.access_token)).setText(getString(R.string.authParamsNotSet)); } else { - /** - * Create the AuthenticatingWebView, a custom WebView, to make the url - * request. We also pass this class's context so that the - * AuthenticatingWebView can execute callbacks. + /* + * Create the AuthenticatingWebView, a custom WebView, to make the url request. We also pass this class's + * context so that the AuthenticatingWebView can execute callbacks. */ authenticatingWebView = new AuthenticatingWebView(webView, this); authenticatingWebView.makeRequest(requestUrl); @@ -210,8 +196,7 @@ protected final void onCreate(final Bundle savedInstanceState) { } /** - * Boilerplate code required by Android to display any menu xml that may - * exist in res/menu. + * Boilerplate code required by Android to display any menu xml that may exist in res/menu. * * @param menu the menu associated with this activity * @return returns true to create the menu @@ -224,63 +209,66 @@ public final boolean onCreateOptionsMenu(final Menu menu) { } /** - * Standard form callback for the [Clear Cookies] button, whose properties - * are described in res/layout/activity_main.xml. + * Standard form callback for the [Clear Cookies] button, whose properties are described in + * res/layout/activity_main.xml. * * @param view [Clear Cookies] button's view */ public final void clearCookies(final View view) { - /** - * Removes the cookies associated with this app only - browser cookies - * and other app's cookies are not affected. + /* + * Removes the cookies associated with this app only - browser cookies and other app's cookies are not affected. */ myCookieManager.removeAllCookie(); } /** - * Standard form callback for the [Sign In Again] button, whose properties - * are described in res/layout/activity_main.xml. + * Standard form callback for the [Sign In Again] button, whose properties are described in + * res/layout/activity_main.xml. * * @param view [Sign In Again] button's view */ public final void signInAgain(final View view) { - if (!getString(R.string.wskey).equals("")) { - /** - * Clear the token count down timer if it is running and set the timer - * text to expired. + if (getString(R.string.wskey).equals("")) { + /* + * If the wskey is blank, then the user probably forgot to set the parameters in authentication.xml + */ + LinearLayout resultLayout = (LinearLayout) findViewById(R.id.resultLayout); + resultLayout.setVisibility(View.VISIBLE); + ((TextView) findViewById(R.id.access_token)).setText(getString(R.string.authParamsNotSet)); + } else { + /* + * Clear the token count down timer if it is running and set the timer text to expired. */ if (tokenCountDownTimer != null) { tokenCountDownTimer.cancel(); tokenCountDownTimer = null; - ((TextView) findViewById(R.id.timeRemainingTextView)) - .setText(getString(R.string.time_remaining_expired)); + ((TextView) findViewById(R.id.timeRemainingTextView)).setText(getString(R.string.time_remaining_expired)); } - /** - * Hide the text result views. + /* + * Hide the text result views. */ LinearLayout resultLayout = (LinearLayout) findViewById(R.id.resultLayout); resultLayout.setVisibility(View.INVISIBLE); - /** + /* * Make another request. */ - authenticatingWebView.makeRequest(requestUrl); } } /** - * Display a progress indicator while authenticating. Implements a callback - * function called by AuthenticatingWebViewCallbackMethods + * Display a progress indicator while authenticating. Implements a callback function called by + * AuthenticatingWebViewCallbackMethods */ @Override public final void startProgressDialog() { - /** - * Create a progressDialog if it does not exist. + /* + * Create a progressDialog if it does not exist. */ if (myProgressDialog == null) { myProgressDialog = new ProgressDialog(myContext); @@ -290,15 +278,15 @@ public final void startProgressDialog() { myProgressDialog.setIndeterminate(true); } - /** - * Show the progress dialog. + /* + * Show the progress dialog. */ myProgressDialog.show(); } /** - * Stop and destroy a progress indicator (if it exists). Implements a - * callback function called by AuthenticatingWebViewCallbackMethods. + * Stop and destroy a progress indicator (if it exists). Implements a callback function called by + * AuthenticatingWebViewCallbackMethods. */ @Override public final void stopProgressDialog() { @@ -306,82 +294,64 @@ public final void stopProgressDialog() { } /** - * Display the results by extracting the values from the Hash Map and - * inserting them into the TextViews which are defined in - * res/layout/activity_main.xml. Implements a callback function called by + * Display the results by extracting the values from the Hash Map and inserting them into the TextViews which are + * defined in res/layout/activity_main.xml. Implements a callback function called by * AuthenticatingWebViewCallbackMethods. * * @param authorizationReturnParameters A list of return params and values */ @Override - public final void displayResults( - final HashMap authorizationReturnParameters) { + public final void displayResults(final HashMap authorizationReturnParameters) { - /** - * Make the text result views visible. Each result parameter's textview - * is grouped into a LinearLayout. + /* + * Make the text result views visible. Each result parameter's textview is grouped into a LinearLayout. */ LinearLayout resultLayout = (LinearLayout) findViewById(R.id.resultLayout); resultLayout.setVisibility(View.VISIBLE); - ((TextView) findViewById(R.id.access_token)) - .setText(authorizationReturnParameters.get("access_token")); - ((TextView) findViewById(R.id.principalID)) - .setText(authorizationReturnParameters.get("principalID")); - ((TextView) findViewById(R.id.principalIDNS)) - .setText(authorizationReturnParameters.get("principalIDNS")); - ((TextView) findViewById(R.id.context_institution_id)) - .setText(authorizationReturnParameters - .get("context_institution_id")); - ((TextView) findViewById(R.id.token_type)) - .setText(authorizationReturnParameters.get("token_type")); - ((TextView) findViewById(R.id.expires_in)) - .setText(authorizationReturnParameters.get("expires_in")); - ((TextView) findViewById(R.id.expires_at)) - .setText(authorizationReturnParameters.get("expires_at")); - - /** - * Check if the token CountDownTimer, and cancel it if it does. + ((TextView) findViewById(R.id.access_token)).setText(authorizationReturnParameters.get("access_token")); + ((TextView) findViewById(R.id.principalID)).setText(authorizationReturnParameters.get("principalID")); + ((TextView) findViewById(R.id.principalIDNS)).setText(authorizationReturnParameters.get("principalIDNS")); + ((TextView) findViewById(R.id.context_institution_id)).setText(authorizationReturnParameters.get("context_institution_id")); + ((TextView) findViewById(R.id.token_type)).setText(authorizationReturnParameters.get("token_type")); + ((TextView) findViewById(R.id.expires_in)).setText(authorizationReturnParameters.get("expires_in")); + ((TextView) findViewById(R.id.expires_at)).setText(authorizationReturnParameters.get("expires_at")); + + /* + * Check if the token CountDownTimer, and cancel it if it does. */ if (tokenCountDownTimer != null) { tokenCountDownTimer.cancel(); } - /** - * Start a new token count down timer based on the time remaining - * returned with the token (time remaining is in seconds). + /* + * Start a new token count down timer based on the time remaining returned with the token (time remaining is in + * seconds). */ if (authorizationReturnParameters.get("expires_in") != null) { - tokenCountDownTimer = new CountDownTimer( - Integer.parseInt(authorizationReturnParameters - .get("expires_in")) * SECONDS_TO_MILLISECONDS, - SECONDS_TO_MILLISECONDS) { + tokenCountDownTimer = new CountDownTimer(Integer.parseInt(authorizationReturnParameters.get("expires_in")) * SECONDS_TO_MILLISECONDS, + SECONDS_TO_MILLISECONDS) { /* Callback fires every 1000 ms. */ @Override public void onTick(final long millisUntilFinished) { - ((TextView) findViewById(R.id.timeRemainingTextView)) - .setText(getString(R.string.time_remaining) - + millisUntilFinished - / SECONDS_TO_MILLISECONDS); + ((TextView) findViewById(R.id.timeRemainingTextView)).setText(getString(R.string.time_remaining) + millisUntilFinished + / SECONDS_TO_MILLISECONDS); } - /** - * Callback fires when timer counts down to zero. + /* + * Callback fires when timer counts down to zero. */ @Override public void onFinish() { - ((TextView) findViewById(R.id.timeRemainingTextView)) - .setText(getString(R.string.time_remaining_expired)); + ((TextView) findViewById(R.id.timeRemainingTextView)).setText(getString(R.string.time_remaining_expired)); } }.start(); } else { - /** - * If the "expires_in" parameter is null, then something has gone - * wrong during authentication. + /* + * If the "expires_in" parameter is null, then something has gone wrong during authentication. */ - ((TextView) findViewById(R.id.timeRemainingTextView)) - .setText(getString(R.string.invalid_authentication_request)); + ((TextView) findViewById(R.id.timeRemainingTextView)).setText(getString(R.string.invalid_authentication_request)); } } }