Browse Source

Update gradle dependencies, fix a number of lint errors

Note: resource closed inspections that were ignored were ignored because
they were being properly closed in finally{} blocks
master
Anthony Restaino 9 years ago
parent
commit
27e01483b1
  1. 10
      app/build.gradle
  2. 4
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  3. 8
      app/src/main/java/acr/browser/lightning/activity/TabsManager.java
  4. 3
      app/src/main/java/acr/browser/lightning/app/AppComponent.java
  5. 3
      app/src/main/java/acr/browser/lightning/app/AppModule.java
  6. 3
      app/src/main/java/acr/browser/lightning/app/BrowserApp.java
  7. 3
      app/src/main/java/acr/browser/lightning/bus/BookmarkEvents.java
  8. 3
      app/src/main/java/acr/browser/lightning/bus/BrowserEvents.java
  9. 1
      app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java
  10. 1
      app/src/main/java/acr/browser/lightning/constant/HistoryPage.java
  11. 1
      app/src/main/java/acr/browser/lightning/constant/StartPage.java
  12. 7
      app/src/main/java/acr/browser/lightning/database/BookmarkManager.java
  13. 2
      app/src/main/java/acr/browser/lightning/database/HistoryDatabase.java
  14. 2
      app/src/main/java/acr/browser/lightning/download/DownloadHandler.java
  15. 7
      app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java
  16. 16
      app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java
  17. 1
      app/src/main/java/acr/browser/lightning/object/SearchAdapter.java
  18. 2
      app/src/main/java/acr/browser/lightning/reading/HtmlFetcher.java
  19. 2
      app/src/main/java/acr/browser/lightning/utils/AdBlock.java
  20. 4
      app/src/main/java/acr/browser/lightning/view/LightningView.java

10
app/build.gradle

@ -4,7 +4,7 @@ apply plugin: 'com.getkeepsafe.dexcount'
android { android {
compileSdkVersion 23 compileSdkVersion 23
buildToolsVersion "23.0.1" buildToolsVersion "23.0.2"
defaultConfig { defaultConfig {
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 23 targetSdkVersion 23
@ -69,8 +69,8 @@ dependencies {
compile 'com.squareup:otto:1.3.8' compile 'com.squareup:otto:1.3.8'
// dependency injection // dependency injection
compile 'com.google.dagger:dagger:2.0.1' compile 'com.google.dagger:dagger:2.0.2'
apt 'com.google.dagger:dagger-compiler:2.0.1' apt 'com.google.dagger:dagger-compiler:2.0.2'
// view binding // view binding
compile 'com.jakewharton:butterknife:7.0.1' compile 'com.jakewharton:butterknife:7.0.1'
@ -86,8 +86,8 @@ dependencies {
compile(project(':libnetcipher')) compile(project(':libnetcipher'))
// memory leak analysis // memory leak analysis
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-SNAPSHOT' debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-SNAPSHOT' releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
provided 'javax.annotation:jsr250-api:1.0' provided 'javax.annotation:jsr250-api:1.0'

4
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -1068,7 +1068,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
Log.d(Constants.TAG, "deleted tab"); Log.d(Constants.TAG, "deleted tab");
} }
public void performExitCleanUp() { void performExitCleanUp() {
final LightningView currentTab = mTabsManager.getCurrentTab(); final LightningView currentTab = mTabsManager.getCurrentTab();
if (mPreferences.getClearCacheExit() && currentTab != null && !isIncognito()) { if (mPreferences.getClearCacheExit() && currentTab != null && !isIncognito()) {
WebUtils.clearCache(currentTab.getWebView()); WebUtils.clearCache(currentTab.getWebView());
@ -1099,7 +1099,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
return true; return true;
} }
public void closeBrowser() { void closeBrowser() {
mBrowserFrame.setBackgroundColor(mBackgroundColor); mBrowserFrame.setBackgroundColor(mBackgroundColor);
performExitCleanUp(); performExitCleanUp();
mTabsManager.shutdown(); mTabsManager.shutdown();

8
app/src/main/java/acr/browser/lightning/activity/TabsManager.java

@ -18,10 +18,8 @@ import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import acr.browser.lightning.R; import acr.browser.lightning.R;
import acr.browser.lightning.bus.BrowserEvents;
import acr.browser.lightning.constant.Constants; import acr.browser.lightning.constant.Constants;
import acr.browser.lightning.preference.PreferenceManager; import acr.browser.lightning.preference.PreferenceManager;
import acr.browser.lightning.utils.UrlUtils;
import acr.browser.lightning.utils.Utils; import acr.browser.lightning.utils.Utils;
import acr.browser.lightning.view.LightningView; import acr.browser.lightning.view.LightningView;
@ -186,12 +184,11 @@ public class TabsManager {
* Remove a tab and return its reference or null if the position is not in tabs range * Remove a tab and return its reference or null if the position is not in tabs range
* *
* @param position The position of the tab to remove * @param position The position of the tab to remove
* @return The removed tab reference or null
*/ */
@Nullable @Nullable
private synchronized LightningView removeTab(final int position) { private synchronized void removeTab(final int position) {
if (position >= mWebViewList.size()) { if (position >= mWebViewList.size()) {
return null; return;
} }
final LightningView tab = mWebViewList.remove(position); final LightningView tab = mWebViewList.remove(position);
if (mCurrentTab == tab) { if (mCurrentTab == tab) {
@ -199,7 +196,6 @@ public class TabsManager {
} }
tab.onDestroy(); tab.onDestroy();
Log.d(Constants.TAG, tab.toString()); Log.d(Constants.TAG, tab.toString());
return tab;
} }
public synchronized void deleteTab(int position) { public synchronized void deleteTab(int position) {

3
app/src/main/java/acr/browser/lightning/app/AppComponent.java

@ -20,9 +20,6 @@ import acr.browser.lightning.preference.PreferenceManager;
import acr.browser.lightning.view.LightningView; import acr.browser.lightning.view.LightningView;
import dagger.Component; import dagger.Component;
/**
* Created by Stefano Pacifici on 01/09/15.
*/
@Singleton @Singleton
@Component(modules = {AppModule.class}) @Component(modules = {AppModule.class})
public interface AppComponent { public interface AppComponent {

3
app/src/main/java/acr/browser/lightning/app/AppModule.java

@ -10,9 +10,6 @@ import acr.browser.lightning.database.BookmarkManager;
import dagger.Module; import dagger.Module;
import dagger.Provides; import dagger.Provides;
/**
* Created by Stefano Pacifici on 01/09/15.
*/
@Module @Module
public class AppModule { public class AppModule {
private final BrowserApp app; private final BrowserApp app;

3
app/src/main/java/acr/browser/lightning/app/BrowserApp.java

@ -1,7 +1,6 @@
package acr.browser.lightning.app; package acr.browser.lightning.app;
import android.app.Application; import android.app.Application;
import android.content.Context;
import com.squareup.leakcanary.LeakCanary; import com.squareup.leakcanary.LeakCanary;
import com.squareup.otto.Bus; import com.squareup.otto.Bus;
@ -17,7 +16,7 @@ public class BrowserApp extends Application {
private static BrowserApp sInstance; private static BrowserApp sInstance;
private static AppComponent appComponent; private static AppComponent appComponent;
private static Executor mIOThread = Executors.newSingleThreadExecutor(); private static final Executor mIOThread = Executors.newSingleThreadExecutor();
@Override @Override
public void onCreate() { public void onCreate() {

3
app/src/main/java/acr/browser/lightning/bus/BookmarkEvents.java

@ -2,9 +2,6 @@ package acr.browser.lightning.bus;
import acr.browser.lightning.database.HistoryItem; import acr.browser.lightning.database.HistoryItem;
/**
* Created by Stefano Pacifici on 26/08/15.
*/
public final class BookmarkEvents { public final class BookmarkEvents {
private BookmarkEvents() { private BookmarkEvents() {

3
app/src/main/java/acr/browser/lightning/bus/BrowserEvents.java

@ -2,9 +2,6 @@ package acr.browser.lightning.bus;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
/**
* Created by Stefano Pacifici on 26/08/15.
*/
public final class BrowserEvents { public final class BrowserEvents {
private BrowserEvents() { private BrowserEvents() {

1
app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java

@ -102,6 +102,7 @@ public final class BookmarkPage {
bookmarkBuilder.append(BookmarkPage.END); bookmarkBuilder.append(BookmarkPage.END);
FileWriter bookWriter = null; FileWriter bookWriter = null;
try { try {
//noinspection IOResourceOpenedButNotSafelyClosed
bookWriter = new FileWriter(bookmarkWebPage, false); bookWriter = new FileWriter(bookmarkWebPage, false);
bookWriter.write(bookmarkBuilder.toString()); bookWriter.write(bookmarkBuilder.toString());
} catch (IOException e) { } catch (IOException e) {

1
app/src/main/java/acr/browser/lightning/constant/HistoryPage.java

@ -55,6 +55,7 @@ public class HistoryPage {
File historyWebPage = new File(context.getFilesDir(), FILENAME); File historyWebPage = new File(context.getFilesDir(), FILENAME);
FileWriter historyWriter = null; FileWriter historyWriter = null;
try { try {
//noinspection IOResourceOpenedButNotSafelyClosed
historyWriter = new FileWriter(historyWebPage, false); historyWriter = new FileWriter(historyWebPage, false);
historyWriter.write(historyBuilder.toString()); historyWriter.write(historyBuilder.toString());
} catch (IOException e) { } catch (IOException e) {

1
app/src/main/java/acr/browser/lightning/constant/StartPage.java

@ -139,6 +139,7 @@ public class StartPage {
File homepage = new File(activity.getFilesDir(), StartPage.FILENAME); File homepage = new File(activity.getFilesDir(), StartPage.FILENAME);
FileWriter hWriter = null; FileWriter hWriter = null;
try { try {
//noinspection IOResourceOpenedButNotSafelyClosed
hWriter = new FileWriter(homepage, false); hWriter = new FileWriter(homepage, false);
hWriter.write(homepageBuilder.toString()); hWriter.write(homepageBuilder.toString());
} catch (IOException e) { } catch (IOException e) {

7
app/src/main/java/acr/browser/lightning/database/BookmarkManager.java

@ -104,10 +104,12 @@ public class BookmarkManager {
InputStream inputStream = null; InputStream inputStream = null;
try { try {
if (bookmarksFile.exists() && bookmarksFile.isFile()) { if (bookmarksFile.exists() && bookmarksFile.isFile()) {
//noinspection IOResourceOpenedButNotSafelyClosed
inputStream = new FileInputStream(bookmarksFile); inputStream = new FileInputStream(bookmarksFile);
} else { } else {
inputStream = mContext.getResources().openRawResource(R.raw.default_bookmarks); inputStream = mContext.getResources().openRawResource(R.raw.default_bookmarks);
} }
//noinspection IOResourceOpenedButNotSafelyClosed
bookmarksReader = new BufferedReader(new InputStreamReader(inputStream)); bookmarksReader = new BufferedReader(new InputStreamReader(inputStream));
String line; String line;
while ((line = bookmarksReader.readLine()) != null) { while ((line = bookmarksReader.readLine()) != null) {
@ -157,6 +159,7 @@ public class BookmarkManager {
boolean success = false; boolean success = false;
BufferedWriter bookmarkWriter = null; BufferedWriter bookmarkWriter = null;
try { try {
//noinspection IOResourceOpenedButNotSafelyClosed
bookmarkWriter = new BufferedWriter(new FileWriter(tempFile, false)); bookmarkWriter = new BufferedWriter(new FileWriter(tempFile, false));
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
for (HistoryItem item : mBookmarks) { for (HistoryItem item : mBookmarks) {
@ -331,6 +334,7 @@ public class BookmarkManager {
} }
BufferedWriter bookmarkWriter = null; BufferedWriter bookmarkWriter = null;
try { try {
//noinspection IOResourceOpenedButNotSafelyClosed
bookmarkWriter = new BufferedWriter(new FileWriter(bookmarksExport, bookmarkWriter = new BufferedWriter(new FileWriter(bookmarksExport,
false)); false));
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
@ -483,6 +487,7 @@ public class BookmarkManager {
List<HistoryItem> list = new ArrayList<>(); List<HistoryItem> list = new ArrayList<>();
BufferedReader bookmarksReader = null; BufferedReader bookmarksReader = null;
try { try {
//noinspection IOResourceOpenedButNotSafelyClosed
bookmarksReader = new BufferedReader(new FileReader(file)); bookmarksReader = new BufferedReader(new FileReader(file));
String line; String line;
int number = 0; int number = 0;
@ -526,7 +531,7 @@ public class BookmarkManager {
/** /**
* This class sorts bookmarks alphabetically, with folders coming after bookmarks * This class sorts bookmarks alphabetically, with folders coming after bookmarks
*/ */
public static class SortIgnoreCase implements Comparator<HistoryItem> { private static class SortIgnoreCase implements Comparator<HistoryItem> {
public int compare(HistoryItem o1, HistoryItem o2) { public int compare(HistoryItem o1, HistoryItem o2) {
if (o1 == null || o2 == null || o1.getTitle() == null || o2.getTitle() == null) { if (o1 == null || o2 == null || o1.getTitle() == null || o2.getTitle() == null) {

2
app/src/main/java/acr/browser/lightning/database/HistoryDatabase.java

@ -13,8 +13,6 @@ import android.support.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;

2
app/src/main/java/acr/browser/lightning/download/DownloadHandler.java

@ -148,7 +148,7 @@ public class DownloadHandler {
msg = context.getString(R.string.download_sdcard_busy_dlg_msg); msg = context.getString(R.string.download_sdcard_busy_dlg_msg);
title = R.string.download_sdcard_busy_dlg_title; title = R.string.download_sdcard_busy_dlg_title;
} else { } else {
msg = context.getString(R.string.download_no_sdcard_dlg_msg, filename); msg = context.getString(R.string.download_no_sdcard_dlg_msg);
title = R.string.download_no_sdcard_dlg_title; title = R.string.download_no_sdcard_dlg_title;
} }

7
app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java

@ -50,9 +50,6 @@ import acr.browser.lightning.async.ImageDownloadTask;
import acr.browser.lightning.utils.ThemeUtils; import acr.browser.lightning.utils.ThemeUtils;
import acr.browser.lightning.view.LightningView; import acr.browser.lightning.view.LightningView;
/**
* Created by Stefano Pacifici on 25/08/15. Based on Anthony C. Restaino's code.
*/
public class BookmarksFragment extends Fragment implements View.OnClickListener, View.OnLongClickListener { public class BookmarksFragment extends Fragment implements View.OnClickListener, View.OnLongClickListener {
private final static String TAG = BookmarksFragment.class.getSimpleName(); private final static String TAG = BookmarksFragment.class.getSimpleName();
@ -136,7 +133,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
@Override @Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
final HistoryItem item = mBookmarks.get(position); final HistoryItem item = mBookmarks.get(position);
handleLongPress(item, position); handleLongPress(item);
return true; return true;
} }
}; };
@ -297,7 +294,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
buttonImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN); buttonImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
} }
private void handleLongPress(final HistoryItem item, final int position) { private void handleLongPress(final HistoryItem item) {
if (item.isFolder()) { if (item.isFolder()) {
mBookmarksDialogBuilder.showBookmarkFolderLongPressedDialog(getContext(), item); mBookmarksDialogBuilder.showBookmarkFolderLongPressedDialog(getContext(), item);
} else { } else {

16
app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java

@ -3,6 +3,7 @@
*/ */
package acr.browser.lightning.fragment; package acr.browser.lightning.fragment;
import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.os.Build; import android.os.Build;
@ -49,7 +50,6 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme
private String mDownloadLocation; private String mDownloadLocation;
private int mAgentChoice; private int mAgentChoice;
private String mHomepage; private String mHomepage;
private CheckBoxPreference cbFlash, cbAds, cbImages, cbJsScript, cbColorMode, cbgooglesuggest, cbDrawerTabs;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -69,13 +69,13 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme
home = findPreference(SETTINGS_HOME); home = findPreference(SETTINGS_HOME);
searchengine = findPreference(SETTINGS_SEARCHENGINE); searchengine = findPreference(SETTINGS_SEARCHENGINE);
cbFlash = (CheckBoxPreference) findPreference(SETTINGS_FLASH); CheckBoxPreference cbFlash = (CheckBoxPreference) findPreference(SETTINGS_FLASH);
cbAds = (CheckBoxPreference) findPreference(SETTINGS_ADS); CheckBoxPreference cbAds = (CheckBoxPreference) findPreference(SETTINGS_ADS);
cbImages = (CheckBoxPreference) findPreference(SETTINGS_IMAGES); CheckBoxPreference cbImages = (CheckBoxPreference) findPreference(SETTINGS_IMAGES);
cbJsScript = (CheckBoxPreference) findPreference(SETTINGS_JAVASCRIPT); CheckBoxPreference cbJsScript = (CheckBoxPreference) findPreference(SETTINGS_JAVASCRIPT);
cbColorMode = (CheckBoxPreference) findPreference(SETTINGS_COLORMODE); CheckBoxPreference cbColorMode = (CheckBoxPreference) findPreference(SETTINGS_COLORMODE);
cbgooglesuggest = (CheckBoxPreference) findPreference(SETTINGS_GOOGLESUGGESTIONS); CheckBoxPreference cbgooglesuggest = (CheckBoxPreference) findPreference(SETTINGS_GOOGLESUGGESTIONS);
cbDrawerTabs = (CheckBoxPreference) findPreference(SETTINGS_DRAWERTABS); CheckBoxPreference cbDrawerTabs = (CheckBoxPreference) findPreference(SETTINGS_DRAWERTABS);
proxy.setOnPreferenceClickListener(this); proxy.setOnPreferenceClickListener(this);
useragent.setOnPreferenceClickListener(this); useragent.setOnPreferenceClickListener(this);

1
app/src/main/java/acr/browser/lightning/object/SearchAdapter.java

@ -398,6 +398,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
in = connection.getInputStream(); in = connection.getInputStream();
if (in != null) { if (in != null) {
//noinspection IOResourceOpenedButNotSafelyClosed
fos = new FileOutputStream(cacheFile); fos = new FileOutputStream(cacheFile);
int buffer; int buffer;
while ((buffer = in.read()) != -1) { while ((buffer = in.read()) != -1) {

2
app/src/main/java/acr/browser/lightning/reading/HtmlFetcher.java

@ -55,6 +55,7 @@ public class HtmlFetcher {
BufferedWriter writer = null; BufferedWriter writer = null;
try { try {
//noinspection IOResourceOpenedButNotSafelyClosed
reader = new BufferedReader(new FileReader("urls.txt")); reader = new BufferedReader(new FileReader("urls.txt"));
String line; String line;
Set<String> existing = new LinkedHashSet<>(); Set<String> existing = new LinkedHashSet<>();
@ -72,6 +73,7 @@ public class HtmlFetcher {
String html = new HtmlFetcher().fetchAsString(url, 2000); String html = new HtmlFetcher().fetchAsString(url, 2000);
String outFile = domainStr + counterStr + ".html"; String outFile = domainStr + counterStr + ".html";
//noinspection IOResourceOpenedButNotSafelyClosed
writer = new BufferedWriter(new FileWriter(outFile)); writer = new BufferedWriter(new FileWriter(outFile));
writer.write(html); writer.write(html);
} }

2
app/src/main/java/acr/browser/lightning/utils/AdBlock.java

@ -59,6 +59,7 @@ public class AdBlock {
AssetManager asset = context.getAssets(); AssetManager asset = context.getAssets();
BufferedReader reader = null; BufferedReader reader = null;
try { try {
//noinspection IOResourceOpenedButNotSafelyClosed
reader = new BufferedReader(new InputStreamReader( reader = new BufferedReader(new InputStreamReader(
asset.open(BLOCKED_DOMAINS_LIST_FILE_NAME))); asset.open(BLOCKED_DOMAINS_LIST_FILE_NAME)));
String line; String line;
@ -139,6 +140,7 @@ public class AdBlock {
AssetManager asset = context.getAssets(); AssetManager asset = context.getAssets();
BufferedReader reader = null; BufferedReader reader = null;
try { try {
//noinspection IOResourceOpenedButNotSafelyClosed
reader = new BufferedReader(new InputStreamReader( reader = new BufferedReader(new InputStreamReader(
asset.open(BLOCKED_DOMAINS_LIST_FILE_NAME))); asset.open(BLOCKED_DOMAINS_LIST_FILE_NAME)));
String line; String line;

4
app/src/main/java/acr/browser/lightning/view/LightningView.java

@ -61,7 +61,7 @@ public class LightningView {
public static final String HEADER_REQUESTED_WITH = "X-Requested-With"; public static final String HEADER_REQUESTED_WITH = "X-Requested-With";
public static final String HEADER_WAP_PROFILE = "X-Wap-Profile"; public static final String HEADER_WAP_PROFILE = "X-Wap-Profile";
public static final String HEADER_DNT = "DNT"; private static final String HEADER_DNT = "DNT";
final LightningViewTitle mTitle; final LightningViewTitle mTitle;
private WebView mWebView; private WebView mWebView;
@ -433,7 +433,7 @@ public class LightningView {
} }
@NonNull @NonNull
protected Map<String, String> getRequestHeaders() { Map<String, String> getRequestHeaders() {
return mRequestHeaders; return mRequestHeaders;
} }

Loading…
Cancel
Save