Code formatting, add final modifiers
This commit is contained in:
		| @@ -34,21 +34,21 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback<Bundle>, | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public Account getItem(int position) { |         public Account getItem(final int position) { | ||||||
|             return mAccounts[position]; |             return mAccounts[position]; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public long getItemId(int position) { |         public long getItemId(final int position) { | ||||||
|             return position; |             return position; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public View getView(int position, View convertView, ViewGroup parent) { |         public View getView(final int position, final View convertView, final ViewGroup parent) { | ||||||
|             LayoutInflater inflater = mActivity.getLayoutInflater(); |             final LayoutInflater inflater = mIitc.getLayoutInflater(); | ||||||
|             View v = inflater.inflate(android.R.layout.simple_list_item_1, parent, false); |             final View v = inflater.inflate(android.R.layout.simple_list_item_1, parent, false); | ||||||
|  |  | ||||||
|             TextView tv = (TextView) v.findViewById(android.R.id.text1); |             final TextView tv = (TextView) v.findViewById(android.R.id.text1); | ||||||
|             tv.setText(mAccounts[position].name); |             tv.setText(mAccounts[position].name); | ||||||
|  |  | ||||||
|             return tv; |             return tv; | ||||||
| @@ -59,7 +59,7 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback<Bundle>, | |||||||
|     private final AccountAdapter mAccountAdapter; |     private final AccountAdapter mAccountAdapter; | ||||||
|     private final AccountManager mAccountManager; |     private final AccountManager mAccountManager; | ||||||
|     private Account[] mAccounts; |     private Account[] mAccounts; | ||||||
|     private final IITC_Mobile mActivity; |     private final IITC_Mobile mIitc; | ||||||
|     private String mAuthToken; |     private String mAuthToken; | ||||||
|     private final AlertDialog mProgressbar; |     private final AlertDialog mProgressbar; | ||||||
|     private final WebView mWebView; |     private final WebView mWebView; | ||||||
| @@ -71,7 +71,7 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback<Bundle>, | |||||||
|     private final DialogInterface.OnClickListener onClickListener = |     private final DialogInterface.OnClickListener onClickListener = | ||||||
|             new DialogInterface.OnClickListener() { |             new DialogInterface.OnClickListener() { | ||||||
|                 @Override |                 @Override | ||||||
|                 public void onClick(DialogInterface dialog, int index) { |                 public void onClick(final DialogInterface dialog, final int index) { | ||||||
|                     if (index >= 0 && index < mAccounts.length) { |                     if (index >= 0 && index < mAccounts.length) { | ||||||
|                         mAccount = mAccounts[index]; |                         mAccount = mAccounts[index]; | ||||||
|                         startAuthentication(); |                         startAuthentication(); | ||||||
| @@ -80,17 +80,17 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback<Bundle>, | |||||||
|                 } |                 } | ||||||
|             }; |             }; | ||||||
|  |  | ||||||
|     public IITC_DeviceAccountLogin(IITC_Mobile activity, WebView webView, |     public IITC_DeviceAccountLogin(final IITC_Mobile iitc, final WebView webView, | ||||||
|                                    WebViewClient webViewClient) { |             final WebViewClient webViewClient) { | ||||||
|         mActivity = activity; |         mIitc = iitc; | ||||||
|         mWebView = webView; |         mWebView = webView; | ||||||
|         mAccountManager = AccountManager.get(activity); |         mAccountManager = AccountManager.get(iitc); | ||||||
|         mAccountAdapter = new AccountAdapter(); |         mAccountAdapter = new AccountAdapter(); | ||||||
|  |  | ||||||
|         // dialog that serves as a progress bar overlay |         // dialog that serves as a progress bar overlay | ||||||
|         mProgressbar = new AlertDialog.Builder(mActivity) |         mProgressbar = new AlertDialog.Builder(mIitc) | ||||||
|                 .setCancelable(false) |                 .setCancelable(false) | ||||||
|                 .setView(mActivity.getLayoutInflater().inflate(R.layout.dialog_progressbar, null)) |                 .setView(mIitc.getLayoutInflater().inflate(R.layout.dialog_progressbar, null)) | ||||||
|                 .create(); |                 .create(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -98,20 +98,19 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback<Bundle>, | |||||||
|      * display all available accounts to the user |      * display all available accounts to the user | ||||||
|      */ |      */ | ||||||
|     private void displayAccountList() { |     private void displayAccountList() { | ||||||
|         AlertDialog.Builder builder = new AlertDialog.Builder(mActivity) |         new AlertDialog.Builder(mIitc) | ||||||
|                 .setTitle(R.string.choose_account_to_login) |                 .setTitle(R.string.choose_account_to_login) | ||||||
|                 .setSingleChoiceItems(mAccountAdapter, 0, onClickListener) |                 .setSingleChoiceItems(mAccountAdapter, 0, onClickListener) | ||||||
|                 .setNegativeButton(android.R.string.cancel, onClickListener); |                 .setNegativeButton(android.R.string.cancel, onClickListener) | ||||||
|  |                 .create() | ||||||
|         AlertDialog dialog = builder.create(); |                 .show(); | ||||||
|         dialog.show(); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * called when something failed. Shows a toast message. Classic login is still available |      * called when something failed. Shows a toast message. Classic login is still available | ||||||
|      */ |      */ | ||||||
|     private void onLoginFailed() { |     private void onLoginFailed() { | ||||||
|         Toast.makeText(mActivity, R.string.login_failed, Toast.LENGTH_SHORT).show(); |         Toast.makeText(mIitc, R.string.login_failed, Toast.LENGTH_SHORT).show(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -122,17 +121,16 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback<Bundle>, | |||||||
|     private void startAuthentication() { |     private void startAuthentication() { | ||||||
|         mProgressbar.show(); |         mProgressbar.show(); | ||||||
|  |  | ||||||
|         mAccountManager.getAuthToken(mAccount, mAuthToken, null, mActivity, this, null); |         mAccountManager.getAuthToken(mAccount, mAuthToken, null, mIitc, this, null); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * called by IITC_Mobile when the authentication activity has finished. |      * called by IITC_Mobile when the authentication activity has finished. | ||||||
|      */ |      */ | ||||||
|     @Override |     @Override | ||||||
|     public void onActivityResult(int resultCode, Intent data) { |     public void onActivityResult(final int resultCode, final Intent data) { | ||||||
|         if (resultCode == Activity.RESULT_OK) |         if (resultCode == Activity.RESULT_OK) { | ||||||
|         // authentication activity succeeded, request token again |             // authentication activity succeeded, request token again | ||||||
|         { |  | ||||||
|             startAuthentication(); |             startAuthentication(); | ||||||
|         } else { |         } else { | ||||||
|             onLoginFailed(); |             onLoginFailed(); | ||||||
| @@ -143,29 +141,29 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback<Bundle>, | |||||||
|      * called by AccountManager |      * called by AccountManager | ||||||
|      */ |      */ | ||||||
|     @Override |     @Override | ||||||
|     public void run(AccountManagerFuture<Bundle> value) { |     public void run(final AccountManagerFuture<Bundle> value) { | ||||||
|         mProgressbar.hide(); |         mProgressbar.hide(); | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
|             Intent launch = (Intent) value.getResult().get(AccountManager.KEY_INTENT); |             final Intent launch = (Intent) value.getResult().get(AccountManager.KEY_INTENT); | ||||||
|             if (launch != null) { |             if (launch != null) { | ||||||
|                 // There is a reason we need to start the given activity if we want an |                 // There is a reason we need to start the given activity if we want an | ||||||
|                 // authentication token. (Could be user confirmation or something else. Whatever, |                 // authentication token. (Could be user confirmation or something else. Whatever, | ||||||
|                 // we have to start it) IITC_Mobile will call it using startActivityForResult |                 // we have to start it) IITC_Mobile will call it using startActivityForResult | ||||||
|                 mActivity.startActivityForResult(launch, this); |                 mIitc.startActivityForResult(launch, this); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             String result = value.getResult().getString(AccountManager.KEY_AUTHTOKEN); |             final String result = value.getResult().getString(AccountManager.KEY_AUTHTOKEN); | ||||||
|             if (result != null) { |             if (result != null) { | ||||||
|                 // authentication succeeded, we can load the given url, which will redirect |                 // authentication succeeded, we can load the given url, which will redirect | ||||||
|                 // back to the intel map |                 // back to the intel map | ||||||
|                 mWebView.loadUrl(result); |                 mWebView.loadUrl(result); | ||||||
|                 mActivity.loginSucceeded(); |                 mIitc.loginSucceeded(); | ||||||
|             } else { |             } else { | ||||||
|                 onLoginFailed(); |                 onLoginFailed(); | ||||||
|             } |             } | ||||||
|         } catch (Exception e) { |         } catch (final Exception e) { | ||||||
|             onLoginFailed(); |             onLoginFailed(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -173,21 +171,19 @@ public class IITC_DeviceAccountLogin implements AccountManagerCallback<Bundle>, | |||||||
|     /** |     /** | ||||||
|      * start authentication |      * start authentication | ||||||
|      * <p/> |      * <p/> | ||||||
|      * if we already have a username (e.g. because the existing login has timed out), |      * if we already have a username (e.g. because the existing login has timed out), we can directly start | ||||||
|      * we can directly start authentication if an account with that username is found. |      * authentication if an account with that username is found. | ||||||
|      */ |      */ | ||||||
|     public void startLogin(String realm, String accountName, String args) { |     public void startLogin(final String realm, final String accountName, final String args) { | ||||||
|         mAccounts = mAccountManager.getAccountsByType(realm); |         mAccounts = mAccountManager.getAccountsByType(realm); | ||||||
|         mAccountAdapter.notifyDataSetChanged(); |         mAccountAdapter.notifyDataSetChanged(); | ||||||
|         mAuthToken = "weblogin:" + args; |         mAuthToken = "weblogin:" + args; | ||||||
|  |  | ||||||
|         if (mAccounts.length == 0) { |         if (mAccounts.length == 0) return; | ||||||
|             return; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         for (Account account : mAccounts) { |         for (final Account account : mAccounts) { | ||||||
|             if (account.name.equals(accountName)) { |             if (account.name.equals(accountName)) { | ||||||
|                 mAccountManager.getAuthToken(account, mAuthToken, null, mActivity, this, null); |                 mAccountManager.getAuthToken(account, mAuthToken, null, mIitc, this, null); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -43,22 +43,22 @@ public class IITC_FileManager { | |||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * copies the contents of a stream into another stream and (optionally) closes the output stream afterwards |      * copies the contents of a stream into another stream and (optionally) closes the output stream afterwards | ||||||
|      *  |      * | ||||||
|      * @param inStream |      * @param inStream | ||||||
|      *            the stream to read from |      *            the stream to read from | ||||||
|      * @param outStream |      * @param outStream | ||||||
|      *            the stream to write to |      *            the stream to write to | ||||||
|      * @param closeOutput |      * @param closeOutput | ||||||
|      *            whether to close the output stream when finished |      *            whether to close the output stream when finished | ||||||
|      *  |      * | ||||||
|      * @throws IOException |      * @throws IOException | ||||||
|      */ |      */ | ||||||
|     public static void copyStream(InputStream inStream, OutputStream outStream, boolean closeOutput) throws IOException |     public static void copyStream(final InputStream inStream, final OutputStream outStream, final boolean closeOutput) | ||||||
|  |             throws IOException | ||||||
|     { |     { | ||||||
|  |  | ||||||
|         // in case Android includes Apache commons IO in the future, this function should be replaced by IOUtils.copy |         // in case Android includes Apache commons IO in the future, this function should be replaced by IOUtils.copy | ||||||
|         int bufferSize = 1024; |         final int bufferSize = 1024; | ||||||
|         byte[] buffer = new byte[bufferSize]; |         final byte[] buffer = new byte[bufferSize]; | ||||||
|         int len = 0; |         int len = 0; | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
| @@ -71,8 +71,8 @@ public class IITC_FileManager { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static HashMap<String, String> getScriptInfo(String js) { |     public static HashMap<String, String> getScriptInfo(final String js) { | ||||||
|         HashMap<String, String> map = new HashMap<String, String>(); |         final HashMap<String, String> map = new HashMap<String, String>(); | ||||||
|         String header = ""; |         String header = ""; | ||||||
|         if (js != null) { |         if (js != null) { | ||||||
|             header = js.substring(js.indexOf("==UserScript=="), |             header = js.substring(js.indexOf("==UserScript=="), | ||||||
| @@ -81,7 +81,7 @@ public class IITC_FileManager { | |||||||
|         // remove new line comments |         // remove new line comments | ||||||
|         header = header.replace("\n//", " "); |         header = header.replace("\n//", " "); | ||||||
|         // get a list of key-value |         // get a list of key-value | ||||||
|         String[] attributes = header.split("  +"); |         final String[] attributes = header.split("  +"); | ||||||
|         // add default values |         // add default values | ||||||
|         map.put("version", "not found"); |         map.put("version", "not found"); | ||||||
|         map.put("name", "unknown"); |         map.put("name", "unknown"); | ||||||
| @@ -106,12 +106,12 @@ public class IITC_FileManager { | |||||||
|         return map; |         return map; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private AssetManager mAssetManager; |     private final AssetManager mAssetManager; | ||||||
|     private IITC_Mobile mIitc; |     private final IITC_Mobile mIitc; | ||||||
|     private String mIitcPath; |     private final String mIitcPath; | ||||||
|     private SharedPreferences mPrefs; |     private final SharedPreferences mPrefs; | ||||||
|  |  | ||||||
|     public IITC_FileManager(IITC_Mobile iitc) { |     public IITC_FileManager(final IITC_Mobile iitc) { | ||||||
|         mIitc = iitc; |         mIitc = iitc; | ||||||
|         mIitcPath = Environment.getExternalStorageDirectory().getPath() + "/IITC_Mobile/"; |         mIitcPath = Environment.getExternalStorageDirectory().getPath() + "/IITC_Mobile/"; | ||||||
|         mPrefs = PreferenceManager.getDefaultSharedPreferences(iitc); |         mPrefs = PreferenceManager.getDefaultSharedPreferences(iitc); | ||||||
| @@ -120,10 +120,10 @@ public class IITC_FileManager { | |||||||
|  |  | ||||||
|     private InputStream getAssetFile(final String filename) throws IOException { |     private InputStream getAssetFile(final String filename) throws IOException { | ||||||
|         if (mPrefs.getBoolean("pref_dev_checkbox", false)) { |         if (mPrefs.getBoolean("pref_dev_checkbox", false)) { | ||||||
|             File file = new File(mIitcPath + "dev/" + filename); |             final File file = new File(mIitcPath + "dev/" + filename); | ||||||
|             try { |             try { | ||||||
|                 return new FileInputStream(file); |                 return new FileInputStream(file); | ||||||
|             } catch (FileNotFoundException e) { |             } catch (final FileNotFoundException e) { | ||||||
|                 mIitc.runOnUiThread(new Runnable() { |                 mIitc.runOnUiThread(new Runnable() { | ||||||
|                     @Override |                     @Override | ||||||
|                     public void run() { |                     public void run() { | ||||||
| @@ -137,22 +137,22 @@ public class IITC_FileManager { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         String source = mPrefs.getString("pref_iitc_source", "local"); |         final String source = mPrefs.getString("pref_iitc_source", "local"); | ||||||
|         if (!source.equals("local")) { |         if (!source.equals("local")) { | ||||||
|             // load iitc script from web or asset folder |             // load iitc script from web or asset folder | ||||||
|             if (source.contains("http")) { |             if (source.contains("http")) { | ||||||
|                 try { |                 try { | ||||||
|                     URL context = new URL(source); |                     final URL context = new URL(source); | ||||||
|                     URL url = new URL(context, filename); |                     final URL url = new URL(context, filename); | ||||||
|                     return url.openStream(); |                     return url.openStream(); | ||||||
|                 } catch (IOException e) { |                 } catch (final IOException e) { | ||||||
|                     Log.w(e); |                     Log.w(e); | ||||||
|                 } |                 } | ||||||
|             } else { |             } else { | ||||||
|                 File file = new File(source + File.separatorChar + filename); |                 final File file = new File(source + File.separatorChar + filename); | ||||||
|                 try { |                 try { | ||||||
|                     return new FileInputStream(file); |                     return new FileInputStream(file); | ||||||
|                 } catch (FileNotFoundException e) { |                 } catch (final FileNotFoundException e) { | ||||||
|                     Log.w(e); |                     Log.w(e); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @@ -162,29 +162,29 @@ public class IITC_FileManager { | |||||||
|         return mAssetManager.open(filename); |         return mAssetManager.open(filename); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private WebResourceResponse getFileRequest(Uri uri) { |     private WebResourceResponse getFileRequest(final Uri uri) { | ||||||
|         return new FileRequest(uri); |         return new FileRequest(uri); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private WebResourceResponse getScript(Uri uri) { |     private WebResourceResponse getScript(final Uri uri) { | ||||||
|         InputStream stream; |         InputStream stream; | ||||||
|         try { |         try { | ||||||
|             stream = getAssetFile(uri.getPath().substring(1)); |             stream = getAssetFile(uri.getPath().substring(1)); | ||||||
|         } catch (IOException e) { |         } catch (final IOException e) { | ||||||
|             Log.w(e); |             Log.w(e); | ||||||
|             return EMPTY; |             return EMPTY; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         InputStream data = prepareUserScript(stream); |         final InputStream data = prepareUserScript(stream); | ||||||
|  |  | ||||||
|         return new WebResourceResponse("application/x-javascript", "UTF-8", data); |         return new WebResourceResponse("application/x-javascript", "UTF-8", data); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private HashMap<String, String> getScriptInfo(InputStream stream) { |     private HashMap<String, String> getScriptInfo(final InputStream stream) { | ||||||
|         return getScriptInfo(readStream(stream)); |         return getScriptInfo(readStream(stream)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private WebResourceResponse getUserPlugin(Uri uri) { |     private WebResourceResponse getUserPlugin(final Uri uri) { | ||||||
|         if (!mPrefs.getBoolean(uri.getPath(), false)) { |         if (!mPrefs.getBoolean(uri.getPath(), false)) { | ||||||
|             Log.e("Attempted to inject user script that is not enabled by user: " + uri.getPath()); |             Log.e("Attempted to inject user script that is not enabled by user: " + uri.getPath()); | ||||||
|             return EMPTY; |             return EMPTY; | ||||||
| @@ -193,40 +193,40 @@ public class IITC_FileManager { | |||||||
|         InputStream stream; |         InputStream stream; | ||||||
|         try { |         try { | ||||||
|             stream = new FileInputStream(new File(uri.getPath())); |             stream = new FileInputStream(new File(uri.getPath())); | ||||||
|         } catch (IOException e) { |         } catch (final IOException e) { | ||||||
|             Log.w(e); |             Log.w(e); | ||||||
|             return EMPTY; |             return EMPTY; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         InputStream data = prepareUserScript(stream); |         final InputStream data = prepareUserScript(stream); | ||||||
|  |  | ||||||
|         return new WebResourceResponse("application/x-javascript", "UTF-8", data); |         return new WebResourceResponse("application/x-javascript", "UTF-8", data); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private InputStream prepareUserScript(InputStream stream) { |     private InputStream prepareUserScript(final InputStream stream) { | ||||||
|         String content = readStream(stream); |         String content = readStream(stream); | ||||||
|         HashMap<String, String> info = getScriptInfo(content); |         final HashMap<String, String> info = getScriptInfo(content); | ||||||
|  |  | ||||||
|         JSONObject jObject = new JSONObject(info); |         final JSONObject jObject = new JSONObject(info); | ||||||
|         String gmInfo = "var GM_info={\"script\":" + jObject.toString() + "}"; |         final String gmInfo = "var GM_info={\"script\":" + jObject.toString() + "}"; | ||||||
|  |  | ||||||
|         content = content.replace(WRAPPER_OLD, WRAPPER_NEW); |         content = content.replace(WRAPPER_OLD, WRAPPER_NEW); | ||||||
|  |  | ||||||
|         return new ByteArrayInputStream((gmInfo + content).getBytes()); |         return new ByteArrayInputStream((gmInfo + content).getBytes()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private String readStream(InputStream stream) { |     private String readStream(final InputStream stream) { | ||||||
|         ByteArrayOutputStream os = new ByteArrayOutputStream(); |         final ByteArrayOutputStream os = new ByteArrayOutputStream(); | ||||||
|         byte[] buffer = new byte[4096]; |         final byte[] buffer = new byte[4096]; | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
|             while (true) { |             while (true) { | ||||||
|                 int read = stream.read(buffer); |                 final int read = stream.read(buffer); | ||||||
|                 if (read == -1) |                 if (read == -1) | ||||||
|                     break; |                     break; | ||||||
|                 os.write(buffer, 0, read); |                 os.write(buffer, 0, read); | ||||||
|             } |             } | ||||||
|         } catch (IOException e) { |         } catch (final IOException e) { | ||||||
|             Log.w(e); |             Log.w(e); | ||||||
|             return ""; |             return ""; | ||||||
|         } |         } | ||||||
| @@ -238,12 +238,12 @@ public class IITC_FileManager { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     public String getIITCVersion() throws IOException { |     public String getIITCVersion() throws IOException { | ||||||
|         InputStream stream = getAssetFile("total-conversion-build.user.js"); |         final InputStream stream = getAssetFile("total-conversion-build.user.js"); | ||||||
|  |  | ||||||
|         return getScriptInfo(stream).get("version"); |         return getScriptInfo(stream).get("version"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public WebResourceResponse getResponse(Uri uri) { |     public WebResourceResponse getResponse(final Uri uri) { | ||||||
|         String host = uri.getHost(); |         String host = uri.getHost(); | ||||||
|         if (!host.endsWith(DOMAIN)) |         if (!host.endsWith(DOMAIN)) | ||||||
|             return EMPTY; |             return EMPTY; | ||||||
| @@ -263,17 +263,17 @@ public class IITC_FileManager { | |||||||
|  |  | ||||||
|     private class FileRequest extends WebResourceResponse implements ResponseHandler, Runnable { |     private class FileRequest extends WebResourceResponse implements ResponseHandler, Runnable { | ||||||
|         private Intent mData; |         private Intent mData; | ||||||
|         private String mFunctionName; |         private final String mFunctionName; | ||||||
|         private int mResultCode; |         private int mResultCode; | ||||||
|         private PipedOutputStream mStreamOut; |         private PipedOutputStream mStreamOut; | ||||||
|  |  | ||||||
|         private FileRequest(Uri uri) { |         private FileRequest(final Uri uri) { | ||||||
|             // create two connected streams we can write to after the file has been read |             // create two connected streams we can write to after the file has been read | ||||||
|             super("application/x-javascript", "UTF-8", new PipedInputStream()); |             super("application/x-javascript", "UTF-8", new PipedInputStream()); | ||||||
|  |  | ||||||
|             try { |             try { | ||||||
|                 mStreamOut = new PipedOutputStream((PipedInputStream) getData()); |                 mStreamOut = new PipedOutputStream((PipedInputStream) getData()); | ||||||
|             } catch (IOException e) { |             } catch (final IOException e) { | ||||||
|                 Log.w(e); |                 Log.w(e); | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -285,17 +285,16 @@ public class IITC_FileManager { | |||||||
|             target.setType("file/*"); |             target.setType("file/*"); | ||||||
|             target.addCategory(Intent.CATEGORY_OPENABLE); |             target.addCategory(Intent.CATEGORY_OPENABLE); | ||||||
|  |  | ||||||
|             Intent intent = Intent.createChooser(target, "Choose file"); |  | ||||||
|             try { |             try { | ||||||
|                 mIitc.startActivityForResult(intent, this); |                 mIitc.startActivityForResult(Intent.createChooser(target, "Choose file"), this); | ||||||
|             } catch (ActivityNotFoundException e) { |             } catch (final ActivityNotFoundException e) { | ||||||
|                 Toast.makeText(mIitc, "No activity to select a file found." + |                 Toast.makeText(mIitc, "No activity to select a file found." + | ||||||
|                         "Please install a file browser of your choice!", Toast.LENGTH_LONG).show(); |                         "Please install a file browser of your choice!", Toast.LENGTH_LONG).show(); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public void onActivityResult(int resultCode, Intent data) { |         public void onActivityResult(final int resultCode, final Intent data) { | ||||||
|             mIitc.deleteResponseHandler(this); // to enable garbage collection |             mIitc.deleteResponseHandler(this); // to enable garbage collection | ||||||
|  |  | ||||||
|             mResultCode = resultCode; |             mResultCode = resultCode; | ||||||
| @@ -309,8 +308,8 @@ public class IITC_FileManager { | |||||||
|         public void run() { |         public void run() { | ||||||
|             try { |             try { | ||||||
|                 if (mResultCode == Activity.RESULT_OK && mData != null) { |                 if (mResultCode == Activity.RESULT_OK && mData != null) { | ||||||
|                     Uri uri = mData.getData(); |                     final Uri uri = mData.getData(); | ||||||
|                     File file = new File(uri.getPath()); |                     final File file = new File(uri.getPath()); | ||||||
|  |  | ||||||
|                     // now create a resource that basically looks like: |                     // now create a resource that basically looks like: | ||||||
|                     // someFunctionName('<url encoded filename>', '<base64 encoded content>'); |                     // someFunctionName('<url encoded filename>', '<base64 encoded content>'); | ||||||
| @@ -318,23 +317,23 @@ public class IITC_FileManager { | |||||||
|                     mStreamOut.write( |                     mStreamOut.write( | ||||||
|                             (mFunctionName + "('" + URLEncoder.encode(file.getName(), "UTF-8") + "', '").getBytes()); |                             (mFunctionName + "('" + URLEncoder.encode(file.getName(), "UTF-8") + "', '").getBytes()); | ||||||
|  |  | ||||||
|                     Base64OutputStream encoder = |                     final Base64OutputStream encoder = | ||||||
|                             new Base64OutputStream(mStreamOut, Base64.NO_CLOSE | Base64.NO_WRAP | Base64.DEFAULT); |                             new Base64OutputStream(mStreamOut, Base64.NO_CLOSE | Base64.NO_WRAP | Base64.DEFAULT); | ||||||
|  |  | ||||||
|                     FileInputStream fileinput = new FileInputStream(file); |                     final FileInputStream fileinput = new FileInputStream(file); | ||||||
|  |  | ||||||
|                     copyStream(fileinput, encoder, true); |                     copyStream(fileinput, encoder, true); | ||||||
|  |  | ||||||
|                     mStreamOut.write("');".getBytes()); |                     mStreamOut.write("');".getBytes()); | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|             } catch (IOException e) { |             } catch (final IOException e) { | ||||||
|                 Log.w(e); |                 Log.w(e); | ||||||
|             } finally { |             } finally { | ||||||
|                 // try to close stream, but ignore errors |                 // try to close stream, but ignore errors | ||||||
|                 try { |                 try { | ||||||
|                     mStreamOut.close(); |                     mStreamOut.close(); | ||||||
|                 } catch (IOException e1) { |                 } catch (final IOException e1) { | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -54,7 +54,7 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|     private IITC_NavigationHelper mNavigationHelper; |     private IITC_NavigationHelper mNavigationHelper; | ||||||
|     private IITC_MapSettings mMapSettings; |     private IITC_MapSettings mMapSettings; | ||||||
|     private IITC_DeviceAccountLogin mLogin; |     private IITC_DeviceAccountLogin mLogin; | ||||||
|     private Vector<ResponseHandler> mResponseHandlers = new Vector<ResponseHandler>(); |     private final Vector<ResponseHandler> mResponseHandlers = new Vector<ResponseHandler>(); | ||||||
|     private boolean mDesktopMode = false; |     private boolean mDesktopMode = false; | ||||||
|     private boolean mAdvancedMenu = false; |     private boolean mAdvancedMenu = false; | ||||||
|     private MenuItem mSearchMenuItem; |     private MenuItem mSearchMenuItem; | ||||||
| @@ -76,13 +76,13 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|  |  | ||||||
|     private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |     private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { | ||||||
|         @Override |         @Override | ||||||
|         public void onReceive(Context context, Intent intent) { |         public void onReceive(final Context context, final Intent intent) { | ||||||
|             ((IITC_Mobile) context).installIitcUpdate(); |             ((IITC_Mobile) context).installIitcUpdate(); | ||||||
|         } |         } | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void onCreate(Bundle savedInstanceState) { |     protected void onCreate(final Bundle savedInstanceState) { | ||||||
|         super.onCreate(savedInstanceState); |         super.onCreate(savedInstanceState); | ||||||
|  |  | ||||||
|         // enable progress bar above action bar |         // enable progress bar above action bar | ||||||
| @@ -97,11 +97,11 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|         mEditCommand = (EditText) findViewById(R.id.editCommand); |         mEditCommand = (EditText) findViewById(R.id.editCommand); | ||||||
|         mEditCommand.setOnEditorActionListener(new TextView.OnEditorActionListener() { |         mEditCommand.setOnEditorActionListener(new TextView.OnEditorActionListener() { | ||||||
|             @Override |             @Override | ||||||
|             public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { |             public boolean onEditorAction(final TextView v, final int actionId, final KeyEvent event) { | ||||||
|                 if (EditorInfo.IME_ACTION_GO == actionId) { |                 if (EditorInfo.IME_ACTION_GO == actionId) { | ||||||
|                     onBtnRunCodeClick(v); |                     onBtnRunCodeClick(v); | ||||||
|  |  | ||||||
|                     InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); |                     final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); | ||||||
|                     imm.hideSoftInputFromWindow(v.getWindowToken(), 0); |                     imm.hideSoftInputFromWindow(v.getWindowToken(), 0); | ||||||
|  |  | ||||||
|                     return true; |                     return true; | ||||||
| @@ -146,12 +146,12 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { |     public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences, final String key) { | ||||||
|         if (key.equals("pref_force_desktop")) { |         if (key.equals("pref_force_desktop")) { | ||||||
|             mDesktopMode = sharedPreferences.getBoolean("pref_force_desktop", false); |             mDesktopMode = sharedPreferences.getBoolean("pref_force_desktop", false); | ||||||
|             mNavigationHelper.onPrefChanged(); |             mNavigationHelper.onPrefChanged(); | ||||||
|         } else if (key.equals("pref_user_location_mode")) { |         } else if (key.equals("pref_user_location_mode")) { | ||||||
|             int mode = Integer.parseInt(mSharedPrefs.getString("pref_user_location_mode", "0")); |             final int mode = Integer.parseInt(mSharedPrefs.getString("pref_user_location_mode", "0")); | ||||||
|             if (mUserLocation.setLocationMode(mode)) |             if (mUserLocation.setLocationMode(mode)) | ||||||
|                 mReloadNeeded = true; |                 mReloadNeeded = true; | ||||||
|             return; |             return; | ||||||
| @@ -179,23 +179,23 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void onNewIntent(Intent intent) { |     protected void onNewIntent(final Intent intent) { | ||||||
|         setIntent(intent); |         setIntent(intent); | ||||||
|         handleIntent(intent, false); |         handleIntent(intent, false); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void handleIntent(Intent intent, boolean onCreate) { |     private void handleIntent(final Intent intent, final boolean onCreate) { | ||||||
|         // load new iitc web view with ingress intel page |         // load new iitc web view with ingress intel page | ||||||
|         String action = intent.getAction(); |         final String action = intent.getAction(); | ||||||
|         if (Intent.ACTION_VIEW.equals(action)) { |         if (Intent.ACTION_VIEW.equals(action)) { | ||||||
|             Uri uri = intent.getData(); |             final Uri uri = intent.getData(); | ||||||
|             Log.d("intent received url: " + uri.toString()); |             Log.d("intent received url: " + uri.toString()); | ||||||
|  |  | ||||||
|             if (uri.getScheme().equals("http") || uri.getScheme().equals("https")) { |             if (uri.getScheme().equals("http") || uri.getScheme().equals("https")) { | ||||||
|                 if (uri.getHost() != null |                 if (uri.getHost() != null | ||||||
|                         && (uri.getHost().equals("ingress.com") || uri.getHost().endsWith(".ingress.com"))) { |                         && (uri.getHost().equals("ingress.com") || uri.getHost().endsWith(".ingress.com"))) { | ||||||
|                     Log.d("loading url..."); |                     Log.d("loading url..."); | ||||||
|                     this.loadUrl(uri.toString()); |                     loadUrl(uri.toString()); | ||||||
|                     return; |                     return; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @@ -204,14 +204,14 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|                 try { |                 try { | ||||||
|                     handleGeoUri(uri); |                     handleGeoUri(uri); | ||||||
|                     return; |                     return; | ||||||
|                 } catch (URISyntaxException e) { |                 } catch (final URISyntaxException e) { | ||||||
|                     Log.w(e); |                     Log.w(e); | ||||||
|                     new AlertDialog.Builder(this) |                     new AlertDialog.Builder(this) | ||||||
|                             .setTitle(R.string.intent_error) |                             .setTitle(R.string.intent_error) | ||||||
|                             .setMessage(e.getReason()) |                             .setMessage(e.getReason()) | ||||||
|                             .setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { |                             .setNeutralButton(android.R.string.ok, new DialogInterface.OnClickListener() { | ||||||
|                                 @Override |                                 @Override | ||||||
|                                 public void onClick(DialogInterface dialog, int which) { |                                 public void onClick(final DialogInterface dialog, final int which) { | ||||||
|                                     dialog.dismiss(); |                                     dialog.dismiss(); | ||||||
|                                 } |                                 } | ||||||
|                             }) |                             }) | ||||||
| @@ -235,38 +235,37 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (onCreate) { |         if (onCreate) { | ||||||
|             this.loadUrl(mIntelUrl); |             loadUrl(mIntelUrl); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void handleGeoUri(Uri uri) throws URISyntaxException { |     private void handleGeoUri(final Uri uri) throws URISyntaxException { | ||||||
|         String[] parts = uri.getSchemeSpecificPart().split("\\?", 2); |         final String[] parts = uri.getSchemeSpecificPart().split("\\?", 2); | ||||||
|         Double lat, lon; |         Double lat, lon; | ||||||
|         Integer z = null; |         Integer z = null; | ||||||
|  |  | ||||||
|         // parts[0] may contain an 'uncertainty' parameter, delimited by a semicolon |         // parts[0] may contain an 'uncertainty' parameter, delimited by a semicolon | ||||||
|         String[] pos = parts[0].split(";", 2)[0].split(",", 2); |         final String[] pos = parts[0].split(";", 2)[0].split(",", 2); | ||||||
|         if (pos.length != 2) { |         if (pos.length != 2) throw new URISyntaxException(uri.toString(), "URI does not contain a valid position"); | ||||||
|             throw new URISyntaxException(uri.toString(), "URI does not contain a valid position"); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
|             lat = Double.valueOf(pos[0]); |             lat = Double.valueOf(pos[0]); | ||||||
|             lon = Double.valueOf(pos[1]); |             lon = Double.valueOf(pos[1]); | ||||||
|         } catch (NumberFormatException e) { |         } catch (final NumberFormatException e) { | ||||||
|             URISyntaxException use = new URISyntaxException(uri.toString(), "position could not be parsed"); |             final URISyntaxException use = new URISyntaxException(uri.toString(), "position could not be parsed"); | ||||||
|             use.initCause(e); |             use.initCause(e); | ||||||
|             throw use; |             throw use; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (parts.length > 1) { // query string present |         if (parts.length > 1) { // query string present | ||||||
|             // search for z= |             // search for z= | ||||||
|             for (String param : parts[1].split("&")) { |             for (final String param : parts[1].split("&")) { | ||||||
|                 if (param.startsWith("z=")) { |                 if (param.startsWith("z=")) { | ||||||
|                     try { |                     try { | ||||||
|                         z = Integer.valueOf(param.substring(2)); |                         z = Integer.valueOf(param.substring(2)); | ||||||
|                     } catch (NumberFormatException e) { |                     } catch (final NumberFormatException e) { | ||||||
|                         URISyntaxException use = new URISyntaxException(uri.toString(), "could not parse zoom level"); |                         final URISyntaxException use = new URISyntaxException( | ||||||
|  |                                 uri.toString(), "could not parse zoom level"); | ||||||
|                         use.initCause(e); |                         use.initCause(e); | ||||||
|                         throw use; |                         throw use; | ||||||
|                     } |                     } | ||||||
| @@ -279,7 +278,7 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|         if (z != null) { |         if (z != null) { | ||||||
|             url += "&z=" + z; |             url += "&z=" + z; | ||||||
|         } |         } | ||||||
|         this.loadUrl(url); |         loadUrl(url); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @@ -330,7 +329,7 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onConfigurationChanged(Configuration newConfig) { |     public void onConfigurationChanged(final Configuration newConfig) { | ||||||
|         super.onConfigurationChanged(newConfig); |         super.onConfigurationChanged(newConfig); | ||||||
|  |  | ||||||
|         mNavigationHelper.onConfigurationChanged(newConfig); |         mNavigationHelper.onConfigurationChanged(newConfig); | ||||||
| @@ -341,7 +340,7 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void onPostCreate(Bundle savedInstanceState) { |     protected void onPostCreate(final Bundle savedInstanceState) { | ||||||
|         super.onPostCreate(savedInstanceState); |         super.onPostCreate(savedInstanceState); | ||||||
|         mNavigationHelper.onPostCreate(savedInstanceState); |         mNavigationHelper.onPostCreate(savedInstanceState); | ||||||
|     } |     } | ||||||
| @@ -363,7 +362,7 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|  |  | ||||||
|         // kill all open iitc dialogs |         // kill all open iitc dialogs | ||||||
|         if (!mDialogStack.isEmpty()) { |         if (!mDialogStack.isEmpty()) { | ||||||
|             String id = mDialogStack.pop(); |             final String id = mDialogStack.pop(); | ||||||
|             mIitcWebView.loadUrl("javascript: " + |             mIitcWebView.loadUrl("javascript: " + | ||||||
|                     "var selector = $(window.DIALOGS['" + id + "']); " + |                     "var selector = $(window.DIALOGS['" + id + "']); " + | ||||||
|                     "selector.dialog('close'); " + |                     "selector.dialog('close'); " + | ||||||
| @@ -400,16 +399,18 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|             mBackStack.push(Pane.MAP); |             mBackStack.push(Pane.MAP); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         Pane pane = mBackStack.pop(); |         final Pane pane = mBackStack.pop(); | ||||||
|         switchToPane(pane); |         switchToPane(pane); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setCurrentPane(Pane pane) { |     public void setCurrentPane(final Pane pane) { | ||||||
|         // ensure no double adds |         // ensure no double adds | ||||||
|         if (pane == mCurrentPane) return; |         if (pane == mCurrentPane) return; | ||||||
|  |  | ||||||
|         // map pane is top-lvl. clear stack. |         // map pane is top-lvl. clear stack. | ||||||
|         if (pane == Pane.MAP) mBackStack.clear(); |         if (pane == Pane.MAP) { | ||||||
|  |             mBackStack.clear(); | ||||||
|  |         } | ||||||
|         // don't push current pane to backstack if this method was called via back button |         // don't push current pane to backstack if this method was called via back button | ||||||
|         else if (!mBackButtonPressed) mBackStack.push(mCurrentPane); |         else if (!mBackButtonPressed) mBackStack.push(mCurrentPane); | ||||||
|  |  | ||||||
| @@ -418,16 +419,16 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|         mNavigationHelper.switchTo(pane); |         mNavigationHelper.switchTo(pane); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void switchToPane(Pane pane) { |     public void switchToPane(final Pane pane) { | ||||||
|         mIitcWebView.loadUrl("javascript: window.show('" + pane.name + "');"); |         mIitcWebView.loadUrl("javascript: window.show('" + pane.name + "');"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onCreateOptionsMenu(Menu menu) { |     public boolean onCreateOptionsMenu(final Menu menu) { | ||||||
|         // Inflate the menu; this adds items to the action bar if it is present. |         // Inflate the menu; this adds items to the action bar if it is present. | ||||||
|         getMenuInflater().inflate(R.menu.main, menu); |         getMenuInflater().inflate(R.menu.main, menu); | ||||||
|         // Get the SearchView and set the searchable configuration |         // Get the SearchView and set the searchable configuration | ||||||
|         SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); |         final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); | ||||||
|         mSearchMenuItem = menu.findItem(R.id.menu_search); |         mSearchMenuItem = menu.findItem(R.id.menu_search); | ||||||
|         final SearchView searchView = |         final SearchView searchView = | ||||||
|                 (SearchView) mSearchMenuItem.getActionView(); |                 (SearchView) mSearchMenuItem.getActionView(); | ||||||
| @@ -438,13 +439,13 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onPrepareOptionsMenu(Menu menu) { |     public boolean onPrepareOptionsMenu(final Menu menu) { | ||||||
|         boolean visible = false; |         boolean visible = false; | ||||||
|         if (mNavigationHelper != null) |         if (mNavigationHelper != null) | ||||||
|             visible = !mNavigationHelper.isDrawerOpened(); |             visible = !mNavigationHelper.isDrawerOpened(); | ||||||
|  |  | ||||||
|         for (int i = 0; i < menu.size(); i++) { |         for (int i = 0; i < menu.size(); i++) { | ||||||
|             MenuItem item = menu.getItem(i); |             final MenuItem item = menu.getItem(i); | ||||||
|  |  | ||||||
|             switch (item.getItemId()) { |             switch (item.getItemId()) { | ||||||
|                 case R.id.action_settings: |                 case R.id.action_settings: | ||||||
| @@ -476,10 +477,8 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onOptionsItemSelected(MenuItem item) { |     public boolean onOptionsItemSelected(final MenuItem item) { | ||||||
|         if (mNavigationHelper.onOptionsItemSelected(item)) { |         if (mNavigationHelper.onOptionsItemSelected(item)) return true; | ||||||
|             return true; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         // Handle item selection |         // Handle item selection | ||||||
|         final int itemId = item.getItemId(); |         final int itemId = item.getItemId(); | ||||||
| @@ -509,17 +508,17 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|                 } |                 } | ||||||
|                 return true; |                 return true; | ||||||
|             case R.id.action_settings: // start settings activity |             case R.id.action_settings: // start settings activity | ||||||
|                 Intent intent = new Intent(this, IITC_PreferenceActivity.class); |                 final Intent intent = new Intent(this, IITC_PreferenceActivity.class); | ||||||
|                 try { |                 try { | ||||||
|                     intent.putExtra("iitc_version", mFileManager.getIITCVersion()); |                     intent.putExtra("iitc_version", mFileManager.getIITCVersion()); | ||||||
|                 } catch (IOException e) { |                 } catch (final IOException e) { | ||||||
|                     Log.w(e); |                     Log.w(e); | ||||||
|                     return true; |                     return true; | ||||||
|                 } |                 } | ||||||
|                 startActivity(intent); |                 startActivity(intent); | ||||||
|                 return true; |                 return true; | ||||||
|             case R.id.menu_clear_cookies: |             case R.id.menu_clear_cookies: | ||||||
|                 CookieManager cm = CookieManager.getInstance(); |                 final CookieManager cm = CookieManager.getInstance(); | ||||||
|                 cm.removeAllCookie(); |                 cm.removeAllCookie(); | ||||||
|                 return true; |                 return true; | ||||||
|             case R.id.menu_debug: |             case R.id.menu_debug: | ||||||
| @@ -552,7 +551,7 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     // vp=f enables mDesktopMode mode...vp=m is the default mobile view |     // vp=f enables mDesktopMode mode...vp=m is the default mobile view | ||||||
|     private String addUrlParam(String url) { |     private String addUrlParam(final String url) { | ||||||
|         if (mDesktopMode) { |         if (mDesktopMode) { | ||||||
|             return (url + "?vp=f"); |             return (url + "?vp=f"); | ||||||
|         } else { |         } else { | ||||||
| @@ -569,10 +568,10 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     public IITC_WebView getWebView() { |     public IITC_WebView getWebView() { | ||||||
|         return this.mIitcWebView; |         return mIitcWebView; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void startActivityForResult(Intent launch, ResponseHandler handler) { |     public void startActivityForResult(final Intent launch, final ResponseHandler handler) { | ||||||
|         int index = mResponseHandlers.indexOf(handler); |         int index = mResponseHandlers.indexOf(handler); | ||||||
|         if (index == -1) { |         if (index == -1) { | ||||||
|             mResponseHandlers.add(handler); |             mResponseHandlers.add(handler); | ||||||
| @@ -582,8 +581,8 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|         startActivityForResult(launch, RESULT_FIRST_USER + index); |         startActivityForResult(launch, RESULT_FIRST_USER + index); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void deleteResponseHandler(ResponseHandler handler) { |     public void deleteResponseHandler(final ResponseHandler handler) { | ||||||
|         int index = mResponseHandlers.indexOf(handler); |         final int index = mResponseHandlers.indexOf(handler); | ||||||
|         if (index != -1) { |         if (index != -1) { | ||||||
|             // set value to null to enable garbage collection, but don't remove it to keep indexes |             // set value to null to enable garbage collection, but don't remove it to keep indexes | ||||||
|             mResponseHandlers.set(index, null); |             mResponseHandlers.set(index, null); | ||||||
| @@ -591,13 +590,13 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void onActivityResult(int requestCode, int resultCode, Intent data) { |     protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) { | ||||||
|         int index = requestCode - RESULT_FIRST_USER; |         final int index = requestCode - RESULT_FIRST_USER; | ||||||
|  |  | ||||||
|         try { |         try { | ||||||
|             ResponseHandler handler = mResponseHandlers.get(index); |             final ResponseHandler handler = mResponseHandlers.get(index); | ||||||
|             handler.onActivityResult(resultCode, data); |             handler.onActivityResult(resultCode, data); | ||||||
|         } catch (ArrayIndexOutOfBoundsException e) { |         } catch (final ArrayIndexOutOfBoundsException e) { | ||||||
|             super.onActivityResult(requestCode, resultCode, data); |             super.onActivityResult(requestCode, resultCode, data); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -605,8 +604,8 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|     /** |     /** | ||||||
|      * called by IITC_WebViewClient when the Google login form is opened. |      * called by IITC_WebViewClient when the Google login form is opened. | ||||||
|      */ |      */ | ||||||
|     public void onReceivedLoginRequest(IITC_WebViewClient client, WebView view, |     public void onReceivedLoginRequest(final IITC_WebViewClient client, final WebView view, final String realm, | ||||||
|             String realm, String account, String args) { |             final String account, final String args) { | ||||||
|         mLogin = new IITC_DeviceAccountLogin(this, view, client); |         mLogin = new IITC_DeviceAccountLogin(this, view, client); | ||||||
|         mLogin.startLogin(realm, account, args); |         mLogin.startLogin(realm, account, args); | ||||||
|     } |     } | ||||||
| @@ -623,14 +622,14 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|     // remove dialog and add it back again |     // remove dialog and add it back again | ||||||
|     // to ensure it is the last element of the list |     // to ensure it is the last element of the list | ||||||
|     // focused dialogs should be closed first |     // focused dialogs should be closed first | ||||||
|     public void setFocusedDialog(String id) { |     public void setFocusedDialog(final String id) { | ||||||
|         Log.d("Dialog " + id + " focused"); |         Log.d("Dialog " + id + " focused"); | ||||||
|         mDialogStack.remove(id); |         mDialogStack.remove(id); | ||||||
|         mDialogStack.push(id); |         mDialogStack.push(id); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // called by the javascript interface |     // called by the javascript interface | ||||||
|     public void dialogOpened(String id, boolean open) { |     public void dialogOpened(final String id, final boolean open) { | ||||||
|         if (open) { |         if (open) { | ||||||
|             Log.d("Dialog " + id + " added"); |             Log.d("Dialog " + id + " added"); | ||||||
|             mDialogStack.push(id); |             mDialogStack.push(id); | ||||||
| @@ -640,7 +639,7 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setLoadingState(boolean isLoading) { |     public void setLoadingState(final boolean isLoading) { | ||||||
|         mIsLoading = isLoading; |         mIsLoading = isLoading; | ||||||
|  |  | ||||||
|         mNavigationHelper.onLoadingStateChanged(); |         mNavigationHelper.onLoadingStateChanged(); | ||||||
| @@ -662,7 +661,7 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             // if the debug container is invisible (and we are about to show it), select the text box |             // if the debug container is invisible (and we are about to show it), select the text box | ||||||
|             boolean select = mViewDebug.getVisibility() != View.VISIBLE; |             final boolean select = mViewDebug.getVisibility() != View.VISIBLE; | ||||||
|  |  | ||||||
|             mImageLoading.setVisibility(View.GONE); // never show splash screen while debugging |             mImageLoading.setVisibility(View.GONE); // never show splash screen while debugging | ||||||
|             mViewDebug.setVisibility(View.VISIBLE); |             mViewDebug.setVisibility(View.VISIBLE); | ||||||
| @@ -684,18 +683,18 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void onBtnRunCodeClick(View v) { |     public void onBtnRunCodeClick(final View v) { | ||||||
|         String code = mEditCommand.getText().toString(); |         final String code = mEditCommand.getText().toString(); | ||||||
|         JSONObject obj = new JSONObject(); |         final JSONObject obj = new JSONObject(); | ||||||
|         try { |         try { | ||||||
|             obj.put("code", code); |             obj.put("code", code); | ||||||
|         } catch (JSONException e) { |         } catch (final JSONException e) { | ||||||
|             Log.w(e); |             Log.w(e); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // throwing an exception will be reported by WebView |         // throwing an exception will be reported by WebView | ||||||
|         String js = "(function(obj){var result;" + |         final String js = "(function(obj){var result;" + | ||||||
|                 "console.log('>>> ' + obj.code);" + |                 "console.log('>>> ' + obj.code);" + | ||||||
|                 "try{result=eval(obj.code);}catch(e){if(e.stack) console.error(e.stack);throw e;}" + |                 "try{result=eval(obj.code);}catch(e){if(e.stack) console.error(e.stack);throw e;}" + | ||||||
|                 "if(result!==undefined) console.log(result.toString());" + |                 "if(result!==undefined) console.log(result.toString());" + | ||||||
| @@ -707,34 +706,34 @@ public class IITC_Mobile extends Activity implements OnSharedPreferenceChangeLis | |||||||
|     /** |     /** | ||||||
|      * onClick handler for R.id.btnToggleMapVisibility, assigned in activity_main.xml |      * onClick handler for R.id.btnToggleMapVisibility, assigned in activity_main.xml | ||||||
|      */ |      */ | ||||||
|     public void onToggleMapVisibility(View v) |     public void onToggleMapVisibility(final View v) | ||||||
|     { |     { | ||||||
|         mShowMapInDebug = !mShowMapInDebug; |         mShowMapInDebug = !mShowMapInDebug; | ||||||
|         updateViews(); |         updateViews(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void deleteUpdateFile() { |     private void deleteUpdateFile() { | ||||||
|         File file = new File(getExternalFilesDir(null).toString() + "/iitcUpdate.apk"); |         final File file = new File(getExternalFilesDir(null).toString() + "/iitcUpdate.apk"); | ||||||
|         if (file != null) file.delete(); |         if (file != null) file.delete(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void updateIitc(String url) { |     public void updateIitc(final String url) { | ||||||
|         DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); |         final DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); | ||||||
|         request.setDescription(getString(R.string.download_description)); |         request.setDescription(getString(R.string.download_description)); | ||||||
|         request.setTitle("IITCm Update"); |         request.setTitle("IITCm Update"); | ||||||
|         request.allowScanningByMediaScanner(); |         request.allowScanningByMediaScanner(); | ||||||
|         Uri fileUri = Uri.parse("file://" + getExternalFilesDir(null).toString() + "/iitcUpdate.apk"); |         final Uri fileUri = Uri.parse("file://" + getExternalFilesDir(null).toString() + "/iitcUpdate.apk"); | ||||||
|         request.setDestinationUri(fileUri); |         request.setDestinationUri(fileUri); | ||||||
|         // remove old update file...we don't want to spam the external storage |         // remove old update file...we don't want to spam the external storage | ||||||
|         deleteUpdateFile(); |         deleteUpdateFile(); | ||||||
|         // get download service and enqueue file |         // get download service and enqueue file | ||||||
|         DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); |         final DownloadManager manager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); | ||||||
|         manager.enqueue(request); |         manager.enqueue(request); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void installIitcUpdate() { |     private void installIitcUpdate() { | ||||||
|         String iitcUpdatePath = getExternalFilesDir(null).toString() + "/iitcUpdate.apk"; |         final String iitcUpdatePath = getExternalFilesDir(null).toString() + "/iitcUpdate.apk"; | ||||||
|         Intent intent = new Intent(Intent.ACTION_VIEW); |         final Intent intent = new Intent(Intent.ACTION_VIEW); | ||||||
|         intent.setDataAndType(Uri.fromFile(new File(iitcUpdatePath)), "application/vnd.android.package-archive"); |         intent.setDataAndType(Uri.fromFile(new File(iitcUpdatePath)), "application/vnd.android.package-archive"); | ||||||
|         startActivity(intent); |         startActivity(intent); | ||||||
|         // finish app, because otherwise it gets killed on update |         // finish app, because otherwise it gets killed on update | ||||||
|   | |||||||
| @@ -1,10 +1,6 @@ | |||||||
| package com.cradle.iitc_mobile; | package com.cradle.iitc_mobile; | ||||||
|  |  | ||||||
| import android.app.ActionBar; | import android.app.ActionBar; | ||||||
| import android.app.AlertDialog; |  | ||||||
| import android.content.DialogInterface; |  | ||||||
| import android.content.DialogInterface.OnClickListener; |  | ||||||
| import android.content.DialogInterface.OnDismissListener; |  | ||||||
| import android.content.SharedPreferences; | import android.content.SharedPreferences; | ||||||
| import android.content.res.Resources; | import android.content.res.Resources; | ||||||
| import android.os.Bundle; | import android.os.Bundle; | ||||||
| @@ -12,15 +8,12 @@ import android.os.Handler; | |||||||
| import android.preference.PreferenceManager; | import android.preference.PreferenceManager; | ||||||
| import android.support.v4.app.ActionBarDrawerToggle; | import android.support.v4.app.ActionBarDrawerToggle; | ||||||
| import android.support.v4.widget.DrawerLayout; | import android.support.v4.widget.DrawerLayout; | ||||||
| import android.text.Html; |  | ||||||
| import android.text.method.LinkMovementMethod; |  | ||||||
| import android.view.MenuItem; | import android.view.MenuItem; | ||||||
| import android.view.View; | import android.view.View; | ||||||
| import android.view.ViewGroup; | import android.view.ViewGroup; | ||||||
| import android.widget.AdapterView; | import android.widget.AdapterView; | ||||||
| import android.widget.AdapterView.OnItemClickListener; | import android.widget.AdapterView.OnItemClickListener; | ||||||
| import android.widget.ArrayAdapter; | import android.widget.ArrayAdapter; | ||||||
| import android.widget.CheckBox; |  | ||||||
| import android.widget.ListView; | import android.widget.ListView; | ||||||
| import android.widget.TextView; | import android.widget.TextView; | ||||||
|  |  | ||||||
| @@ -51,17 +44,17 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt | |||||||
|     private Pane mPane = Pane.MAP; |     private Pane mPane = Pane.MAP; | ||||||
|     private String mHighlighter = null; |     private String mHighlighter = null; | ||||||
|  |  | ||||||
|     public IITC_NavigationHelper(IITC_Mobile activity, ActionBar bar) { |     public IITC_NavigationHelper(final IITC_Mobile iitc, final ActionBar bar) { | ||||||
|         super(activity, (DrawerLayout) activity.findViewById(R.id.drawer_layout), |         super(iitc, (DrawerLayout) iitc.findViewById(R.id.drawer_layout), | ||||||
|                 R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close); |                 R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close); | ||||||
|  |  | ||||||
|         mIitc = activity; |         mIitc = iitc; | ||||||
|         mActionBar = bar; |         mActionBar = bar; | ||||||
|         mDrawerLeft = (ListView) activity.findViewById(R.id.left_drawer); |         mDrawerLeft = (ListView) iitc.findViewById(R.id.left_drawer); | ||||||
|         mDrawerRight = activity.findViewById(R.id.right_drawer); |         mDrawerRight = iitc.findViewById(R.id.right_drawer); | ||||||
|         mDrawerLayout = (DrawerLayout) activity.findViewById(R.id.drawer_layout); |         mDrawerLayout = (DrawerLayout) iitc.findViewById(R.id.drawer_layout); | ||||||
|  |  | ||||||
|         mPrefs = PreferenceManager.getDefaultSharedPreferences(activity); |         mPrefs = PreferenceManager.getDefaultSharedPreferences(iitc); | ||||||
|  |  | ||||||
|         mActionBar.setDisplayShowHomeEnabled(true); // show icon |         mActionBar.setDisplayShowHomeEnabled(true); // show icon | ||||||
|  |  | ||||||
| @@ -78,7 +71,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void updateViews() { |     private void updateViews() { | ||||||
|         int position = mNavigationAdapter.getPosition(mPane); |         final int position = mNavigationAdapter.getPosition(mPane); | ||||||
|         if (position >= 0 && position < mNavigationAdapter.getCount()) { |         if (position >= 0 && position < mNavigationAdapter.getCount()) { | ||||||
|             mDrawerLeft.setItemChecked(position, true); |             mDrawerLeft.setItemChecked(position, true); | ||||||
|         } else { |         } else { | ||||||
| @@ -117,7 +110,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         boolean mapVisible = mDesktopMode || mPane == Pane.MAP; |         final boolean mapVisible = mDesktopMode || mPane == Pane.MAP; | ||||||
|         if ("No Highlights".equals(mHighlighter) || isDrawerOpened() || mIitc.isLoading() || !mapVisible) { |         if ("No Highlights".equals(mHighlighter) || isDrawerOpened() || mIitc.isLoading() || !mapVisible) { | ||||||
|             mActionBar.setSubtitle(null); |             mActionBar.setSubtitle(null); | ||||||
|         } else { |         } else { | ||||||
| @@ -125,11 +118,11 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void addPane(String name, String label, String icon) { |     public void addPane(final String name, final String label, final String icon) { | ||||||
|         mNotificationHelper.showNotice(IITC_NotificationHelper.NOTICE_PANES); |         mNotificationHelper.showNotice(IITC_NotificationHelper.NOTICE_PANES); | ||||||
|  |  | ||||||
|         Resources res = mIitc.getResources(); |         final Resources res = mIitc.getResources(); | ||||||
|         String packageName = res.getResourcePackageName(R.string.app_name); |         final String packageName = res.getResourcePackageName(R.string.app_name); | ||||||
|         /* |         /* | ||||||
|          * since the package name is overridden in test builds |          * since the package name is overridden in test builds | ||||||
|          * we can't use context.getPackageName() to get the package name |          * we can't use context.getPackageName() to get the package name | ||||||
| @@ -137,7 +130,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt | |||||||
|          * so we have to retrieve the package name of another resource with Resources.getResourcePackageName() |          * so we have to retrieve the package name of another resource with Resources.getResourcePackageName() | ||||||
|          * see http://www.piwai.info/renaming-android-manifest-package/ |          * see http://www.piwai.info/renaming-android-manifest-package/ | ||||||
|          */ |          */ | ||||||
|         int resId = mIitc.getResources().getIdentifier(icon, "drawable", packageName); |         final int resId = mIitc.getResources().getIdentifier(icon, "drawable", packageName); | ||||||
|         mNavigationAdapter.add(new Pane(name, label, resId)); |         mNavigationAdapter.add(new Pane(name, label, resId)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -145,9 +138,9 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt | |||||||
|         mDrawerLayout.closeDrawers(); |         mDrawerLayout.closeDrawers(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public Pane getPane(String id) { |     public Pane getPane(final String id) { | ||||||
|         for (int i = 0; i < mNavigationAdapter.getCount(); i++) { |         for (int i = 0; i < mNavigationAdapter.getCount(); i++) { | ||||||
|             Pane pane = mNavigationAdapter.getItem(i); |             final Pane pane = mNavigationAdapter.getItem(i); | ||||||
|             if (pane.name.equals(id)) |             if (pane.name.equals(id)) | ||||||
|                 return pane; |                 return pane; | ||||||
|         } |         } | ||||||
| @@ -163,7 +156,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onDrawerClosed(View drawerView) { |     public void onDrawerClosed(final View drawerView) { | ||||||
|         super.onDrawerClosed(drawerView); |         super.onDrawerClosed(drawerView); | ||||||
|  |  | ||||||
|         mIitc.getWebView().onWindowFocusChanged(true); |         mIitc.getWebView().onWindowFocusChanged(true); | ||||||
| @@ -178,7 +171,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onDrawerOpened(View drawerView) { |     public void onDrawerOpened(final View drawerView) { | ||||||
|         super.onDrawerOpened(drawerView); |         super.onDrawerOpened(drawerView); | ||||||
|         mIitc.getWebView().onWindowFocusChanged(false); |         mIitc.getWebView().onWindowFocusChanged(false); | ||||||
|         mIitc.invalidateOptionsMenu(); |         mIitc.invalidateOptionsMenu(); | ||||||
| @@ -187,8 +180,8 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |     public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) { | ||||||
|         Pane item = mNavigationAdapter.getItem(position); |         final Pane item = mNavigationAdapter.getItem(position); | ||||||
|         mIitc.switchToPane(item); |         mIitc.switchToPane(item); | ||||||
|  |  | ||||||
|         if (item == Pane.INFO) { |         if (item == Pane.INFO) { | ||||||
| @@ -203,7 +196,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onOptionsItemSelected(MenuItem item) { |     public boolean onOptionsItemSelected(final MenuItem item) { | ||||||
|         if (item.getItemId() == android.R.id.home) { |         if (item.getItemId() == android.R.id.home) { | ||||||
|             mDrawerLayout.closeDrawer(mDrawerRight); |             mDrawerLayout.closeDrawer(mDrawerRight); | ||||||
|         } |         } | ||||||
| @@ -211,7 +204,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt | |||||||
|         return super.onOptionsItemSelected(item); |         return super.onOptionsItemSelected(item); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void onPostCreate(Bundle savedInstanceState) { |     public void onPostCreate(final Bundle savedInstanceState) { | ||||||
|         // Sync the toggle state after onRestoreInstanceState has occurred. |         // Sync the toggle state after onRestoreInstanceState has occurred. | ||||||
|         syncState(); |         syncState(); | ||||||
|     } |     } | ||||||
| @@ -233,11 +226,11 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt | |||||||
|         updateViews(); |         updateViews(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setDebugMode(boolean enabled) { |     public void setDebugMode(final boolean enabled) { | ||||||
|         mNavigationAdapter.reset(); |         mNavigationAdapter.reset(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setHighlighter(String name) { |     public void setHighlighter(final String name) { | ||||||
|         mHighlighter = name; |         mHighlighter = name; | ||||||
|         updateViews(); |         updateViews(); | ||||||
|     } |     } | ||||||
| @@ -246,7 +239,7 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt | |||||||
|         mActionBar.show(); |         mActionBar.show(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void switchTo(Pane pane) { |     public void switchTo(final Pane pane) { | ||||||
|         mPane = pane; |         mPane = pane; | ||||||
|  |  | ||||||
|         updateViews(); |         updateViews(); | ||||||
| @@ -260,9 +253,9 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public View getView(int position, View convertView, ViewGroup parent) { |         public View getView(final int position, final View convertView, final ViewGroup parent) { | ||||||
|             TextView view = (TextView) super.getView(position, convertView, parent); |             final TextView view = (TextView) super.getView(position, convertView, parent); | ||||||
|             Pane item = getItem(position); |             final Pane item = getItem(position); | ||||||
|             view.setText(item.label); |             view.setText(item.label); | ||||||
|  |  | ||||||
|             if (item.icon != 0) { |             if (item.icon != 0) { | ||||||
| @@ -291,22 +284,22 @@ public class IITC_NavigationHelper extends ActionBarDrawerToggle implements OnIt | |||||||
|         public static final Pane MAP = new Pane("map", "Map", R.drawable.ic_action_map); |         public static final Pane MAP = new Pane("map", "Map", R.drawable.ic_action_map); | ||||||
|         public static final Pane PUBLIC = new Pane("public", "Public", R.drawable.ic_action_group); |         public static final Pane PUBLIC = new Pane("public", "Public", R.drawable.ic_action_group); | ||||||
|  |  | ||||||
|         private int icon; |         private final int icon; | ||||||
|         public String label; |         public String label; | ||||||
|         public String name; |         public String name; | ||||||
|  |  | ||||||
|         public Pane(String name, String label, int icon) { |         public Pane(final String name, final String label, final int icon) { | ||||||
|             this.name = name; |             this.name = name; | ||||||
|             this.label = label; |             this.label = label; | ||||||
|             this.icon = icon; |             this.icon = icon; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         @Override |         @Override | ||||||
|         public boolean equals(Object o) { |         public boolean equals(final Object o) { | ||||||
|             if (o == null) return false; |             if (o == null) return false; | ||||||
|             if (o.getClass() != getClass()) return false; |             if (o.getClass() != getClass()) return false; | ||||||
|  |  | ||||||
|             Pane pane = (Pane) o; |             final Pane pane = (Pane) o; | ||||||
|             return name.equals(pane.name); |             return name.equals(pane.name); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -24,7 +24,7 @@ public class IITC_NotificationHelper { | |||||||
|     private final SharedPreferences mPrefs; |     private final SharedPreferences mPrefs; | ||||||
|     private int mDialogs = 0; |     private int mDialogs = 0; | ||||||
|  |  | ||||||
|     public IITC_NotificationHelper(Activity activity) { |     public IITC_NotificationHelper(final Activity activity) { | ||||||
|         mActivity = activity; |         mActivity = activity; | ||||||
|         mPrefs = PreferenceManager.getDefaultSharedPreferences(mActivity); |         mPrefs = PreferenceManager.getDefaultSharedPreferences(mActivity); | ||||||
|     } |     } | ||||||
| @@ -45,30 +45,31 @@ public class IITC_NotificationHelper { | |||||||
|                 break; |                 break; | ||||||
|             case NOTICE_EXTPLUGINS: |             case NOTICE_EXTPLUGINS: | ||||||
|                 text = mActivity.getString(R.string.notice_extplugins); |                 text = mActivity.getString(R.string.notice_extplugins); | ||||||
|                 text = String.format(text, Environment.getExternalStorageDirectory().getPath() + "/IITC_Mobile/plugins/"); |                 text = String.format(text, Environment.getExternalStorageDirectory().getPath() | ||||||
|  |                         + "/IITC_Mobile/plugins/"); | ||||||
|                 break; |                 break; | ||||||
|             default: |             default: | ||||||
|                 return; |                 return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         final View content = mActivity.getLayoutInflater().inflate(R.layout.dialog_notice, null); |         final View content = mActivity.getLayoutInflater().inflate(R.layout.dialog_notice, null); | ||||||
|         TextView message = (TextView) content.findViewById(R.id.tv_notice); |         final TextView message = (TextView) content.findViewById(R.id.tv_notice); | ||||||
|         message.setText(Html.fromHtml(text)); |         message.setText(Html.fromHtml(text)); | ||||||
|         message.setMovementMethod(LinkMovementMethod.getInstance()); |         message.setMovementMethod(LinkMovementMethod.getInstance()); | ||||||
|  |  | ||||||
|         AlertDialog dialog = new AlertDialog.Builder(mActivity) |         final AlertDialog dialog = new AlertDialog.Builder(mActivity) | ||||||
|                 .setView(content) |                 .setView(content) | ||||||
|                 .setCancelable(true) |                 .setCancelable(true) | ||||||
|                 .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { |                 .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { | ||||||
|                     @Override |                     @Override | ||||||
|                     public void onClick(DialogInterface dialog, int which) { |                     public void onClick(final DialogInterface dialog, final int which) { | ||||||
|                         dialog.cancel(); |                         dialog.cancel(); | ||||||
|                     } |                     } | ||||||
|                 }) |                 }) | ||||||
|                 .create(); |                 .create(); | ||||||
|         dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { |         dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { | ||||||
|             @Override |             @Override | ||||||
|             public void onDismiss(DialogInterface dialog) { |             public void onDismiss(final DialogInterface dialog) { | ||||||
|                 mDialogs &= ~which; |                 mDialogs &= ~which; | ||||||
|                 if (((CheckBox) content.findViewById(R.id.cb_do_not_show_again)).isChecked()) { |                 if (((CheckBox) content.findViewById(R.id.cb_do_not_show_again)).isChecked()) { | ||||||
|                     int value = mPrefs.getInt("pref_messages", 0); |                     int value = mPrefs.getInt("pref_messages", 0); | ||||||
| @@ -85,6 +86,4 @@ public class IITC_NotificationHelper { | |||||||
|         mDialogs |= which; |         mDialogs |= which; | ||||||
|         dialog.show(); |         dialog.show(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -10,10 +10,10 @@ import android.webkit.WebView; | |||||||
|  */ |  */ | ||||||
| public class IITC_WebChromeClient extends WebChromeClient { | public class IITC_WebChromeClient extends WebChromeClient { | ||||||
|  |  | ||||||
|     private IITC_Mobile mIitcm; |     private final IITC_Mobile mIitc; | ||||||
|  |  | ||||||
|     public IITC_WebChromeClient(IITC_Mobile iitcm) { |     public IITC_WebChromeClient(final IITC_Mobile iitc) { | ||||||
|         mIitcm = iitcm; |         mIitc = iitc; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -22,7 +22,7 @@ public class IITC_WebChromeClient extends WebChromeClient { | |||||||
|      * allow access by default |      * allow access by default | ||||||
|      */ |      */ | ||||||
|     @Override |     @Override | ||||||
|     public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { |     public void onGeolocationPermissionsShowPrompt(final String origin, final GeolocationPermissions.Callback callback) { | ||||||
|         callback.invoke(origin, true, false); |         callback.invoke(origin, true, false); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -30,21 +30,21 @@ public class IITC_WebChromeClient extends WebChromeClient { | |||||||
|      * display progress bar in activity |      * display progress bar in activity | ||||||
|      */ |      */ | ||||||
|     @Override |     @Override | ||||||
|     public void onProgressChanged(WebView view, int newProgress) { |     public void onProgressChanged(final WebView view, final int newProgress) { | ||||||
|         super.onProgressChanged(view, newProgress); |         super.onProgressChanged(view, newProgress); | ||||||
|  |  | ||||||
|         // maximum for newProgress is 100 |         // maximum for newProgress is 100 | ||||||
|         // maximum for setProgress is 10,000 |         // maximum for setProgress is 10,000 | ||||||
|         mIitcm.setProgress(newProgress * 100); |         mIitc.setProgress(newProgress * 100); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * remove splash screen if any JS error occurs |      * remove splash screen if any JS error occurs | ||||||
|      */ |      */ | ||||||
|     @Override |     @Override | ||||||
|     public boolean onConsoleMessage(ConsoleMessage message) { |     public boolean onConsoleMessage(final ConsoleMessage message) { | ||||||
|         if (message.messageLevel() == ConsoleMessage.MessageLevel.ERROR) { |         if (message.messageLevel() == ConsoleMessage.MessageLevel.ERROR) { | ||||||
|             mIitcm.setLoadingState(false); |             mIitc.setLoadingState(false); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (Log.log(message)) |         if (Log.log(message)) | ||||||
|   | |||||||
| @@ -44,7 +44,7 @@ public class IITC_WebView extends WebView { | |||||||
|             " Gecko/20130810 Firefox/17.0 Iceweasel/17.0.8"; |             " Gecko/20130810 Firefox/17.0 Iceweasel/17.0.8"; | ||||||
|  |  | ||||||
|     // init web view |     // init web view | ||||||
|     private void iitc_init(Context c) { |     private void iitc_init(final Context c) { | ||||||
|         if (isInEditMode()) return; |         if (isInEditMode()) return; | ||||||
|         mIitc = (IITC_Mobile) c; |         mIitc = (IITC_Mobile) c; | ||||||
|         mSettings = getSettings(); |         mSettings = getSettings(); | ||||||
| @@ -86,19 +86,19 @@ public class IITC_WebView extends WebView { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     // constructors ------------------------------------------------- |     // constructors ------------------------------------------------- | ||||||
|     public IITC_WebView(Context context) { |     public IITC_WebView(final Context context) { | ||||||
|         super(context); |         super(context); | ||||||
|  |  | ||||||
|         iitc_init(context); |         iitc_init(context); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public IITC_WebView(Context context, AttributeSet attrs) { |     public IITC_WebView(final Context context, final AttributeSet attrs) { | ||||||
|         super(context, attrs); |         super(context, attrs); | ||||||
|  |  | ||||||
|         iitc_init(context); |         iitc_init(context); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public IITC_WebView(Context context, AttributeSet attrs, int defStyle) { |     public IITC_WebView(final Context context, final AttributeSet attrs, final int defStyle) { | ||||||
|         super(context, attrs, defStyle); |         super(context, attrs, defStyle); | ||||||
|  |  | ||||||
|         iitc_init(context); |         iitc_init(context); | ||||||
| @@ -117,7 +117,7 @@ public class IITC_WebView extends WebView { | |||||||
|             loadJS(url.substring("javascript:".length())); |             loadJS(url.substring("javascript:".length())); | ||||||
|         } else { |         } else { | ||||||
|             // force https if enabled in settings |             // force https if enabled in settings | ||||||
|             SharedPreferences sharedPref = PreferenceManager |             final SharedPreferences sharedPref = PreferenceManager | ||||||
|                     .getDefaultSharedPreferences(getContext()); |                     .getDefaultSharedPreferences(getContext()); | ||||||
|             if (sharedPref.getBoolean("pref_force_https", true)) { |             if (sharedPref.getBoolean("pref_force_https", true)) { | ||||||
|                 url = url.replace("http://", "https://"); |                 url = url.replace("http://", "https://"); | ||||||
| @@ -133,12 +133,12 @@ public class IITC_WebView extends WebView { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @TargetApi(19) |     @TargetApi(19) | ||||||
|     public void loadJS(String js) { |     public void loadJS(final String js) { | ||||||
|         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { |         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { | ||||||
|             evaluateJavascript(js, null); |             evaluateJavascript(js, null); | ||||||
|         } else { |         } else { | ||||||
|             // if in edit text mode, don't load javascript otherwise the keyboard closes. |             // if in edit text mode, don't load javascript otherwise the keyboard closes. | ||||||
|             HitTestResult testResult = getHitTestResult(); |             final HitTestResult testResult = getHitTestResult(); | ||||||
|             if (testResult != null && testResult.getType() == HitTestResult.EDIT_TEXT_TYPE) { |             if (testResult != null && testResult.getType() == HitTestResult.EDIT_TEXT_TYPE) { | ||||||
|                 // let window.show(...) interrupt input |                 // let window.show(...) interrupt input | ||||||
|                 // window.show(...) is called if one of the action bar buttons |                 // window.show(...) is called if one of the action bar buttons | ||||||
| @@ -153,14 +153,14 @@ public class IITC_WebView extends WebView { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public boolean onTouchEvent(MotionEvent event) { |     public boolean onTouchEvent(final MotionEvent event) { | ||||||
|         getHandler().removeCallbacks(mNavHider); |         getHandler().removeCallbacks(mNavHider); | ||||||
|         getHandler().postDelayed(mNavHider, 3000); |         getHandler().postDelayed(mNavHider, 3000); | ||||||
|         return super.onTouchEvent(event); |         return super.onTouchEvent(event); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void setSystemUiVisibility(int visibility) { |     public void setSystemUiVisibility(final int visibility) { | ||||||
|         if ((visibility & SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) { |         if ((visibility & SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) { | ||||||
|             getHandler().postDelayed(mNavHider, 3000); |             getHandler().postDelayed(mNavHider, 3000); | ||||||
|         } |         } | ||||||
| @@ -168,7 +168,7 @@ public class IITC_WebView extends WebView { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onWindowFocusChanged(boolean hasWindowFocus) { |     public void onWindowFocusChanged(final boolean hasWindowFocus) { | ||||||
|         if (hasWindowFocus) { |         if (hasWindowFocus) { | ||||||
|             getHandler().postDelayed(mNavHider, 3000); |             getHandler().postDelayed(mNavHider, 3000); | ||||||
|         } else { |         } else { | ||||||
| @@ -180,7 +180,7 @@ public class IITC_WebView extends WebView { | |||||||
|     public void toggleFullscreen() { |     public void toggleFullscreen() { | ||||||
|         mFullscreenStatus ^= FS_ENABLED; |         mFullscreenStatus ^= FS_ENABLED; | ||||||
|  |  | ||||||
|         WindowManager.LayoutParams attrs = mIitc.getWindow().getAttributes(); |         final WindowManager.LayoutParams attrs = mIitc.getWindow().getAttributes(); | ||||||
|         // toggle notification bar |         // toggle notification bar | ||||||
|         if (isInFullscreen()) { |         if (isInFullscreen()) { | ||||||
|             // show a toast with instructions to exit the fullscreen mode again |             // show a toast with instructions to exit the fullscreen mode again | ||||||
| @@ -206,14 +206,14 @@ public class IITC_WebView extends WebView { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     void updateFullscreenStatus() { |     void updateFullscreenStatus() { | ||||||
|         Set<String> entries = mSharedPrefs.getStringSet("pref_fullscreen", new HashSet<String>()); |         final Set<String> entries = mSharedPrefs.getStringSet("pref_fullscreen", new HashSet<String>()); | ||||||
|         mFullscreenStatus &= FS_ENABLED; |         mFullscreenStatus &= FS_ENABLED; | ||||||
|  |  | ||||||
|         // default values...android has no nice way to add default values to multiSelectListPreferences |         // default values...android has no nice way to add default values to multiSelectListPreferences | ||||||
|         if (entries.isEmpty()) { |         if (entries.isEmpty()) { | ||||||
|             mFullscreenStatus += FS_ACTIONBAR | FS_SYSBAR; |             mFullscreenStatus += FS_ACTIONBAR | FS_SYSBAR; | ||||||
|         } |         } | ||||||
|         for (String entry : entries) { |         for (final String entry : entries) { | ||||||
|             mFullscreenStatus += Integer.parseInt(entry); |             mFullscreenStatus += Integer.parseInt(entry); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -236,27 +236,28 @@ public class IITC_WebView extends WebView { | |||||||
|  |  | ||||||
|     @TargetApi(Build.VERSION_CODES.JELLY_BEAN) |     @TargetApi(Build.VERSION_CODES.JELLY_BEAN) | ||||||
|     public boolean isConnectedToWifi() { |     public boolean isConnectedToWifi() { | ||||||
|         ConnectivityManager conMan = (ConnectivityManager) getContext() |         final ConnectivityManager conMan = (ConnectivityManager) mIitc.getSystemService(Context.CONNECTIVITY_SERVICE); | ||||||
|                 .getSystemService(Context.CONNECTIVITY_SERVICE); |         final NetworkInfo wifi = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI); | ||||||
|         NetworkInfo wifi = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI); |  | ||||||
|         // since jelly bean you can mark wifi networks as mobile hotspots |         // since jelly bean you can mark wifi networks as mobile hotspots | ||||||
|         // settings -> data usage -> menu -> mobile hotspots |         // settings -> data usage -> menu -> mobile hotspots | ||||||
|         // ConnectivityManager.isActiveNetworkMeter returns if the currently used wifi-network |         // ConnectivityManager.isActiveNetworkMeter returns if the currently used wifi-network | ||||||
|         // is ticked as mobile hotspot or not. |         // is ticked as mobile hotspot or not. | ||||||
|         // --> IITC_WebView.isConnectedToWifi should return 'false' if connected to mobile hotspot |         // --> IITC_WebView.isConnectedToWifi should return 'false' if connected to mobile hotspot | ||||||
|         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { |         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { | ||||||
|             return ((wifi.getState() == NetworkInfo.State.CONNECTED) && |             if (conMan.isActiveNetworkMetered()) return false; | ||||||
|                     !conMan.isActiveNetworkMetered()); |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return (wifi.getState() == NetworkInfo.State.CONNECTED); |         return (wifi.getState() == NetworkInfo.State.CONNECTED); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void disableJS(boolean val) { |     public void disableJS(final boolean val) { | ||||||
|         mDisableJs = val; |         mDisableJs = val; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void setUserAgent() { |     public void setUserAgent() { | ||||||
|         String ua = mSharedPrefs.getBoolean("pref_fake_user_agent", false) ? mDesktopUserAgent : mDefaultUserAgent; |         final String ua = mSharedPrefs.getBoolean("pref_fake_user_agent", false) ? | ||||||
|  |                 mDesktopUserAgent : mDefaultUserAgent; | ||||||
|         Log.d("setting user agent to: " + ua); |         Log.d("setting user agent to: " + ua); | ||||||
|         mSettings.setUserAgentString(ua); |         mSettings.setUserAgentString(ua); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -25,25 +25,25 @@ public class IITC_WebViewClient extends WebViewClient { | |||||||
|     private static final ByteArrayInputStream EMPTY = new ByteArrayInputStream("".getBytes()); |     private static final ByteArrayInputStream EMPTY = new ByteArrayInputStream("".getBytes()); | ||||||
|     private static final String DOMAIN = IITC_FileManager.DOMAIN; |     private static final String DOMAIN = IITC_FileManager.DOMAIN; | ||||||
|  |  | ||||||
|     private String mIitcPath; |     private final String mIitcPath; | ||||||
|     private boolean mIitcInjected = false; |     private boolean mIitcInjected = false; | ||||||
|     private final IITC_Mobile mIitc; |     private final IITC_Mobile mIitc; | ||||||
|     private final IITC_TileManager mTileManager; |     private final IITC_TileManager mTileManager; | ||||||
|  |  | ||||||
|     public IITC_WebViewClient(IITC_Mobile iitc) { |     public IITC_WebViewClient(final IITC_Mobile iitc) { | ||||||
|         this.mIitc = iitc; |         mIitc = iitc; | ||||||
|         this.mTileManager = new IITC_TileManager(mIitc); |         mTileManager = new IITC_TileManager(mIitc); | ||||||
|         this.mIitcPath = Environment.getExternalStorageDirectory().getPath() + "/IITC_Mobile/"; |         mIitcPath = Environment.getExternalStorageDirectory().getPath() + "/IITC_Mobile/"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // enable https |     // enable https | ||||||
|     @Override |     @Override | ||||||
|     public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { |     public void onReceivedSslError(final WebView view, final SslErrorHandler handler, final SslError error) { | ||||||
|         handler.proceed(); |         handler.proceed(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onPageFinished(WebView view, String url) { |     public void onPageFinished(final WebView view, final String url) { | ||||||
|         if (url.startsWith("http://www.ingress.com/intel") |         if (url.startsWith("http://www.ingress.com/intel") | ||||||
|                 || url.startsWith("https://www.ingress.com/intel")) { |                 || url.startsWith("https://www.ingress.com/intel")) { | ||||||
|             if (mIitcInjected) return; |             if (mIitcInjected) return; | ||||||
| @@ -54,18 +54,18 @@ public class IITC_WebViewClient extends WebViewClient { | |||||||
|         super.onPageFinished(view, url); |         super.onPageFinished(view, url); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void loadScripts(IITC_WebView view) { |     private void loadScripts(final IITC_WebView view) { | ||||||
|         List<String> scripts = new LinkedList<String>(); |         final List<String> scripts = new LinkedList<String>(); | ||||||
|  |  | ||||||
|         scripts.add("script" + DOMAIN + "/total-conversion-build.user.js"); |         scripts.add("script" + DOMAIN + "/total-conversion-build.user.js"); | ||||||
|  |  | ||||||
|         // get the plugin preferences |         // get the plugin preferences | ||||||
|         SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(mIitc); |         final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(mIitc); | ||||||
|         Map<String, ?> all_prefs = sharedPref.getAll(); |         final Map<String, ?> all_prefs = sharedPref.getAll(); | ||||||
|  |  | ||||||
|         // iterate through all plugins |         // iterate through all plugins | ||||||
|         for (Map.Entry<String, ?> entry : all_prefs.entrySet()) { |         for (final Map.Entry<String, ?> entry : all_prefs.entrySet()) { | ||||||
|             String plugin = entry.getKey(); |             final String plugin = entry.getKey(); | ||||||
|             if (plugin.endsWith(".user.js") && entry.getValue().toString().equals("true")) { |             if (plugin.endsWith(".user.js") && entry.getValue().toString().equals("true")) { | ||||||
|                 if (plugin.startsWith(mIitcPath)) { |                 if (plugin.startsWith(mIitcPath)) { | ||||||
|                     scripts.add("user-plugin" + DOMAIN + plugin); |                     scripts.add("user-plugin" + DOMAIN + plugin); | ||||||
| @@ -80,7 +80,7 @@ public class IITC_WebViewClient extends WebViewClient { | |||||||
|             scripts.add("script" + DOMAIN + "/user-location.user.js"); |             scripts.add("script" + DOMAIN + "/user-location.user.js"); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         String js = "(function(){['" + TextUtils.join("','", scripts) + "'].forEach(function(src) {" + |         final String js = "(function(){['" + TextUtils.join("','", scripts) + "'].forEach(function(src) {" + | ||||||
|                 "var script = document.createElement('script');script.src = '//'+src;" + |                 "var script = document.createElement('script');script.src = '//'+src;" + | ||||||
|                 "(document.body || document.head || document.documentElement).appendChild(script);" + |                 "(document.body || document.head || document.documentElement).appendChild(script);" + | ||||||
|                 "});})();"; |                 "});})();"; | ||||||
| @@ -92,7 +92,7 @@ public class IITC_WebViewClient extends WebViewClient { | |||||||
|      * this method is called automatically when the Google login form is opened. |      * this method is called automatically when the Google login form is opened. | ||||||
|      */ |      */ | ||||||
|     @Override |     @Override | ||||||
|     public void onReceivedLoginRequest(WebView view, String realm, String account, String args) { |     public void onReceivedLoginRequest(final WebView view, final String realm, final String account, final String args) { | ||||||
|         mIitcInjected = false; |         mIitcInjected = false; | ||||||
|         // Log.d("iitcm", "Login requested: " + realm + " " + account + " " + args); |         // Log.d("iitcm", "Login requested: " + realm + " " + account + " " + args); | ||||||
|         // ((IITC_Mobile) mContext).onReceivedLoginRequest(this, view, realm, account, args); |         // ((IITC_Mobile) mContext).onReceivedLoginRequest(this, view, realm, account, args); | ||||||
| @@ -104,7 +104,7 @@ public class IITC_WebViewClient extends WebViewClient { | |||||||
|      * via http://stackoverflow.com/a/8274881/1684530 |      * via http://stackoverflow.com/a/8274881/1684530 | ||||||
|      */ |      */ | ||||||
|     @Override |     @Override | ||||||
|     public WebResourceResponse shouldInterceptRequest(final WebView view, String url) { |     public WebResourceResponse shouldInterceptRequest(final WebView view, final String url) { | ||||||
|         // if any tiles are requested, handle it with IITC_TileManager |         // if any tiles are requested, handle it with IITC_TileManager | ||||||
|         if (url.matches(".*tile.*jpg.*") // mapquest tiles | ovi tiles |         if (url.matches(".*tile.*jpg.*") // mapquest tiles | ovi tiles | ||||||
|                 || url.matches(".*tile.*png.*") // cloudmade tiles |                 || url.matches(".*tile.*png.*") // cloudmade tiles | ||||||
| @@ -115,7 +115,7 @@ public class IITC_WebViewClient extends WebViewClient { | |||||||
|         ) { |         ) { | ||||||
|             try { |             try { | ||||||
|                 return mTileManager.getTile(url); |                 return mTileManager.getTile(url); | ||||||
|             } catch (Exception e) { |             } catch (final Exception e) { | ||||||
|                 Log.w(e); |                 Log.w(e); | ||||||
|                 return super.shouldInterceptRequest(view, url); |                 return super.shouldInterceptRequest(view, url); | ||||||
|             } |             } | ||||||
| @@ -140,8 +140,8 @@ public class IITC_WebViewClient extends WebViewClient { | |||||||
|             return new WebResourceResponse("text/plain", "UTF-8", EMPTY); |             return new WebResourceResponse("text/plain", "UTF-8", EMPTY); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         Uri uri = Uri.parse(url); |         final Uri uri = Uri.parse(url); | ||||||
|         if (uri.getHost()!=null && uri.getHost().endsWith(DOMAIN) && |         if (uri.getHost() != null && uri.getHost().endsWith(DOMAIN) && | ||||||
|                 ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme()))) |                 ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme()))) | ||||||
|             return mIitc.getFileManager().getResponse(uri); |             return mIitc.getFileManager().getResponse(uri); | ||||||
|  |  | ||||||
| @@ -150,7 +150,7 @@ public class IITC_WebViewClient extends WebViewClient { | |||||||
|  |  | ||||||
|     // start non-ingress-intel-urls in another app... |     // start non-ingress-intel-urls in another app... | ||||||
|     @Override |     @Override | ||||||
|     public boolean shouldOverrideUrlLoading(WebView view, String url) { |     public boolean shouldOverrideUrlLoading(final WebView view, final String url) { | ||||||
|         if (url.contains("ingress.com") || url.contains("appengine.google.com")) { |         if (url.contains("ingress.com") || url.contains("appengine.google.com")) { | ||||||
|             // reload iitc if a poslink is clicked inside the app |             // reload iitc if a poslink is clicked inside the app | ||||||
|             if (url.contains("intel?ll=") |             if (url.contains("intel?ll=") | ||||||
| @@ -161,7 +161,7 @@ public class IITC_WebViewClient extends WebViewClient { | |||||||
|             return false; |             return false; | ||||||
|         } else { |         } else { | ||||||
|             Log.d("no ingress intel link, start external app to load url: " + url); |             Log.d("no ingress intel link, start external app to load url: " + url); | ||||||
|             Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); |             final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); | ||||||
|             mIitc.startActivity(intent); |             mIitc.startActivity(intent); | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -37,20 +37,20 @@ public final class Log { | |||||||
|                 Pattern.CASE_INSENSITIVE); |                 Pattern.CASE_INSENSITIVE); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|     private static synchronized void log(int priority, String tag, String msg, Throwable tr) { |     private static synchronized void log(final int priority, final String tag, final String msg, final Throwable tr) { | ||||||
|         Date now = new Date(); |         final Date now = new Date(); | ||||||
|  |  | ||||||
|         Message message = new Message(now, priority, tag, msg, tr); |         final Message message = new Message(now, priority, tag, msg, tr); | ||||||
|         for (Receiver receiver : RECEIVERS) { |         for (final Receiver receiver : RECEIVERS) { | ||||||
|             receiver.handle(message); |             receiver.handle(message); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void addReceiver(Log.Receiver receiver) { |     public static void addReceiver(final Log.Receiver receiver) { | ||||||
|         RECEIVERS.add(receiver); |         RECEIVERS.add(receiver); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void d(String msg) { |     public static void d(final String msg) { | ||||||
|         d(DEFAULT_TAG, msg); |         d(DEFAULT_TAG, msg); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -58,7 +58,7 @@ public final class Log { | |||||||
|      * @deprecated A default tag is provided by {@link Log.d} |      * @deprecated A default tag is provided by {@link Log.d} | ||||||
|      */ |      */ | ||||||
|     @Deprecated |     @Deprecated | ||||||
|     public static void d(String tag, String msg) { |     public static void d(final String tag, final String msg) { | ||||||
|         log(android.util.Log.DEBUG, tag, msg, null); |         log(android.util.Log.DEBUG, tag, msg, null); | ||||||
|         android.util.Log.d(tag, msg); |         android.util.Log.d(tag, msg); | ||||||
|     } |     } | ||||||
| @@ -67,20 +67,20 @@ public final class Log { | |||||||
|      * @deprecated A default tag is provided by {@link Log.d} |      * @deprecated A default tag is provided by {@link Log.d} | ||||||
|      */ |      */ | ||||||
|     @Deprecated |     @Deprecated | ||||||
|     public static void d(String tag, String msg, Throwable tr) { |     public static void d(final String tag, final String msg, final Throwable tr) { | ||||||
|         log(android.util.Log.DEBUG, tag, msg, tr); |         log(android.util.Log.DEBUG, tag, msg, tr); | ||||||
|         android.util.Log.d(tag, msg, tr); |         android.util.Log.d(tag, msg, tr); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void d(String msg, Throwable tr) { |     public static void d(final String msg, final Throwable tr) { | ||||||
|         d(DEFAULT_TAG, msg, tr); |         d(DEFAULT_TAG, msg, tr); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void d(Throwable tr) { |     public static void d(final Throwable tr) { | ||||||
|         d("Unexpected " + tr, tr); |         d("Unexpected " + tr, tr); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void e(String msg) { |     public static void e(final String msg) { | ||||||
|         e(DEFAULT_TAG, msg); |         e(DEFAULT_TAG, msg); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -88,7 +88,7 @@ public final class Log { | |||||||
|      * @deprecated A default tag is provided by {@link Log.e} |      * @deprecated A default tag is provided by {@link Log.e} | ||||||
|      */ |      */ | ||||||
|     @Deprecated |     @Deprecated | ||||||
|     public static void e(String tag, String msg) { |     public static void e(final String tag, final String msg) { | ||||||
|         log(android.util.Log.ERROR, tag, msg, null); |         log(android.util.Log.ERROR, tag, msg, null); | ||||||
|         android.util.Log.e(tag, msg); |         android.util.Log.e(tag, msg); | ||||||
|     } |     } | ||||||
| @@ -97,20 +97,20 @@ public final class Log { | |||||||
|      * @deprecated A default tag is provided by {@link Log.e} |      * @deprecated A default tag is provided by {@link Log.e} | ||||||
|      */ |      */ | ||||||
|     @Deprecated |     @Deprecated | ||||||
|     public static void e(String tag, String msg, Throwable tr) { |     public static void e(final String tag, final String msg, final Throwable tr) { | ||||||
|         log(android.util.Log.ERROR, tag, msg, tr); |         log(android.util.Log.ERROR, tag, msg, tr); | ||||||
|         android.util.Log.e(tag, msg, tr); |         android.util.Log.e(tag, msg, tr); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void e(String msg, Throwable tr) { |     public static void e(final String msg, final Throwable tr) { | ||||||
|         e(DEFAULT_TAG, msg, tr); |         e(DEFAULT_TAG, msg, tr); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void e(Throwable tr) { |     public static void e(final Throwable tr) { | ||||||
|         e("Unexpected " + tr, tr); |         e("Unexpected " + tr, tr); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void i(String msg) { |     public static void i(final String msg) { | ||||||
|         i(DEFAULT_TAG, msg); |         i(DEFAULT_TAG, msg); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -118,7 +118,7 @@ public final class Log { | |||||||
|      * @deprecated A default tag is provided by {@link Log.i} |      * @deprecated A default tag is provided by {@link Log.i} | ||||||
|      */ |      */ | ||||||
|     @Deprecated |     @Deprecated | ||||||
|     public static void i(String tag, String msg) { |     public static void i(final String tag, final String msg) { | ||||||
|         log(android.util.Log.INFO, tag, msg, null); |         log(android.util.Log.INFO, tag, msg, null); | ||||||
|         android.util.Log.i(tag, msg); |         android.util.Log.i(tag, msg); | ||||||
|     } |     } | ||||||
| @@ -127,26 +127,26 @@ public final class Log { | |||||||
|      * @deprecated A default tag is provided by {@link Log.i} |      * @deprecated A default tag is provided by {@link Log.i} | ||||||
|      */ |      */ | ||||||
|     @Deprecated |     @Deprecated | ||||||
|     public static void i(String tag, String msg, Throwable tr) { |     public static void i(final String tag, final String msg, final Throwable tr) { | ||||||
|         log(android.util.Log.INFO, tag, msg, tr); |         log(android.util.Log.INFO, tag, msg, tr); | ||||||
|         android.util.Log.i(tag, msg, tr); |         android.util.Log.i(tag, msg, tr); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void i(String msg, Throwable tr) { |     public static void i(final String msg, final Throwable tr) { | ||||||
|         i(DEFAULT_TAG, msg, tr); |         i(DEFAULT_TAG, msg, tr); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void i(Throwable tr) { |     public static void i(final Throwable tr) { | ||||||
|         i("Unexpected " + tr, tr); |         i("Unexpected " + tr, tr); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static boolean log(ConsoleMessage message) { |     public static boolean log(final ConsoleMessage message) { | ||||||
|         String msg = message.sourceId(); |         String msg = message.sourceId(); | ||||||
|  |  | ||||||
|         if (msg == null || "".equals(msg)) { |         if (msg == null || "".equals(msg)) { | ||||||
|             msg = "<no source>"; |             msg = "<no source>"; | ||||||
|         } else { |         } else { | ||||||
|             Matcher matcher = URL_PATTERN.matcher(msg); |             final Matcher matcher = URL_PATTERN.matcher(msg); | ||||||
|             if (matcher.matches()) { |             if (matcher.matches()) { | ||||||
|                 msg = "<" + matcher.group(1) + "/" + matcher.group(2) + ">"; |                 msg = "<" + matcher.group(1) + "/" + matcher.group(2) + ">"; | ||||||
|             } |             } | ||||||
| @@ -167,7 +167,7 @@ public final class Log { | |||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static int println(int priority, String msg) { |     public static int println(final int priority, final String msg) { | ||||||
|         return println(priority, DEFAULT_TAG, msg); |         return println(priority, DEFAULT_TAG, msg); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -175,16 +175,16 @@ public final class Log { | |||||||
|      * @deprecated A default tag is provided by {@link Log.println} |      * @deprecated A default tag is provided by {@link Log.println} | ||||||
|      */ |      */ | ||||||
|     @Deprecated |     @Deprecated | ||||||
|     public static int println(int priority, String tag, String msg) { |     public static int println(final int priority, final String tag, final String msg) { | ||||||
|         log(priority, tag, msg, null); |         log(priority, tag, msg, null); | ||||||
|         return android.util.Log.println(priority, tag, msg); |         return android.util.Log.println(priority, tag, msg); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void removeReceiver(Log.Receiver receiver) { |     public static void removeReceiver(final Log.Receiver receiver) { | ||||||
|         RECEIVERS.remove(receiver); |         RECEIVERS.remove(receiver); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void v(String msg) { |     public static void v(final String msg) { | ||||||
|         v(DEFAULT_TAG, msg); |         v(DEFAULT_TAG, msg); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -192,7 +192,7 @@ public final class Log { | |||||||
|      * @deprecated A default tag is provided by {@link Log.v} |      * @deprecated A default tag is provided by {@link Log.v} | ||||||
|      */ |      */ | ||||||
|     @Deprecated |     @Deprecated | ||||||
|     public static void v(String tag, String msg) { |     public static void v(final String tag, final String msg) { | ||||||
|         log(android.util.Log.VERBOSE, tag, msg, null); |         log(android.util.Log.VERBOSE, tag, msg, null); | ||||||
|         android.util.Log.v(tag, msg); |         android.util.Log.v(tag, msg); | ||||||
|     } |     } | ||||||
| @@ -201,20 +201,20 @@ public final class Log { | |||||||
|      * @deprecated A default tag is provided by {@link Log.v} |      * @deprecated A default tag is provided by {@link Log.v} | ||||||
|      */ |      */ | ||||||
|     @Deprecated |     @Deprecated | ||||||
|     public static void v(String tag, String msg, Throwable tr) { |     public static void v(final String tag, final String msg, final Throwable tr) { | ||||||
|         log(android.util.Log.VERBOSE, tag, msg, tr); |         log(android.util.Log.VERBOSE, tag, msg, tr); | ||||||
|         android.util.Log.v(tag, msg, tr); |         android.util.Log.v(tag, msg, tr); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void v(String msg, Throwable tr) { |     public static void v(final String msg, final Throwable tr) { | ||||||
|         v(DEFAULT_TAG, msg, tr); |         v(DEFAULT_TAG, msg, tr); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void v(Throwable tr) { |     public static void v(final Throwable tr) { | ||||||
|         v("Unexpected " + tr, tr); |         v("Unexpected " + tr, tr); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void w(String msg) { |     public static void w(final String msg) { | ||||||
|         w(DEFAULT_TAG, msg); |         w(DEFAULT_TAG, msg); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -222,7 +222,7 @@ public final class Log { | |||||||
|      * @deprecated A default tag is provided by {@link Log.w} |      * @deprecated A default tag is provided by {@link Log.w} | ||||||
|      */ |      */ | ||||||
|     @Deprecated |     @Deprecated | ||||||
|     public static void w(String tag, String msg) { |     public static void w(final String tag, final String msg) { | ||||||
|         log(android.util.Log.WARN, tag, msg, null); |         log(android.util.Log.WARN, tag, msg, null); | ||||||
|         android.util.Log.w(tag, msg); |         android.util.Log.w(tag, msg); | ||||||
|     } |     } | ||||||
| @@ -231,16 +231,16 @@ public final class Log { | |||||||
|      * @deprecated A default tag is provided by {@link Log.w} |      * @deprecated A default tag is provided by {@link Log.w} | ||||||
|      */ |      */ | ||||||
|     @Deprecated |     @Deprecated | ||||||
|     public static void w(String tag, String msg, Throwable tr) { |     public static void w(final String tag, final String msg, final Throwable tr) { | ||||||
|         log(android.util.Log.WARN, tag, msg, tr); |         log(android.util.Log.WARN, tag, msg, tr); | ||||||
|         android.util.Log.w(tag, msg, tr); |         android.util.Log.w(tag, msg, tr); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void w(String msg, Throwable tr) { |     public static void w(final String msg, final Throwable tr) { | ||||||
|         w(DEFAULT_TAG, msg, tr); |         w(DEFAULT_TAG, msg, tr); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static void w(Throwable tr) { |     public static void w(final Throwable tr) { | ||||||
|         w("Unexpected " + tr, tr); |         w("Unexpected " + tr, tr); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -250,13 +250,13 @@ public final class Log { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static class Message { |     public static class Message { | ||||||
|         private Date mDate; |         private final Date mDate; | ||||||
|         private String mMsg; |         private final String mMsg; | ||||||
|         private int mPriority; |         private final int mPriority; | ||||||
|         private String mTag; |         private final String mTag; | ||||||
|         private Throwable mTr; |         private final Throwable mTr; | ||||||
|  |  | ||||||
|         private Message(Date date, int priority, String tag, String msg, Throwable tr) { |         private Message(final Date date, final int priority, final String tag, final String msg, final Throwable tr) { | ||||||
|             mDate = date; |             mDate = date; | ||||||
|             mPriority = priority; |             mPriority = priority; | ||||||
|             mTag = tag; |             mTag = tag; | ||||||
| @@ -265,23 +265,23 @@ public final class Log { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         public Date getDate() { |         public Date getDate() { | ||||||
|             return this.mDate; |             return mDate; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public String getMsg() { |         public String getMsg() { | ||||||
|             return this.mMsg; |             return mMsg; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public int getPriority() { |         public int getPriority() { | ||||||
|             return this.mPriority; |             return mPriority; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public String getTag() { |         public String getTag() { | ||||||
|             return this.mTag; |             return mTag; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public Throwable getTr() { |         public Throwable getTr() { | ||||||
|             return this.mTr; |             return mTr; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -14,36 +14,36 @@ import java.net.URLConnection; | |||||||
|  |  | ||||||
| public class DownloadTile extends AsyncTask<String, Void, Boolean> { | public class DownloadTile extends AsyncTask<String, Void, Boolean> { | ||||||
|  |  | ||||||
|     private String mFilePath; |     private final String mFilePath; | ||||||
|  |  | ||||||
|     public DownloadTile(String path) { |     public DownloadTile(final String path) { | ||||||
|         mFilePath = path; |         mFilePath = path; | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected Boolean doInBackground(String... urls) { |     protected Boolean doInBackground(final String... urls) { | ||||||
|         URL tileUrl = null; |         URL tileUrl = null; | ||||||
|         URLConnection conn = null; |         URLConnection conn = null; | ||||||
|         try { |         try { | ||||||
|             tileUrl = new URL(urls[0]); |             tileUrl = new URL(urls[0]); | ||||||
|             conn = tileUrl.openConnection(); |             conn = tileUrl.openConnection(); | ||||||
|             File file = new File(mFilePath); |             final File file = new File(mFilePath); | ||||||
|             // update tile if needed, else return |             // update tile if needed, else return | ||||||
|             if (conn.getLastModified() < file.lastModified()) return true; |             if (conn.getLastModified() < file.lastModified()) return true; | ||||||
|             InputStream is = null; |             InputStream is = null; | ||||||
|             is = conn.getInputStream(); |             is = conn.getInputStream(); | ||||||
|             Log.d("writing to file: " + file.toString()); |             Log.d("writing to file: " + file.toString()); | ||||||
|             writeTileToFile(is, file); |             writeTileToFile(is, file); | ||||||
|         } catch (IOException e) { |         } catch (final IOException e) { | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void writeTileToFile(InputStream inStream, File file) throws IOException { |     private void writeTileToFile(final InputStream inStream, final File file) throws IOException { | ||||||
|         file.getParentFile().mkdirs(); |         file.getParentFile().mkdirs(); | ||||||
|         FileOutputStream outStream = new FileOutputStream(file); |         final FileOutputStream outStream = new FileOutputStream(file); | ||||||
|  |  | ||||||
|         IITC_FileManager.copyStream(inStream, outStream, true); |         IITC_FileManager.copyStream(inStream, outStream, true); | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user