|
|
@ -4,38 +4,10 @@ |
|
|
|
|
|
|
|
|
|
|
|
package acr.browser.lightning; |
|
|
|
package acr.browser.lightning; |
|
|
|
|
|
|
|
|
|
|
|
import info.guardianproject.onionkit.ui.OrbotHelper; |
|
|
|
|
|
|
|
import info.guardianproject.onionkit.web.WebkitProxy; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedReader; |
|
|
|
|
|
|
|
import java.io.BufferedWriter; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
import java.io.FileNotFoundException; |
|
|
|
|
|
|
|
import java.io.FileOutputStream; |
|
|
|
|
|
|
|
import java.io.FileReader; |
|
|
|
|
|
|
|
import java.io.FileWriter; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
import java.io.InputStream; |
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
|
|
|
|
import java.net.URI; |
|
|
|
|
|
|
|
import java.net.URISyntaxException; |
|
|
|
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
|
|
|
|
import java.util.Comparator; |
|
|
|
|
|
|
|
import java.util.Iterator; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Locale; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.app.ActionBar; |
|
|
|
import android.app.ActionBar; |
|
|
|
import android.app.Activity; |
|
|
|
import android.app.Activity; |
|
|
|
import android.app.AlertDialog; |
|
|
|
import android.app.AlertDialog; |
|
|
|
import android.content.ClipData; |
|
|
|
import android.content.*; |
|
|
|
import android.content.ClipboardManager; |
|
|
|
|
|
|
|
import android.content.Context; |
|
|
|
|
|
|
|
import android.content.DialogInterface; |
|
|
|
|
|
|
|
import android.content.Intent; |
|
|
|
|
|
|
|
import android.content.SharedPreferences; |
|
|
|
|
|
|
|
import android.content.res.Configuration; |
|
|
|
import android.content.res.Configuration; |
|
|
|
import android.content.res.Resources.Theme; |
|
|
|
import android.content.res.Resources.Theme; |
|
|
|
import android.content.res.TypedArray; |
|
|
|
import android.content.res.TypedArray; |
|
|
@ -64,96 +36,131 @@ import android.support.v4.widget.DrawerLayout; |
|
|
|
import android.text.TextUtils; |
|
|
|
import android.text.TextUtils; |
|
|
|
import android.util.Log; |
|
|
|
import android.util.Log; |
|
|
|
import android.util.TypedValue; |
|
|
|
import android.util.TypedValue; |
|
|
|
import android.view.KeyEvent; |
|
|
|
import android.view.*; |
|
|
|
import android.view.LayoutInflater; |
|
|
|
|
|
|
|
import android.view.Menu; |
|
|
|
|
|
|
|
import android.view.MenuItem; |
|
|
|
|
|
|
|
import android.view.MotionEvent; |
|
|
|
|
|
|
|
import android.view.View; |
|
|
|
|
|
|
|
import android.view.View.OnClickListener; |
|
|
|
import android.view.View.OnClickListener; |
|
|
|
import android.view.View.OnKeyListener; |
|
|
|
import android.view.View.OnKeyListener; |
|
|
|
import android.view.View.OnTouchListener; |
|
|
|
import android.view.View.OnTouchListener; |
|
|
|
import android.view.ViewGroup; |
|
|
|
|
|
|
|
import android.view.Window; |
|
|
|
|
|
|
|
import android.view.WindowManager; |
|
|
|
|
|
|
|
import android.view.inputmethod.EditorInfo; |
|
|
|
import android.view.inputmethod.EditorInfo; |
|
|
|
import android.view.inputmethod.InputMethodManager; |
|
|
|
import android.view.inputmethod.InputMethodManager; |
|
|
|
import android.webkit.CookieManager; |
|
|
|
import android.webkit.*; |
|
|
|
import android.webkit.CookieSyncManager; |
|
|
|
|
|
|
|
import android.webkit.ValueCallback; |
|
|
|
|
|
|
|
import android.webkit.WebViewDatabase; |
|
|
|
|
|
|
|
import android.webkit.WebChromeClient.CustomViewCallback; |
|
|
|
import android.webkit.WebChromeClient.CustomViewCallback; |
|
|
|
import android.webkit.WebIconDatabase; |
|
|
|
|
|
|
|
import android.webkit.WebView; |
|
|
|
|
|
|
|
import android.webkit.WebView.HitTestResult; |
|
|
|
import android.webkit.WebView.HitTestResult; |
|
|
|
import android.widget.AdapterView; |
|
|
|
import android.widget.*; |
|
|
|
import android.widget.AdapterView.OnItemClickListener; |
|
|
|
import android.widget.AdapterView.OnItemClickListener; |
|
|
|
import android.widget.ArrayAdapter; |
|
|
|
|
|
|
|
import android.widget.AutoCompleteTextView; |
|
|
|
|
|
|
|
import android.widget.EditText; |
|
|
|
|
|
|
|
import android.widget.FrameLayout; |
|
|
|
|
|
|
|
import android.widget.ImageView; |
|
|
|
|
|
|
|
import android.widget.LinearLayout; |
|
|
|
|
|
|
|
import android.widget.ListView; |
|
|
|
|
|
|
|
import android.widget.ProgressBar; |
|
|
|
|
|
|
|
import android.widget.RelativeLayout; |
|
|
|
|
|
|
|
import android.widget.TextView; |
|
|
|
|
|
|
|
import android.widget.TextView.OnEditorActionListener; |
|
|
|
import android.widget.TextView.OnEditorActionListener; |
|
|
|
import android.widget.VideoView; |
|
|
|
import info.guardianproject.onionkit.ui.OrbotHelper; |
|
|
|
|
|
|
|
import info.guardianproject.onionkit.web.WebkitProxy; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.*; |
|
|
|
|
|
|
|
import java.net.URI; |
|
|
|
|
|
|
|
import java.net.URISyntaxException; |
|
|
|
|
|
|
|
import java.net.URLEncoder; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
|
|
|
|
|
|
|
|
private DrawerLayout mDrawerLayout; |
|
|
|
private DrawerLayout mDrawerLayout; |
|
|
|
|
|
|
|
|
|
|
|
private ListView mDrawerList; |
|
|
|
private ListView mDrawerList; |
|
|
|
|
|
|
|
|
|
|
|
private RelativeLayout mDrawer; |
|
|
|
private RelativeLayout mDrawer; |
|
|
|
|
|
|
|
|
|
|
|
private LinearLayout mDrawerRight; |
|
|
|
private LinearLayout mDrawerRight; |
|
|
|
|
|
|
|
|
|
|
|
private ListView mDrawerListRight; |
|
|
|
private ListView mDrawerListRight; |
|
|
|
|
|
|
|
|
|
|
|
private RelativeLayout mNewTab; |
|
|
|
private RelativeLayout mNewTab; |
|
|
|
|
|
|
|
|
|
|
|
private ActionBarDrawerToggle mDrawerToggle; |
|
|
|
private ActionBarDrawerToggle mDrawerToggle; |
|
|
|
|
|
|
|
|
|
|
|
private List<LightningView> mWebViews = new ArrayList<LightningView>(); |
|
|
|
private List<LightningView> mWebViews = new ArrayList<LightningView>(); |
|
|
|
|
|
|
|
|
|
|
|
private List<Integer> mIdList = new ArrayList<Integer>(); |
|
|
|
private List<Integer> mIdList = new ArrayList<Integer>(); |
|
|
|
|
|
|
|
|
|
|
|
private LightningView mCurrentView; |
|
|
|
private LightningView mCurrentView; |
|
|
|
|
|
|
|
|
|
|
|
private int mIdGenerator; |
|
|
|
private int mIdGenerator; |
|
|
|
|
|
|
|
|
|
|
|
private LightningViewAdapter mTitleAdapter; |
|
|
|
private LightningViewAdapter mTitleAdapter; |
|
|
|
|
|
|
|
|
|
|
|
private List<HistoryItem> mBookmarkList; |
|
|
|
private List<HistoryItem> mBookmarkList; |
|
|
|
|
|
|
|
|
|
|
|
private BookmarkViewAdapter mBookmarkAdapter; |
|
|
|
private BookmarkViewAdapter mBookmarkAdapter; |
|
|
|
|
|
|
|
|
|
|
|
private AutoCompleteTextView mSearch; |
|
|
|
private AutoCompleteTextView mSearch; |
|
|
|
|
|
|
|
|
|
|
|
private ClickHandler mClickHandler; |
|
|
|
private ClickHandler mClickHandler; |
|
|
|
|
|
|
|
|
|
|
|
private ProgressBar mProgress; |
|
|
|
private ProgressBar mProgress; |
|
|
|
|
|
|
|
|
|
|
|
private boolean mSystemBrowser = false; |
|
|
|
private boolean mSystemBrowser = false; |
|
|
|
|
|
|
|
|
|
|
|
private ValueCallback<Uri> mUploadMessage; |
|
|
|
private ValueCallback<Uri> mUploadMessage; |
|
|
|
|
|
|
|
|
|
|
|
private View mCustomView; |
|
|
|
private View mCustomView; |
|
|
|
|
|
|
|
|
|
|
|
private int mOriginalOrientation; |
|
|
|
private int mOriginalOrientation; |
|
|
|
|
|
|
|
|
|
|
|
private int mActionBarSize; |
|
|
|
private int mActionBarSize; |
|
|
|
|
|
|
|
|
|
|
|
private ActionBar mActionBar; |
|
|
|
private ActionBar mActionBar; |
|
|
|
|
|
|
|
|
|
|
|
private boolean mFullScreen; |
|
|
|
private boolean mFullScreen; |
|
|
|
|
|
|
|
|
|
|
|
private FrameLayout mBrowserFrame; |
|
|
|
private FrameLayout mBrowserFrame; |
|
|
|
|
|
|
|
|
|
|
|
private FullscreenHolder mFullscreenContainer; |
|
|
|
private FullscreenHolder mFullscreenContainer; |
|
|
|
|
|
|
|
|
|
|
|
private CustomViewCallback mCustomViewCallback; |
|
|
|
private CustomViewCallback mCustomViewCallback; |
|
|
|
|
|
|
|
|
|
|
|
private final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams( |
|
|
|
private final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams( |
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT, |
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT, |
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT); |
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT); |
|
|
|
|
|
|
|
|
|
|
|
private Bitmap mDefaultVideoPoster; |
|
|
|
private Bitmap mDefaultVideoPoster; |
|
|
|
|
|
|
|
|
|
|
|
private View mVideoProgressView; |
|
|
|
private View mVideoProgressView; |
|
|
|
|
|
|
|
|
|
|
|
private DatabaseHandler mHistoryHandler; |
|
|
|
private DatabaseHandler mHistoryHandler; |
|
|
|
|
|
|
|
|
|
|
|
private SQLiteDatabase mHistoryDatabase; |
|
|
|
private SQLiteDatabase mHistoryDatabase; |
|
|
|
|
|
|
|
|
|
|
|
private SharedPreferences mPreferences; |
|
|
|
private SharedPreferences mPreferences; |
|
|
|
|
|
|
|
|
|
|
|
private SharedPreferences.Editor mEditPrefs; |
|
|
|
private SharedPreferences.Editor mEditPrefs; |
|
|
|
|
|
|
|
|
|
|
|
private Context mContext; |
|
|
|
private Context mContext; |
|
|
|
|
|
|
|
|
|
|
|
private Bitmap mWebpageBitmap; |
|
|
|
private Bitmap mWebpageBitmap; |
|
|
|
|
|
|
|
|
|
|
|
private String mSearchText; |
|
|
|
private String mSearchText; |
|
|
|
|
|
|
|
|
|
|
|
private Activity mActivity; |
|
|
|
private Activity mActivity; |
|
|
|
|
|
|
|
|
|
|
|
private CookieManager mCookieManager; |
|
|
|
private CookieManager mCookieManager; |
|
|
|
|
|
|
|
|
|
|
|
private final int API = android.os.Build.VERSION.SDK_INT; |
|
|
|
private final int API = android.os.Build.VERSION.SDK_INT; |
|
|
|
|
|
|
|
|
|
|
|
private Drawable mDeleteIcon; |
|
|
|
private Drawable mDeleteIcon; |
|
|
|
|
|
|
|
|
|
|
|
private Drawable mRefreshIcon; |
|
|
|
private Drawable mRefreshIcon; |
|
|
|
|
|
|
|
|
|
|
|
private Drawable mCopyIcon; |
|
|
|
private Drawable mCopyIcon; |
|
|
|
|
|
|
|
|
|
|
|
private Drawable mIcon; |
|
|
|
private Drawable mIcon; |
|
|
|
|
|
|
|
|
|
|
|
private int mActionBarSizeDp; |
|
|
|
private int mActionBarSizeDp; |
|
|
|
|
|
|
|
|
|
|
|
private int mNumberIconColor; |
|
|
|
private int mNumberIconColor; |
|
|
|
|
|
|
|
|
|
|
|
private String mHomepage; |
|
|
|
private String mHomepage; |
|
|
|
|
|
|
|
|
|
|
|
private boolean mIsNewIntent = false; |
|
|
|
private boolean mIsNewIntent = false; |
|
|
|
|
|
|
|
|
|
|
|
private VideoView mVideoView; |
|
|
|
private VideoView mVideoView; |
|
|
|
|
|
|
|
|
|
|
|
private static SearchAdapter mSearchAdapter; |
|
|
|
private static SearchAdapter mSearchAdapter; |
|
|
|
|
|
|
|
|
|
|
|
private boolean isIncognito = false; |
|
|
|
private boolean isIncognito = false; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -203,7 +210,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
mActionBar = getActionBar(); |
|
|
|
mActionBar = getActionBar(); |
|
|
|
final TypedArray styledAttributes = mContext.getTheme() |
|
|
|
final TypedArray styledAttributes = mContext.getTheme() |
|
|
|
.obtainStyledAttributes( |
|
|
|
.obtainStyledAttributes( |
|
|
|
new int[] { android.R.attr.actionBarSize }); |
|
|
|
new int[]{android.R.attr.actionBarSize}); |
|
|
|
mActionBarSize = (int) styledAttributes.getDimension(0, 0); |
|
|
|
mActionBarSize = (int) styledAttributes.getDimension(0, 0); |
|
|
|
if (pixelsToDp(mActionBarSize) < 48) { |
|
|
|
if (pixelsToDp(mActionBarSize) < 48) { |
|
|
|
mActionBarSize = getDp(48); |
|
|
|
mActionBarSize = getDp(48); |
|
|
@ -518,8 +525,9 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
public void initializeTor() { |
|
|
|
public void initializeTor() { |
|
|
|
|
|
|
|
|
|
|
|
OrbotHelper oh = new OrbotHelper(this); |
|
|
|
OrbotHelper oh = new OrbotHelper(this); |
|
|
|
if (!oh.isOrbotRunning()) |
|
|
|
if (!oh.isOrbotRunning()) { |
|
|
|
oh.requestOrbotStart(this); |
|
|
|
oh.requestOrbotStart(this); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WebkitProxy wkp = new WebkitProxy(); |
|
|
|
WebkitProxy wkp = new WebkitProxy(); |
|
|
|
try { |
|
|
|
try { |
|
|
@ -720,15 +728,17 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
case R.id.action_back: |
|
|
|
case R.id.action_back: |
|
|
|
if (mCurrentView != null) { |
|
|
|
if (mCurrentView != null) { |
|
|
|
if (mCurrentView.canGoBack()) |
|
|
|
if (mCurrentView.canGoBack()) { |
|
|
|
mCurrentView.goBack(); |
|
|
|
mCurrentView.goBack(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
case R.id.action_forward: |
|
|
|
case R.id.action_forward: |
|
|
|
if (mCurrentView != null) { |
|
|
|
if (mCurrentView != null) { |
|
|
|
if (mCurrentView.canGoForward()) |
|
|
|
if (mCurrentView.canGoForward()) { |
|
|
|
mCurrentView.goForward(); |
|
|
|
mCurrentView.goForward(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
case R.id.action_new_tab: |
|
|
|
case R.id.action_new_tab: |
|
|
|
newTab(null, true); |
|
|
|
newTab(null, true); |
|
|
@ -786,8 +796,8 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* refreshes the underlying list of the Bookmark adapter since the bookmark |
|
|
|
* refreshes the underlying list of the Bookmark adapter since the bookmark adapter doesn't always change when |
|
|
|
* adapter doesn't always change when notifyDataChanged gets called. |
|
|
|
* notifyDataChanged gets called. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void notifyBookmarkDataSetChanged() { |
|
|
|
private void notifyBookmarkDataSetChanged() { |
|
|
|
mBookmarkAdapter.clear(); |
|
|
|
mBookmarkAdapter.clear(); |
|
|
@ -796,8 +806,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* method that shows a dialog asking what string the user wishes to search |
|
|
|
* method that shows a dialog asking what string the user wishes to search for. It highlights the text entered. |
|
|
|
* for. It highlights the text entered. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void findInPage() { |
|
|
|
private void findInPage() { |
|
|
|
final AlertDialog.Builder finder = new AlertDialog.Builder(mActivity); |
|
|
|
final AlertDialog.Builder finder = new AlertDialog.Builder(mActivity); |
|
|
@ -820,9 +829,12 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
finder.show(); |
|
|
|
finder.show(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** The click listener for ListView in the navigation drawer */ |
|
|
|
/** |
|
|
|
|
|
|
|
* The click listener for ListView in the navigation drawer |
|
|
|
|
|
|
|
*/ |
|
|
|
private class DrawerItemClickListener implements |
|
|
|
private class DrawerItemClickListener implements |
|
|
|
ListView.OnItemClickListener { |
|
|
|
ListView.OnItemClickListener { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, |
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, |
|
|
|
long id) { |
|
|
|
long id) { |
|
|
@ -831,9 +843,12 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** long click listener for Navigation Drawer */ |
|
|
|
/** |
|
|
|
|
|
|
|
* long click listener for Navigation Drawer |
|
|
|
|
|
|
|
*/ |
|
|
|
private class DrawerItemLongClickListener implements |
|
|
|
private class DrawerItemLongClickListener implements |
|
|
|
ListView.OnItemLongClickListener { |
|
|
|
ListView.OnItemLongClickListener { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, |
|
|
|
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, |
|
|
|
int position, long arg3) { |
|
|
|
int position, long arg3) { |
|
|
@ -844,6 +859,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
|
|
|
|
|
|
|
|
private class BookmarkItemClickListener implements |
|
|
|
private class BookmarkItemClickListener implements |
|
|
|
ListView.OnItemClickListener { |
|
|
|
ListView.OnItemClickListener { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, |
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, |
|
|
|
long id) { |
|
|
|
long id) { |
|
|
@ -864,6 +880,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
|
|
|
|
|
|
|
|
private class BookmarkItemLongClickListener implements |
|
|
|
private class BookmarkItemLongClickListener implements |
|
|
|
ListView.OnItemLongClickListener { |
|
|
|
ListView.OnItemLongClickListener { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, |
|
|
|
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, |
|
|
|
final int position, long arg3) { |
|
|
|
final int position, long arg3) { |
|
|
@ -913,11 +930,10 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Takes in the id of which bookmark was selected and shows a dialog that |
|
|
|
* Takes in the id of which bookmark was selected and shows a dialog that allows the user to rename and change the |
|
|
|
* allows the user to rename and change the url of the bookmark |
|
|
|
* url of the bookmark |
|
|
|
* |
|
|
|
* |
|
|
|
* @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) { |
|
|
|
public synchronized void editBookmark(final int id) { |
|
|
|
final AlertDialog.Builder homePicker = new AlertDialog.Builder( |
|
|
|
final AlertDialog.Builder homePicker = new AlertDialog.Builder( |
|
|
@ -989,11 +1005,9 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* displays the WebView contained in the LightningView Also handles the |
|
|
|
* displays the WebView contained in the LightningView Also handles the removal of previous views |
|
|
|
* removal of previous views |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* @param view |
|
|
|
* @param view the LightningView to show |
|
|
|
* the LightningView to show |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private synchronized void showTab(LightningView view) { |
|
|
|
private synchronized void showTab(LightningView view) { |
|
|
|
if (view == null) { |
|
|
|
if (view == null) { |
|
|
@ -1037,8 +1051,9 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
url = intent.getDataString(); |
|
|
|
url = intent.getDataString(); |
|
|
|
} |
|
|
|
} |
|
|
|
int num = 0; |
|
|
|
int num = 0; |
|
|
|
if (intent != null && intent.getExtras() != null) |
|
|
|
if (intent != null && intent.getExtras() != null) { |
|
|
|
num = intent.getExtras().getInt(getPackageName() + ".Origin"); |
|
|
|
num = intent.getExtras().getInt(getPackageName() + ".Origin"); |
|
|
|
|
|
|
|
} |
|
|
|
if (num == 1) { |
|
|
|
if (num == 1) { |
|
|
|
mCurrentView.loadUrl(url); |
|
|
|
mCurrentView.loadUrl(url); |
|
|
|
} else if (url != null) { |
|
|
|
} else if (url != null) { |
|
|
@ -1085,8 +1100,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* When using the ActionBarDrawerToggle, you must call it during |
|
|
|
* When using the ActionBarDrawerToggle, you must call it during onPostCreate() and onConfigurationChanged()... |
|
|
|
* onPostCreate() and onConfigurationChanged()... |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -1224,9 +1238,10 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
mCurrentView = null; |
|
|
|
mCurrentView = null; |
|
|
|
for (int n = 0; n < mWebViews.size(); n++) { |
|
|
|
for (int n = 0; n < mWebViews.size(); n++) { |
|
|
|
if (mWebViews.get(n) != null) |
|
|
|
if (mWebViews.get(n) != null) { |
|
|
|
mWebViews.get(n).onDestroy(); |
|
|
|
mWebViews.get(n).onDestroy(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
mWebViews.clear(); |
|
|
|
mWebViews.clear(); |
|
|
|
mTitleAdapter.notifyDataSetChanged(); |
|
|
|
mTitleAdapter.notifyDataSetChanged(); |
|
|
|
finish(); |
|
|
|
finish(); |
|
|
@ -1297,13 +1312,15 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
mCurrentView.onPause(); |
|
|
|
mCurrentView.onPause(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (mHistoryDatabase != null) { |
|
|
|
if (mHistoryDatabase != null) { |
|
|
|
if (mHistoryDatabase.isOpen()) |
|
|
|
if (mHistoryDatabase.isOpen()) { |
|
|
|
mHistoryDatabase.close(); |
|
|
|
mHistoryDatabase.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if (mHistoryHandler != null) { |
|
|
|
if (mHistoryHandler != null) { |
|
|
|
if (mHistoryHandler.isOpen()) |
|
|
|
if (mHistoryHandler.isOpen()) { |
|
|
|
mHistoryHandler.close(); |
|
|
|
mHistoryHandler.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1325,13 +1342,15 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
protected void onDestroy() { |
|
|
|
protected void onDestroy() { |
|
|
|
Log.i(Constants.TAG, "onDestroy"); |
|
|
|
Log.i(Constants.TAG, "onDestroy"); |
|
|
|
if (mHistoryDatabase != null) { |
|
|
|
if (mHistoryDatabase != null) { |
|
|
|
if (mHistoryDatabase.isOpen()) |
|
|
|
if (mHistoryDatabase.isOpen()) { |
|
|
|
mHistoryDatabase.close(); |
|
|
|
mHistoryDatabase.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if (mHistoryHandler != null) { |
|
|
|
if (mHistoryHandler != null) { |
|
|
|
if (mHistoryHandler.isOpen()) |
|
|
|
if (mHistoryHandler.isOpen()) { |
|
|
|
mHistoryHandler.close(); |
|
|
|
mHistoryHandler.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
super.onDestroy(); |
|
|
|
super.onDestroy(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1380,8 +1399,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 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) { |
|
|
|
void searchTheWeb(String query) { |
|
|
|
if (query.equals("")) { |
|
|
|
if (query.equals("")) { |
|
|
@ -1467,7 +1485,6 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* converts the int num into density pixels |
|
|
|
* converts the int num into density pixels |
|
|
|
* |
|
|
|
* |
|
|
|
* @param num |
|
|
|
|
|
|
|
* @return density pixels |
|
|
|
* @return density pixels |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private int getDp(int num) { |
|
|
|
private int getDp(int num) { |
|
|
@ -1493,8 +1510,9 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
paint.setAntiAlias(true); |
|
|
|
paint.setAntiAlias(true); |
|
|
|
paint.setStyle(Style.FILL); |
|
|
|
paint.setStyle(Style.FILL); |
|
|
|
paint.setColor(mNumberIconColor); |
|
|
|
paint.setColor(mNumberIconColor); |
|
|
|
if (number > 99) |
|
|
|
if (number > 99) { |
|
|
|
number = 99; |
|
|
|
number = 99; |
|
|
|
|
|
|
|
} |
|
|
|
// pixels, 36 dp
|
|
|
|
// pixels, 36 dp
|
|
|
|
if (mActionBarSizeDp < 50) { |
|
|
|
if (mActionBarSizeDp < 50) { |
|
|
|
if (number > 9) { |
|
|
|
if (number > 9) { |
|
|
@ -1524,7 +1542,9 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
public class LightningViewAdapter extends ArrayAdapter<LightningView> { |
|
|
|
public class LightningViewAdapter extends ArrayAdapter<LightningView> { |
|
|
|
|
|
|
|
|
|
|
|
Context context; |
|
|
|
Context context; |
|
|
|
|
|
|
|
|
|
|
|
int layoutResourceId; |
|
|
|
int layoutResourceId; |
|
|
|
|
|
|
|
|
|
|
|
List<LightningView> data = null; |
|
|
|
List<LightningView> data = null; |
|
|
|
|
|
|
|
|
|
|
|
public LightningViewAdapter(Context context, int layoutResourceId, |
|
|
|
public LightningViewAdapter(Context context, int layoutResourceId, |
|
|
@ -1578,8 +1598,11 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class LightningViewHolder { |
|
|
|
class LightningViewHolder { |
|
|
|
|
|
|
|
|
|
|
|
TextView txtTitle; |
|
|
|
TextView txtTitle; |
|
|
|
|
|
|
|
|
|
|
|
ImageView favicon; |
|
|
|
ImageView favicon; |
|
|
|
|
|
|
|
|
|
|
|
ImageView exit; |
|
|
|
ImageView exit; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1587,7 +1610,9 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
public class BookmarkViewAdapter extends ArrayAdapter<HistoryItem> { |
|
|
|
public class BookmarkViewAdapter extends ArrayAdapter<HistoryItem> { |
|
|
|
|
|
|
|
|
|
|
|
Context context; |
|
|
|
Context context; |
|
|
|
|
|
|
|
|
|
|
|
int layoutResourceId; |
|
|
|
int layoutResourceId; |
|
|
|
|
|
|
|
|
|
|
|
List<HistoryItem> data = null; |
|
|
|
List<HistoryItem> data = null; |
|
|
|
|
|
|
|
|
|
|
|
public BookmarkViewAdapter(Context context, int layoutResourceId, |
|
|
|
public BookmarkViewAdapter(Context context, int layoutResourceId, |
|
|
@ -1628,7 +1653,9 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class BookmarkViewHolder { |
|
|
|
class BookmarkViewHolder { |
|
|
|
|
|
|
|
|
|
|
|
TextView txtTitle; |
|
|
|
TextView txtTitle; |
|
|
|
|
|
|
|
|
|
|
|
ImageView favicon; |
|
|
|
ImageView favicon; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1646,7 +1673,9 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> { |
|
|
|
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> { |
|
|
|
|
|
|
|
|
|
|
|
ImageView bmImage; |
|
|
|
ImageView bmImage; |
|
|
|
|
|
|
|
|
|
|
|
HistoryItem mWeb; |
|
|
|
HistoryItem mWeb; |
|
|
|
|
|
|
|
|
|
|
|
public DownloadImageTask(ImageView bmImage, HistoryItem web) { |
|
|
|
public DownloadImageTask(ImageView bmImage, HistoryItem web) { |
|
|
@ -1729,8 +1758,9 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void updateUrl(String url) { |
|
|
|
public void updateUrl(String url) { |
|
|
|
if (url == null) |
|
|
|
if (url == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
url = url.replaceFirst(Constants.HTTP, ""); |
|
|
|
url = url.replaceFirst(Constants.HTTP, ""); |
|
|
|
if (url.startsWith(Constants.FILE)) { |
|
|
|
if (url.startsWith(Constants.FILE)) { |
|
|
|
url = ""; |
|
|
|
url = ""; |
|
|
@ -1741,8 +1771,9 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void updateProgress(int n) { |
|
|
|
public void updateProgress(int n) { |
|
|
|
if (!mProgress.isShown()) |
|
|
|
if (!mProgress.isShown()) { |
|
|
|
mProgress.setVisibility(View.VISIBLE); |
|
|
|
mProgress.setVisibility(View.VISIBLE); |
|
|
|
|
|
|
|
} |
|
|
|
mProgress.setProgress(n); |
|
|
|
mProgress.setProgress(n); |
|
|
|
if (n == 100) { |
|
|
|
if (n == 100) { |
|
|
|
mProgress.setVisibility(View.INVISIBLE); |
|
|
|
mProgress.setVisibility(View.INVISIBLE); |
|
|
@ -1788,8 +1819,8 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
.getReadableDatabase(); |
|
|
|
.getReadableDatabase(); |
|
|
|
} |
|
|
|
} |
|
|
|
Cursor cursor = mHistoryDatabase.query( |
|
|
|
Cursor cursor = mHistoryDatabase.query( |
|
|
|
DatabaseHandler.TABLE_HISTORY, new String[] { "id", |
|
|
|
DatabaseHandler.TABLE_HISTORY, new String[]{"id", |
|
|
|
"url", "title" }, sb.toString(), null, |
|
|
|
"url", "title"}, sb.toString(), null, |
|
|
|
null, null, null); |
|
|
|
null, null, null); |
|
|
|
if (!cursor.moveToFirst()) { |
|
|
|
if (!cursor.moveToFirst()) { |
|
|
|
mHistoryHandler.addHistoryItem(new HistoryItem(url, |
|
|
|
mHistoryHandler.addHistoryItem(new HistoryItem(url, |
|
|
@ -1821,20 +1852,19 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 1, 2, 3, testing... is there a system browser that has some nice |
|
|
|
* 1, 2, 3, testing... is there a system browser that has some nice bookmarks for us? |
|
|
|
* bookmarks for us? |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean isSystemBrowserAvailable() { |
|
|
|
public boolean isSystemBrowserAvailable() { |
|
|
|
return mSystemBrowser; |
|
|
|
return mSystemBrowser; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 1, 2, 3, testing... is there a system browser that has some nice |
|
|
|
* 1, 2, 3, testing... is there a system browser that has some nice bookmarks for us? helper method for |
|
|
|
* bookmarks for us? helper method for isSystemBrowserAvailable |
|
|
|
* isSystemBrowserAvailable |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean getSystemBrowser() { |
|
|
|
public boolean getSystemBrowser() { |
|
|
|
Cursor c = null; |
|
|
|
Cursor c = null; |
|
|
|
String[] columns = new String[] { "url", "title" }; |
|
|
|
String[] columns = new String[]{"url", "title"}; |
|
|
|
boolean browserFlag = false; |
|
|
|
boolean browserFlag = false; |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
@ -1863,8 +1893,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* method to generate search suggestions for the AutoCompleteTextView from |
|
|
|
* method to generate search suggestions for the AutoCompleteTextView from previously searched URLs |
|
|
|
* previously searched URLs |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void initializeSearchSuggestions(final AutoCompleteTextView getUrl) { |
|
|
|
private void initializeSearchSuggestions(final AutoCompleteTextView getUrl) { |
|
|
|
|
|
|
|
|
|
|
@ -1936,8 +1965,6 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* returns a list of HistoryItems |
|
|
|
* returns a list of HistoryItems |
|
|
|
* |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<HistoryItem> getLatestHistory() { |
|
|
|
private List<HistoryItem> getLatestHistory() { |
|
|
|
DatabaseHandler historyHandler = new DatabaseHandler(mContext); |
|
|
|
DatabaseHandler historyHandler = new DatabaseHandler(mContext); |
|
|
@ -2096,8 +2123,9 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
protected void onActivityResult(int requestCode, int resultCode, |
|
|
|
protected void onActivityResult(int requestCode, int resultCode, |
|
|
|
Intent intent) { |
|
|
|
Intent intent) { |
|
|
|
if (requestCode == 1) { |
|
|
|
if (requestCode == 1) { |
|
|
|
if (null == mUploadMessage) |
|
|
|
if (null == mUploadMessage) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
Uri result = intent == null || resultCode != RESULT_OK ? null |
|
|
|
Uri result = intent == null || resultCode != RESULT_OK ? null |
|
|
|
: intent.getData(); |
|
|
|
: intent.getData(); |
|
|
|
mUploadMessage.onReceiveValue(result); |
|
|
|
mUploadMessage.onReceiveValue(result); |
|
|
@ -2156,8 +2184,9 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onHideCustomView() { |
|
|
|
public void onHideCustomView() { |
|
|
|
if (mCustomView == null || mCustomViewCallback == null |
|
|
|
if (mCustomView == null || mCustomViewCallback == null |
|
|
|
|| mCurrentView == null) |
|
|
|
|| mCurrentView == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
Log.i(Constants.TAG, "onHideCustomView"); |
|
|
|
Log.i(Constants.TAG, "onHideCustomView"); |
|
|
|
mCurrentView.setVisibility(View.VISIBLE); |
|
|
|
mCurrentView.setVisibility(View.VISIBLE); |
|
|
|
mCustomView.setKeepScreenOn(false); |
|
|
|
mCustomView.setKeepScreenOn(false); |
|
|
@ -2203,8 +2232,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* turns on fullscreen mode in the app |
|
|
|
* turns on fullscreen mode in the app |
|
|
|
* |
|
|
|
* |
|
|
|
* @param enabled |
|
|
|
* @param enabled whether to enable fullscreen or not |
|
|
|
* whether to enable fullscreen or not |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setFullscreen(boolean enabled) { |
|
|
|
public void setFullscreen(boolean enabled) { |
|
|
|
Window win = getWindow(); |
|
|
|
Window win = getWindow(); |
|
|
@ -2330,15 +2358,15 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
switch (which) { |
|
|
|
switch (which) { |
|
|
|
case DialogInterface.BUTTON_POSITIVE: { |
|
|
|
case DialogInterface.BUTTON_POSITIVE: |
|
|
|
newTab(url, false); |
|
|
|
newTab(url, false); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case DialogInterface.BUTTON_NEGATIVE: { |
|
|
|
case DialogInterface.BUTTON_NEGATIVE: |
|
|
|
mCurrentView.loadUrl(url); |
|
|
|
mCurrentView.loadUrl(url); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case DialogInterface.BUTTON_NEUTRAL: { |
|
|
|
case DialogInterface.BUTTON_NEUTRAL: |
|
|
|
if (API > 8) { |
|
|
|
if (API > 8) { |
|
|
|
Utils.downloadFile(mActivity, url, |
|
|
|
Utils.downloadFile(mActivity, url, |
|
|
|
mCurrentView.getUserAgent(), |
|
|
|
mCurrentView.getUserAgent(), |
|
|
@ -2347,7 +2375,6 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder( |
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder( |
|
|
@ -2374,24 +2401,22 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
switch (which) { |
|
|
|
switch (which) { |
|
|
|
case DialogInterface.BUTTON_POSITIVE: { |
|
|
|
case DialogInterface.BUTTON_POSITIVE: |
|
|
|
newTab(url, false); |
|
|
|
newTab(url, false); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case DialogInterface.BUTTON_NEGATIVE: { |
|
|
|
case DialogInterface.BUTTON_NEGATIVE: |
|
|
|
mCurrentView.loadUrl(url); |
|
|
|
mCurrentView.loadUrl(url); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case DialogInterface.BUTTON_NEUTRAL: { |
|
|
|
case DialogInterface.BUTTON_NEUTRAL: |
|
|
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); |
|
|
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); |
|
|
|
ClipData clip = ClipData.newPlainText("label", |
|
|
|
ClipData clip = ClipData.newPlainText("label", |
|
|
|
url); |
|
|
|
url); |
|
|
|
clipboard.setPrimaryClip(clip); |
|
|
|
clipboard.setPrimaryClip(clip); |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder( |
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder( |
|
|
@ -2418,15 +2443,15 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
switch (which) { |
|
|
|
switch (which) { |
|
|
|
case DialogInterface.BUTTON_POSITIVE: { |
|
|
|
case DialogInterface.BUTTON_POSITIVE: |
|
|
|
newTab(url, false); |
|
|
|
newTab(url, false); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case DialogInterface.BUTTON_NEGATIVE: { |
|
|
|
case DialogInterface.BUTTON_NEGATIVE: |
|
|
|
mCurrentView.loadUrl(url); |
|
|
|
mCurrentView.loadUrl(url); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case DialogInterface.BUTTON_NEUTRAL: { |
|
|
|
case DialogInterface.BUTTON_NEUTRAL: |
|
|
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); |
|
|
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); |
|
|
|
ClipData clip = ClipData.newPlainText("label", url); |
|
|
|
ClipData clip = ClipData.newPlainText("label", url); |
|
|
|
clipboard.setPrimaryClip(clip); |
|
|
|
clipboard.setPrimaryClip(clip); |
|
|
@ -2434,7 +2459,6 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
|
|
|
@ -2461,15 +2485,15 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
switch (which) { |
|
|
|
switch (which) { |
|
|
|
case DialogInterface.BUTTON_POSITIVE: { |
|
|
|
case DialogInterface.BUTTON_POSITIVE: |
|
|
|
newTab(newUrl, false); |
|
|
|
newTab(newUrl, false); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case DialogInterface.BUTTON_NEGATIVE: { |
|
|
|
case DialogInterface.BUTTON_NEGATIVE: |
|
|
|
mCurrentView.loadUrl(newUrl); |
|
|
|
mCurrentView.loadUrl(newUrl); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case DialogInterface.BUTTON_NEUTRAL: { |
|
|
|
case DialogInterface.BUTTON_NEUTRAL: |
|
|
|
if (API > 8) { |
|
|
|
if (API > 8) { |
|
|
|
Utils.downloadFile(mActivity, newUrl, |
|
|
|
Utils.downloadFile(mActivity, newUrl, |
|
|
|
mCurrentView.getUserAgent(), |
|
|
|
mCurrentView.getUserAgent(), |
|
|
@ -2478,7 +2502,6 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder( |
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder( |
|
|
@ -2505,15 +2528,15 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
switch (which) { |
|
|
|
switch (which) { |
|
|
|
case DialogInterface.BUTTON_POSITIVE: { |
|
|
|
case DialogInterface.BUTTON_POSITIVE: |
|
|
|
newTab(newUrl, false); |
|
|
|
newTab(newUrl, false); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case DialogInterface.BUTTON_NEGATIVE: { |
|
|
|
case DialogInterface.BUTTON_NEGATIVE: |
|
|
|
mCurrentView.loadUrl(newUrl); |
|
|
|
mCurrentView.loadUrl(newUrl); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
case DialogInterface.BUTTON_NEUTRAL: { |
|
|
|
case DialogInterface.BUTTON_NEUTRAL: |
|
|
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); |
|
|
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); |
|
|
|
ClipData clip = ClipData.newPlainText("label", |
|
|
|
ClipData clip = ClipData.newPlainText("label", |
|
|
|
newUrl); |
|
|
|
newUrl); |
|
|
@ -2522,7 +2545,6 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder( |
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder( |
|
|
@ -2552,9 +2574,8 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* This method lets the search bar know that the page is currently loading |
|
|
|
* This method lets the search bar know that the page is currently loading and that it should display the stop icon |
|
|
|
* and that it should display the stop icon to indicate to the user that |
|
|
|
* to indicate to the user that pressing it stops the page from loading |
|
|
|
* pressing it stops the page from loading |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setIsLoading() { |
|
|
|
public void setIsLoading() { |
|
|
|
if (!mSearch.hasFocus()) { |
|
|
|
if (!mSearch.hasFocus()) { |
|
|
@ -2564,8 +2585,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 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() { |
|
|
|
public void setIsFinishedLoading() { |
|
|
|
if (!mSearch.hasFocus()) { |
|
|
|
if (!mSearch.hasFocus()) { |
|
|
@ -2575,8 +2595,8 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* handle presses on the refresh icon in the search bar, if the page is |
|
|
|
* handle presses on the refresh icon in the search bar, if the page is loading, stop the page, if it is done |
|
|
|
* loading, stop the page, if it is done loading refresh the page. |
|
|
|
* loading refresh the page. |
|
|
|
* |
|
|
|
* |
|
|
|
* See setIsFinishedLoading and setIsLoading for displaying the correct icon |
|
|
|
* See setIsFinishedLoading and setIsLoading for displaying the correct icon |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -2612,5 +2632,4 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |