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' @@ -4,7 +4,7 @@ apply plugin: 'com.getkeepsafe.dexcount'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
@ -69,8 +69,8 @@ dependencies { @@ -69,8 +69,8 @@ dependencies {
compile 'com.squareup:otto:1.3.8'
// dependency injection
compile 'com.google.dagger:dagger:2.0.1'
apt 'com.google.dagger:dagger-compiler:2.0.1'
compile 'com.google.dagger:dagger:2.0.2'
apt 'com.google.dagger:dagger-compiler:2.0.2'
// view binding
compile 'com.jakewharton:butterknife:7.0.1'
@ -86,8 +86,8 @@ dependencies { @@ -86,8 +86,8 @@ dependencies {
compile(project(':libnetcipher'))
// memory leak analysis
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-SNAPSHOT'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-SNAPSHOT'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'
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 @@ -1068,7 +1068,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
Log.d(Constants.TAG, "deleted tab");
}
public void performExitCleanUp() {
void performExitCleanUp() {
final LightningView currentTab = mTabsManager.getCurrentTab();
if (mPreferences.getClearCacheExit() && currentTab != null && !isIncognito()) {
WebUtils.clearCache(currentTab.getWebView());
@ -1099,7 +1099,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -1099,7 +1099,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
return true;
}
public void closeBrowser() {
void closeBrowser() {
mBrowserFrame.setBackgroundColor(mBackgroundColor);
performExitCleanUp();
mTabsManager.shutdown();

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

@ -18,10 +18,8 @@ import javax.inject.Inject; @@ -18,10 +18,8 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import acr.browser.lightning.R;
import acr.browser.lightning.bus.BrowserEvents;
import acr.browser.lightning.constant.Constants;
import acr.browser.lightning.preference.PreferenceManager;
import acr.browser.lightning.utils.UrlUtils;
import acr.browser.lightning.utils.Utils;
import acr.browser.lightning.view.LightningView;
@ -186,12 +184,11 @@ public class TabsManager { @@ -186,12 +184,11 @@ public class TabsManager {
* 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
* @return The removed tab reference or null
*/
@Nullable
private synchronized LightningView removeTab(final int position) {
private synchronized void removeTab(final int position) {
if (position >= mWebViewList.size()) {
return null;
return;
}
final LightningView tab = mWebViewList.remove(position);
if (mCurrentTab == tab) {
@ -199,7 +196,6 @@ public class TabsManager { @@ -199,7 +196,6 @@ public class TabsManager {
}
tab.onDestroy();
Log.d(Constants.TAG, tab.toString());
return tab;
}
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; @@ -20,9 +20,6 @@ import acr.browser.lightning.preference.PreferenceManager;
import acr.browser.lightning.view.LightningView;
import dagger.Component;
/**
* Created by Stefano Pacifici on 01/09/15.
*/
@Singleton
@Component(modules = {AppModule.class})
public interface AppComponent {

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -104,10 +104,12 @@ public class BookmarkManager { @@ -104,10 +104,12 @@ public class BookmarkManager {
InputStream inputStream = null;
try {
if (bookmarksFile.exists() && bookmarksFile.isFile()) {
//noinspection IOResourceOpenedButNotSafelyClosed
inputStream = new FileInputStream(bookmarksFile);
} else {
inputStream = mContext.getResources().openRawResource(R.raw.default_bookmarks);
}
//noinspection IOResourceOpenedButNotSafelyClosed
bookmarksReader = new BufferedReader(new InputStreamReader(inputStream));
String line;
while ((line = bookmarksReader.readLine()) != null) {
@ -157,6 +159,7 @@ public class BookmarkManager { @@ -157,6 +159,7 @@ public class BookmarkManager {
boolean success = false;
BufferedWriter bookmarkWriter = null;
try {
//noinspection IOResourceOpenedButNotSafelyClosed
bookmarkWriter = new BufferedWriter(new FileWriter(tempFile, false));
JSONObject object = new JSONObject();
for (HistoryItem item : mBookmarks) {
@ -331,6 +334,7 @@ public class BookmarkManager { @@ -331,6 +334,7 @@ public class BookmarkManager {
}
BufferedWriter bookmarkWriter = null;
try {
//noinspection IOResourceOpenedButNotSafelyClosed
bookmarkWriter = new BufferedWriter(new FileWriter(bookmarksExport,
false));
JSONObject object = new JSONObject();
@ -483,6 +487,7 @@ public class BookmarkManager { @@ -483,6 +487,7 @@ public class BookmarkManager {
List<HistoryItem> list = new ArrayList<>();
BufferedReader bookmarksReader = null;
try {
//noinspection IOResourceOpenedButNotSafelyClosed
bookmarksReader = new BufferedReader(new FileReader(file));
String line;
int number = 0;
@ -526,7 +531,7 @@ public class BookmarkManager { @@ -526,7 +531,7 @@ public class BookmarkManager {
/**
* 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) {
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; @@ -13,8 +13,6 @@ import android.support.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import javax.inject.Inject;
import javax.inject.Singleton;

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

@ -148,7 +148,7 @@ public class DownloadHandler { @@ -148,7 +148,7 @@ public class DownloadHandler {
msg = context.getString(R.string.download_sdcard_busy_dlg_msg);
title = R.string.download_sdcard_busy_dlg_title;
} 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;
}

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

@ -50,9 +50,6 @@ import acr.browser.lightning.async.ImageDownloadTask; @@ -50,9 +50,6 @@ import acr.browser.lightning.async.ImageDownloadTask;
import acr.browser.lightning.utils.ThemeUtils;
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 {
private final static String TAG = BookmarksFragment.class.getSimpleName();
@ -136,7 +133,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener, @@ -136,7 +133,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
final HistoryItem item = mBookmarks.get(position);
handleLongPress(item, position);
handleLongPress(item);
return true;
}
};
@ -297,7 +294,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener, @@ -297,7 +294,7 @@ public class BookmarksFragment extends Fragment implements View.OnClickListener,
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()) {
mBookmarksDialogBuilder.showBookmarkFolderLongPressedDialog(getContext(), item);
} else {

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

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
*/
package acr.browser.lightning.fragment;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.DialogInterface;
import android.os.Build;
@ -49,7 +50,6 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme @@ -49,7 +50,6 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme
private String mDownloadLocation;
private int mAgentChoice;
private String mHomepage;
private CheckBoxPreference cbFlash, cbAds, cbImages, cbJsScript, cbColorMode, cbgooglesuggest, cbDrawerTabs;
@Override
public void onCreate(Bundle savedInstanceState) {
@ -69,13 +69,13 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme @@ -69,13 +69,13 @@ public class GeneralSettingsFragment extends LightningPreferenceFragment impleme
home = findPreference(SETTINGS_HOME);
searchengine = findPreference(SETTINGS_SEARCHENGINE);
cbFlash = (CheckBoxPreference) findPreference(SETTINGS_FLASH);
cbAds = (CheckBoxPreference) findPreference(SETTINGS_ADS);
cbImages = (CheckBoxPreference) findPreference(SETTINGS_IMAGES);
cbJsScript = (CheckBoxPreference) findPreference(SETTINGS_JAVASCRIPT);
cbColorMode = (CheckBoxPreference) findPreference(SETTINGS_COLORMODE);
cbgooglesuggest = (CheckBoxPreference) findPreference(SETTINGS_GOOGLESUGGESTIONS);
cbDrawerTabs = (CheckBoxPreference) findPreference(SETTINGS_DRAWERTABS);
CheckBoxPreference cbFlash = (CheckBoxPreference) findPreference(SETTINGS_FLASH);
CheckBoxPreference cbAds = (CheckBoxPreference) findPreference(SETTINGS_ADS);
CheckBoxPreference cbImages = (CheckBoxPreference) findPreference(SETTINGS_IMAGES);
CheckBoxPreference cbJsScript = (CheckBoxPreference) findPreference(SETTINGS_JAVASCRIPT);
CheckBoxPreference cbColorMode = (CheckBoxPreference) findPreference(SETTINGS_COLORMODE);
CheckBoxPreference cbgooglesuggest = (CheckBoxPreference) findPreference(SETTINGS_GOOGLESUGGESTIONS);
CheckBoxPreference cbDrawerTabs = (CheckBoxPreference) findPreference(SETTINGS_DRAWERTABS);
proxy.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 { @@ -398,6 +398,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
in = connection.getInputStream();
if (in != null) {
//noinspection IOResourceOpenedButNotSafelyClosed
fos = new FileOutputStream(cacheFile);
int buffer;
while ((buffer = in.read()) != -1) {

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

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

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

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

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

@ -61,7 +61,7 @@ public class LightningView { @@ -61,7 +61,7 @@ public class LightningView {
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_DNT = "DNT";
private static final String HEADER_DNT = "DNT";
final LightningViewTitle mTitle;
private WebView mWebView;
@ -433,7 +433,7 @@ public class LightningView { @@ -433,7 +433,7 @@ public class LightningView {
}
@NonNull
protected Map<String, String> getRequestHeaders() {
Map<String, String> getRequestHeaders() {
return mRequestHeaders;
}

Loading…
Cancel
Save