|
|
@ -69,8 +69,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View |
|
|
|
private boolean mColorMode = true; |
|
|
|
private boolean mColorMode = true; |
|
|
|
private boolean mShowInNavigationDrawer; |
|
|
|
private boolean mShowInNavigationDrawer; |
|
|
|
|
|
|
|
|
|
|
|
private RecyclerView mRecyclerView; |
|
|
|
@Nullable private LightningViewAdapter mTabsAdapter; |
|
|
|
private LightningViewAdapter mTabsAdapter; |
|
|
|
|
|
|
|
private UIController mUiController; |
|
|
|
private UIController mUiController; |
|
|
|
|
|
|
|
|
|
|
|
@Inject TabsManager tabsManager; |
|
|
|
@Inject TabsManager tabsManager; |
|
|
@ -99,7 +98,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View |
|
|
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { |
|
|
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { |
|
|
|
final View view; |
|
|
|
final View view; |
|
|
|
final LayoutManager layoutManager; |
|
|
|
final LayoutManager layoutManager; |
|
|
|
if (mShowInNavigationDrawer) { |
|
|
|
if (mShowInNavigationDrawer) { |
|
|
@ -114,11 +113,11 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View |
|
|
|
view = inflater.inflate(R.layout.tab_strip, container, false); |
|
|
|
view = inflater.inflate(R.layout.tab_strip, container, false); |
|
|
|
layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false); |
|
|
|
layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false); |
|
|
|
} |
|
|
|
} |
|
|
|
mRecyclerView = (RecyclerView) view.findViewById(R.id.tabs_list); |
|
|
|
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.tabs_list); |
|
|
|
mRecyclerView.setLayoutManager(layoutManager); |
|
|
|
recyclerView.setLayoutManager(layoutManager); |
|
|
|
mTabsAdapter = new LightningViewAdapter(mShowInNavigationDrawer); |
|
|
|
mTabsAdapter = new LightningViewAdapter(mShowInNavigationDrawer); |
|
|
|
mRecyclerView.setAdapter(mTabsAdapter); |
|
|
|
recyclerView.setAdapter(mTabsAdapter); |
|
|
|
mRecyclerView.setHasFixedSize(true); |
|
|
|
recyclerView.setHasFixedSize(true); |
|
|
|
return view; |
|
|
|
return view; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -134,7 +133,6 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onDestroyView() { |
|
|
|
public void onDestroyView() { |
|
|
|
super.onDestroyView(); |
|
|
|
super.onDestroyView(); |
|
|
|
mRecyclerView = null; |
|
|
|
|
|
|
|
mTabsAdapter = null; |
|
|
|
mTabsAdapter = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -148,7 +146,9 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View |
|
|
|
public void onResume() { |
|
|
|
public void onResume() { |
|
|
|
super.onResume(); |
|
|
|
super.onResume(); |
|
|
|
// Force adapter refresh
|
|
|
|
// Force adapter refresh
|
|
|
|
mTabsAdapter.notifyDataSetChanged(); |
|
|
|
if (mTabsAdapter != null) { |
|
|
|
|
|
|
|
mTabsAdapter.notifyDataSetChanged(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -165,7 +165,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(View v) { |
|
|
|
public void onClick(@NonNull View v) { |
|
|
|
switch (v.getId()) { |
|
|
|
switch (v.getId()) { |
|
|
|
case R.id.new_tab_button: |
|
|
|
case R.id.new_tab_button: |
|
|
|
mBus.post(new TabEvents.NewTab()); |
|
|
|
mBus.post(new TabEvents.NewTab()); |
|
|
@ -184,7 +184,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean onLongClick(View v) { |
|
|
|
public boolean onLongClick(@NonNull View v) { |
|
|
|
switch (v.getId()) { |
|
|
|
switch (v.getId()) { |
|
|
|
case R.id.action_new_tab: |
|
|
|
case R.id.action_new_tab: |
|
|
|
mBus.post(new TabEvents.NewTabLongPress()); |
|
|
|
mBus.post(new TabEvents.NewTabLongPress()); |
|
|
@ -198,9 +198,9 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View |
|
|
|
public class LightningViewAdapter extends RecyclerView.Adapter<LightningViewAdapter.LightningViewHolder> { |
|
|
|
public class LightningViewAdapter extends RecyclerView.Adapter<LightningViewAdapter.LightningViewHolder> { |
|
|
|
|
|
|
|
|
|
|
|
private final int mLayoutResourceId; |
|
|
|
private final int mLayoutResourceId; |
|
|
|
private final Drawable mBackgroundTabDrawable; |
|
|
|
@Nullable private final Drawable mBackgroundTabDrawable; |
|
|
|
private final Drawable mForegroundTabDrawable; |
|
|
|
@Nullable private final Drawable mForegroundTabDrawable; |
|
|
|
private final Bitmap mForegroundTabBitmap; |
|
|
|
@Nullable private final Bitmap mForegroundTabBitmap; |
|
|
|
private ColorMatrix mColorMatrix; |
|
|
|
private ColorMatrix mColorMatrix; |
|
|
|
private Paint mPaint; |
|
|
|
private Paint mPaint; |
|
|
|
private ColorFilter mFilter; |
|
|
|
private ColorFilter mFilter; |
|
|
@ -229,15 +229,16 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@NonNull |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public LightningViewHolder onCreateViewHolder(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); |
|
|
|
return new LightningViewHolder(view); |
|
|
|
return new LightningViewHolder(view); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onBindViewHolder(final LightningViewHolder holder, int position) { |
|
|
|
public void onBindViewHolder(@NonNull final LightningViewHolder holder, int position) { |
|
|
|
holder.exitButton.setTag(position); |
|
|
|
holder.exitButton.setTag(position); |
|
|
|
|
|
|
|
|
|
|
|
ViewCompat.jumpDrawablesToCurrentState(holder.exitButton); |
|
|
|
ViewCompat.jumpDrawablesToCurrentState(holder.exitButton); |
|
|
@ -293,7 +294,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View |
|
|
|
return tabsManager.size(); |
|
|
|
return tabsManager.size(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Bitmap getDesaturatedBitmap(Bitmap favicon) { |
|
|
|
public Bitmap getDesaturatedBitmap(@NonNull Bitmap favicon) { |
|
|
|
Bitmap grayscaleBitmap = Bitmap.createBitmap(favicon.getWidth(), |
|
|
|
Bitmap grayscaleBitmap = Bitmap.createBitmap(favicon.getWidth(), |
|
|
|
favicon.getHeight(), Bitmap.Config.ARGB_8888); |
|
|
|
favicon.getHeight(), Bitmap.Config.ARGB_8888); |
|
|
|
|
|
|
|
|
|
|
@ -312,7 +313,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View |
|
|
|
|
|
|
|
|
|
|
|
public class LightningViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener { |
|
|
|
public class LightningViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener { |
|
|
|
|
|
|
|
|
|
|
|
public LightningViewHolder(View view) { |
|
|
|
public LightningViewHolder(@NonNull View view) { |
|
|
|
super(view); |
|
|
|
super(view); |
|
|
|
txtTitle = (TextView) view.findViewById(R.id.textTab); |
|
|
|
txtTitle = (TextView) view.findViewById(R.id.textTab); |
|
|
|
favicon = (ImageView) view.findViewById(R.id.faviconTab); |
|
|
|
favicon = (ImageView) view.findViewById(R.id.faviconTab); |
|
|
@ -326,11 +327,11 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View |
|
|
|
layout.setOnLongClickListener(this); |
|
|
|
layout.setOnLongClickListener(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
final TextView txtTitle; |
|
|
|
@NonNull final TextView txtTitle; |
|
|
|
final ImageView favicon; |
|
|
|
@NonNull final ImageView favicon; |
|
|
|
final ImageView exit; |
|
|
|
@NonNull final ImageView exit; |
|
|
|
final FrameLayout exitButton; |
|
|
|
@NonNull final FrameLayout exitButton; |
|
|
|
final LinearLayout layout; |
|
|
|
@NonNull final LinearLayout layout; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onClick(View v) { |
|
|
|
public void onClick(View v) { |
|
|
|