Browse Source

First step toward Android M support, compile with sdk 23, fix errors caused by upgrade

removed copy button from search bar and replaced with go action. Had to
remove browser content provider usage as it is not longer included in
the sdk and has been completely removed.
master
Anthony Restaino 9 years ago
parent
commit
9f2f9d74eb
  1. 2
      .travis.yml
  2. 24
      app/app.iml
  3. 8
      app/build.gradle
  4. 283
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  5. 38
      app/src/main/java/acr/browser/lightning/database/BookmarkManager.java
  6. 16
      app/src/main/java/acr/browser/lightning/fragment/BookmarkSettingsFragment.java
  7. 24
      app/src/main/java/acr/browser/lightning/fragment/PrivacySettingsFragment.java
  8. 6
      app/src/main/java/acr/browser/lightning/object/DrawerArrowDrawable.java
  9. 18
      app/src/main/java/acr/browser/lightning/preference/PreferenceManager.java
  10. 9
      app/src/main/java/acr/browser/lightning/utils/WebUtils.java
  11. BIN
      app/src/main/res/drawable-hdpi/ic_action_copy.png
  12. BIN
      app/src/main/res/drawable-xhdpi/ic_action_copy.png
  13. BIN
      app/src/main/res/drawable-xxhdpi/ic_action_copy.png
  14. 4
      app/src/main/res/xml/preference_bookmarks.xml
  15. 4
      app/src/main/res/xml/preference_privacy.xml
  16. 2
      build.gradle

2
.travis.yml

@ -3,7 +3,7 @@ sudo: false
android: android:
components: components:
- build-tools-22.0.1 - build-tools-22.0.1
- android-22 - android-23
- extra-android-support - extra-android-support
- extra-android-m2repository - extra-android-m2repository
licenses: licenses:

24
app/app.iml

@ -36,7 +36,7 @@
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/lightningPlus/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/lightningPlus/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/lightningPlus/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/lightningPlus/debug" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/lightningPlus/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlusDebug/res" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/lightningPlusDebug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlusDebug/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/lightningPlusDebug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/lightningPlusDebug/assets" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/lightningPlusDebug/assets" type="java-resource" />
@ -49,7 +49,7 @@
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/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/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/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$/build/generated/res/resValues/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/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/LightningPlus/resources" 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/assets" type="java-resource" />
@ -92,10 +92,10 @@
<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.2.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/22.2.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/palette-v7/22.2.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/palette-v7/23.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.2.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/net.i2p.android/client/0.7/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/net.i2p.android/client/0.7/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/org.lucasr.twowayview/twowayview/0.1.4/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/org.lucasr.twowayview/twowayview/0.1.4/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
@ -113,16 +113,16 @@
<excludeFolder url="file://$MODULE_DIR$/build/outputs" /> <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" /> <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content> </content>
<orderEntry type="jdk" jdkName="Android API 22 Platform (1)" jdkType="Android SDK" /> <orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="palette-v7-22.2.1" level="project" />
<orderEntry type="library" exported="" name="client-0.7" level="project" /> <orderEntry type="library" exported="" name="client-0.7" level="project" />
<orderEntry type="library" exported="" name="design-22.2.1" level="project" /> <orderEntry type="library" exported="" name="design-23.0.0" level="project" />
<orderEntry type="library" exported="" name="twowayview-0.1.4" level="project" /> <orderEntry type="library" exported="" name="twowayview-0.1.4" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.2.1" level="project" /> <orderEntry type="library" exported="" name="palette-v7-23.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.2.1" level="project" /> <orderEntry type="library" exported="" name="appcompat-v7-23.0.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="appcompat-v7-22.2.1" level="project" /> <orderEntry type="library" exported="" name="support-v4-23.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.0" level="project" />
<orderEntry type="module" module-name="libnetcipher" exported="" /> <orderEntry type="module" module-name="libnetcipher" exported="" />
</component> </component>
</module> </module>

8
app/build.gradle

@ -1,7 +1,7 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
compileSdkVersion 22 compileSdkVersion 23
buildToolsVersion "22.0.1" buildToolsVersion "22.0.1"
defaultConfig { defaultConfig {
minSdkVersion 14 minSdkVersion 14
@ -43,9 +43,9 @@ android {
} }
dependencies { dependencies {
compile 'com.android.support:palette-v7:22.2.1' compile 'com.android.support:palette-v7:23.0.0'
compile 'com.android.support:appcompat-v7:22.2.1' compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:22.2.1' compile 'com.android.support:design:23.0.0'
compile 'org.jsoup:jsoup:1.8.1' compile 'org.jsoup:jsoup:1.8.1'
compile 'org.lucasr.twowayview:twowayview:0.1.4' compile 'org.lucasr.twowayview:twowayview:0.1.4'
// Only Lightning Plus needs the proxy libraries // Only Lightning Plus needs the proxy libraries

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

@ -15,7 +15,6 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.database.Cursor;
import android.database.sqlite.SQLiteException; import android.database.sqlite.SQLiteException;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
@ -35,7 +34,6 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.provider.Browser;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.support.annotation.IdRes; import android.support.annotation.IdRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
@ -48,9 +46,7 @@ import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.graphics.Palette; import android.support.v7.graphics.Palette;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.util.Patterns;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
@ -101,12 +97,10 @@ import java.io.FileOutputStream;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -172,7 +166,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
// Primatives // Primatives
private boolean mFullScreen, mColorMode, mDarkTheme, private boolean mFullScreen, mColorMode, mDarkTheme,
mSystemBrowser = false,
mIsNewIntent = false, mIsNewIntent = false,
mIsFullScreen = false, mIsFullScreen = false,
mIsImmersive = false, mIsImmersive = false,
@ -188,7 +181,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
// Image // Image
private Bitmap mDefaultVideoPoster, mWebpageBitmap, mFolderBitmap; private Bitmap mDefaultVideoPoster, mWebpageBitmap, mFolderBitmap;
private final ColorDrawable mBackground = new ColorDrawable(); private final ColorDrawable mBackground = new ColorDrawable();
private Drawable mDeleteIcon, mRefreshIcon, mCopyIcon, mIcon; private Drawable mDeleteIcon, mRefreshIcon, mSearchIcon, mIcon;
private DrawerArrowDrawable mArrowDrawable; private DrawerArrowDrawable mArrowDrawable;
// Proxy // Proxy
@ -335,21 +328,20 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
mBackgroundColor = getResources().getColor(R.color.primary_color); mBackgroundColor = getResources().getColor(R.color.primary_color);
mDeleteIcon = ThemeUtils.getLightThemedDrawable(this, R.drawable.ic_action_delete); mDeleteIcon = ThemeUtils.getLightThemedDrawable(this, R.drawable.ic_action_delete);
mRefreshIcon = ThemeUtils.getLightThemedDrawable(this, R.drawable.ic_action_refresh); mRefreshIcon = ThemeUtils.getLightThemedDrawable(this, R.drawable.ic_action_refresh);
mCopyIcon = ThemeUtils.getLightThemedDrawable(this, R.drawable.ic_action_copy); mSearchIcon = ThemeUtils.getLightThemedDrawable(this, R.drawable.ic_action_forward);
int iconBounds = Utils.dpToPx(30); int iconBounds = Utils.dpToPx(30);
mDeleteIcon.setBounds(0, 0, iconBounds, iconBounds); mDeleteIcon.setBounds(0, 0, iconBounds, iconBounds);
mRefreshIcon.setBounds(0, 0, iconBounds, iconBounds); mRefreshIcon.setBounds(0, 0, iconBounds, iconBounds);
mCopyIcon.setBounds(0, 0, iconBounds, iconBounds); mSearchIcon.setBounds(0, 0, iconBounds, iconBounds);
mIcon = mRefreshIcon; mIcon = mRefreshIcon;
SearchClass search = new SearchClass(); SearchListenerClass search = new SearchListenerClass();
mSearch.setCompoundDrawables(null, null, mRefreshIcon, null); mSearch.setCompoundDrawables(null, null, mRefreshIcon, null);
mSearch.setOnKeyListener(search.new KeyListener()); mSearch.setOnKeyListener(search);
mSearch.setOnFocusChangeListener(search.new FocusChangeListener()); mSearch.setOnFocusChangeListener(search);
mSearch.setOnEditorActionListener(search.new EditorActionListener()); mSearch.setOnEditorActionListener(search);
mSearch.setOnTouchListener(search.new TouchListener()); mSearch.setOnTouchListener(search);
mSystemBrowser = getSystemBrowser();
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
@ -398,40 +390,13 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
mProxyUtils.checkForProxy(this); mProxyUtils.checkForProxy(this);
} }
private class SearchClass { private class SearchListenerClass implements OnKeyListener, OnEditorActionListener, OnFocusChangeListener, OnTouchListener {
public class KeyListener implements OnKeyListener { @Override
public boolean onKey(View arg0, int arg1, KeyEvent arg2) {
@Override
public boolean onKey(View arg0, int arg1, KeyEvent arg2) {
switch (arg1) {
case KeyEvent.KEYCODE_ENTER:
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0);
searchTheWeb(mSearch.getText().toString());
if (mCurrentView != null) {
mCurrentView.requestFocus();
}
return true;
default:
break;
}
return false;
}
}
public class EditorActionListener implements OnEditorActionListener { switch (arg1) {
@Override case KeyEvent.KEYCODE_ENTER:
public boolean onEditorAction(TextView arg0, int actionId, KeyEvent arg2) {
// hide the keyboard and search the web when the enter key
// button is pressed
if (actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_DONE
|| actionId == EditorInfo.IME_ACTION_NEXT
|| actionId == EditorInfo.IME_ACTION_SEND
|| actionId == EditorInfo.IME_ACTION_SEARCH
|| (arg2.getAction() == KeyEvent.KEYCODE_ENTER)) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0); imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0);
searchTheWeb(mSearch.getText().toString()); searchTheWeb(mSearch.getText().toString());
@ -439,116 +404,132 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
mCurrentView.requestFocus(); mCurrentView.requestFocus();
} }
return true; return true;
default:
break;
}
return false;
}
@Override
public boolean onEditorAction(TextView arg0, int actionId, KeyEvent arg2) {
// hide the keyboard and search the web when the enter key
// button is pressed
if (actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_DONE
|| actionId == EditorInfo.IME_ACTION_NEXT
|| actionId == EditorInfo.IME_ACTION_SEND
|| actionId == EditorInfo.IME_ACTION_SEARCH
|| (arg2.getAction() == KeyEvent.KEYCODE_ENTER)) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0);
searchTheWeb(mSearch.getText().toString());
if (mCurrentView != null) {
mCurrentView.requestFocus();
} }
return false; return true;
} }
return false;
} }
public class FocusChangeListener implements OnFocusChangeListener { @Override
@Override public void onFocusChange(View v, final boolean hasFocus) {
public void onFocusChange(View v, final boolean hasFocus) { if (!hasFocus && mCurrentView != null) {
if (!hasFocus && mCurrentView != null) { if (mCurrentView.getProgress() < 100) {
if (mCurrentView.getProgress() < 100) { setIsLoading();
setIsLoading(); } else {
} else { setIsFinishedLoading();
setIsFinishedLoading(); }
} updateUrl(mCurrentView.getUrl(), true);
updateUrl(mCurrentView.getUrl(), true); } else if (hasFocus) {
} else if (hasFocus) { String url = mCurrentView.getUrl();
String url = mCurrentView.getUrl(); if (url.startsWith(Constants.FILE)) {
if (url.startsWith(Constants.FILE)) { mSearch.setText("");
mSearch.setText(""); } else {
mSearch.setText(url);
}
((AutoCompleteTextView) v).selectAll(); // Hack to make sure
// the text gets
// selected
mIcon = mSearchIcon;
mSearch.setCompoundDrawables(null, null, mSearchIcon, null);
}
final Animation anim = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
if (!hasFocus) {
mArrowDrawable.setProgress(1.0f - interpolatedTime);
} else { } else {
mSearch.setText(url); mArrowDrawable.setProgress(interpolatedTime);
} }
((AutoCompleteTextView) v).selectAll(); // Hack to make sure
// the text gets
// selected
mIcon = mCopyIcon;
mSearch.setCompoundDrawables(null, null, mCopyIcon, null);
} }
final Animation anim = new Animation() {
@Override @Override
protected void applyTransformation(float interpolatedTime, Transformation t) { public boolean willChangeBounds() {
if (!hasFocus) { return true;
mArrowDrawable.setProgress(1.0f - interpolatedTime); }
} else {
mArrowDrawable.setProgress(interpolatedTime);
}
}
@Override };
public boolean willChangeBounds() { anim.setDuration(300);
return true; anim.setInterpolator(new DecelerateInterpolator());
} anim.setAnimationListener(new AnimationListener() {
}; @Override
anim.setDuration(300); public void onAnimationStart(Animation animation) {
anim.setInterpolator(new DecelerateInterpolator()); }
anim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override @Override
public void onAnimationEnd(Animation animation) { public void onAnimationEnd(Animation animation) {
if (!hasFocus) { if (!hasFocus) {
mArrowDrawable.setProgress(0.0f); mArrowDrawable.setProgress(0.0f);
} else { } else {
mArrowDrawable.setProgress(1.0f); mArrowDrawable.setProgress(1.0f);
}
} }
}
@Override @Override
public void onAnimationRepeat(Animation animation) { public void onAnimationRepeat(Animation animation) {
} }
}); });
new Handler().postDelayed(new Runnable() { new Handler().postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
if (mArrowDrawable != null) { if (mArrowDrawable != null) {
mArrowImage.startAnimation(anim); mArrowImage.startAnimation(anim);
}
} }
}
}, 100); }, 100);
if (!hasFocus) { if (!hasFocus) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0); imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0);
}
} }
} }
public class TouchListener implements OnTouchListener { @Override
public boolean onTouch(View v, MotionEvent event) {
@Override if (mSearch.getCompoundDrawables()[2] != null) {
public boolean onTouch(View v, MotionEvent event) { boolean tappedX = event.getX() > (mSearch.getWidth()
if (mSearch.getCompoundDrawables()[2] != null) { - mSearch.getPaddingRight() - mIcon.getIntrinsicWidth());
boolean tappedX = event.getX() > (mSearch.getWidth() if (tappedX) {
- mSearch.getPaddingRight() - mIcon.getIntrinsicWidth()); if (event.getAction() == MotionEvent.ACTION_UP) {
if (tappedX) { if (mSearch.hasFocus()) {
if (event.getAction() == MotionEvent.ACTION_UP) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (mSearch.hasFocus()) { imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0);
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); searchTheWeb(mSearch.getText().toString());
ClipData clip = ClipData.newPlainText("label", mSearch.getText() if (mCurrentView != null) {
.toString()); mCurrentView.requestFocus();
clipboard.setPrimaryClip(clip);
Utils.showSnackbar(mActivity, R.string.message_text_copied);
} else {
refreshOrStop();
} }
} else {
refreshOrStop();
} }
return true;
} }
return true;
} }
return false;
} }
return false;
} }
} }
@ -1362,7 +1343,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} }
if (mPreferences.getClearHistoryExitEnabled() && !isIncognito()) { if (mPreferences.getClearHistoryExitEnabled() && !isIncognito()) {
WebUtils.clearHistory(this, mSystemBrowser); WebUtils.clearHistory(this);
Log.d(Constants.TAG, "History Cleared"); Log.d(Constants.TAG, "History Cleared");
} }
@ -1916,13 +1897,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
Runnable update = new Runnable() { Runnable update = new Runnable() {
@Override @Override
public void run() { public void run() {
if (isSystemBrowserAvailable() && mPreferences.getSyncHistoryEnabled()) {
try {
Browser.updateVisitedHistory(getContentResolver(), url, true);
} catch (Exception ignored) {
// ignored
}
}
try { try {
if (mHistoryDatabase == null) { if (mHistoryDatabase == null) {
mHistoryDatabase = HistoryDatabase.getInstance(mActivity.getApplicationContext()); mHistoryDatabase = HistoryDatabase.getInstance(mActivity.getApplicationContext());
@ -1942,35 +1916,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} }
} }
private boolean isSystemBrowserAvailable() {
return mSystemBrowser;
}
private boolean getSystemBrowser() {
Cursor c = null;
String[] columns = new String[]{"url", "title"};
boolean browserFlag;
try {
Uri bookmarks = Browser.BOOKMARKS_URI;
c = getContentResolver().query(bookmarks, columns, null, null, null);
} catch (Exception e) {
e.printStackTrace();
}
if (c != null) {
Log.d("Browser", "System Browser Available");
browserFlag = true;
} else {
Log.e("Browser", "System Browser Unavailable");
browserFlag = false;
}
if (c != null) {
c.close();
}
mPreferences.setSystemBrowserPresent(browserFlag);
return browserFlag;
}
/** /**
* method to generate search suggestions for the AutoCompleteTextView from * method to generate search suggestions for the AutoCompleteTextView from
* previously searched URLs * previously searched URLs

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

@ -395,44 +395,6 @@ public class BookmarkManager {
return folders; return folders;
} }
/**
* This method imports all bookmarks that are included in the device's
* permanent bookmark storage
*/
public synchronized void importBookmarksFromBrowser(Activity activity) throws Exception{
if (PreferenceManager.getInstance().getSystemBrowserPresent()) {
List<HistoryItem> bookmarkList = new ArrayList<>();
String[] columns = new String[]{Browser.BookmarkColumns.TITLE,
Browser.BookmarkColumns.URL};
String selection = Browser.BookmarkColumns.BOOKMARK + " = 1";
Cursor cursor = mContext.getContentResolver().query(Browser.BOOKMARKS_URI, columns,
selection, null, null);
if (cursor == null)
return;
String title, url;
int number = 0;
if (cursor.moveToFirst()) {
do {
title = cursor.getString(0);
url = cursor.getString(1);
if (title.isEmpty()) {
title = Utils.getDomainName(url);
}
number++;
bookmarkList.add(new HistoryItem(url, title));
} while (cursor.moveToNext());
}
cursor.close();
addBookmarkList(bookmarkList);
Utils.showSnackbar(activity, number + " " + mContext.getResources().getString(R.string.message_import));
} else {
Utils.createInformativeDialog(activity, R.string.title_error, R.string.dialog_import_error);
}
}
/** /**
* This method imports the bookmarks from a backup file that is located on * This method imports the bookmarks from a backup file that is located on
* external storage * external storage

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

@ -23,7 +23,6 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
private static final String SETTINGS_EXPORT = "export_bookmark"; private static final String SETTINGS_EXPORT = "export_bookmark";
private static final String SETTINGS_IMPORT = "import_bookmark"; private static final String SETTINGS_IMPORT = "import_bookmark";
private static final String SETTINGS_BROWSER_IMPORT = "import_browser_bookmark";
private Activity mActivity; private Activity mActivity;
private BookmarkManager mBookmarkManager; private BookmarkManager mBookmarkManager;
@ -50,17 +49,9 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
Preference exportpref = findPreference(SETTINGS_EXPORT); Preference exportpref = findPreference(SETTINGS_EXPORT);
Preference importpref = findPreference(SETTINGS_IMPORT); Preference importpref = findPreference(SETTINGS_IMPORT);
Preference importBrowserpref = findPreference(SETTINGS_BROWSER_IMPORT);
exportpref.setOnPreferenceClickListener(this); exportpref.setOnPreferenceClickListener(this);
importpref.setOnPreferenceClickListener(this); importpref.setOnPreferenceClickListener(this);
importBrowserpref.setOnPreferenceClickListener(this);
if (mPreferences.getSystemBrowserPresent()) {
importBrowserpref.setSummary(getResources().getString(R.string.stock_browser_available));
} else {
importBrowserpref.setSummary(getResources().getString(R.string.stock_browser_unavailable));
}
} }
@Override @Override
@ -73,13 +64,6 @@ public class BookmarkSettingsFragment extends PreferenceFragment implements Pref
loadFileList(null); loadFileList(null);
createDialog(); createDialog();
return true; return true;
case SETTINGS_BROWSER_IMPORT:
try {
mBookmarkManager.importBookmarksFromBrowser(getActivity());
} catch (Exception e) {
e.printStackTrace();
}
return true;
default: default:
return false; return false;
} }

24
app/src/main/java/acr/browser/lightning/fragment/PrivacySettingsFragment.java

@ -28,19 +28,16 @@ public class PrivacySettingsFragment extends PreferenceFragment implements Prefe
private static final String SETTINGS_CACHEEXIT = "clear_cache_exit"; private static final String SETTINGS_CACHEEXIT = "clear_cache_exit";
private static final String SETTINGS_HISTORYEXIT = "clear_history_exit"; private static final String SETTINGS_HISTORYEXIT = "clear_history_exit";
private static final String SETTINGS_COOKIEEXIT = "clear_cookies_exit"; private static final String SETTINGS_COOKIEEXIT = "clear_cookies_exit";
private static final String SETTINGS_SYNCHISTORY = "sync_history";
private static final String SETTINGS_CLEARCACHE = "clear_cache"; private static final String SETTINGS_CLEARCACHE = "clear_cache";
private static final String SETTINGS_CLEARHISTORY = "clear_history"; private static final String SETTINGS_CLEARHISTORY = "clear_history";
private static final String SETTINGS_CLEARCOOKIES = "clear_cookies"; private static final String SETTINGS_CLEARCOOKIES = "clear_cookies";
private static final String SETTINGS_CLEARWEBSTORAGE = "clear_webstorage"; private static final String SETTINGS_CLEARWEBSTORAGE = "clear_webstorage";
private static final String SETTINGS_WEBSTORAGEEXIT = "clear_webstorage_exit"; private static final String SETTINGS_WEBSTORAGEEXIT = "clear_webstorage_exit";
private static final int API = android.os.Build.VERSION.SDK_INT;
private Activity mActivity; private Activity mActivity;
private PreferenceManager mPreferences; private PreferenceManager mPreferences;
private CheckBoxPreference cblocation, cb3cookies, cbsavepasswords, cbcacheexit, cbhistoryexit, private CheckBoxPreference cblocation, cb3cookies, cbsavepasswords, cbcacheexit, cbhistoryexit,
cbcookiesexit, cbsynchistory, cbwebstorageexit; cbcookiesexit, cbwebstorageexit;
private boolean mSystemBrowser;
private Handler messageHandler; private Handler messageHandler;
@Override @Override
@ -57,7 +54,6 @@ public class PrivacySettingsFragment extends PreferenceFragment implements Prefe
private void initPrefs() { private void initPrefs() {
// mPreferences storage // mPreferences storage
mPreferences = PreferenceManager.getInstance(); mPreferences = PreferenceManager.getInstance();
mSystemBrowser = mPreferences.getSystemBrowserPresent();
Preference clearcache = findPreference(SETTINGS_CLEARCACHE); Preference clearcache = findPreference(SETTINGS_CLEARCACHE);
Preference clearhistory = findPreference(SETTINGS_CLEARHISTORY); Preference clearhistory = findPreference(SETTINGS_CLEARHISTORY);
@ -70,7 +66,6 @@ public class PrivacySettingsFragment extends PreferenceFragment implements Prefe
cbcacheexit = (CheckBoxPreference) findPreference(SETTINGS_CACHEEXIT); cbcacheexit = (CheckBoxPreference) findPreference(SETTINGS_CACHEEXIT);
cbhistoryexit = (CheckBoxPreference) findPreference(SETTINGS_HISTORYEXIT); cbhistoryexit = (CheckBoxPreference) findPreference(SETTINGS_HISTORYEXIT);
cbcookiesexit = (CheckBoxPreference) findPreference(SETTINGS_COOKIEEXIT); cbcookiesexit = (CheckBoxPreference) findPreference(SETTINGS_COOKIEEXIT);
cbsynchistory = (CheckBoxPreference) findPreference(SETTINGS_SYNCHISTORY);
cbwebstorageexit = (CheckBoxPreference) findPreference(SETTINGS_WEBSTORAGEEXIT); cbwebstorageexit = (CheckBoxPreference) findPreference(SETTINGS_WEBSTORAGEEXIT);
clearcache.setOnPreferenceClickListener(this); clearcache.setOnPreferenceClickListener(this);
@ -84,7 +79,6 @@ public class PrivacySettingsFragment extends PreferenceFragment implements Prefe
cbcacheexit.setOnPreferenceChangeListener(this); cbcacheexit.setOnPreferenceChangeListener(this);
cbhistoryexit.setOnPreferenceChangeListener(this); cbhistoryexit.setOnPreferenceChangeListener(this);
cbcookiesexit.setOnPreferenceChangeListener(this); cbcookiesexit.setOnPreferenceChangeListener(this);
cbsynchistory.setOnPreferenceChangeListener(this);
cbwebstorageexit.setOnPreferenceChangeListener(this); cbwebstorageexit.setOnPreferenceChangeListener(this);
cblocation.setChecked(mPreferences.getLocationEnabled()); cblocation.setChecked(mPreferences.getLocationEnabled());
@ -97,16 +91,6 @@ public class PrivacySettingsFragment extends PreferenceFragment implements Prefe
cb3cookies.setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP); cb3cookies.setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP);
if (!mSystemBrowser) {
cbsynchistory.setChecked(false);
cbsynchistory.setEnabled(false);
cbsynchistory.setSummary(getResources().getString(R.string.stock_browser_unavailable));
} else {
cbsynchistory.setEnabled(true);
cbsynchistory.setChecked(mPreferences.getSyncHistoryEnabled());
cbsynchistory.setSummary(getResources().getString(R.string.stock_browser_available));
}
messageHandler = new MessageHandler(mActivity); messageHandler = new MessageHandler(mActivity);
} }
@ -210,7 +194,7 @@ public class PrivacySettingsFragment extends PreferenceFragment implements Prefe
} }
private void clearHistory() { private void clearHistory() {
WebUtils.clearHistory(getActivity(), mSystemBrowser); WebUtils.clearHistory(getActivity());
messageHandler.sendEmptyMessage(1); messageHandler.sendEmptyMessage(1);
} }
@ -256,10 +240,6 @@ public class PrivacySettingsFragment extends PreferenceFragment implements Prefe
mPreferences.setClearWebStorageExitEnabled((Boolean) newValue); mPreferences.setClearWebStorageExitEnabled((Boolean) newValue);
cbwebstorageexit.setChecked((Boolean) newValue); cbwebstorageexit.setChecked((Boolean) newValue);
return true; return true;
case SETTINGS_SYNCHISTORY:
mPreferences.setSyncHistoryEnabled((Boolean) newValue);
cbsynchistory.setChecked((Boolean) newValue);
return true;
default: default:
return false; return false;
} }

6
app/src/main/java/acr/browser/lightning/object/DrawerArrowDrawable.java

@ -67,14 +67,14 @@ public class DrawerArrowDrawable extends Drawable {
mPaint.setAntiAlias(true); mPaint.setAntiAlias(true);
mPaint.setColor(typedArray.getColor(R.styleable.DrawerArrowToggle_color, 0)); mPaint.setColor(typedArray.getColor(R.styleable.DrawerArrowToggle_color, 0));
mSize = typedArray.getDimensionPixelSize(R.styleable.DrawerArrowToggle_drawableSize, 0); mSize = typedArray.getDimensionPixelSize(R.styleable.DrawerArrowToggle_drawableSize, 0);
mBarSize = typedArray.getDimension(R.styleable.DrawerArrowToggle_barSize, 0); mBarSize = typedArray.getDimension(R.styleable.DrawerArrowToggle_barLength, 0);
mTopBottomArrowSize = typedArray.getDimension( mTopBottomArrowSize = typedArray.getDimension(
R.styleable.DrawerArrowToggle_topBottomBarArrowSize, 0); R.styleable.DrawerArrowToggle_arrowHeadLength, 0);
mBarThickness = typedArray.getDimension(R.styleable.DrawerArrowToggle_thickness, 0); mBarThickness = typedArray.getDimension(R.styleable.DrawerArrowToggle_thickness, 0);
mBarGap = typedArray.getDimension(R.styleable.DrawerArrowToggle_gapBetweenBars, 0); mBarGap = typedArray.getDimension(R.styleable.DrawerArrowToggle_gapBetweenBars, 0);
mSpin = typedArray.getBoolean(R.styleable.DrawerArrowToggle_spinBars, true); mSpin = typedArray.getBoolean(R.styleable.DrawerArrowToggle_spinBars, true);
mMiddleArrowSize = typedArray.getDimension( mMiddleArrowSize = typedArray.getDimension(
R.styleable.DrawerArrowToggle_middleBarArrowSize, 0); R.styleable.DrawerArrowToggle_arrowShaftLength, 0);
typedArray.recycle(); typedArray.recycle();
mPaint.setStyle(Paint.Style.STROKE); mPaint.setStyle(Paint.Style.STROKE);
mPaint.setStrokeJoin(Paint.Join.ROUND); mPaint.setStrokeJoin(Paint.Join.ROUND);

18
app/src/main/java/acr/browser/lightning/preference/PreferenceManager.java

@ -27,7 +27,6 @@ public class PreferenceManager {
public static final String SAVE_PASSWORDS = "passwords"; public static final String SAVE_PASSWORDS = "passwords";
public static final String SEARCH = "search"; public static final String SEARCH = "search";
public static final String SEARCH_URL = "searchurl"; public static final String SEARCH_URL = "searchurl";
public static final String SYSTEM_BROWSER_PRESENT = "SystemBrowser";
public static final String TEXT_REFLOW = "textreflow"; public static final String TEXT_REFLOW = "textreflow";
public static final String TEXT_SIZE = "textsize"; public static final String TEXT_SIZE = "textsize";
public static final String URL_MEMORY = "memory"; public static final String URL_MEMORY = "memory";
@ -39,7 +38,6 @@ public class PreferenceManager {
public static final String CLEAR_COOKIES_EXIT = "clearCookiesExit"; public static final String CLEAR_COOKIES_EXIT = "clearCookiesExit";
public static final String SAVE_URL = "saveUrl"; public static final String SAVE_URL = "saveUrl";
public static final String RENDERING_MODE = "renderMode"; public static final String RENDERING_MODE = "renderMode";
public static final String SYNC_HISTORY = "syncHistory";
public static final String BLOCK_THIRD_PARTY = "thirdParty"; public static final String BLOCK_THIRD_PARTY = "thirdParty";
public static final String ENABLE_COLOR_MODE = "colorMode"; public static final String ENABLE_COLOR_MODE = "colorMode";
public static final String URL_BOX_CONTENTS = "urlContent"; public static final String URL_BOX_CONTENTS = "urlContent";
@ -211,14 +209,6 @@ public class PreferenceManager {
return mPrefs.getString(Name.SEARCH_URL, Constants.GOOGLE_SEARCH); return mPrefs.getString(Name.SEARCH_URL, Constants.GOOGLE_SEARCH);
} }
public boolean getSyncHistoryEnabled() {
return mPrefs.getBoolean(Name.SYNC_HISTORY, true);
}
public boolean getSystemBrowserPresent() {
return mPrefs.getBoolean(Name.SYSTEM_BROWSER_PRESENT, false);
}
public boolean getTextReflowEnabled() { public boolean getTextReflowEnabled() {
return mPrefs.getBoolean(Name.TEXT_REFLOW, false); return mPrefs.getBoolean(Name.TEXT_REFLOW, false);
} }
@ -411,14 +401,6 @@ public class PreferenceManager {
putString(Name.SEARCH_URL, url); putString(Name.SEARCH_URL, url);
} }
public void setSyncHistoryEnabled(boolean enable) {
putBoolean(Name.SYNC_HISTORY, enable);
}
public void setSystemBrowserPresent(boolean available) {
putBoolean(Name.SYSTEM_BROWSER_PRESENT, available);
}
public void setTextReflowEnabled(boolean enable) { public void setTextReflowEnabled(boolean enable) {
putBoolean(Name.TEXT_REFLOW, enable); putBoolean(Name.TEXT_REFLOW, enable);
} }

9
app/src/main/java/acr/browser/lightning/utils/WebUtils.java

@ -32,7 +32,7 @@ public class WebUtils {
WebStorage.getInstance().deleteAllData(); WebStorage.getInstance().deleteAllData();
} }
public static void clearHistory(@NonNull Context context, boolean systemBrowserPresent) { public static void clearHistory(@NonNull Context context) {
HistoryDatabase.getInstance(context).deleteHistory(); HistoryDatabase.getInstance(context).deleteHistory();
WebViewDatabase m = WebViewDatabase.getInstance(context); WebViewDatabase m = WebViewDatabase.getInstance(context);
m.clearFormData(); m.clearFormData();
@ -41,13 +41,6 @@ public class WebUtils {
m.clearUsernamePassword(); m.clearUsernamePassword();
WebIconDatabase.getInstance().removeAllIcons(); WebIconDatabase.getInstance().removeAllIcons();
} }
if (systemBrowserPresent) {
try {
Browser.clearHistory(context.getContentResolver());
} catch (Exception ignored) {
// ignored
}
}
Utils.trimCache(context); Utils.trimCache(context);
} }

BIN
app/src/main/res/drawable-hdpi/ic_action_copy.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 244 B

BIN
app/src/main/res/drawable-xhdpi/ic_action_copy.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 244 B

BIN
app/src/main/res/drawable-xxhdpi/ic_action_copy.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 379 B

4
app/src/main/res/xml/preference_bookmarks.xml

@ -8,9 +8,5 @@
<Preference <Preference
android:key="import_bookmark" android:key="import_bookmark"
android:title="@string/import_backup" /> android:title="@string/import_backup" />
<Preference
android:key="import_browser_bookmark"
android:title="@string/importbookmarks"
android:summary="@string/recommended" />
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

4
app/src/main/res/xml/preference_privacy.xml

@ -31,10 +31,6 @@
android:defaultValue="false" android:defaultValue="false"
android:key="clear_webstorage_exit" android:key="clear_webstorage_exit"
android:title="@string/clear_web_storage_exit" /> android:title="@string/clear_web_storage_exit" />
<CheckBoxPreference
android:defaultValue="false"
android:key="sync_history"
android:title="@string/sync_history" />
<Preference <Preference
android:key="clear_cache" android:key="clear_cache"
android:title="@string/clear_cache" /> android:title="@string/clear_cache" />

2
build.gradle

@ -4,7 +4,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:1.2.3' classpath 'com.android.tools.build:gradle:1.3.1'
} }
} }

Loading…
Cancel
Save