diff --git a/app/app.iml b/app/app.iml index 9c6161c..2c475ab 100644 --- a/app/app.iml +++ b/app/app.iml @@ -8,14 +8,14 @@ - - - + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -69,9 +90,9 @@ - - - + + + @@ -89,11 +110,11 @@ - - + + + + - - \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 825b670..57776ec 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -49,7 +49,7 @@ dependencies { exclude module: 'support-v4' exclude module: 'android-support-v4' } - compile 'com.android.support:palette-v7:22.1.1' - compile 'com.android.support:appcompat-v7:22.1.1' + compile 'com.android.support:palette-v7:22.2.0' + compile 'com.android.support:appcompat-v7:22.2.0' compile 'org.jsoup:jsoup:1.8.1' } 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 7092f7e..68b2e12 100644 --- a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java +++ b/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java @@ -634,7 +634,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll } } - public void initializePreferences() { + private void initializePreferences() { if (mPreferences == null) { mPreferences = PreferenceManager.getInstance(); } @@ -1012,7 +1012,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll * @param id * which id in the list was chosen */ - public synchronized void editBookmark(final int id) { + private synchronized void editBookmark(final int id) { final AlertDialog.Builder homePicker = new AlertDialog.Builder(mActivity); homePicker.setTitle(getResources().getString(R.string.title_edit_bookmark)); final EditText getTitle = new EditText(mActivity); @@ -1287,7 +1287,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll } @SuppressWarnings("deprecation") - public void clearHistory() { + private void clearHistory() { this.deleteDatabase(HistoryDatabase.DATABASE_NAME); WebViewDatabase m = WebViewDatabase.getInstance(this); m.clearFormData(); @@ -1307,7 +1307,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll @SuppressLint("NewApi") @SuppressWarnings("deprecation") - public void clearCookies() { + private void clearCookies() { // TODO Break out web storage deletion into its own option/action // TODO clear web storage for all sites that are visited in Incognito mode WebStorage storage = WebStorage.getInstance(); @@ -1413,7 +1413,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll * searches the web for the query fixing any and all problems with the input * checks if it is a search, url, etc. */ - void searchTheWeb(String query) { + private void searchTheWeb(String query) { if (query.equals("")) { return; } @@ -1556,8 +1556,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll int finalColor; // Lighten up the dark color if it is // too dark - if (isColorTooDark(color)) { - finalColor = mixTwoColors( + if (Utils.isColorTooDark(color)) { + finalColor = Utils.mixTwoColors( mActivity.getResources().getColor(R.color.primary_color), color, 0.25f); } else { @@ -1586,35 +1586,6 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll }); } - public static boolean isColorTooDark(int color) { - final byte RED_CHANNEL = 16; - final byte GREEN_CHANNEL = 8; - //final byte BLUE_CHANNEL = 0; - - int r = ((int) ((float) (color >> RED_CHANNEL & 0xff) * 0.3f)) & 0xff; - int g = ((int) ((float) (color >> GREEN_CHANNEL & 0xff) * 0.59)) & 0xff; - int b = ((int) ((float) (color & 0xff) * 0.11)) & 0xff; - int gr = (r + g + b) & 0xff; - int gray = gr + (gr << GREEN_CHANNEL) + (gr << RED_CHANNEL); - - return gray < 0x727272; - } - - public static int mixTwoColors(int color1, int color2, float amount) { - final byte ALPHA_CHANNEL = 24; - final byte RED_CHANNEL = 16; - final byte GREEN_CHANNEL = 8; - //final byte BLUE_CHANNEL = 0; - - final float inverseAmount = 1.0f - amount; - - int r = ((int) (((float) (color1 >> RED_CHANNEL & 0xff) * amount) + ((float) (color2 >> RED_CHANNEL & 0xff) * inverseAmount))) & 0xff; - int g = ((int) (((float) (color1 >> GREEN_CHANNEL & 0xff) * amount) + ((float) (color2 >> GREEN_CHANNEL & 0xff) * inverseAmount))) & 0xff; - int b = ((int) (((float) (color1 & 0xff) * amount) + ((float) (color2 & 0xff) * inverseAmount))) & 0xff; - - return 0xff << ALPHA_CHANNEL | r << RED_CHANNEL | g << GREEN_CHANNEL | b; - } - public class BookmarkViewAdapter extends ArrayAdapter { final Context context; @@ -1758,7 +1729,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll } } - static String getDomainName(String url) throws URISyntaxException { + private static String getDomainName(String url) throws URISyntaxException { URI uri = new URI(url); String domain = uri.getHost(); if (domain == null) { @@ -1843,11 +1814,11 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll } } - public boolean isSystemBrowserAvailable() { + private boolean isSystemBrowserAvailable() { return mSystemBrowser; } - public boolean getSystemBrowser() { + private boolean getSystemBrowser() { Cursor c = null; String[] columns = new String[] { "url", "title" }; boolean browserFlag; @@ -2194,7 +2165,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll * @param enabled * whether to enable fullscreen or not */ - public void setFullscreen(boolean enabled) { + private void setFullscreen(boolean enabled) { Window win = getWindow(); WindowManager.LayoutParams winParams = win.getAttributes(); final int bits = WindowManager.LayoutParams.FLAG_FULLSCREEN; @@ -2559,7 +2530,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll * and that it should display the stop icon to indicate to the user that * pressing it stops the page from loading */ - public void setIsLoading() { + private void setIsLoading() { if (!mSearch.hasFocus()) { mIcon = mDeleteIcon; mSearch.setCompoundDrawables(null, null, mDeleteIcon, null); @@ -2570,7 +2541,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll * This tells the search bar that the page is finished loading and it should * display the refresh icon */ - public void setIsFinishedLoading() { + private void setIsFinishedLoading() { if (!mSearch.hasFocus()) { mIcon = mRefreshIcon; mSearch.setCompoundDrawables(null, null, mRefreshIcon, null); @@ -2583,7 +2554,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll * * See setIsFinishedLoading and setIsLoading for displaying the correct icon */ - public void refreshOrStop() { + private void refreshOrStop() { if (mCurrentView != null) { if (mCurrentView.getProgress() < 100) { mCurrentView.stopLoading(); @@ -2598,7 +2569,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll finish(); } - public class SortIgnoreCase implements Comparator { + private class SortIgnoreCase implements Comparator { public int compare(HistoryItem o1, HistoryItem o2) { return o1.getTitle().toLowerCase(Locale.getDefault()) diff --git a/app/src/main/java/acr/browser/lightning/activity/IncognitoActivity.java b/app/src/main/java/acr/browser/lightning/activity/IncognitoActivity.java index 2595845..7be8e5c 100644 --- a/app/src/main/java/acr/browser/lightning/activity/IncognitoActivity.java +++ b/app/src/main/java/acr/browser/lightning/activity/IncognitoActivity.java @@ -13,7 +13,7 @@ import acr.browser.lightning.R; @SuppressWarnings("deprecation") public class IncognitoActivity extends BrowserActivity { - CookieManager mCookieManager; + private CookieManager mCookieManager; @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/app/src/main/java/acr/browser/lightning/activity/MainActivity.java b/app/src/main/java/acr/browser/lightning/activity/MainActivity.java index ab8d744..b465d69 100644 --- a/app/src/main/java/acr/browser/lightning/activity/MainActivity.java +++ b/app/src/main/java/acr/browser/lightning/activity/MainActivity.java @@ -13,7 +13,7 @@ import acr.browser.lightning.R; @SuppressWarnings("deprecation") public class MainActivity extends BrowserActivity { - CookieManager mCookieManager; + private CookieManager mCookieManager; @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/app/src/main/java/acr/browser/lightning/activity/PrivacySettingsActivity.java b/app/src/main/java/acr/browser/lightning/activity/PrivacySettingsActivity.java index 68220ef..958f901 100644 --- a/app/src/main/java/acr/browser/lightning/activity/PrivacySettingsActivity.java +++ b/app/src/main/java/acr/browser/lightning/activity/PrivacySettingsActivity.java @@ -403,7 +403,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity { } - public void clearCache() { + private void clearCache() { WebView webView = new WebView(this); webView.clearCache(true); webView.destroy(); @@ -411,7 +411,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity { } @SuppressWarnings("deprecation") - public void clearHistory() { + private void clearHistory() { deleteDatabase(HistoryDatabase.DATABASE_NAME); WebViewDatabase m = WebViewDatabase.getInstance(this); m.clearFormData(); @@ -431,7 +431,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity { } @SuppressWarnings("deprecation") - public void clearCookies() { + private void clearCookies() { // TODO Break out web storage deletion into its own option/action // TODO clear web storage for all sites that are visited in Incognito mode WebStorage storage = WebStorage.getInstance(); diff --git a/app/src/main/java/acr/browser/lightning/activity/ReadingActivity.java b/app/src/main/java/acr/browser/lightning/activity/ReadingActivity.java index 75bb05c..7ad73a8 100644 --- a/app/src/main/java/acr/browser/lightning/activity/ReadingActivity.java +++ b/app/src/main/java/acr/browser/lightning/activity/ReadingActivity.java @@ -140,7 +140,7 @@ public class ReadingActivity extends AppCompatActivity { HtmlFetcher fetcher = new HtmlFetcher(); try { - JResult result = fetcher.fetchAndExtract(params[0], 5000, true); + JResult result = fetcher.fetchAndExtract(params[0], 2500, true); mTitleText = result.getTitle(); mBodyText = result.getTextList(); } catch (Exception e) { diff --git a/app/src/main/java/acr/browser/lightning/activity/SettingsActivity.java b/app/src/main/java/acr/browser/lightning/activity/SettingsActivity.java index c5a8b92..78fc491 100644 --- a/app/src/main/java/acr/browser/lightning/activity/SettingsActivity.java +++ b/app/src/main/java/acr/browser/lightning/activity/SettingsActivity.java @@ -53,7 +53,7 @@ public class SettingsActivity extends ThemableSettingsActivity { } @SuppressLint("NewApi") - public void init() { + private void init() { // set up ActionBar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); 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 a12e8c4..0e20397 100644 --- a/app/src/main/java/acr/browser/lightning/database/HistoryDatabase.java +++ b/app/src/main/java/acr/browser/lightning/database/HistoryDatabase.java @@ -23,15 +23,15 @@ public class HistoryDatabase extends SQLiteOpenHelper { public static final String DATABASE_NAME = "historyManager"; // HistoryItems table name - public static final String TABLE_HISTORY = "history"; + private static final String TABLE_HISTORY = "history"; // HistoryItems Table Columns names - public static final String KEY_ID = "id"; - public static final String KEY_URL = "url"; - public static final String KEY_TITLE = "title"; - public static final String KEY_TIME_VISITED = "time"; + private static final String KEY_ID = "id"; + private static final String KEY_URL = "url"; + private static final String KEY_TITLE = "title"; + private static final String KEY_TIME_VISITED = "time"; - public static SQLiteDatabase mDatabase; + private static SQLiteDatabase mDatabase; private static HistoryDatabase mInstance; 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 58d49cc..81cf4da 100644 --- a/app/src/main/java/acr/browser/lightning/object/SearchAdapter.java +++ b/app/src/main/java/acr/browser/lightning/object/SearchAdapter.java @@ -224,7 +224,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable { return mFilter; } - public class SearchFilter extends Filter { + private class SearchFilter extends Filter { @Override protected FilterResults performFiltering(CharSequence constraint) { @@ -397,7 +397,8 @@ public class SearchAdapter extends BaseAdapter implements Filterable { return connectivity.getActiveNetworkInfo(); } - public List getSuggestions() { + //TODO Write simpler algorithm + private List getSuggestions() { List filteredList = new ArrayList<>(); int suggestionsSize = (mSuggestions == null) ? 0 : mSuggestions.size(); 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 81a62cc..f55542f 100644 --- a/app/src/main/java/acr/browser/lightning/reading/HtmlFetcher.java +++ b/app/src/main/java/acr/browser/lightning/reading/HtmlFetcher.java @@ -22,7 +22,6 @@ import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; -import java.net.MalformedURLException; import java.net.Proxy; import java.net.URL; import java.util.LinkedHashSet; diff --git a/app/src/main/java/acr/browser/lightning/reading/MapEntry.java b/app/src/main/java/acr/browser/lightning/reading/MapEntry.java index 6cf24a9..8325578 100644 --- a/app/src/main/java/acr/browser/lightning/reading/MapEntry.java +++ b/app/src/main/java/acr/browser/lightning/reading/MapEntry.java @@ -27,7 +27,7 @@ import java.util.Map; public class MapEntry implements Map.Entry, Serializable { private static final long serialVersionUID = 1L; - private K key; + private final K key; private V value; public MapEntry(K key, V value) { diff --git a/app/src/main/java/acr/browser/lightning/utils/Utils.java b/app/src/main/java/acr/browser/lightning/utils/Utils.java index fcc8af8..2dd93ef 100644 --- a/app/src/main/java/acr/browser/lightning/utils/Utils.java +++ b/app/src/main/java/acr/browser/lightning/utils/Utils.java @@ -63,11 +63,11 @@ public final class Utils { builder.setMessage(message) .setCancelable(true) .setPositiveButton(context.getResources().getString(R.string.action_ok), - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - } - }); + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) { + } + }); AlertDialog alert = builder.create(); alert.show(); } @@ -135,7 +135,7 @@ public final class Utils { } public static String[] getArray(String input) { - return input.split("\\|\\$\\|SEPARATOR\\|\\$\\|"); + return input.split(Constants.SEPARATOR); } public static void trimCache(Context context) { @@ -185,6 +185,35 @@ public final class Utils { return paddedBitmap; } + public static boolean isColorTooDark(int color) { + final byte RED_CHANNEL = 16; + final byte GREEN_CHANNEL = 8; + //final byte BLUE_CHANNEL = 0; + + int r = ((int) ((float) (color >> RED_CHANNEL & 0xff) * 0.3f)) & 0xff; + int g = ((int) ((float) (color >> GREEN_CHANNEL & 0xff) * 0.59)) & 0xff; + int b = ((int) ((float) (color /* >> BLUE_CHANNEL */ & 0xff) * 0.11)) & 0xff; + int gr = (r + g + b) & 0xff; + int gray = gr /* << BLUE_CHANNEL */ + (gr << GREEN_CHANNEL) + (gr << RED_CHANNEL); + + return gray < 0x727272; + } + + public static int mixTwoColors(int color1, int color2, float amount) { + final byte ALPHA_CHANNEL = 24; + final byte RED_CHANNEL = 16; + final byte GREEN_CHANNEL = 8; + //final byte BLUE_CHANNEL = 0; + + final float inverseAmount = 1.0f - amount; + + int r = ((int) (((float) (color1 >> RED_CHANNEL & 0xff) * amount) + ((float) (color2 >> RED_CHANNEL & 0xff) * inverseAmount))) & 0xff; + int g = ((int) (((float) (color1 >> GREEN_CHANNEL & 0xff) * amount) + ((float) (color2 >> GREEN_CHANNEL & 0xff) * inverseAmount))) & 0xff; + int b = ((int) (((float) (color1 & 0xff) * amount) + ((float) (color2 & 0xff) * inverseAmount))) & 0xff; + + return 0xff << ALPHA_CHANNEL | r << RED_CHANNEL | g << GREEN_CHANNEL | b; + } + @SuppressLint("SimpleDateFormat") public static File createImageFile() throws IOException { // Create an image file name 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 f50b87d..6d5ee30 100644 --- a/app/src/main/java/acr/browser/lightning/view/LightningView.java +++ b/app/src/main/java/acr/browser/lightning/view/LightningView.java @@ -150,7 +150,7 @@ public class LightningView { } } - public String getHomepage() { + private String getHomepage() { StringBuilder homepageBuilder = new StringBuilder(); homepageBuilder.append(StartPage.HEAD); String icon; @@ -362,7 +362,7 @@ public class LightningView { @SuppressWarnings("deprecation") @SuppressLint({ "SetJavaScriptEnabled", "NewApi" }) - public void initializeSettings(WebSettings settings, Context context) { + private void initializeSettings(WebSettings settings, Context context) { if (API < 18) { settings.setAppCacheMaxSize(Long.MAX_VALUE); } diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index 601a9d6..0000000 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ