|
|
@ -12,18 +12,21 @@ import android.graphics.Paint; |
|
|
|
import android.graphics.PorterDuff; |
|
|
|
import android.graphics.PorterDuff; |
|
|
|
import android.graphics.drawable.BitmapDrawable; |
|
|
|
import android.graphics.drawable.BitmapDrawable; |
|
|
|
import android.graphics.drawable.Drawable; |
|
|
|
import android.graphics.drawable.Drawable; |
|
|
|
|
|
|
|
import android.graphics.drawable.TransitionDrawable; |
|
|
|
import android.os.Build; |
|
|
|
import android.os.Build; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Bundle; |
|
|
|
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.annotation.Nullable; |
|
|
|
import android.support.v4.app.Fragment; |
|
|
|
import android.support.v4.app.Fragment; |
|
|
|
|
|
|
|
import android.support.v4.content.ContextCompat; |
|
|
|
import android.support.v4.view.ViewCompat; |
|
|
|
import android.support.v4.view.ViewCompat; |
|
|
|
import android.support.v4.widget.TextViewCompat; |
|
|
|
import android.support.v4.widget.TextViewCompat; |
|
|
|
import android.support.v7.widget.LinearLayoutManager; |
|
|
|
import android.support.v7.widget.LinearLayoutManager; |
|
|
|
import android.support.v7.widget.RecyclerView; |
|
|
|
import android.support.v7.widget.RecyclerView; |
|
|
|
import android.support.v7.widget.RecyclerView.LayoutManager; |
|
|
|
import android.support.v7.widget.RecyclerView.LayoutManager; |
|
|
|
import android.support.v7.widget.SimpleItemAnimator; |
|
|
|
import android.support.v7.widget.SimpleItemAnimator; |
|
|
|
|
|
|
|
import android.util.Log; |
|
|
|
import android.view.LayoutInflater; |
|
|
|
import android.view.LayoutInflater; |
|
|
|
import android.view.View; |
|
|
|
import android.view.View; |
|
|
|
import android.view.ViewGroup; |
|
|
|
import android.view.ViewGroup; |
|
|
@ -46,8 +49,10 @@ import acr.browser.lightning.controller.UIController; |
|
|
|
import acr.browser.lightning.fragment.anim.HorizontalItemAnimator; |
|
|
|
import acr.browser.lightning.fragment.anim.HorizontalItemAnimator; |
|
|
|
import acr.browser.lightning.fragment.anim.VerticalItemAnimator; |
|
|
|
import acr.browser.lightning.fragment.anim.VerticalItemAnimator; |
|
|
|
import acr.browser.lightning.preference.PreferenceManager; |
|
|
|
import acr.browser.lightning.preference.PreferenceManager; |
|
|
|
|
|
|
|
import acr.browser.lightning.utils.DrawableUtils; |
|
|
|
import acr.browser.lightning.utils.ThemeUtils; |
|
|
|
import acr.browser.lightning.utils.ThemeUtils; |
|
|
|
import acr.browser.lightning.utils.Utils; |
|
|
|
import acr.browser.lightning.utils.Utils; |
|
|
|
|
|
|
|
import acr.browser.lightning.view.BackgroundDrawable; |
|
|
|
import acr.browser.lightning.view.LightningView; |
|
|
|
import acr.browser.lightning.view.LightningView; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -272,7 +277,6 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View |
|
|
|
|
|
|
|
|
|
|
|
private final int mLayoutResourceId; |
|
|
|
private final int mLayoutResourceId; |
|
|
|
@Nullable private final Drawable mBackgroundTabDrawable; |
|
|
|
@Nullable private final Drawable mBackgroundTabDrawable; |
|
|
|
@Nullable private final Drawable mForegroundTabDrawable; |
|
|
|
|
|
|
|
@Nullable private final Bitmap mForegroundTabBitmap; |
|
|
|
@Nullable private final Bitmap mForegroundTabBitmap; |
|
|
|
private ColorMatrix mColorMatrix; |
|
|
|
private ColorMatrix mColorMatrix; |
|
|
|
private Paint mPaint; |
|
|
|
private Paint mPaint; |
|
|
@ -288,7 +292,6 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View |
|
|
|
if (vertical) { |
|
|
|
if (vertical) { |
|
|
|
mBackgroundTabDrawable = null; |
|
|
|
mBackgroundTabDrawable = null; |
|
|
|
mForegroundTabBitmap = null; |
|
|
|
mForegroundTabBitmap = null; |
|
|
|
mForegroundTabDrawable = ThemeUtils.getSelectedBackground(getContext(), mDarkTheme); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
int backgroundColor = Utils.mixTwoColors(ThemeUtils.getPrimaryColor(getContext()), Color.BLACK, 0.75f); |
|
|
|
int backgroundColor = Utils.mixTwoColors(ThemeUtils.getPrimaryColor(getContext()), Color.BLACK, 0.75f); |
|
|
|
Bitmap backgroundTabBitmap = Bitmap.createBitmap(Utils.dpToPx(175), Utils.dpToPx(30), Bitmap.Config.ARGB_8888); |
|
|
|
Bitmap backgroundTabBitmap = Bitmap.createBitmap(Utils.dpToPx(175), Utils.dpToPx(30), Bitmap.Config.ARGB_8888); |
|
|
@ -298,7 +301,6 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View |
|
|
|
int foregroundColor = ThemeUtils.getPrimaryColor(getContext()); |
|
|
|
int foregroundColor = ThemeUtils.getPrimaryColor(getContext()); |
|
|
|
mForegroundTabBitmap = Bitmap.createBitmap(Utils.dpToPx(175), Utils.dpToPx(30), Bitmap.Config.ARGB_8888); |
|
|
|
mForegroundTabBitmap = Bitmap.createBitmap(Utils.dpToPx(175), Utils.dpToPx(30), Bitmap.Config.ARGB_8888); |
|
|
|
Utils.drawTrapezoid(new Canvas(mForegroundTabBitmap), foregroundColor, false); |
|
|
|
Utils.drawTrapezoid(new Canvas(mForegroundTabBitmap), foregroundColor, false); |
|
|
|
mForegroundTabDrawable = null; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -307,6 +309,9 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View |
|
|
|
public LightningViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { |
|
|
|
public LightningViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { |
|
|
|
LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext()); |
|
|
|
LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext()); |
|
|
|
View view = inflater.inflate(mLayoutResourceId, viewGroup, false); |
|
|
|
View view = inflater.inflate(mLayoutResourceId, viewGroup, false); |
|
|
|
|
|
|
|
if (mDrawerTabs) { |
|
|
|
|
|
|
|
DrawableUtils.setBackground(view, new BackgroundDrawable(view.getContext())); |
|
|
|
|
|
|
|
} |
|
|
|
return new LightningViewHolder(view); |
|
|
|
return new LightningViewHolder(view); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -324,36 +329,39 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View |
|
|
|
|
|
|
|
|
|
|
|
final Bitmap favicon = web.getFavicon(); |
|
|
|
final Bitmap favicon = web.getFavicon(); |
|
|
|
if (web.isForegroundTab()) { |
|
|
|
if (web.isForegroundTab()) { |
|
|
|
TextViewCompat.setTextAppearance(holder.txtTitle, R.style.boldText); |
|
|
|
Drawable foregroundDrawable = null; |
|
|
|
Drawable foregroundDrawable; |
|
|
|
|
|
|
|
if (!mDrawerTabs) { |
|
|
|
if (!mDrawerTabs) { |
|
|
|
foregroundDrawable = new BitmapDrawable(getResources(), mForegroundTabBitmap); |
|
|
|
foregroundDrawable = new BitmapDrawable(getResources(), mForegroundTabBitmap); |
|
|
|
if (!mIsIncognito && mColorMode) { |
|
|
|
if (!mIsIncognito && mColorMode) { |
|
|
|
foregroundDrawable.setColorFilter(mUiController.getUiColor(), PorterDuff.Mode.SRC_IN); |
|
|
|
foregroundDrawable.setColorFilter(mUiController.getUiColor(), PorterDuff.Mode.SRC_IN); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
foregroundDrawable = mForegroundTabDrawable; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { |
|
|
|
|
|
|
|
holder.layout.setBackground(foregroundDrawable); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
//noinspection deprecation
|
|
|
|
|
|
|
|
holder.layout.setBackgroundDrawable(foregroundDrawable); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (!mIsIncognito && mColorMode) { |
|
|
|
if (!mIsIncognito && mColorMode) { |
|
|
|
mUiController.changeToolbarBackground(favicon, foregroundDrawable); |
|
|
|
mUiController.changeToolbarBackground(favicon, foregroundDrawable); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TextViewCompat.setTextAppearance(holder.txtTitle, R.style.boldText); |
|
|
|
|
|
|
|
if (!mDrawerTabs) { |
|
|
|
|
|
|
|
DrawableUtils.setBackground(holder.layout, foregroundDrawable); |
|
|
|
|
|
|
|
} |
|
|
|
holder.favicon.setImageBitmap(favicon); |
|
|
|
holder.favicon.setImageBitmap(favicon); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
TextViewCompat.setTextAppearance(holder.txtTitle, R.style.normalText); |
|
|
|
TextViewCompat.setTextAppearance(holder.txtTitle, R.style.normalText); |
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { |
|
|
|
if (!mDrawerTabs) { |
|
|
|
holder.layout.setBackground(mBackgroundTabDrawable); |
|
|
|
DrawableUtils.setBackground(holder.layout, mBackgroundTabDrawable); |
|
|
|
} else { |
|
|
|
|
|
|
|
//noinspection deprecation
|
|
|
|
|
|
|
|
holder.layout.setBackgroundDrawable(mBackgroundTabDrawable); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
holder.favicon.setImageBitmap(getDesaturatedBitmap(favicon)); |
|
|
|
holder.favicon.setImageBitmap(getDesaturatedBitmap(favicon)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mDrawerTabs) { |
|
|
|
|
|
|
|
BackgroundDrawable verticalBackground = (BackgroundDrawable) holder.layout.getBackground(); |
|
|
|
|
|
|
|
verticalBackground.setCrossFadeEnabled(false); |
|
|
|
|
|
|
|
if (web.isForegroundTab()) { |
|
|
|
|
|
|
|
verticalBackground.startTransition(200); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
verticalBackground.reverseTransition(200); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -403,7 +411,6 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(View v) { |
|
|
|
public void onClick(View v) { |
|
|
|
if (v == exitButton) { |
|
|
|
if (v == exitButton) { |
|
|
|
// Close tab
|
|
|
|
|
|
|
|
mBus.post(new TabEvents.CloseTab(getAdapterPosition())); |
|
|
|
mBus.post(new TabEvents.CloseTab(getAdapterPosition())); |
|
|
|
} |
|
|
|
} |
|
|
|
if (v == layout) { |
|
|
|
if (v == layout) { |
|
|
|