|
|
@ -15,16 +15,17 @@ 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.content.res.Configuration; |
|
|
|
|
|
|
|
import android.database.Cursor; |
|
|
|
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; |
|
|
|
import android.graphics.Canvas; |
|
|
|
import android.graphics.Canvas; |
|
|
|
|
|
|
|
import android.graphics.Color; |
|
|
|
import android.graphics.ColorMatrix; |
|
|
|
import android.graphics.ColorMatrix; |
|
|
|
import android.graphics.ColorMatrixColorFilter; |
|
|
|
import android.graphics.ColorMatrixColorFilter; |
|
|
|
import android.graphics.Paint; |
|
|
|
import android.graphics.Paint; |
|
|
|
import android.graphics.PorterDuff; |
|
|
|
import android.graphics.PorterDuff; |
|
|
|
|
|
|
|
import android.graphics.drawable.BitmapDrawable; |
|
|
|
import android.graphics.drawable.ColorDrawable; |
|
|
|
import android.graphics.drawable.ColorDrawable; |
|
|
|
import android.graphics.drawable.Drawable; |
|
|
|
import android.graphics.drawable.Drawable; |
|
|
|
import android.media.MediaPlayer; |
|
|
|
import android.media.MediaPlayer; |
|
|
@ -38,6 +39,7 @@ 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; |
|
|
|
|
|
|
|
import android.support.annotation.Nullable; |
|
|
|
import android.support.v4.view.GravityCompat; |
|
|
|
import android.support.v4.view.GravityCompat; |
|
|
|
import android.support.v4.view.ViewCompat; |
|
|
|
import android.support.v4.view.ViewCompat; |
|
|
|
import android.support.v4.widget.DrawerLayout; |
|
|
|
import android.support.v4.widget.DrawerLayout; |
|
|
@ -90,6 +92,8 @@ import android.widget.TextView; |
|
|
|
import android.widget.TextView.OnEditorActionListener; |
|
|
|
import android.widget.TextView.OnEditorActionListener; |
|
|
|
import android.widget.VideoView; |
|
|
|
import android.widget.VideoView; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.lucasr.twowayview.TwoWayView; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.File; |
|
|
|
import java.io.FileNotFoundException; |
|
|
|
import java.io.FileNotFoundException; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.FileOutputStream; |
|
|
@ -126,13 +130,14 @@ import acr.browser.lightning.utils.WebUtils; |
|
|
|
import acr.browser.lightning.view.AnimatedProgressBar; |
|
|
|
import acr.browser.lightning.view.AnimatedProgressBar; |
|
|
|
import acr.browser.lightning.view.LightningView; |
|
|
|
import acr.browser.lightning.view.LightningView; |
|
|
|
|
|
|
|
|
|
|
|
public abstract class BrowserActivity extends ThemableActivity implements BrowserController, OnClickListener, OnLongClickListener { |
|
|
|
public abstract class BrowserActivity extends ThemableBrowserActivity implements BrowserController, OnClickListener, OnLongClickListener { |
|
|
|
|
|
|
|
|
|
|
|
// Layout
|
|
|
|
// Layout
|
|
|
|
private DrawerLayout mDrawerLayout; |
|
|
|
private DrawerLayout mDrawerLayout; |
|
|
|
private FrameLayout mBrowserFrame; |
|
|
|
private FrameLayout mBrowserFrame; |
|
|
|
private FullscreenHolder mFullscreenContainer; |
|
|
|
private FullscreenHolder mFullscreenContainer; |
|
|
|
private ListView mDrawerListLeft, mDrawerListRight; |
|
|
|
private ListView mDrawerListRight; |
|
|
|
|
|
|
|
private TwoWayView mDrawerListLeft; |
|
|
|
private LinearLayout mDrawerLeft, mDrawerRight, mUiLayout, mToolbarLayout; |
|
|
|
private LinearLayout mDrawerLeft, mDrawerRight, mUiLayout, mToolbarLayout; |
|
|
|
private RelativeLayout mSearchBar; |
|
|
|
private RelativeLayout mSearchBar; |
|
|
|
|
|
|
|
|
|
|
@ -168,7 +173,8 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
mSystemBrowser = false, |
|
|
|
mSystemBrowser = false, |
|
|
|
mIsNewIntent = false, |
|
|
|
mIsNewIntent = false, |
|
|
|
mIsFullScreen = false, |
|
|
|
mIsFullScreen = false, |
|
|
|
mIsImmersive = false; |
|
|
|
mIsImmersive = false, |
|
|
|
|
|
|
|
mShowTabsInDrawer; |
|
|
|
private int mOriginalOrientation, mBackgroundColor, mIdGenerator, mIconColor; |
|
|
|
private int mOriginalOrientation, mBackgroundColor, mIdGenerator, mIconColor; |
|
|
|
private String mSearchText, mUntitledTitle, mHomepage, mCameraPhotoPath; |
|
|
|
private String mSearchText, mUntitledTitle, mHomepage, mCameraPhotoPath; |
|
|
|
|
|
|
|
|
|
|
@ -221,6 +227,8 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
//TODO make sure dark theme flag gets set correctly
|
|
|
|
//TODO make sure dark theme flag gets set correctly
|
|
|
|
mDarkTheme = mPreferences.getUseTheme() != 0 || isIncognito(); |
|
|
|
mDarkTheme = mPreferences.getUseTheme() != 0 || isIncognito(); |
|
|
|
mIconColor = mDarkTheme ? ThemeUtils.getIconDarkThemeColor(this) : ThemeUtils.getIconLightThemeColor(this); |
|
|
|
mIconColor = mDarkTheme ? ThemeUtils.getIconDarkThemeColor(this) : ThemeUtils.getIconLightThemeColor(this); |
|
|
|
|
|
|
|
mShowTabsInDrawer = mPreferences.getShowTabsInDrawer(!isTablet()); |
|
|
|
|
|
|
|
|
|
|
|
mActivity = this; |
|
|
|
mActivity = this; |
|
|
|
mWebViewList.clear(); |
|
|
|
mWebViewList.clear(); |
|
|
|
|
|
|
|
|
|
|
@ -237,7 +245,6 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
// Drawer stutters otherwise
|
|
|
|
// Drawer stutters otherwise
|
|
|
|
mDrawerLeft.setLayerType(View.LAYER_TYPE_HARDWARE, null); |
|
|
|
mDrawerLeft.setLayerType(View.LAYER_TYPE_HARDWARE, null); |
|
|
|
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); |
|
|
|
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); |
|
|
|
mDrawerListLeft = (ListView) findViewById(R.id.left_drawer_list); |
|
|
|
|
|
|
|
mDrawerRight = (LinearLayout) findViewById(R.id.right_drawer); |
|
|
|
mDrawerRight = (LinearLayout) findViewById(R.id.right_drawer); |
|
|
|
mDrawerRight.setLayerType(View.LAYER_TYPE_HARDWARE, null); |
|
|
|
mDrawerRight.setLayerType(View.LAYER_TYPE_HARDWARE, null); |
|
|
|
mDrawerListRight = (ListView) findViewById(R.id.right_drawer_list); |
|
|
|
mDrawerListRight = (ListView) findViewById(R.id.right_drawer_list); |
|
|
@ -246,6 +253,10 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
ImageView tabTitleImage = (ImageView) findViewById(R.id.plusIcon); |
|
|
|
ImageView tabTitleImage = (ImageView) findViewById(R.id.plusIcon); |
|
|
|
tabTitleImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN); |
|
|
|
tabTitleImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !mShowTabsInDrawer) { |
|
|
|
|
|
|
|
getWindow().setStatusBarColor(Color.BLACK); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setNavigationDrawerWidth(); |
|
|
|
setNavigationDrawerWidth(); |
|
|
|
mDrawerLayout.setDrawerListener(new DrawerLocker()); |
|
|
|
mDrawerLayout.setDrawerListener(new DrawerLocker()); |
|
|
|
|
|
|
|
|
|
|
@ -254,7 +265,20 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
|
|
|
|
|
|
|
|
mHomepage = mPreferences.getHomepage(); |
|
|
|
mHomepage = mPreferences.getHomepage(); |
|
|
|
|
|
|
|
|
|
|
|
mTitleAdapter = new LightningViewAdapter(this, R.layout.tab_list_item, mWebViewList); |
|
|
|
TwoWayView horizontalListView = (TwoWayView) findViewById(R.id.twv_list); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mShowTabsInDrawer) { |
|
|
|
|
|
|
|
mTitleAdapter = new LightningViewAdapter(this, R.layout.tab_list_item, mWebViewList); |
|
|
|
|
|
|
|
mDrawerListLeft = (TwoWayView) findViewById(R.id.left_drawer_list); |
|
|
|
|
|
|
|
mDrawerListLeft.setOverScrollMode(View.OVER_SCROLL_IF_CONTENT_SCROLLS); |
|
|
|
|
|
|
|
mToolbarLayout.removeView(horizontalListView); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
mTitleAdapter = new LightningViewAdapter(this, R.layout.tab_list_item_horizontal, mWebViewList); |
|
|
|
|
|
|
|
mDrawerListLeft = horizontalListView; |
|
|
|
|
|
|
|
mDrawerListLeft.setOverScrollMode(View.OVER_SCROLL_NEVER); |
|
|
|
|
|
|
|
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, mDrawerLeft); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mDrawerListLeft.setAdapter(mTitleAdapter); |
|
|
|
mDrawerListLeft.setAdapter(mTitleAdapter); |
|
|
|
mDrawerListLeft.setOnItemClickListener(new DrawerItemClickListener()); |
|
|
|
mDrawerListLeft.setOnItemClickListener(new DrawerItemClickListener()); |
|
|
|
mDrawerListLeft.setOnItemLongClickListener(new DrawerItemLongClickListener()); |
|
|
|
mDrawerListLeft.setOnItemLongClickListener(new DrawerItemLongClickListener()); |
|
|
@ -276,8 +300,15 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
View v = actionBar.getCustomView(); |
|
|
|
View v = actionBar.getCustomView(); |
|
|
|
LayoutParams lp = v.getLayoutParams(); |
|
|
|
LayoutParams lp = v.getLayoutParams(); |
|
|
|
lp.width = LayoutParams.MATCH_PARENT; |
|
|
|
lp.width = LayoutParams.MATCH_PARENT; |
|
|
|
|
|
|
|
lp.height = LayoutParams.MATCH_PARENT; |
|
|
|
v.setLayoutParams(lp); |
|
|
|
v.setLayoutParams(lp); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LinearLayout searchContainer = (LinearLayout) v.findViewById(R.id.search_container); |
|
|
|
|
|
|
|
LinearLayout.LayoutParams p = (LinearLayout.LayoutParams) searchContainer.getLayoutParams(); |
|
|
|
|
|
|
|
int leftMargin = !mShowTabsInDrawer ? Utils.dpToPx(10) : Utils.dpToPx(2); |
|
|
|
|
|
|
|
p.setMargins(leftMargin, Utils.dpToPx(8), Utils.dpToPx(2), Utils.dpToPx(6)); |
|
|
|
|
|
|
|
searchContainer.setLayoutParams(p); |
|
|
|
|
|
|
|
|
|
|
|
mArrowDrawable = new DrawerArrowDrawable(this); |
|
|
|
mArrowDrawable = new DrawerArrowDrawable(this); |
|
|
|
mArrowImage = (ImageView) actionBar.getCustomView().findViewById(R.id.arrow); |
|
|
|
mArrowImage = (ImageView) actionBar.getCustomView().findViewById(R.id.arrow); |
|
|
|
// Use hardware acceleration for the animation
|
|
|
|
// Use hardware acceleration for the animation
|
|
|
@ -285,7 +316,11 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
mArrowImage.setImageDrawable(mArrowDrawable); |
|
|
|
mArrowImage.setImageDrawable(mArrowDrawable); |
|
|
|
FrameLayout arrowButton = (FrameLayout) actionBar.getCustomView().findViewById( |
|
|
|
FrameLayout arrowButton = (FrameLayout) actionBar.getCustomView().findViewById( |
|
|
|
R.id.arrow_button); |
|
|
|
R.id.arrow_button); |
|
|
|
arrowButton.setOnClickListener(this); |
|
|
|
if (mShowTabsInDrawer) { |
|
|
|
|
|
|
|
arrowButton.setOnClickListener(this); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
arrowButton.setVisibility(View.GONE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mProxyUtils = ProxyUtils.getInstance(this); |
|
|
|
mProxyUtils = ProxyUtils.getInstance(this); |
|
|
|
|
|
|
|
|
|
|
@ -305,7 +340,7 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
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); |
|
|
|
mCopyIcon = ThemeUtils.getLightThemedDrawable(this, R.drawable.ic_action_copy); |
|
|
|
|
|
|
|
|
|
|
|
int iconBounds = Utils.convertDpToPixels(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); |
|
|
|
mCopyIcon.setBounds(0, 0, iconBounds, iconBounds); |
|
|
@ -522,7 +557,7 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onDrawerClosed(View v) { |
|
|
|
public void onDrawerClosed(View v) { |
|
|
|
if (v == mDrawerRight) { |
|
|
|
if (v == mDrawerRight && mShowTabsInDrawer) { |
|
|
|
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawerLeft); |
|
|
|
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawerLeft); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawerRight); |
|
|
|
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawerRight); |
|
|
@ -548,17 +583,13 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean isTablet() { |
|
|
|
|
|
|
|
return (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setNavigationDrawerWidth() { |
|
|
|
private void setNavigationDrawerWidth() { |
|
|
|
int width = getResources().getDisplayMetrics().widthPixels - Utils.convertDpToPixels(56); |
|
|
|
int width = getResources().getDisplayMetrics().widthPixels - Utils.dpToPx(56); |
|
|
|
int maxWidth; |
|
|
|
int maxWidth; |
|
|
|
if (isTablet()) { |
|
|
|
if (isTablet()) { |
|
|
|
maxWidth = Utils.convertDpToPixels(320); |
|
|
|
maxWidth = Utils.dpToPx(320); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
maxWidth = Utils.convertDpToPixels(300); |
|
|
|
maxWidth = Utils.dpToPx(300); |
|
|
|
} |
|
|
|
} |
|
|
|
if (width > maxWidth) { |
|
|
|
if (width > maxWidth) { |
|
|
|
DrawerLayout.LayoutParams params = (android.support.v4.widget.DrawerLayout.LayoutParams) mDrawerLeft |
|
|
|
DrawerLayout.LayoutParams params = (android.support.v4.widget.DrawerLayout.LayoutParams) mDrawerLeft |
|
|
@ -630,10 +661,11 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
mColorMode = mPreferences.getColorModeEnabled(); |
|
|
|
mColorMode = mPreferences.getColorModeEnabled(); |
|
|
|
mColorMode &= !mDarkTheme; |
|
|
|
mColorMode &= !mDarkTheme; |
|
|
|
if (!isIncognito() && !mColorMode && !mDarkTheme && mWebpageBitmap != null) { |
|
|
|
if (!isIncognito() && !mColorMode && !mDarkTheme && mWebpageBitmap != null) { |
|
|
|
changeToolbarBackground(mWebpageBitmap); |
|
|
|
//TODO fix toolbar coloring
|
|
|
|
|
|
|
|
// changeToolbarBackground(mWebpageBitmap, null);
|
|
|
|
} else if (!isIncognito() && mCurrentView != null && !mDarkTheme |
|
|
|
} else if (!isIncognito() && mCurrentView != null && !mDarkTheme |
|
|
|
&& mCurrentView.getFavicon() != null) { |
|
|
|
&& mCurrentView.getFavicon() != null) { |
|
|
|
changeToolbarBackground(mCurrentView.getFavicon()); |
|
|
|
// changeToolbarBackground(mCurrentView.getFavicon(), null);
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mFullScreen) { |
|
|
|
if (mFullScreen) { |
|
|
@ -914,6 +946,9 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void showCloseDialog(final int position) { |
|
|
|
private void showCloseDialog(final int position) { |
|
|
|
|
|
|
|
if (position < 0) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); |
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); |
|
|
|
ArrayAdapter<String> adapter = new ArrayAdapter<>(mActivity, |
|
|
|
ArrayAdapter<String> adapter = new ArrayAdapter<>(mActivity, |
|
|
|
android.R.layout.simple_dropdown_item_1line); |
|
|
|
android.R.layout.simple_dropdown_item_1line); |
|
|
@ -1022,7 +1057,7 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
getFolder.setAdapter(suggestionsAdapter); |
|
|
|
getFolder.setAdapter(suggestionsAdapter); |
|
|
|
LinearLayout layout = new LinearLayout(mActivity); |
|
|
|
LinearLayout layout = new LinearLayout(mActivity); |
|
|
|
layout.setOrientation(LinearLayout.VERTICAL); |
|
|
|
layout.setOrientation(LinearLayout.VERTICAL); |
|
|
|
int padding = Utils.convertDpToPixels(10); |
|
|
|
int padding = Utils.dpToPx(10); |
|
|
|
layout.setPadding(padding, padding, padding, padding); |
|
|
|
layout.setPadding(padding, padding, padding, padding); |
|
|
|
layout.addView(getTitle); |
|
|
|
layout.addView(getTitle); |
|
|
|
layout.addView(getUrl); |
|
|
|
layout.addView(getUrl); |
|
|
@ -1074,7 +1109,7 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
getTitle.setSingleLine(); |
|
|
|
getTitle.setSingleLine(); |
|
|
|
LinearLayout layout = new LinearLayout(mActivity); |
|
|
|
LinearLayout layout = new LinearLayout(mActivity); |
|
|
|
layout.setOrientation(LinearLayout.VERTICAL); |
|
|
|
layout.setOrientation(LinearLayout.VERTICAL); |
|
|
|
int padding = Utils.convertDpToPixels(10); |
|
|
|
int padding = Utils.dpToPx(10); |
|
|
|
layout.setPadding(padding, padding, padding, padding); |
|
|
|
layout.setPadding(padding, padding, padding, padding); |
|
|
|
layout.addView(getTitle); |
|
|
|
layout.addView(getTitle); |
|
|
|
editFolderDialog.setView(layout); |
|
|
|
editFolderDialog.setView(layout); |
|
|
@ -1240,6 +1275,13 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
mDrawerListLeft.setItemChecked(mWebViewList.size() - 1, true); |
|
|
|
mDrawerListLeft.setItemChecked(mWebViewList.size() - 1, true); |
|
|
|
showTab(startingTab); |
|
|
|
showTab(startingTab); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
new Handler().postDelayed(new Runnable() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void run() { |
|
|
|
|
|
|
|
mDrawerListLeft.smoothScrollToPosition(mWebViewList.size() - 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, 300); |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1248,7 +1290,10 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int current = mDrawerListLeft.getCheckedItemPosition(); |
|
|
|
int current = mWebViewList.indexOf(mCurrentView); |
|
|
|
|
|
|
|
if (current < 0) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
LightningView reference = mWebViewList.get(position); |
|
|
|
LightningView reference = mWebViewList.get(position); |
|
|
|
if (reference == null) { |
|
|
|
if (reference == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -1336,7 +1381,7 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean onKeyLongPress(int keyCode, KeyEvent event) { |
|
|
|
public boolean onKeyLongPress(int keyCode, KeyEvent event) { |
|
|
|
if (keyCode == KeyEvent.KEYCODE_BACK) { |
|
|
|
if (keyCode == KeyEvent.KEYCODE_BACK) { |
|
|
|
showCloseDialog(mDrawerListLeft.getCheckedItemPosition()); |
|
|
|
showCloseDialog(mWebViewList.indexOf(mCurrentView)); |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@ -1378,7 +1423,7 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
mCurrentView.goBack(); |
|
|
|
mCurrentView.goBack(); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
deleteTab(mDrawerListLeft.getCheckedItemPosition()); |
|
|
|
deleteTab(mWebViewList.indexOf(mCurrentView)); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Log.e(Constants.TAG, "This shouldn't happen ever"); |
|
|
|
Log.e(Constants.TAG, "This shouldn't happen ever"); |
|
|
@ -1470,8 +1515,8 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
* 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. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void searchTheWeb(String query) { |
|
|
|
private void searchTheWeb(@NonNull String query) { |
|
|
|
if (query.equals("")) { |
|
|
|
if (query.isEmpty()) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
String SEARCH = mSearchText; |
|
|
|
String SEARCH = mSearchText; |
|
|
@ -1521,6 +1566,8 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
final int layoutResourceId; |
|
|
|
final int layoutResourceId; |
|
|
|
List<LightningView> data = null; |
|
|
|
List<LightningView> data = null; |
|
|
|
final CloseTabListener mExitListener; |
|
|
|
final CloseTabListener mExitListener; |
|
|
|
|
|
|
|
private final Drawable mBackgroundTabDrawable; |
|
|
|
|
|
|
|
private final Drawable mForegroundTabDrawable; |
|
|
|
|
|
|
|
|
|
|
|
public LightningViewAdapter(Context context, int layoutResourceId, List<LightningView> data) { |
|
|
|
public LightningViewAdapter(Context context, int layoutResourceId, List<LightningView> data) { |
|
|
|
super(context, layoutResourceId, data); |
|
|
|
super(context, layoutResourceId, data); |
|
|
@ -1528,6 +1575,17 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
this.context = context; |
|
|
|
this.context = context; |
|
|
|
this.data = data; |
|
|
|
this.data = data; |
|
|
|
this.mExitListener = new CloseTabListener(); |
|
|
|
this.mExitListener = new CloseTabListener(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int backgroundColor = Utils.mixTwoColors(ThemeUtils.getPrimaryColor(mActivity), Color.BLACK, 0.75f); |
|
|
|
|
|
|
|
Bitmap backgroundTabBitmap = Bitmap.createBitmap(Utils.dpToPx(175), Utils.dpToPx(30), Bitmap.Config.ARGB_8888); |
|
|
|
|
|
|
|
Utils.drawTrapezoid(new Canvas(backgroundTabBitmap), backgroundColor, true); |
|
|
|
|
|
|
|
mBackgroundTabDrawable = new BitmapDrawable(getResources(), backgroundTabBitmap); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int foregroundColor = ThemeUtils.getPrimaryColor(context); |
|
|
|
|
|
|
|
Bitmap foregroundTabBitmap = Bitmap.createBitmap(Utils.dpToPx(175), Utils.dpToPx(30), Bitmap.Config.ARGB_8888); |
|
|
|
|
|
|
|
Utils.drawTrapezoid(new Canvas(foregroundTabBitmap), foregroundColor, false); |
|
|
|
|
|
|
|
mForegroundTabDrawable = new BitmapDrawable(getResources(), foregroundTabBitmap); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -1535,13 +1593,16 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
View row = convertView; |
|
|
|
View row = convertView; |
|
|
|
LightningViewHolder holder; |
|
|
|
LightningViewHolder holder; |
|
|
|
if (row == null) { |
|
|
|
if (row == null) { |
|
|
|
LayoutInflater inflater = ((Activity) context).getLayoutInflater(); |
|
|
|
LayoutInflater inflater = LayoutInflater.from(context); |
|
|
|
row = inflater.inflate(layoutResourceId, parent, false); |
|
|
|
row = inflater.inflate(layoutResourceId, parent, false); |
|
|
|
|
|
|
|
|
|
|
|
holder = new LightningViewHolder(); |
|
|
|
holder = new LightningViewHolder(); |
|
|
|
holder.txtTitle = (TextView) row.findViewById(R.id.textTab); |
|
|
|
holder.txtTitle = (TextView) row.findViewById(R.id.textTab); |
|
|
|
holder.favicon = (ImageView) row.findViewById(R.id.faviconTab); |
|
|
|
holder.favicon = (ImageView) row.findViewById(R.id.faviconTab); |
|
|
|
holder.exit = (ImageView) row.findViewById(R.id.deleteButton); |
|
|
|
holder.exit = (ImageView) row.findViewById(R.id.deleteButton); |
|
|
|
|
|
|
|
if (!mShowTabsInDrawer) { |
|
|
|
|
|
|
|
holder.layout = (LinearLayout) row.findViewById(R.id.tab_item_background); |
|
|
|
|
|
|
|
} |
|
|
|
holder.exitButton = (FrameLayout) row.findViewById(R.id.deleteAction); |
|
|
|
holder.exitButton = (FrameLayout) row.findViewById(R.id.deleteAction); |
|
|
|
holder.exit.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN); |
|
|
|
holder.exit.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN); |
|
|
|
row.setTag(holder); |
|
|
|
row.setTag(holder); |
|
|
@ -1552,23 +1613,35 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
holder.exitButton.setTag(position); |
|
|
|
holder.exitButton.setTag(position); |
|
|
|
holder.exitButton.setOnClickListener(mExitListener); |
|
|
|
holder.exitButton.setOnClickListener(mExitListener); |
|
|
|
|
|
|
|
|
|
|
|
ViewCompat.jumpDrawablesToCurrentState(holder.exit); |
|
|
|
ViewCompat.jumpDrawablesToCurrentState(holder.exitButton); |
|
|
|
|
|
|
|
|
|
|
|
LightningView web = data.get(position); |
|
|
|
LightningView web = data.get(position); |
|
|
|
holder.txtTitle.setText(web.getTitle()); |
|
|
|
holder.txtTitle.setText(web.getTitle()); |
|
|
|
if (web.isForegroundTab()) { |
|
|
|
|
|
|
|
holder.txtTitle.setTextAppearance(context, R.style.boldText); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
holder.txtTitle.setTextAppearance(context, R.style.normalText); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bitmap favicon = web.getFavicon(); |
|
|
|
Bitmap favicon = web.getFavicon(); |
|
|
|
if (web.isForegroundTab()) { |
|
|
|
if (web.isForegroundTab()) { |
|
|
|
|
|
|
|
holder.txtTitle.setTextAppearance(context, R.style.boldText); |
|
|
|
holder.favicon.setImageBitmap(favicon); |
|
|
|
holder.favicon.setImageBitmap(favicon); |
|
|
|
if (!isIncognito() && mColorMode) |
|
|
|
if (!mShowTabsInDrawer) { |
|
|
|
changeToolbarBackground(favicon); |
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { |
|
|
|
|
|
|
|
holder.layout.setBackground(mForegroundTabDrawable); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
holder.layout.setBackgroundDrawable(mForegroundTabDrawable); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!isIncognito() && mColorMode) { |
|
|
|
|
|
|
|
// TODO fix toolbar coloring
|
|
|
|
|
|
|
|
// changeToolbarBackground(favicon, mForegroundTabDrawable);
|
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
holder.txtTitle.setTextAppearance(context, R.style.normalText); |
|
|
|
|
|
|
|
if (!mShowTabsInDrawer) { |
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { |
|
|
|
|
|
|
|
holder.layout.setBackground(mBackgroundTabDrawable); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
holder.layout.setBackgroundDrawable(mBackgroundTabDrawable); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
Bitmap grayscaleBitmap = Bitmap.createBitmap(favicon.getWidth(), |
|
|
|
Bitmap grayscaleBitmap = Bitmap.createBitmap(favicon.getWidth(), |
|
|
|
favicon.getHeight(), Bitmap.Config.ARGB_8888); |
|
|
|
favicon.getHeight(), Bitmap.Config.ARGB_8888); |
|
|
|
|
|
|
|
|
|
|
@ -1576,7 +1649,7 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
if (colorMatrix == null || filter == null || paint == null) { |
|
|
|
if (colorMatrix == null || filter == null || paint == null) { |
|
|
|
paint = new Paint(); |
|
|
|
paint = new Paint(); |
|
|
|
colorMatrix = new ColorMatrix(); |
|
|
|
colorMatrix = new ColorMatrix(); |
|
|
|
colorMatrix.setSaturation(0); |
|
|
|
colorMatrix.setSaturation(0.5f); |
|
|
|
filter = new ColorMatrixColorFilter(colorMatrix); |
|
|
|
filter = new ColorMatrixColorFilter(colorMatrix); |
|
|
|
paint.setColorFilter(filter); |
|
|
|
paint.setColorFilter(filter); |
|
|
|
} |
|
|
|
} |
|
|
@ -1592,6 +1665,7 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
ImageView favicon; |
|
|
|
ImageView favicon; |
|
|
|
ImageView exit; |
|
|
|
ImageView exit; |
|
|
|
FrameLayout exitButton; |
|
|
|
FrameLayout exitButton; |
|
|
|
|
|
|
|
LinearLayout layout; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1604,7 +1678,15 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void changeToolbarBackground(Bitmap favicon) { |
|
|
|
/** |
|
|
|
|
|
|
|
* Animates the color of the toolbar from one color to another. Optionally animates |
|
|
|
|
|
|
|
* the color of the tab background, for use when the tabs are displayed on the top |
|
|
|
|
|
|
|
* of the screen. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param favicon the Bitmap to extract the color from |
|
|
|
|
|
|
|
* @param tabBackground the optional LinearLayout to color |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void changeToolbarBackground(@NonNull Bitmap favicon, @Nullable final Drawable tabBackground) { |
|
|
|
Palette.from(favicon).generate(new Palette.PaletteAsyncListener() { |
|
|
|
Palette.from(favicon).generate(new Palette.PaletteAsyncListener() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onGenerated(Palette palette) { |
|
|
|
public void onGenerated(Palette palette) { |
|
|
@ -1625,22 +1707,28 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
|
|
|
|
|
|
|
|
ValueAnimator anim = ValueAnimator.ofObject(new ArgbEvaluator(), |
|
|
|
ValueAnimator anim = ValueAnimator.ofObject(new ArgbEvaluator(), |
|
|
|
mBackground.getColor(), finalColor); |
|
|
|
mBackground.getColor(), finalColor); |
|
|
|
|
|
|
|
final Window window = getWindow(); |
|
|
|
|
|
|
|
if (!mShowTabsInDrawer) { |
|
|
|
|
|
|
|
window.setBackgroundDrawable(new ColorDrawable(Color.BLACK)); |
|
|
|
|
|
|
|
} |
|
|
|
anim.addUpdateListener(new AnimatorUpdateListener() { |
|
|
|
anim.addUpdateListener(new AnimatorUpdateListener() { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onAnimationUpdate(ValueAnimator animation) { |
|
|
|
public void onAnimationUpdate(ValueAnimator animation) { |
|
|
|
int color = (Integer) animation.getAnimatedValue(); |
|
|
|
final int color = (Integer) animation.getAnimatedValue(); |
|
|
|
mBackground.setColor(color); |
|
|
|
if (mShowTabsInDrawer) { |
|
|
|
getWindow().setBackgroundDrawable(mBackground); |
|
|
|
mBackground.setColor(color); |
|
|
|
|
|
|
|
window.setBackgroundDrawable(mBackground); |
|
|
|
|
|
|
|
} |
|
|
|
mToolbarLayout.setBackgroundColor(color); |
|
|
|
mToolbarLayout.setBackgroundColor(color); |
|
|
|
|
|
|
|
if (tabBackground != null) { |
|
|
|
|
|
|
|
tabBackground.setColorFilter(color, PorterDuff.Mode.SRC_IN); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
anim.setDuration(300); |
|
|
|
anim.setDuration(300); |
|
|
|
anim.start(); |
|
|
|
anim.start(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
@ -2138,7 +2226,7 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
mFilePathCallback = filePathCallback; |
|
|
|
mFilePathCallback = filePathCallback; |
|
|
|
|
|
|
|
|
|
|
|
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
|
|
|
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
|
|
|
if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) { |
|
|
|
if (takePictureIntent.resolveActivity(mActivity.getPackageManager()) != null) { |
|
|
|
// Create the File where the photo should go
|
|
|
|
// Create the File where the photo should go
|
|
|
|
File photoFile = null; |
|
|
|
File photoFile = null; |
|
|
|
try { |
|
|
|
try { |
|
|
@ -2370,6 +2458,7 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Closes the specified view, implementing the JavaScript callback to close a window |
|
|
|
* Closes the specified view, implementing the JavaScript callback to close a window |
|
|
|
|
|
|
|
* |
|
|
|
* @param view the LightningView to close |
|
|
|
* @param view the LightningView to close |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -2776,7 +2865,7 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
if (mCurrentView.canGoBack()) { |
|
|
|
if (mCurrentView.canGoBack()) { |
|
|
|
mCurrentView.goBack(); |
|
|
|
mCurrentView.goBack(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
deleteTab(mDrawerListLeft.getCheckedItemPosition()); |
|
|
|
deleteTab(mWebViewList.indexOf(mCurrentView)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
@ -2790,7 +2879,7 @@ public abstract class BrowserActivity extends ThemableActivity implements Browse |
|
|
|
case R.id.arrow_button: |
|
|
|
case R.id.arrow_button: |
|
|
|
if (mSearch != null && mSearch.hasFocus()) { |
|
|
|
if (mSearch != null && mSearch.hasFocus()) { |
|
|
|
mCurrentView.requestFocus(); |
|
|
|
mCurrentView.requestFocus(); |
|
|
|
} else { |
|
|
|
} else if (mShowTabsInDrawer) { |
|
|
|
mDrawerLayout.openDrawer(mDrawerLeft); |
|
|
|
mDrawerLayout.openDrawer(mDrawerLeft); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|