Initial support for tabs on the top instead of in the navigation drawer
added a setting to switch between modes. Still needs work to be less buggy
This commit is contained in:
parent
e71e09c2e8
commit
58c9e820ed
@ -43,6 +43,7 @@ dependencies {
|
|||||||
compile 'com.android.support:appcompat-v7:22.2.1'
|
compile 'com.android.support:appcompat-v7:22.2.1'
|
||||||
compile 'com.android.support:design:22.2.1'
|
compile 'com.android.support:design:22.2.1'
|
||||||
compile 'org.jsoup:jsoup:1.8.1'
|
compile 'org.jsoup:jsoup:1.8.1'
|
||||||
|
compile 'org.lucasr.twowayview:twowayview:0.1.4'
|
||||||
// Only Lightning Plus needs the proxy libraries
|
// Only Lightning Plus needs the proxy libraries
|
||||||
lightningPlusCompile 'net.i2p.android:client:0.7'
|
lightningPlusCompile 'net.i2p.android:client:0.7'
|
||||||
lightningPlusCompile(project(':libnetcipher'))
|
lightningPlusCompile(project(':libnetcipher'))
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
-keep public class * extends android.preference.Preference
|
-keep public class * extends android.preference.Preference
|
||||||
-keep public class com.android.vending.licensing.ILicensingService
|
-keep public class com.android.vending.licensing.ILicensingService
|
||||||
-keep public class acr.browser.lightning.reading.*
|
-keep public class acr.browser.lightning.reading.*
|
||||||
|
-keep class org.lucasr.twowayview.** { *; }
|
||||||
|
|
||||||
-assumenosideeffects class android.util.Log {
|
-assumenosideeffects class android.util.Log {
|
||||||
public static *** d(...);
|
public static *** d(...);
|
||||||
|
@ -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();
|
||||||
|
|
||||||
|
TwoWayView horizontalListView = (TwoWayView) findViewById(R.id.twv_list);
|
||||||
|
|
||||||
|
if (mShowTabsInDrawer) {
|
||||||
mTitleAdapter = new LightningViewAdapter(this, R.layout.tab_list_item, mWebViewList);
|
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);
|
||||||
|
if (mShowTabsInDrawer) {
|
||||||
arrowButton.setOnClickListener(this);
|
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 {
|
} else {
|
||||||
|
holder.layout.setBackgroundDrawable(mForegroundTabDrawable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!isIncognito() && mColorMode) {
|
||||||
|
// TODO fix toolbar coloring
|
||||||
|
// changeToolbarBackground(favicon, mForegroundTabDrawable);
|
||||||
|
}
|
||||||
|
} 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();
|
||||||
|
if (mShowTabsInDrawer) {
|
||||||
mBackground.setColor(color);
|
mBackground.setColor(color);
|
||||||
getWindow().setBackgroundDrawable(mBackground);
|
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;
|
||||||
|
@ -1,19 +1,22 @@
|
|||||||
package acr.browser.lightning.activity;
|
package acr.browser.lightning.activity;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
|
||||||
import acr.browser.lightning.R;
|
import acr.browser.lightning.R;
|
||||||
import acr.browser.lightning.preference.PreferenceManager;
|
import acr.browser.lightning.preference.PreferenceManager;
|
||||||
|
|
||||||
public abstract class ThemableActivity extends AppCompatActivity {
|
public abstract class ThemableBrowserActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private int mTheme;
|
private int mTheme;
|
||||||
|
private boolean mShowTabsInDrawer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
mTheme = PreferenceManager.getInstance().getUseTheme();
|
mTheme = PreferenceManager.getInstance().getUseTheme();
|
||||||
|
mShowTabsInDrawer = PreferenceManager.getInstance().getShowTabsInDrawer(!isTablet());
|
||||||
|
|
||||||
// set the theme
|
// set the theme
|
||||||
if (mTheme == 1) {
|
if (mTheme == 1) {
|
||||||
@ -27,11 +30,17 @@ public abstract class ThemableActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (PreferenceManager.getInstance().getUseTheme() != mTheme) {
|
int theme = PreferenceManager.getInstance().getUseTheme();
|
||||||
|
boolean drawerTabs = PreferenceManager.getInstance().getShowTabsInDrawer(!isTablet());
|
||||||
|
if (theme != mTheme || mShowTabsInDrawer != drawerTabs) {
|
||||||
restart();
|
restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isTablet() {
|
||||||
|
return (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE;
|
||||||
|
}
|
||||||
|
|
||||||
private void restart() {
|
private void restart() {
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
finish();
|
finish();
|
@ -41,6 +41,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe
|
|||||||
private static final String SETTINGS_HOME = "home";
|
private static final String SETTINGS_HOME = "home";
|
||||||
private static final String SETTINGS_SEARCHENGINE = "search";
|
private static final String SETTINGS_SEARCHENGINE = "search";
|
||||||
private static final String SETTINGS_GOOGLESUGGESTIONS = "google_suggestions";
|
private static final String SETTINGS_GOOGLESUGGESTIONS = "google_suggestions";
|
||||||
|
private static final String SETTINGS_DRAWERTABS = "cb_drawertabs";
|
||||||
|
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
private static final int API = android.os.Build.VERSION.SDK_INT;
|
private static final int API = android.os.Build.VERSION.SDK_INT;
|
||||||
@ -50,7 +51,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe
|
|||||||
private String mDownloadLocation;
|
private String mDownloadLocation;
|
||||||
private int mAgentChoice;
|
private int mAgentChoice;
|
||||||
private String mHomepage;
|
private String mHomepage;
|
||||||
private CheckBoxPreference cbFlash, cbAds, cbImages, cbJsScript, cbColorMode, cbgooglesuggest;
|
private CheckBoxPreference cbFlash, cbAds, cbImages, cbJsScript, cbColorMode, cbgooglesuggest, cbDrawerTabs;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@ -72,12 +73,14 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe
|
|||||||
downloadloc = findPreference(SETTINGS_DOWNLOAD);
|
downloadloc = findPreference(SETTINGS_DOWNLOAD);
|
||||||
home = findPreference(SETTINGS_HOME);
|
home = findPreference(SETTINGS_HOME);
|
||||||
searchengine = findPreference(SETTINGS_SEARCHENGINE);
|
searchengine = findPreference(SETTINGS_SEARCHENGINE);
|
||||||
|
|
||||||
cbFlash = (CheckBoxPreference) findPreference(SETTINGS_FLASH);
|
cbFlash = (CheckBoxPreference) findPreference(SETTINGS_FLASH);
|
||||||
cbAds = (CheckBoxPreference) findPreference(SETTINGS_ADS);
|
cbAds = (CheckBoxPreference) findPreference(SETTINGS_ADS);
|
||||||
cbImages = (CheckBoxPreference) findPreference(SETTINGS_IMAGES);
|
cbImages = (CheckBoxPreference) findPreference(SETTINGS_IMAGES);
|
||||||
cbJsScript = (CheckBoxPreference) findPreference(SETTINGS_JAVASCRIPT);
|
cbJsScript = (CheckBoxPreference) findPreference(SETTINGS_JAVASCRIPT);
|
||||||
cbColorMode = (CheckBoxPreference) findPreference(SETTINGS_COLORMODE);
|
cbColorMode = (CheckBoxPreference) findPreference(SETTINGS_COLORMODE);
|
||||||
cbgooglesuggest = (CheckBoxPreference) findPreference(SETTINGS_GOOGLESUGGESTIONS);
|
cbgooglesuggest = (CheckBoxPreference) findPreference(SETTINGS_GOOGLESUGGESTIONS);
|
||||||
|
cbDrawerTabs = (CheckBoxPreference) findPreference(SETTINGS_DRAWERTABS);
|
||||||
|
|
||||||
proxy.setOnPreferenceClickListener(this);
|
proxy.setOnPreferenceClickListener(this);
|
||||||
useragent.setOnPreferenceClickListener(this);
|
useragent.setOnPreferenceClickListener(this);
|
||||||
@ -90,6 +93,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe
|
|||||||
cbJsScript.setOnPreferenceChangeListener(this);
|
cbJsScript.setOnPreferenceChangeListener(this);
|
||||||
cbColorMode.setOnPreferenceChangeListener(this);
|
cbColorMode.setOnPreferenceChangeListener(this);
|
||||||
cbgooglesuggest.setOnPreferenceChangeListener(this);
|
cbgooglesuggest.setOnPreferenceChangeListener(this);
|
||||||
|
cbDrawerTabs.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
mAgentChoice = mPreferences.getUserAgentChoice();
|
mAgentChoice = mPreferences.getUserAgentChoice();
|
||||||
mHomepage = mPreferences.getHomepage();
|
mHomepage = mPreferences.getHomepage();
|
||||||
@ -149,6 +153,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe
|
|||||||
cbAds.setChecked(Constants.FULL_VERSION && mPreferences.getAdBlockEnabled());
|
cbAds.setChecked(Constants.FULL_VERSION && mPreferences.getAdBlockEnabled());
|
||||||
cbColorMode.setChecked(mPreferences.getColorModeEnabled());
|
cbColorMode.setChecked(mPreferences.getColorModeEnabled());
|
||||||
cbgooglesuggest.setChecked(mPreferences.getGoogleSearchSuggestionsEnabled());
|
cbgooglesuggest.setChecked(mPreferences.getGoogleSearchSuggestionsEnabled());
|
||||||
|
cbDrawerTabs.setChecked(mPreferences.getShowTabsInDrawer(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void searchUrlPicker() {
|
private void searchUrlPicker() {
|
||||||
@ -477,7 +482,7 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe
|
|||||||
final EditText getDownload = new EditText(mActivity);
|
final EditText getDownload = new EditText(mActivity);
|
||||||
getDownload.setText(mPreferences.getDownloadDirectory());
|
getDownload.setText(mPreferences.getDownloadDirectory());
|
||||||
|
|
||||||
int padding = Utils.convertDpToPixels(10);
|
int padding = Utils.dpToPx(10);
|
||||||
|
|
||||||
TextView v = new TextView(mActivity);
|
TextView v = new TextView(mActivity);
|
||||||
v.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
|
v.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
|
||||||
@ -607,6 +612,9 @@ public class GeneralSettingsFragment extends PreferenceFragment implements Prefe
|
|||||||
mPreferences.setGoogleSearchSuggestionsEnabled((Boolean) newValue);
|
mPreferences.setGoogleSearchSuggestionsEnabled((Boolean) newValue);
|
||||||
cbgooglesuggest.setChecked((Boolean) newValue);
|
cbgooglesuggest.setChecked((Boolean) newValue);
|
||||||
return true;
|
return true;
|
||||||
|
case SETTINGS_DRAWERTABS:
|
||||||
|
mPreferences.setShowTabsInDrawer((Boolean) newValue);
|
||||||
|
cbDrawerTabs.setChecked((Boolean) newValue);
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ public class PreferenceManager {
|
|||||||
public static final String DEFAULT_BOOKMARKS = "defaultBookmarks";
|
public static final String DEFAULT_BOOKMARKS = "defaultBookmarks";
|
||||||
public static final String TEXT_ENCODING = "textEncoding";
|
public static final String TEXT_ENCODING = "textEncoding";
|
||||||
public static final String CLEAR_WEBSTORAGE_EXIT = "clearWebStorageExit";
|
public static final String CLEAR_WEBSTORAGE_EXIT = "clearWebStorageExit";
|
||||||
|
public static final String SHOW_TABS_IN_DRAWER = "showTabsInDrawer";
|
||||||
|
|
||||||
public static final String USE_PROXY = "useProxy";
|
public static final String USE_PROXY = "useProxy";
|
||||||
public static final String PROXY_CHOICE = "proxyChoice";
|
public static final String PROXY_CHOICE = "proxyChoice";
|
||||||
@ -258,6 +259,10 @@ public class PreferenceManager {
|
|||||||
return mPrefs.getString(Name.TEXT_ENCODING, Constants.DEFAULT_ENCODING);
|
return mPrefs.getString(Name.TEXT_ENCODING, Constants.DEFAULT_ENCODING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getShowTabsInDrawer(boolean defaultValue){
|
||||||
|
return mPrefs.getBoolean(Name.SHOW_TABS_IN_DRAWER, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
private void putBoolean(String name, boolean value) {
|
private void putBoolean(String name, boolean value) {
|
||||||
mPrefs.edit().putBoolean(name, value).apply();
|
mPrefs.edit().putBoolean(name, value).apply();
|
||||||
}
|
}
|
||||||
@ -270,6 +275,10 @@ public class PreferenceManager {
|
|||||||
mPrefs.edit().putString(name, value).apply();
|
mPrefs.edit().putString(name, value).apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setShowTabsInDrawer(boolean show){
|
||||||
|
putBoolean(Name.SHOW_TABS_IN_DRAWER, show);
|
||||||
|
}
|
||||||
|
|
||||||
public void setTextEncoding(String encoding) {
|
public void setTextEncoding(String encoding) {
|
||||||
putString(Name.TEXT_ENCODING, encoding);
|
putString(Name.TEXT_ENCODING, encoding);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,11 @@ import android.content.pm.PackageManager;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.LinearGradient;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.Path;
|
||||||
|
import android.graphics.Shader;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
@ -88,9 +92,12 @@ public final class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of pixels corresponding to the passed density pixels
|
* Converts Density Pixels (DP) to Pixels (PX)
|
||||||
|
*
|
||||||
|
* @param dp the number of density pixels to convert
|
||||||
|
* @return the number of pixels
|
||||||
*/
|
*/
|
||||||
public static int convertDpToPixels(int dp) {
|
public static int dpToPx(int dp) {
|
||||||
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
|
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
|
||||||
return (int) (dp * metrics.density + 0.5f);
|
return (int) (dp * metrics.density + 0.5f);
|
||||||
}
|
}
|
||||||
@ -166,7 +173,7 @@ public final class Utils {
|
|||||||
* @return the padded bitmap.
|
* @return the padded bitmap.
|
||||||
*/
|
*/
|
||||||
public static Bitmap padFavicon(Bitmap bitmap) {
|
public static Bitmap padFavicon(Bitmap bitmap) {
|
||||||
int padding = Utils.convertDpToPixels(4);
|
int padding = Utils.dpToPx(4);
|
||||||
|
|
||||||
Bitmap paddedBitmap = Bitmap.createBitmap(bitmap.getWidth() + padding, bitmap.getHeight()
|
Bitmap paddedBitmap = Bitmap.createBitmap(bitmap.getWidth() + padding, bitmap.getHeight()
|
||||||
+ padding, Bitmap.Config.ARGB_8888);
|
+ padding, Bitmap.Config.ARGB_8888);
|
||||||
@ -220,6 +227,12 @@ public final class Utils {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if flash player is installed
|
||||||
|
*
|
||||||
|
* @param context the context needed to obtain the PackageManager
|
||||||
|
* @return true if flash is installed, false otherwise
|
||||||
|
*/
|
||||||
public static boolean isFlashInstalled(Context context) {
|
public static boolean isFlashInstalled(Context context) {
|
||||||
try {
|
try {
|
||||||
PackageManager pm = context.getPackageManager();
|
PackageManager pm = context.getPackageManager();
|
||||||
@ -233,6 +246,12 @@ public final class Utils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quietly closes a closeable object like an InputStream or OutputStream without
|
||||||
|
* throwing any errors or requiring you do do any checks.
|
||||||
|
*
|
||||||
|
* @param closeable the object to close
|
||||||
|
*/
|
||||||
public static void close(Closeable closeable) {
|
public static void close(Closeable closeable) {
|
||||||
if (closeable == null)
|
if (closeable == null)
|
||||||
return;
|
return;
|
||||||
@ -251,4 +270,43 @@ public final class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws the trapezoid background for the horizontal tabs on a canvas object using
|
||||||
|
* the specified color.
|
||||||
|
*
|
||||||
|
* @param canvas the canvas to draw upon
|
||||||
|
* @param color the color to use to draw the tab
|
||||||
|
*/
|
||||||
|
public static void drawTrapezoid(Canvas canvas, int color, boolean withShader) {
|
||||||
|
|
||||||
|
Paint paint = new Paint();
|
||||||
|
paint.setColor(color);
|
||||||
|
paint.setStyle(Paint.Style.FILL);
|
||||||
|
// paint.setFilterBitmap(true);
|
||||||
|
paint.setAntiAlias(true);
|
||||||
|
paint.setDither(true);
|
||||||
|
if (withShader) {
|
||||||
|
paint.setShader(new LinearGradient(0, 0.9f * canvas.getHeight(),
|
||||||
|
0, canvas.getHeight(),
|
||||||
|
color, mixTwoColors(Color.BLACK, color, 0.5f),
|
||||||
|
Shader.TileMode.CLAMP));
|
||||||
|
} else {
|
||||||
|
paint.setShader(null);
|
||||||
|
}
|
||||||
|
int width = canvas.getWidth();
|
||||||
|
int height = canvas.getHeight();
|
||||||
|
double radians = Math.PI / 3;
|
||||||
|
int base = (int) (height / Math.tan(radians));
|
||||||
|
|
||||||
|
Path wallpath = new Path();
|
||||||
|
wallpath.reset();
|
||||||
|
wallpath.moveTo(0, height);
|
||||||
|
wallpath.lineTo(width, height);
|
||||||
|
wallpath.lineTo(width - base, 0);
|
||||||
|
wallpath.lineTo(base, 0);
|
||||||
|
wallpath.close();
|
||||||
|
|
||||||
|
canvas.drawPath(wallpath, paint);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,8 @@ public class LightningView {
|
|||||||
private final Activity mActivity;
|
private final Activity mActivity;
|
||||||
private static String mHomepage;
|
private static String mHomepage;
|
||||||
private static String mDefaultUserAgent;
|
private static String mDefaultUserAgent;
|
||||||
private static Bitmap mWebpageBitmap;
|
// TODO fix so that mWebpageBitmap can be static - static changes the icon when switching from light to dark and then back to light
|
||||||
|
private Bitmap mWebpageBitmap;
|
||||||
private static PreferenceManager mPreferences;
|
private static PreferenceManager mPreferences;
|
||||||
private final AdBlock mAdBlock;
|
private final AdBlock mAdBlock;
|
||||||
private IntentUtils mIntentUtils;
|
private IntentUtils mIntentUtils;
|
||||||
@ -86,7 +87,7 @@ public class LightningView {
|
|||||||
private boolean mToggleDesktop = false;
|
private boolean mToggleDesktop = false;
|
||||||
private static float mMaxFling;
|
private static float mMaxFling;
|
||||||
private static final int API = android.os.Build.VERSION.SDK_INT;
|
private static final int API = android.os.Build.VERSION.SDK_INT;
|
||||||
private static final int SCROLL_UP_THRESHOLD = Utils.convertDpToPixels(10);
|
private static final int SCROLL_UP_THRESHOLD = Utils.dpToPx(10);
|
||||||
private static final float[] mNegativeColorArray = {-1.0f, 0, 0, 0, 255, // red
|
private static final float[] mNegativeColorArray = {-1.0f, 0, 0, 0, 255, // red
|
||||||
0, -1.0f, 0, 0, 255, // green
|
0, -1.0f, 0, 0, 255, // green
|
||||||
0, 0, -1.0f, 0, 255, // blue
|
0, 0, -1.0f, 0, 255, // blue
|
||||||
|
@ -1,24 +1,25 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/search_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginBottom="6dp"
|
android:layout_marginBottom="6dp"
|
||||||
android:layout_marginLeft="2dp"
|
android:layout_marginLeft="2dp"
|
||||||
android:layout_marginRight="2dp"
|
android:layout_marginRight="2dp"
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:elevation="2dp"
|
android:layout_weight="1"
|
||||||
android:background="?attr/searchBackground"
|
android:background="?attr/searchBackground"
|
||||||
android:clipChildren="false"
|
android:clipChildren="false"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:descendantFocusability="beforeDescendants"
|
android:descendantFocusability="beforeDescendants"
|
||||||
|
android:elevation="2dp"
|
||||||
android:focusableInTouchMode="true"
|
android:focusableInTouchMode="true"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
|
|
||||||
<AutoCompleteTextView
|
<AutoCompleteTextView
|
||||||
android:id="@+id/search"
|
android:id="@+id/search"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:background="@null"
|
android:background="@null"
|
||||||
android:gravity="left|center_vertical"
|
android:gravity="left|center_vertical"
|
||||||
android:hint="@string/search_hint"
|
android:hint="@string/search_hint"
|
||||||
@ -32,7 +33,6 @@
|
|||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textColor="@color/gray_dark"
|
android:textColor="@color/gray_dark"
|
||||||
android:textColorHint="@color/hint_text"
|
android:textColorHint="@color/hint_text"
|
||||||
android:textCursorDrawable="@null" >
|
android:textCursorDrawable="@null"></AutoCompleteTextView>
|
||||||
</AutoCompleteTextView>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -44,7 +44,7 @@
|
|||||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ListView
|
<org.lucasr.twowayview.TwoWayView
|
||||||
android:id="@+id/left_drawer_list"
|
android:id="@+id/left_drawer_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/tab_item_background"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="56dp"
|
android:layout_height="56dp"
|
||||||
android:background="?attr/selectedBackground"
|
android:background="?attr/selectedBackground"
|
||||||
|
51
app/src/main/res/layout/tab_list_item_horizontal.xml
Normal file
51
app/src/main/res/layout/tab_list_item_horizontal.xml
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/tab_item_background"
|
||||||
|
android:layout_width="175dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="10dp"
|
||||||
|
android:paddingRight="10dp"
|
||||||
|
android:weightSum="1">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/faviconTab"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_marginLeft="5dp"
|
||||||
|
android:layout_marginRight="5dp"
|
||||||
|
android:contentDescription="Favicon"
|
||||||
|
android:gravity="center_vertical" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textTab"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:fontFamily="sans-serif-light"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/deleteAction"
|
||||||
|
android:layout_width="36dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:background="?attr/actionBarItemBackground"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/deleteButton"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:contentDescription="Delete Tab"
|
||||||
|
android:src="@drawable/ic_action_delete" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -8,6 +8,19 @@
|
|||||||
android:elevation="2dp"
|
android:elevation="2dp"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<org.lucasr.twowayview.TwoWayView
|
||||||
|
android:id="@+id/twv_list"
|
||||||
|
style="@style/TwoWayView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:background="@color/black"
|
||||||
|
android:overScrollMode="never"
|
||||||
|
android:listSelector="?attr/listBackground"
|
||||||
|
android:scrollbars="none" />
|
||||||
|
<!--
|
||||||
|
TODO fucking fix the list selector aka remove it
|
||||||
|
-->
|
||||||
|
|
||||||
<android.support.v7.widget.Toolbar
|
<android.support.v7.widget.Toolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
@ -213,4 +213,7 @@
|
|||||||
<string name="clear_web_storage">Clear Web Storage</string>
|
<string name="clear_web_storage">Clear Web Storage</string>
|
||||||
<string name="clear_web_storage_exit">Clear web storage on exit</string>
|
<string name="clear_web_storage_exit">Clear web storage on exit</string>
|
||||||
<string name="message_web_storage_cleared">Web Storage Cleared</string>
|
<string name="message_web_storage_cleared">Web Storage Cleared</string>
|
||||||
|
<string name="hosts_source">Hosts File Ad Blocking Source</string>
|
||||||
|
<string name="settings_adblock">Ad Block Settings</string>
|
||||||
|
<string name="tabs_in_drawer">Show tabs in Navigation Drawer</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -126,4 +126,8 @@
|
|||||||
<item name="android:fontFamily">sans-serif-light</item>
|
<item name="android:fontFamily">sans-serif-light</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="TwoWayView">
|
||||||
|
<item name="android:orientation">horizontal</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
@ -2,6 +2,10 @@
|
|||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/settings_general">
|
<PreferenceCategory android:title="@string/settings_general">
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="cb_drawertabs"
|
||||||
|
android:title="@string/tabs_in_drawer" />
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="cb_flash"
|
android:key="cb_flash"
|
||||||
|
Loading…
Reference in New Issue
Block a user