diff --git a/app/build.gradle b/app/build.gradle index b2fa505..cc94151 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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 { 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 { 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' diff --git a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java b/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java index 4c298a3..3cb142d 100644 --- a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java +++ b/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"); } - 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 return true; } - public void closeBrowser() { + void closeBrowser() { mBrowserFrame.setBackgroundColor(mBackgroundColor); performExitCleanUp(); mTabsManager.shutdown(); diff --git a/app/src/main/java/acr/browser/lightning/activity/TabsManager.java b/app/src/main/java/acr/browser/lightning/activity/TabsManager.java index 1d5cdfd..6e866eb 100644 --- a/app/src/main/java/acr/browser/lightning/activity/TabsManager.java +++ b/app/src/main/java/acr/browser/lightning/activity/TabsManager.java @@ -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 { * 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 { } tab.onDestroy(); Log.d(Constants.TAG, tab.toString()); - return tab; } public synchronized void deleteTab(int position) { diff --git a/app/src/main/java/acr/browser/lightning/app/AppComponent.java b/app/src/main/java/acr/browser/lightning/app/AppComponent.java index 6be83ca..4ccd906 100644 --- a/app/src/main/java/acr/browser/lightning/app/AppComponent.java +++ b/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 dagger.Component; -/** - * Created by Stefano Pacifici on 01/09/15. - */ @Singleton @Component(modules = {AppModule.class}) public interface AppComponent { diff --git a/app/src/main/java/acr/browser/lightning/app/AppModule.java b/app/src/main/java/acr/browser/lightning/app/AppModule.java index d273880..6eabb69 100644 --- a/app/src/main/java/acr/browser/lightning/app/AppModule.java +++ b/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.Provides; -/** - * Created by Stefano Pacifici on 01/09/15. - */ @Module public class AppModule { private final BrowserApp app; diff --git a/app/src/main/java/acr/browser/lightning/app/BrowserApp.java b/app/src/main/java/acr/browser/lightning/app/BrowserApp.java index 7c1020b..72712b7 100644 --- a/app/src/main/java/acr/browser/lightning/app/BrowserApp.java +++ b/app/src/main/java/acr/browser/lightning/app/BrowserApp.java @@ -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 { 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() { diff --git a/app/src/main/java/acr/browser/lightning/bus/BookmarkEvents.java b/app/src/main/java/acr/browser/lightning/bus/BookmarkEvents.java index 4306ca8..20c10e5 100644 --- a/app/src/main/java/acr/browser/lightning/bus/BookmarkEvents.java +++ b/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; -/** - * Created by Stefano Pacifici on 26/08/15. - */ public final class BookmarkEvents { private BookmarkEvents() { diff --git a/app/src/main/java/acr/browser/lightning/bus/BrowserEvents.java b/app/src/main/java/acr/browser/lightning/bus/BrowserEvents.java index 9f2a0cd..2a363ec 100644 --- a/app/src/main/java/acr/browser/lightning/bus/BrowserEvents.java +++ b/app/src/main/java/acr/browser/lightning/bus/BrowserEvents.java @@ -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() { diff --git a/app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java b/app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java index e3bbda2..ec8b2ba 100644 --- a/app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java +++ b/app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java @@ -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) { diff --git a/app/src/main/java/acr/browser/lightning/constant/HistoryPage.java b/app/src/main/java/acr/browser/lightning/constant/HistoryPage.java index 2dcacf3..faf4040 100644 --- a/app/src/main/java/acr/browser/lightning/constant/HistoryPage.java +++ b/app/src/main/java/acr/browser/lightning/constant/HistoryPage.java @@ -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) { diff --git a/app/src/main/java/acr/browser/lightning/constant/StartPage.java b/app/src/main/java/acr/browser/lightning/constant/StartPage.java index 51bef32..9d7e7d5 100644 --- a/app/src/main/java/acr/browser/lightning/constant/StartPage.java +++ b/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); FileWriter hWriter = null; try { + //noinspection IOResourceOpenedButNotSafelyClosed hWriter = new FileWriter(homepage, false); hWriter.write(homepageBuilder.toString()); } catch (IOException e) { diff --git a/app/src/main/java/acr/browser/lightning/database/BookmarkManager.java b/app/src/main/java/acr/browser/lightning/database/BookmarkManager.java index 3790146..d4ed5b3 100644 --- a/app/src/main/java/acr/browser/lightning/database/BookmarkManager.java +++ b/app/src/main/java/acr/browser/lightning/database/BookmarkManager.java @@ -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 { 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 { } BufferedWriter bookmarkWriter = null; try { + //noinspection IOResourceOpenedButNotSafelyClosed bookmarkWriter = new BufferedWriter(new FileWriter(bookmarksExport, false)); JSONObject object = new JSONObject(); @@ -483,6 +487,7 @@ public class BookmarkManager { List 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 { /** * This class sorts bookmarks alphabetically, with folders coming after bookmarks */ - public static class SortIgnoreCase implements Comparator { + private static class SortIgnoreCase implements Comparator { public int compare(HistoryItem o1, HistoryItem o2) { if (o1 == null || o2 == null || o1.getTitle() == null || o2.getTitle() == null) { diff --git a/app/src/main/java/acr/browser/lightning/database/HistoryDatabase.java b/app/src/main/java/acr/browser/lightning/database/HistoryDatabase.java index a8b09c0..bc1895d 100644 --- a/app/src/main/java/acr/browser/lightning/database/HistoryDatabase.java +++ b/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.List; -import java.util.concurrent.Executor; -import java.util.concurrent.Executors; import javax.inject.Inject; import javax.inject.Singleton; diff --git a/app/src/main/java/acr/browser/lightning/download/DownloadHandler.java b/app/src/main/java/acr/browser/lightning/download/DownloadHandler.java index 6f7fda2..fcb9388 100644 --- a/app/src/main/java/acr/browser/lightning/download/DownloadHandler.java +++ b/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); 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; } diff --git a/app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java b/app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java index e7ffb88..c1537d2 100644 --- a/app/src/main/java/acr/browser/lightning/fragment/BookmarksFragment.java +++ b/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.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, @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, 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 { diff --git a/app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java b/app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java index c5c95c8..6372266 100644 --- a/app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java +++ b/app/src/main/java/acr/browser/lightning/fragment/GeneralSettingsFragment.java @@ -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 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 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); diff --git a/app/src/main/java/acr/browser/lightning/object/SearchAdapter.java b/app/src/main/java/acr/browser/lightning/object/SearchAdapter.java index 6f89cd3..6e3b7a2 100644 --- a/app/src/main/java/acr/browser/lightning/object/SearchAdapter.java +++ b/app/src/main/java/acr/browser/lightning/object/SearchAdapter.java @@ -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) { diff --git a/app/src/main/java/acr/browser/lightning/reading/HtmlFetcher.java b/app/src/main/java/acr/browser/lightning/reading/HtmlFetcher.java index c6d7a8b..85a1862 100644 --- a/app/src/main/java/acr/browser/lightning/reading/HtmlFetcher.java +++ b/app/src/main/java/acr/browser/lightning/reading/HtmlFetcher.java @@ -55,6 +55,7 @@ public class HtmlFetcher { BufferedWriter writer = null; try { + //noinspection IOResourceOpenedButNotSafelyClosed reader = new BufferedReader(new FileReader("urls.txt")); String line; Set existing = new LinkedHashSet<>(); @@ -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); } diff --git a/app/src/main/java/acr/browser/lightning/utils/AdBlock.java b/app/src/main/java/acr/browser/lightning/utils/AdBlock.java index a7d6b82..be1f78f 100644 --- a/app/src/main/java/acr/browser/lightning/utils/AdBlock.java +++ b/app/src/main/java/acr/browser/lightning/utils/AdBlock.java @@ -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 { AssetManager asset = context.getAssets(); BufferedReader reader = null; try { + //noinspection IOResourceOpenedButNotSafelyClosed reader = new BufferedReader(new InputStreamReader( asset.open(BLOCKED_DOMAINS_LIST_FILE_NAME))); String line; diff --git a/app/src/main/java/acr/browser/lightning/view/LightningView.java b/app/src/main/java/acr/browser/lightning/view/LightningView.java index 495cfc8..1ba97fc 100644 --- a/app/src/main/java/acr/browser/lightning/view/LightningView.java +++ b/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_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 { } @NonNull - protected Map getRequestHeaders() { + Map getRequestHeaders() { return mRequestHeaders; }