Browse Source

Code cleanup

master
Anthony Restaino 10 years ago
parent
commit
b478c1ea98
  1. 77
      app/app.iml
  2. 4
      app/build.gradle
  3. 59
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  4. 2
      app/src/main/java/acr/browser/lightning/activity/IncognitoActivity.java
  5. 2
      app/src/main/java/acr/browser/lightning/activity/MainActivity.java
  6. 6
      app/src/main/java/acr/browser/lightning/activity/PrivacySettingsActivity.java
  7. 2
      app/src/main/java/acr/browser/lightning/activity/ReadingActivity.java
  8. 2
      app/src/main/java/acr/browser/lightning/activity/SettingsActivity.java
  9. 12
      app/src/main/java/acr/browser/lightning/database/HistoryDatabase.java
  10. 5
      app/src/main/java/acr/browser/lightning/object/SearchAdapter.java
  11. 1
      app/src/main/java/acr/browser/lightning/reading/HtmlFetcher.java
  12. 2
      app/src/main/java/acr/browser/lightning/reading/MapEntry.java
  13. 31
      app/src/main/java/acr/browser/lightning/utils/Utils.java
  14. 4
      app/src/main/java/acr/browser/lightning/view/LightningView.java
  15. BIN
      app/src/main/res/mipmap-mdpi/ic_launcher.png

77
app/app.iml

@ -8,14 +8,14 @@
</facet> </facet>
<facet type="android" name="Android"> <facet type="android" name="Android">
<configuration> <configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" /> <option name="SELECTED_BUILD_VARIANT" value="LightningPlusDebug" />
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" /> <option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" /> <option name="ASSEMBLE_TASK_NAME" value="assembleLightningPlusDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" /> <option name="COMPILE_JAVA_TASK_NAME" value="compileLightningPlusDebugSources" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" /> <option name="SOURCE_GEN_TASK_NAME" value="generateLightningPlusDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" /> <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleLightningPlusDebugAndroidTest" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" /> <option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileLightningPlusDebugAndroidTestSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" /> <option name="TEST_SOURCE_GEN_TASK_NAME" value="generateLightningPlusDebugAndroidTestSources" />
<option name="ALLOW_USER_CONFIGURATION" value="false" /> <option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" /> <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" /> <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
@ -25,22 +25,43 @@
</facet> </facet>
</component> </component>
<component name="NewModuleRootManager" inherit-compiler-output="false"> <component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" /> <output url="file://$MODULE_DIR$/build/intermediates/classes/LightningPlus/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" /> <output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/LightningPlus/debug" />
<exclude-output /> <exclude-output />
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/LightningPlus/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/LightningPlus/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/LightningPlus/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/LightningPlus/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/LightningPlus/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/LightningPlus/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/src/LightningPlusDebug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/src/LightningPlusDebug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/src/LightningPlusDebug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" /> <sourceFolder url="file://$MODULE_DIR$/src/LightningPlusDebug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/LightningPlusDebug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/androidTest/debug" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/LightningPlusDebug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlusDebug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/LightningPlus/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/LightningPlus/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/LightningPlus/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/LightningPlus/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/LightningPlus/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/androidTest/LightningPlus/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlus/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlus/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlus/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlus/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlus/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlus/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlus/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestLightningPlus/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestLightningPlus/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestLightningPlus/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestLightningPlus/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestLightningPlus/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestLightningPlus/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestLightningPlus/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
@ -69,9 +90,9 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.1.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/palette-v7/22.1.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/palette-v7/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.1.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
@ -89,11 +110,11 @@
</content> </content>
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" /> <orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="appcompat-v7-22.1.1" level="project" /> <orderEntry type="library" exported="" name="palette-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="palette-v7-22.1.1" level="project" /> <orderEntry type="library" exported="" name="support-v4-22.2.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.2.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-22.2.0" level="project" />
<orderEntry type="library" exported="" name="jsoup-1.8.1" level="project" /> <orderEntry type="library" exported="" name="jsoup-1.8.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.1.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.1.1" level="project" />
<orderEntry type="module" module-name="libnetcipher" exported="" /> <orderEntry type="module" module-name="libnetcipher" exported="" />
</component> </component>
</module> </module>

4
app/build.gradle

@ -49,7 +49,7 @@ dependencies {
exclude module: 'support-v4' exclude module: 'support-v4'
exclude module: 'android-support-v4' exclude module: 'android-support-v4'
} }
compile 'com.android.support:palette-v7:22.1.1' compile 'com.android.support:palette-v7:22.2.0'
compile 'com.android.support:appcompat-v7:22.1.1' compile 'com.android.support:appcompat-v7:22.2.0'
compile 'org.jsoup:jsoup:1.8.1' compile 'org.jsoup:jsoup:1.8.1'
} }

59
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) { if (mPreferences == null) {
mPreferences = PreferenceManager.getInstance(); mPreferences = PreferenceManager.getInstance();
} }
@ -1012,7 +1012,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
* @param id * @param id
* which id in the list was chosen * 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); final AlertDialog.Builder homePicker = new AlertDialog.Builder(mActivity);
homePicker.setTitle(getResources().getString(R.string.title_edit_bookmark)); homePicker.setTitle(getResources().getString(R.string.title_edit_bookmark));
final EditText getTitle = new EditText(mActivity); final EditText getTitle = new EditText(mActivity);
@ -1287,7 +1287,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void clearHistory() { private void clearHistory() {
this.deleteDatabase(HistoryDatabase.DATABASE_NAME); this.deleteDatabase(HistoryDatabase.DATABASE_NAME);
WebViewDatabase m = WebViewDatabase.getInstance(this); WebViewDatabase m = WebViewDatabase.getInstance(this);
m.clearFormData(); m.clearFormData();
@ -1307,7 +1307,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
@SuppressLint("NewApi") @SuppressLint("NewApi")
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void clearCookies() { private void clearCookies() {
// TODO Break out web storage deletion into its own option/action // TODO Break out web storage deletion into its own option/action
// TODO clear web storage for all sites that are visited in Incognito mode // TODO clear web storage for all sites that are visited in Incognito mode
WebStorage storage = WebStorage.getInstance(); 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 * searches the web for the query fixing any and all problems with the input
* checks if it is a search, url, etc. * checks if it is a search, url, etc.
*/ */
void searchTheWeb(String query) { private void searchTheWeb(String query) {
if (query.equals("")) { if (query.equals("")) {
return; return;
} }
@ -1556,8 +1556,8 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
int finalColor; // Lighten up the dark color if it is int finalColor; // Lighten up the dark color if it is
// too dark // too dark
if (isColorTooDark(color)) { if (Utils.isColorTooDark(color)) {
finalColor = mixTwoColors( finalColor = Utils.mixTwoColors(
mActivity.getResources().getColor(R.color.primary_color), mActivity.getResources().getColor(R.color.primary_color),
color, 0.25f); color, 0.25f);
} else { } 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<HistoryItem> { public class BookmarkViewAdapter extends ArrayAdapter<HistoryItem> {
final Context context; 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); URI uri = new URI(url);
String domain = uri.getHost(); String domain = uri.getHost();
if (domain == null) { if (domain == null) {
@ -1843,11 +1814,11 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
} }
} }
public boolean isSystemBrowserAvailable() { private boolean isSystemBrowserAvailable() {
return mSystemBrowser; return mSystemBrowser;
} }
public boolean getSystemBrowser() { private boolean getSystemBrowser() {
Cursor c = null; Cursor c = null;
String[] columns = new String[] { "url", "title" }; String[] columns = new String[] { "url", "title" };
boolean browserFlag; boolean browserFlag;
@ -2194,7 +2165,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
* @param enabled * @param enabled
* whether to enable fullscreen or not * whether to enable fullscreen or not
*/ */
public void setFullscreen(boolean enabled) { private void setFullscreen(boolean enabled) {
Window win = getWindow(); Window win = getWindow();
WindowManager.LayoutParams winParams = win.getAttributes(); WindowManager.LayoutParams winParams = win.getAttributes();
final int bits = WindowManager.LayoutParams.FLAG_FULLSCREEN; 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 * and that it should display the stop icon to indicate to the user that
* pressing it stops the page from loading * pressing it stops the page from loading
*/ */
public void setIsLoading() { private void setIsLoading() {
if (!mSearch.hasFocus()) { if (!mSearch.hasFocus()) {
mIcon = mDeleteIcon; mIcon = mDeleteIcon;
mSearch.setCompoundDrawables(null, null, mDeleteIcon, null); 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 * This tells the search bar that the page is finished loading and it should
* display the refresh icon * display the refresh icon
*/ */
public void setIsFinishedLoading() { private void setIsFinishedLoading() {
if (!mSearch.hasFocus()) { if (!mSearch.hasFocus()) {
mIcon = mRefreshIcon; mIcon = mRefreshIcon;
mSearch.setCompoundDrawables(null, null, mRefreshIcon, null); 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 * See setIsFinishedLoading and setIsLoading for displaying the correct icon
*/ */
public void refreshOrStop() { private void refreshOrStop() {
if (mCurrentView != null) { if (mCurrentView != null) {
if (mCurrentView.getProgress() < 100) { if (mCurrentView.getProgress() < 100) {
mCurrentView.stopLoading(); mCurrentView.stopLoading();
@ -2598,7 +2569,7 @@ public class BrowserActivity extends ThemableActivity implements BrowserControll
finish(); finish();
} }
public class SortIgnoreCase implements Comparator<HistoryItem> { private class SortIgnoreCase implements Comparator<HistoryItem> {
public int compare(HistoryItem o1, HistoryItem o2) { public int compare(HistoryItem o1, HistoryItem o2) {
return o1.getTitle().toLowerCase(Locale.getDefault()) return o1.getTitle().toLowerCase(Locale.getDefault())

2
app/src/main/java/acr/browser/lightning/activity/IncognitoActivity.java

@ -13,7 +13,7 @@ import acr.browser.lightning.R;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class IncognitoActivity extends BrowserActivity { public class IncognitoActivity extends BrowserActivity {
CookieManager mCookieManager; private CookieManager mCookieManager;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {

2
app/src/main/java/acr/browser/lightning/activity/MainActivity.java

@ -13,7 +13,7 @@ import acr.browser.lightning.R;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class MainActivity extends BrowserActivity { public class MainActivity extends BrowserActivity {
CookieManager mCookieManager; private CookieManager mCookieManager;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {

6
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 webView = new WebView(this);
webView.clearCache(true); webView.clearCache(true);
webView.destroy(); webView.destroy();
@ -411,7 +411,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void clearHistory() { private void clearHistory() {
deleteDatabase(HistoryDatabase.DATABASE_NAME); deleteDatabase(HistoryDatabase.DATABASE_NAME);
WebViewDatabase m = WebViewDatabase.getInstance(this); WebViewDatabase m = WebViewDatabase.getInstance(this);
m.clearFormData(); m.clearFormData();
@ -431,7 +431,7 @@ public class PrivacySettingsActivity extends ThemableSettingsActivity {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void clearCookies() { private void clearCookies() {
// TODO Break out web storage deletion into its own option/action // TODO Break out web storage deletion into its own option/action
// TODO clear web storage for all sites that are visited in Incognito mode // TODO clear web storage for all sites that are visited in Incognito mode
WebStorage storage = WebStorage.getInstance(); WebStorage storage = WebStorage.getInstance();

2
app/src/main/java/acr/browser/lightning/activity/ReadingActivity.java

@ -140,7 +140,7 @@ public class ReadingActivity extends AppCompatActivity {
HtmlFetcher fetcher = new HtmlFetcher(); HtmlFetcher fetcher = new HtmlFetcher();
try { try {
JResult result = fetcher.fetchAndExtract(params[0], 5000, true); JResult result = fetcher.fetchAndExtract(params[0], 2500, true);
mTitleText = result.getTitle(); mTitleText = result.getTitle();
mBodyText = result.getTextList(); mBodyText = result.getTextList();
} catch (Exception e) { } catch (Exception e) {

2
app/src/main/java/acr/browser/lightning/activity/SettingsActivity.java

@ -53,7 +53,7 @@ public class SettingsActivity extends ThemableSettingsActivity {
} }
@SuppressLint("NewApi") @SuppressLint("NewApi")
public void init() { private void init() {
// set up ActionBar // set up ActionBar
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);

12
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"; public static final String DATABASE_NAME = "historyManager";
// HistoryItems table name // HistoryItems table name
public static final String TABLE_HISTORY = "history"; private static final String TABLE_HISTORY = "history";
// HistoryItems Table Columns names // HistoryItems Table Columns names
public static final String KEY_ID = "id"; private static final String KEY_ID = "id";
public static final String KEY_URL = "url"; private static final String KEY_URL = "url";
public static final String KEY_TITLE = "title"; private static final String KEY_TITLE = "title";
public static final String KEY_TIME_VISITED = "time"; private static final String KEY_TIME_VISITED = "time";
public static SQLiteDatabase mDatabase; private static SQLiteDatabase mDatabase;
private static HistoryDatabase mInstance; private static HistoryDatabase mInstance;

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

@ -224,7 +224,7 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
return mFilter; return mFilter;
} }
public class SearchFilter extends Filter { private class SearchFilter extends Filter {
@Override @Override
protected FilterResults performFiltering(CharSequence constraint) { protected FilterResults performFiltering(CharSequence constraint) {
@ -397,7 +397,8 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
return connectivity.getActiveNetworkInfo(); return connectivity.getActiveNetworkInfo();
} }
public List<HistoryItem> getSuggestions() { //TODO Write simpler algorithm
private List<HistoryItem> getSuggestions() {
List<HistoryItem> filteredList = new ArrayList<>(); List<HistoryItem> filteredList = new ArrayList<>();
int suggestionsSize = (mSuggestions == null) ? 0 : mSuggestions.size(); int suggestionsSize = (mSuggestions == null) ? 0 : mSuggestions.size();

1
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.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.Proxy; import java.net.Proxy;
import java.net.URL; import java.net.URL;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;

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

@ -27,7 +27,7 @@ import java.util.Map;
public class MapEntry<K, V> implements Map.Entry<K, V>, Serializable { public class MapEntry<K, V> implements Map.Entry<K, V>, Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private K key; private final K key;
private V value; private V value;
public MapEntry(K key, V value) { public MapEntry(K key, V value) {

31
app/src/main/java/acr/browser/lightning/utils/Utils.java

@ -135,7 +135,7 @@ public final class Utils {
} }
public static String[] getArray(String input) { public static String[] getArray(String input) {
return input.split("\\|\\$\\|SEPARATOR\\|\\$\\|"); return input.split(Constants.SEPARATOR);
} }
public static void trimCache(Context context) { public static void trimCache(Context context) {
@ -185,6 +185,35 @@ public final class Utils {
return paddedBitmap; 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") @SuppressLint("SimpleDateFormat")
public static File createImageFile() throws IOException { public static File createImageFile() throws IOException {
// Create an image file name // Create an image file name

4
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(); StringBuilder homepageBuilder = new StringBuilder();
homepageBuilder.append(StartPage.HEAD); homepageBuilder.append(StartPage.HEAD);
String icon; String icon;
@ -362,7 +362,7 @@ public class LightningView {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@SuppressLint({ "SetJavaScriptEnabled", "NewApi" }) @SuppressLint({ "SetJavaScriptEnabled", "NewApi" })
public void initializeSettings(WebSettings settings, Context context) { private void initializeSettings(WebSettings settings, Context context) {
if (API < 18) { if (API < 18) {
settings.setAppCacheMaxSize(Long.MAX_VALUE); settings.setAppCacheMaxSize(Long.MAX_VALUE);
} }

BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Loading…
Cancel
Save