|
|
@ -77,7 +77,6 @@ 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.CookieManager; |
|
|
|
import android.webkit.CookieSyncManager; |
|
|
|
|
|
|
|
import android.webkit.ValueCallback; |
|
|
|
import android.webkit.ValueCallback; |
|
|
|
import android.webkit.WebChromeClient.CustomViewCallback; |
|
|
|
import android.webkit.WebChromeClient.CustomViewCallback; |
|
|
|
import android.webkit.WebIconDatabase; |
|
|
|
import android.webkit.WebIconDatabase; |
|
|
@ -99,57 +98,57 @@ import android.widget.TextView.OnEditorActionListener; |
|
|
|
import android.widget.VideoView; |
|
|
|
import android.widget.VideoView; |
|
|
|
|
|
|
|
|
|
|
|
public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
private static DrawerLayout mDrawerLayout; |
|
|
|
private DrawerLayout mDrawerLayout; |
|
|
|
private static ListView mDrawerList; |
|
|
|
private ListView mDrawerList; |
|
|
|
private static RelativeLayout mDrawer; |
|
|
|
private RelativeLayout mDrawer; |
|
|
|
private static LinearLayout mDrawerRight; |
|
|
|
private LinearLayout mDrawerRight; |
|
|
|
private static ListView mDrawerListRight; |
|
|
|
private ListView mDrawerListRight; |
|
|
|
private static TextView mNewTab; |
|
|
|
private TextView mNewTab; |
|
|
|
private static ActionBarDrawerToggle mDrawerToggle; |
|
|
|
private ActionBarDrawerToggle mDrawerToggle; |
|
|
|
private List<LightningView> mWebViews = new ArrayList<LightningView>(); |
|
|
|
private List<LightningView> mWebViews = new ArrayList<LightningView>(); |
|
|
|
private static List<Integer> mIdList = new ArrayList<Integer>(); |
|
|
|
private List<Integer> mIdList = new ArrayList<Integer>(); |
|
|
|
private LightningView mCurrentView; |
|
|
|
private LightningView mCurrentView; |
|
|
|
private static int mIdGenerator; |
|
|
|
private int mIdGenerator; |
|
|
|
private static LightningViewAdapter mTitleAdapter; |
|
|
|
private LightningViewAdapter mTitleAdapter; |
|
|
|
private static List<HistoryItem> mBookmarkList; |
|
|
|
private List<HistoryItem> mBookmarkList; |
|
|
|
private static BookmarkViewAdapter mBookmarkAdapter; |
|
|
|
private BookmarkViewAdapter mBookmarkAdapter; |
|
|
|
private static AutoCompleteTextView mSearch; |
|
|
|
private AutoCompleteTextView mSearch; |
|
|
|
private static ClickHandler mClickHandler; |
|
|
|
private ClickHandler mClickHandler; |
|
|
|
private static ProgressBar mProgress; |
|
|
|
private ProgressBar mProgress; |
|
|
|
private static boolean mSystemBrowser = false; |
|
|
|
private boolean mSystemBrowser = false; |
|
|
|
private static ValueCallback<Uri> mUploadMessage; |
|
|
|
private ValueCallback<Uri> mUploadMessage; |
|
|
|
private static View mCustomView; |
|
|
|
private View mCustomView; |
|
|
|
private static int mOriginalOrientation; |
|
|
|
private int mOriginalOrientation; |
|
|
|
private static int mActionBarSize; |
|
|
|
private int mActionBarSize; |
|
|
|
private static ActionBar mActionBar; |
|
|
|
private ActionBar mActionBar; |
|
|
|
private static boolean mFullScreen; |
|
|
|
private boolean mFullScreen; |
|
|
|
private static FrameLayout mBrowserFrame; |
|
|
|
private FrameLayout mBrowserFrame; |
|
|
|
private static FullscreenHolder mFullscreenContainer; |
|
|
|
private FullscreenHolder mFullscreenContainer; |
|
|
|
private static CustomViewCallback mCustomViewCallback; |
|
|
|
private CustomViewCallback mCustomViewCallback; |
|
|
|
private static 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 static Bitmap mDefaultVideoPoster; |
|
|
|
private Bitmap mDefaultVideoPoster; |
|
|
|
private static View mVideoProgressView; |
|
|
|
private View mVideoProgressView; |
|
|
|
private static DatabaseHandler mHistoryHandler; |
|
|
|
private DatabaseHandler mHistoryHandler; |
|
|
|
private static SQLiteDatabase mHistoryDatabase; |
|
|
|
private SQLiteDatabase mHistoryDatabase; |
|
|
|
private static SharedPreferences mPreferences; |
|
|
|
private SharedPreferences mPreferences; |
|
|
|
private static SharedPreferences.Editor mEditPrefs; |
|
|
|
private SharedPreferences.Editor mEditPrefs; |
|
|
|
private static Context mContext; |
|
|
|
private Context mContext; |
|
|
|
private static Bitmap mWebpageBitmap; |
|
|
|
private Bitmap mWebpageBitmap; |
|
|
|
private static String mSearchText; |
|
|
|
private String mSearchText; |
|
|
|
private static Activity mActivity; |
|
|
|
private Activity mActivity; |
|
|
|
private static CookieManager mCookieManager; |
|
|
|
private CookieManager mCookieManager; |
|
|
|
private static final int API = android.os.Build.VERSION.SDK_INT; |
|
|
|
private final int API = android.os.Build.VERSION.SDK_INT; |
|
|
|
private static Drawable mDeleteIcon; |
|
|
|
private Drawable mDeleteIcon; |
|
|
|
private static Drawable mRefreshIcon; |
|
|
|
private Drawable mRefreshIcon; |
|
|
|
private static Drawable mCopyIcon; |
|
|
|
private Drawable mCopyIcon; |
|
|
|
private static Drawable mIcon; |
|
|
|
private Drawable mIcon; |
|
|
|
private static int mActionBarSizeDp; |
|
|
|
private int mActionBarSizeDp; |
|
|
|
private static int mNumberIconColor; |
|
|
|
private int mNumberIconColor; |
|
|
|
private static String mHomepage; |
|
|
|
private String mHomepage; |
|
|
|
private static boolean mIsNewIntent = false; |
|
|
|
private boolean mIsNewIntent = false; |
|
|
|
private static VideoView mVideoView; |
|
|
|
private VideoView mVideoView; |
|
|
|
private static SearchAdapter mSearchAdapter; |
|
|
|
private static SearchAdapter mSearchAdapter; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -443,17 +442,19 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
getDir("icons", MODE_PRIVATE).getPath()); |
|
|
|
getDir("icons", MODE_PRIVATE).getPath()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
boolean useProxy = mPreferences.getBoolean(PreferenceConstants.USE_PROXY, false); |
|
|
|
//boolean useProxy = mPreferences.getBoolean(
|
|
|
|
|
|
|
|
// PreferenceConstants.USE_PROXY, false);
|
|
|
|
|
|
|
|
|
|
|
|
if (useProxy) |
|
|
|
// if (useProxy)
|
|
|
|
initializeTor(); |
|
|
|
// initializeTor();
|
|
|
|
else |
|
|
|
// else
|
|
|
|
checkForTor(); |
|
|
|
checkForTor(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
|
* If Orbot/Tor is installed, prompt the user if they want to enable proxying for this session |
|
|
|
* If Orbot/Tor is installed, prompt the user if they want to enable |
|
|
|
|
|
|
|
* proxying for this session |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean checkForTor() { |
|
|
|
public boolean checkForTor() { |
|
|
|
|
|
|
|
|
|
|
@ -465,7 +466,10 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
switch (which) { |
|
|
|
switch (which) { |
|
|
|
case DialogInterface.BUTTON_POSITIVE: |
|
|
|
case DialogInterface.BUTTON_POSITIVE: |
|
|
|
|
|
|
|
|
|
|
|
mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, true).apply(); |
|
|
|
mPreferences |
|
|
|
|
|
|
|
.edit() |
|
|
|
|
|
|
|
.putBoolean(PreferenceConstants.USE_PROXY, true) |
|
|
|
|
|
|
|
.apply(); |
|
|
|
|
|
|
|
|
|
|
|
initializeTor(); |
|
|
|
initializeTor(); |
|
|
|
|
|
|
|
|
|
|
@ -473,15 +477,19 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
|
|
|
|
|
|
|
|
case DialogInterface.BUTTON_NEGATIVE: |
|
|
|
case DialogInterface.BUTTON_NEGATIVE: |
|
|
|
|
|
|
|
|
|
|
|
mPreferences.edit().putBoolean(PreferenceConstants.USE_PROXY, false).apply(); |
|
|
|
mPreferences |
|
|
|
|
|
|
|
.edit() |
|
|
|
|
|
|
|
.putBoolean(PreferenceConstants.USE_PROXY, |
|
|
|
|
|
|
|
false).apply(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this); |
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this); |
|
|
|
builder.setMessage(R.string.use_tor_prompt).setPositiveButton(android.R.string.yes, dialogClickListener) |
|
|
|
builder.setMessage(R.string.use_tor_prompt) |
|
|
|
.setNegativeButton(android.R.string.no, dialogClickListener).show(); |
|
|
|
.setPositiveButton(R.string.yes, dialogClickListener) |
|
|
|
|
|
|
|
.setNegativeButton(R.string.no, dialogClickListener).show(); |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@ -500,15 +508,25 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
|
|
|
|
|
|
|
|
WebkitProxy wkp = new WebkitProxy(); |
|
|
|
WebkitProxy wkp = new WebkitProxy(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
String host = mPreferences.getString(PreferenceConstants.USE_PROXY_HOST, "localhost"); |
|
|
|
String host = mPreferences.getString( |
|
|
|
int port = mPreferences.getInt(PreferenceConstants.USE_PROXY_PORT, 8118); |
|
|
|
PreferenceConstants.USE_PROXY_HOST, "localhost"); |
|
|
|
wkp.setProxy("acr.browser.lightning.BrowserApp", getApplicationContext(), host, port); |
|
|
|
int port = mPreferences.getInt(PreferenceConstants.USE_PROXY_PORT, |
|
|
|
|
|
|
|
8118); |
|
|
|
|
|
|
|
wkp.setProxy("acr.browser.lightning.BrowserApp", |
|
|
|
|
|
|
|
getApplicationContext(), host, port); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
Log.d("Lightning","error enabling web proxying",e); |
|
|
|
Log.d(Constants.LOGTAG, "error enabling web proxying", e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
* Override this class |
|
|
|
|
|
|
|
*/ |
|
|
|
public synchronized void initializeTabs() { |
|
|
|
public synchronized void initializeTabs() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void restoreOrNewTab() { |
|
|
|
mIdGenerator = 0; |
|
|
|
mIdGenerator = 0; |
|
|
|
|
|
|
|
|
|
|
|
String url = null; |
|
|
|
String url = null; |
|
|
@ -545,7 +563,6 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
newTab(url, true); |
|
|
|
newTab(url, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void initializePreferences() { |
|
|
|
public void initializePreferences() { |
|
|
@ -603,10 +620,14 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mCookieManager = CookieManager.getInstance(); |
|
|
|
updateCookiePreference(); |
|
|
|
CookieSyncManager.createInstance(this); |
|
|
|
|
|
|
|
mCookieManager.setAcceptCookie(mPreferences.getBoolean( |
|
|
|
} |
|
|
|
PreferenceConstants.COOKIES, true)); |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
* Override this if class overrides BrowserActivity |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void updateCookiePreference() { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -622,7 +643,6 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean onCreateOptionsMenu(Menu menu) { |
|
|
|
public boolean onCreateOptionsMenu(Menu menu) { |
|
|
|
getMenuInflater().inflate(R.menu.main, menu); |
|
|
|
|
|
|
|
return super.onCreateOptionsMenu(menu); |
|
|
|
return super.onCreateOptionsMenu(menu); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -938,6 +958,9 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onNewIntent(Intent intent) { |
|
|
|
protected void onNewIntent(Intent intent) { |
|
|
|
super.onNewIntent(intent); |
|
|
|
super.onNewIntent(intent); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void handleNewIntent(Intent intent) { |
|
|
|
if (mCurrentView == null) { |
|
|
|
if (mCurrentView == null) { |
|
|
|
initialize(); |
|
|
|
initialize(); |
|
|
|
} |
|
|
|
} |
|
|
@ -991,9 +1014,10 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
mDrawerToggle.onConfigurationChanged(newConfig); |
|
|
|
mDrawerToggle.onConfigurationChanged(newConfig); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private synchronized void newTab(String url, boolean show) { |
|
|
|
protected synchronized void newTab(String url, boolean show) { |
|
|
|
mIsNewIntent = false; |
|
|
|
mIsNewIntent = false; |
|
|
|
LightningView startingTab = new LightningView(mActivity, url, mCookieManager); |
|
|
|
LightningView startingTab = new LightningView(mActivity, url, |
|
|
|
|
|
|
|
mCookieManager); |
|
|
|
if (mIdGenerator == 0) { |
|
|
|
if (mIdGenerator == 0) { |
|
|
|
startingTab.resumeTimers(); |
|
|
|
startingTab.resumeTimers(); |
|
|
|
} |
|
|
|
} |
|
|
@ -1041,7 +1065,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (mCurrentView.getUrl().startsWith(Constants.FILE) |
|
|
|
if (mCurrentView.getUrl().startsWith(Constants.FILE) |
|
|
|
|| mCurrentView.getUrl().equals(mHomepage)) { |
|
|
|
|| mCurrentView.getUrl().equals(mHomepage)) { |
|
|
|
moveTaskToBack(true); |
|
|
|
closeActivity(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
mIdList.remove(position); |
|
|
|
mIdList.remove(position); |
|
|
|
mWebViews.remove(position); |
|
|
|
mWebViews.remove(position); |
|
|
@ -1049,7 +1073,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
PreferenceConstants.CLEAR_CACHE_EXIT, false) |
|
|
|
PreferenceConstants.CLEAR_CACHE_EXIT, false) |
|
|
|
&& mCurrentView != null) { |
|
|
|
&& mCurrentView != null) { |
|
|
|
mCurrentView.clearCache(true); |
|
|
|
mCurrentView.clearCache(true); |
|
|
|
Log.i("Lightning", "Cache Cleared"); |
|
|
|
Log.i(Constants.LOGTAG, "Cache Cleared"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (reference != null) { |
|
|
|
if (reference != null) { |
|
|
@ -1068,10 +1092,10 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
|
|
|
|
|
|
|
|
if (mIsNewIntent && isShown) { |
|
|
|
if (mIsNewIntent && isShown) { |
|
|
|
mIsNewIntent = false; |
|
|
|
mIsNewIntent = false; |
|
|
|
moveTaskToBack(true); |
|
|
|
closeActivity(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Log.i("Lightning", "deleted tab"); |
|
|
|
Log.i(Constants.LOGTAG, "deleted tab"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -1080,7 +1104,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
if (mPreferences.getBoolean(PreferenceConstants.CLEAR_CACHE_EXIT, |
|
|
|
if (mPreferences.getBoolean(PreferenceConstants.CLEAR_CACHE_EXIT, |
|
|
|
false) && mCurrentView != null) { |
|
|
|
false) && mCurrentView != null) { |
|
|
|
mCurrentView.clearCache(true); |
|
|
|
mCurrentView.clearCache(true); |
|
|
|
Log.i("Lightning", "Cache Cleared"); |
|
|
|
Log.i(Constants.LOGTAG, "Cache Cleared"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
mCurrentView = null; |
|
|
|
mCurrentView = null; |
|
|
@ -1106,7 +1130,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
mDrawerLayout.closeDrawer(mDrawerRight); |
|
|
|
mDrawerLayout.closeDrawer(mDrawerRight); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (mCurrentView != null) { |
|
|
|
if (mCurrentView != null) { |
|
|
|
Log.i("Lightning", "onBackPressed"); |
|
|
|
Log.i(Constants.LOGTAG, "onBackPressed"); |
|
|
|
if (mCurrentView.canGoBack()) { |
|
|
|
if (mCurrentView.canGoBack()) { |
|
|
|
if (!mCurrentView.isShown()) { |
|
|
|
if (!mCurrentView.isShown()) { |
|
|
|
onHideCustomView(); |
|
|
|
onHideCustomView(); |
|
|
@ -1117,7 +1141,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
deleteTab(mDrawerList.getCheckedItemPosition()); |
|
|
|
deleteTab(mDrawerList.getCheckedItemPosition()); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Log.e("Lightning Browser", |
|
|
|
Log.e(Constants.LOGTAG, |
|
|
|
"So madness. Much confusion. Why happen."); |
|
|
|
"So madness. Much confusion. Why happen."); |
|
|
|
super.onBackPressed(); |
|
|
|
super.onBackPressed(); |
|
|
|
} |
|
|
|
} |
|
|
@ -1127,7 +1151,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onPause() { |
|
|
|
protected void onPause() { |
|
|
|
super.onPause(); |
|
|
|
super.onPause(); |
|
|
|
Log.i("Lightning", "onPause"); |
|
|
|
Log.i(Constants.LOGTAG, "onPause"); |
|
|
|
if (mCurrentView != null) { |
|
|
|
if (mCurrentView != null) { |
|
|
|
mCurrentView.pauseTimers(); |
|
|
|
mCurrentView.pauseTimers(); |
|
|
|
mCurrentView.onPause(); |
|
|
|
mCurrentView.onPause(); |
|
|
@ -1140,6 +1164,10 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
if (mHistoryHandler.isOpen()) |
|
|
|
if (mHistoryHandler.isOpen()) |
|
|
|
mHistoryHandler.close(); |
|
|
|
mHistoryHandler.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void saveOpenTabs() { |
|
|
|
if (mPreferences |
|
|
|
if (mPreferences |
|
|
|
.getBoolean(PreferenceConstants.RESTORE_LOST_TABS, true)) { |
|
|
|
.getBoolean(PreferenceConstants.RESTORE_LOST_TABS, true)) { |
|
|
|
String s = ""; |
|
|
|
String s = ""; |
|
|
@ -1155,7 +1183,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onDestroy() { |
|
|
|
protected void onDestroy() { |
|
|
|
Log.i("Lightning", "onDestroy"); |
|
|
|
Log.i(Constants.LOGTAG, "onDestroy"); |
|
|
|
if (mHistoryDatabase != null) { |
|
|
|
if (mHistoryDatabase != null) { |
|
|
|
if (mHistoryDatabase.isOpen()) |
|
|
|
if (mHistoryDatabase.isOpen()) |
|
|
|
mHistoryDatabase.close(); |
|
|
|
mHistoryDatabase.close(); |
|
|
@ -1170,7 +1198,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void onResume() { |
|
|
|
protected void onResume() { |
|
|
|
super.onResume(); |
|
|
|
super.onResume(); |
|
|
|
Log.i("Lightning", "onResume"); |
|
|
|
Log.i(Constants.LOGTAG, "onResume"); |
|
|
|
if (SettingsController.getClearHistory()) { |
|
|
|
if (SettingsController.getClearHistory()) { |
|
|
|
} |
|
|
|
} |
|
|
|
if (mSearchAdapter != null) { |
|
|
|
if (mSearchAdapter != null) { |
|
|
@ -1544,7 +1572,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static String getDomainName(String url) throws URISyntaxException { |
|
|
|
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) { |
|
|
@ -1580,6 +1608,10 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void updateHistory(final String title, final String url) { |
|
|
|
public void updateHistory(final String title, final String url) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void addItemToHistory(final String title, final String url) { |
|
|
|
Runnable update = new Runnable() { |
|
|
|
Runnable update = new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
@ -1624,11 +1656,13 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
cursor.close(); |
|
|
|
cursor.close(); |
|
|
|
cursor = null; |
|
|
|
cursor = null; |
|
|
|
} catch (IllegalStateException e) { |
|
|
|
} catch (IllegalStateException e) { |
|
|
|
Log.e("Lightning", "IllegalStateException in updateHistory"); |
|
|
|
Log.e(Constants.LOGTAG, |
|
|
|
|
|
|
|
"IllegalStateException in updateHistory"); |
|
|
|
} catch (NullPointerException e) { |
|
|
|
} catch (NullPointerException e) { |
|
|
|
Log.e("Lightning", "NullPointerException in updateHistory"); |
|
|
|
Log.e(Constants.LOGTAG, |
|
|
|
|
|
|
|
"NullPointerException in updateHistory"); |
|
|
|
} catch (SQLiteException e) { |
|
|
|
} catch (SQLiteException e) { |
|
|
|
Log.e("Lightning", "SQLiteException in updateHistory"); |
|
|
|
Log.e(Constants.LOGTAG, "SQLiteException in updateHistory"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -1722,10 +1756,15 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
getUrl.setSelectAllOnFocus(true); |
|
|
|
getUrl.setSelectAllOnFocus(true); |
|
|
|
mSearchAdapter = new SearchAdapter(mContext, false); |
|
|
|
mSearchAdapter = new SearchAdapter(mContext, isIncognito()); |
|
|
|
getUrl.setAdapter(mSearchAdapter); |
|
|
|
getUrl.setAdapter(mSearchAdapter); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isIncognito() { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Damn it, I regret not using SQLite in the first place for this
|
|
|
|
private List<HistoryItem> getBookmarks() { |
|
|
|
private List<HistoryItem> getBookmarks() { |
|
|
|
List<HistoryItem> bookmarks = new ArrayList<HistoryItem>(); |
|
|
|
List<HistoryItem> bookmarks = new ArrayList<HistoryItem>(); |
|
|
|
File bookUrl = new File(getApplicationContext().getFilesDir(), |
|
|
|
File bookUrl = new File(getApplicationContext().getFilesDir(), |
|
|
@ -1969,7 +2008,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
if (mCustomView == null || mCustomViewCallback == null |
|
|
|
if (mCustomView == null || mCustomViewCallback == null |
|
|
|
|| mCurrentView == null) |
|
|
|
|| mCurrentView == null) |
|
|
|
return; |
|
|
|
return; |
|
|
|
Log.i("Lightning", "onHideCustomView"); |
|
|
|
Log.i(Constants.LOGTAG, "onHideCustomView"); |
|
|
|
mCurrentView.setVisibility(View.VISIBLE); |
|
|
|
mCurrentView.setVisibility(View.VISIBLE); |
|
|
|
mCustomView.setKeepScreenOn(false); |
|
|
|
mCustomView.setKeepScreenOn(false); |
|
|
|
setFullscreen(mPreferences.getBoolean( |
|
|
|
setFullscreen(mPreferences.getBoolean( |
|
|
@ -2133,15 +2172,13 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
if (mCurrentView.getWebView() != null) { |
|
|
|
if (mCurrentView.getWebView() != null) { |
|
|
|
result = mCurrentView.getWebView().getHitTestResult(); |
|
|
|
result = mCurrentView.getWebView().getHitTestResult(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (url != null) { |
|
|
|
|
|
|
|
if (url != null) { |
|
|
|
if (url != null) { |
|
|
|
if (result != null) { |
|
|
|
if (result != null) { |
|
|
|
if (result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE |
|
|
|
if (result.getType() == HitTestResult.SRC_IMAGE_ANCHOR_TYPE |
|
|
|
|| result.getType() == HitTestResult.IMAGE_TYPE) { |
|
|
|
|| result.getType() == HitTestResult.IMAGE_TYPE) { |
|
|
|
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { |
|
|
|
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
int which) { |
|
|
|
|
|
|
|
switch (which) { |
|
|
|
switch (which) { |
|
|
|
case DialogInterface.BUTTON_POSITIVE: { |
|
|
|
case DialogInterface.BUTTON_POSITIVE: { |
|
|
|
newTab(url, false); |
|
|
|
newTab(url, false); |
|
|
@ -2185,8 +2222,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { |
|
|
|
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(DialogInterface dialog, |
|
|
|
public void onClick(DialogInterface dialog, int which) { |
|
|
|
int which) { |
|
|
|
|
|
|
|
switch (which) { |
|
|
|
switch (which) { |
|
|
|
case DialogInterface.BUTTON_POSITIVE: { |
|
|
|
case DialogInterface.BUTTON_POSITIVE: { |
|
|
|
newTab(url, false); |
|
|
|
newTab(url, false); |
|
|
@ -2198,8 +2234,8 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
case DialogInterface.BUTTON_NEUTRAL: { |
|
|
|
case DialogInterface.BUTTON_NEUTRAL: { |
|
|
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); |
|
|
|
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); |
|
|
|
ClipData clip = ClipData.newPlainText( |
|
|
|
ClipData clip = ClipData.newPlainText("label", |
|
|
|
"label", url); |
|
|
|
url); |
|
|
|
clipboard.setPrimaryClip(clip); |
|
|
|
clipboard.setPrimaryClip(clip); |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
@ -2242,8 +2278,7 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
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; |
|
|
@ -2252,26 +2287,21 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder( |
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
|
|
|
|
mActivity); // dialog
|
|
|
|
|
|
|
|
builder.setTitle(url) |
|
|
|
builder.setTitle(url) |
|
|
|
.setMessage( |
|
|
|
.setMessage( |
|
|
|
getResources().getString( |
|
|
|
getResources().getString(R.string.dialog_link)) |
|
|
|
R.string.dialog_link)) |
|
|
|
|
|
|
|
.setPositiveButton( |
|
|
|
.setPositiveButton( |
|
|
|
getResources().getString( |
|
|
|
getResources().getString( |
|
|
|
R.string.action_new_tab), |
|
|
|
R.string.action_new_tab), |
|
|
|
dialogClickListener) |
|
|
|
dialogClickListener) |
|
|
|
.setNegativeButton( |
|
|
|
.setNegativeButton( |
|
|
|
getResources().getString( |
|
|
|
getResources().getString(R.string.action_open), |
|
|
|
R.string.action_open), |
|
|
|
|
|
|
|
dialogClickListener) |
|
|
|
dialogClickListener) |
|
|
|
.setNeutralButton( |
|
|
|
.setNeutralButton( |
|
|
|
getResources().getString( |
|
|
|
getResources().getString(R.string.action_copy), |
|
|
|
R.string.action_copy), |
|
|
|
|
|
|
|
dialogClickListener).show(); |
|
|
|
dialogClickListener).show(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else if (result != null) { |
|
|
|
} else if (result != null) { |
|
|
|
if (result.getExtra() != null) { |
|
|
|
if (result.getExtra() != null) { |
|
|
|
final String newUrl = result.getExtra(); |
|
|
|
final String newUrl = result.getExtra(); |
|
|
@ -2419,6 +2449,11 @@ public class BrowserActivity extends Activity implements BrowserController { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Override this, use finish() for Incognito, moveTaskToBack for Main
|
|
|
|
|
|
|
|
public void closeActivity() { |
|
|
|
|
|
|
|
finish(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class SortIgnoreCase implements Comparator<HistoryItem> { |
|
|
|
public class SortIgnoreCase implements Comparator<HistoryItem> { |
|
|
|
|
|
|
|
|
|
|
|
public int compare(HistoryItem o1, HistoryItem o2) { |
|
|
|
public int compare(HistoryItem o1, HistoryItem o2) { |
|
|
|