Browse Source

Switched to RecyclerView, cleaned up some HTML generator methods

master
Anthony Restaino 9 years ago
parent
commit
85d92db738
  1. 4
      app/app.iml
  2. 2
      app/build.gradle
  3. 262
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  4. 56
      app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java
  5. 110
      app/src/main/java/acr/browser/lightning/constant/StartPage.java
  6. 2
      app/src/main/java/acr/browser/lightning/controller/BrowserController.java
  7. 25
      app/src/main/java/acr/browser/lightning/utils/ThemeUtils.java
  8. 114
      app/src/main/java/acr/browser/lightning/view/LightningView.java
  9. 6
      app/src/main/res/layout/tab_drawer.xml
  10. 88
      app/src/main/res/layout/tab_list_item.xml
  11. 1
      app/src/main/res/layout/tab_list_item_horizontal.xml
  12. 7
      app/src/main/res/layout/toolbar.xml

4
app/app.iml

@ -95,9 +95,9 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.0.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/palette-v7/23.0.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/palette-v7/23.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/net.i2p.android/client/0.7/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/net.i2p.android/client/0.7/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/org.lucasr.twowayview/twowayview/0.1.4/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
@ -117,10 +117,10 @@
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="client-0.7" level="project" /> <orderEntry type="library" exported="" name="client-0.7" level="project" />
<orderEntry type="library" exported="" name="design-23.0.0" level="project" /> <orderEntry type="library" exported="" name="design-23.0.0" level="project" />
<orderEntry type="library" exported="" name="twowayview-0.1.4" level="project" />
<orderEntry type="library" exported="" name="palette-v7-23.0.0" level="project" /> <orderEntry type="library" exported="" name="palette-v7-23.0.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.0.0" level="project" /> <orderEntry type="library" exported="" name="appcompat-v7-23.0.0" level="project" />
<orderEntry type="library" exported="" name="jsoup-1.8.1" level="project" /> <orderEntry type="library" exported="" name="jsoup-1.8.1" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.0.0" level="project" /> <orderEntry type="library" exported="" name="support-v4-23.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.0" level="project" /> <orderEntry type="library" exported="" name="support-annotations-23.0.0" level="project" />
<orderEntry type="module" module-name="libnetcipher" exported="" /> <orderEntry type="module" module-name="libnetcipher" exported="" />

2
app/build.gradle

@ -46,8 +46,8 @@ dependencies {
compile 'com.android.support:palette-v7:23.0.0' compile 'com.android.support:palette-v7:23.0.0'
compile 'com.android.support:appcompat-v7:23.0.0' compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:design:23.0.0' compile 'com.android.support:design:23.0.0'
compile 'com.android.support:recyclerview-v7:23.0.0'
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'))

262
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -20,6 +20,7 @@ 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.Color;
import android.graphics.ColorFilter;
import android.graphics.ColorMatrix; import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter; import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint; import android.graphics.Paint;
@ -45,6 +46,8 @@ import android.support.v4.widget.DrawerLayout.DrawerListener;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.graphics.Palette; import android.support.v7.graphics.Palette;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
@ -89,8 +92,6 @@ 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;
@ -134,7 +135,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
private FrameLayout mBrowserFrame; private FrameLayout mBrowserFrame;
private FullscreenHolder mFullscreenContainer; private FullscreenHolder mFullscreenContainer;
private ListView mDrawerListRight; private ListView mDrawerListRight;
private TwoWayView mDrawerListLeft; private RecyclerView mDrawerListLeft;
private LinearLayout mDrawerLeft, mDrawerRight, mUiLayout, mToolbarLayout; private LinearLayout mDrawerLeft, mDrawerRight, mUiLayout, mToolbarLayout;
private RelativeLayout mSearchBar; private RelativeLayout mSearchBar;
@ -153,7 +154,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
// Adapter // Adapter
private BookmarkViewAdapter mBookmarkAdapter; private BookmarkViewAdapter mBookmarkAdapter;
private LightningViewAdapter mTitleAdapter; private LightningViewAdapter mTabAdapter;
private SearchAdapter mSearchAdapter; private SearchAdapter mSearchAdapter;
// Callback // Callback
@ -261,23 +262,30 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
mHomepage = mPreferences.getHomepage(); mHomepage = mPreferences.getHomepage();
TwoWayView horizontalListView = (TwoWayView) findViewById(R.id.twv_list); RecyclerView horizontalListView = (RecyclerView) findViewById(R.id.twv_list);
if (mShowTabsInDrawer) { if (mShowTabsInDrawer) {
mTitleAdapter = new LightningViewAdapter(this, R.layout.tab_list_item, mWebViewList); mTabAdapter = new LightningViewAdapter(this, R.layout.tab_list_item, mWebViewList);
mDrawerListLeft = (TwoWayView) findViewById(R.id.left_drawer_list); mDrawerListLeft = (RecyclerView) findViewById(R.id.left_drawer_list);
mDrawerListLeft.setOverScrollMode(View.OVER_SCROLL_IF_CONTENT_SCROLLS); mDrawerListLeft.setOverScrollMode(View.OVER_SCROLL_IF_CONTENT_SCROLLS);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
mDrawerListLeft.setLayoutManager(layoutManager);
mDrawerListLeft.setHasFixedSize(true);
mToolbarLayout.removeView(horizontalListView); mToolbarLayout.removeView(horizontalListView);
} else { } else {
mTitleAdapter = new LightningViewAdapter(this, R.layout.tab_list_item_horizontal, mWebViewList); mTabAdapter = new LightningViewAdapter(this, R.layout.tab_list_item_horizontal, mWebViewList);
mDrawerListLeft = horizontalListView; mDrawerListLeft = horizontalListView;
mDrawerListLeft.setOverScrollMode(View.OVER_SCROLL_NEVER); mDrawerListLeft.setOverScrollMode(View.OVER_SCROLL_NEVER);
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, mDrawerLeft); mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, mDrawerLeft);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
mDrawerListLeft.setLayoutManager(layoutManager);
mDrawerListLeft.setHasFixedSize(true);
} }
mDrawerListLeft.setAdapter(mTitleAdapter); mDrawerListLeft.setAdapter(mTabAdapter);
mDrawerListLeft.setOnItemClickListener(new DrawerItemClickListener()); // mDrawerListLeft.setOnItemClickListener(new DrawerItemClickListener());
mDrawerListLeft.setOnItemLongClickListener(new DrawerItemLongClickListener()); // mDrawerListLeft.setOnItemLongClickListener(new DrawerItemLongClickListener());
mDrawerListRight.setOnItemClickListener(new BookmarkItemClickListener()); mDrawerListRight.setOnItemClickListener(new BookmarkItemClickListener());
mDrawerListRight.setOnItemLongClickListener(new BookmarkItemLongClickListener()); mDrawerListRight.setOnItemLongClickListener(new BookmarkItemLongClickListener());
@ -957,10 +965,11 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
/** /**
* The click listener for ListView in the navigation drawer * The click listener for ListView in the navigation drawer
*/ */
private class DrawerItemClickListener implements ListView.OnItemClickListener { private class DrawerItemClickListener implements OnClickListener {
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onClick(View v) {
int position = mDrawerListLeft.getChildAdapterPosition(v);
if (mCurrentView != mWebViewList.get(position)) { if (mCurrentView != mWebViewList.get(position)) {
mIsNewIntent = false; mIsNewIntent = false;
showTab(mWebViewList.get(position)); showTab(mWebViewList.get(position));
@ -971,10 +980,11 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
/** /**
* long click listener for Navigation Drawer * long click listener for Navigation Drawer
*/ */
private class DrawerItemLongClickListener implements ListView.OnItemLongClickListener { private class DrawerItemLongClickListener implements OnLongClickListener {
@Override @Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int position, long arg3) { public boolean onLongClick(View v) {
int position = mDrawerListLeft.getChildAdapterPosition(v);
showCloseDialog(position); showCloseDialog(position);
return true; return true;
} }
@ -1253,11 +1263,10 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
mIdGenerator++; mIdGenerator++;
mWebViewList.add(startingTab); mWebViewList.add(startingTab);
mTitleAdapter.notifyDataSetChanged();
if (show) { if (show) {
mDrawerListLeft.setItemChecked(mWebViewList.size() - 1, true);
showTab(startingTab); showTab(startingTab);
} }
updateTabs();
new Handler().postDelayed(new Runnable() { new Handler().postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -1290,13 +1299,15 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} }
if (current > position) { if (current > position) {
mWebViewList.remove(position); mWebViewList.remove(position);
mDrawerListLeft.setItemChecked(current - 1, true); showTab(mWebViewList.get(current - 1));
updateTabs();
reference.onDestroy(); reference.onDestroy();
} else if (mWebViewList.size() > position + 1) { } else if (mWebViewList.size() > position + 1) {
if (current == position) { if (current == position) {
showTab(mWebViewList.get(position + 1)); showTab(mWebViewList.get(position + 1));
mWebViewList.remove(position); mWebViewList.remove(position);
mDrawerListLeft.setItemChecked(position, true); showTab(mWebViewList.get(position));
updateTabs();
} else { } else {
mWebViewList.remove(position); mWebViewList.remove(position);
} }
@ -1306,7 +1317,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
if (current == position) { if (current == position) {
showTab(mWebViewList.get(position - 1)); showTab(mWebViewList.get(position - 1));
mWebViewList.remove(position); mWebViewList.remove(position);
mDrawerListLeft.setItemChecked(position - 1, true); showTab(mWebViewList.get(position - 1));
updateTabs();
} else { } else {
mWebViewList.remove(position); mWebViewList.remove(position);
} }
@ -1322,12 +1334,11 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
reference.onDestroy(); reference.onDestroy();
mCurrentView = null; mCurrentView = null;
mWebView = null; mWebView = null;
mTitleAdapter.notifyDataSetChanged(); mTabAdapter.notifyDataSetChanged();
finish(); finish();
} }
} }
mTitleAdapter.notifyDataSetChanged(); mTabAdapter.notifyDataSetChanged();
if (mIsNewIntent && isShown) { if (mIsNewIntent && isShown) {
mIsNewIntent = false; mIsNewIntent = false;
@ -1380,7 +1391,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} }
} }
mWebViewList.clear(); mWebViewList.clear();
mTitleAdapter.notifyDataSetChanged(); mTabAdapter.notifyDataSetChanged();
finish(); finish();
} }
@ -1510,61 +1521,58 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} }
} }
public class LightningViewAdapter extends ArrayAdapter<LightningView> { public class LightningViewAdapter extends RecyclerView.Adapter<LightningViewAdapter.LightningViewHolder> {
final Context context; private final Context context;
ColorMatrix colorMatrix; private final int layoutResourceId;
ColorMatrixColorFilter filter; private List<LightningView> data = null;
Paint paint;
final int layoutResourceId;
List<LightningView> data = null;
final CloseTabListener mExitListener; final CloseTabListener mExitListener;
private final Drawable mBackgroundTabDrawable; private final Drawable mBackgroundTabDrawable;
private final Drawable mForegroundTabDrawable; private final Drawable mForegroundTabDrawable;
private final DrawerItemClickListener mClickListener;
private final DrawerItemLongClickListener mLongClickListener;
private ColorMatrix mColorMatrix;
private Paint mPaint;
private ColorFilter mFilter;
private static final float DESATURATED = 0.5f;
public LightningViewAdapter(Context context, int layoutResourceId, List<LightningView> data) { public LightningViewAdapter(Context context, int layoutResourceId, List<LightningView> data) {
super(context, layoutResourceId, data);
this.layoutResourceId = layoutResourceId; this.layoutResourceId = layoutResourceId;
this.context = context; this.context = context;
this.data = data; this.data = data;
this.mExitListener = new CloseTabListener(); this.mExitListener = new CloseTabListener();
this.mClickListener = new DrawerItemClickListener();
this.mLongClickListener = new DrawerItemLongClickListener();
if (mShowTabsInDrawer) {
mBackgroundTabDrawable = null;
mForegroundTabDrawable = ThemeUtils.getSelectedBackground(context, mDarkTheme);
} else {
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 backgroundColor = Utils.mixTwoColors(ThemeUtils.getPrimaryColor(mActivity), Color.BLACK, 0.75f); int foregroundColor = ThemeUtils.getPrimaryColor(context);
Bitmap backgroundTabBitmap = Bitmap.createBitmap(Utils.dpToPx(175), Utils.dpToPx(30), Bitmap.Config.ARGB_8888); Bitmap foregroundTabBitmap = Bitmap.createBitmap(Utils.dpToPx(175), Utils.dpToPx(30), Bitmap.Config.ARGB_8888);
Utils.drawTrapezoid(new Canvas(backgroundTabBitmap), backgroundColor, true); Utils.drawTrapezoid(new Canvas(foregroundTabBitmap), foregroundColor, false);
mBackgroundTabDrawable = new BitmapDrawable(getResources(), backgroundTabBitmap); mForegroundTabDrawable = new BitmapDrawable(getResources(), foregroundTabBitmap);
}
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
public View getView(final int position, View convertView, ViewGroup parent) { public LightningViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View row = convertView; LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
LightningViewHolder holder; View view = inflater.inflate(layoutResourceId, viewGroup, false);
if (row == null) { return new LightningViewHolder(view);
LayoutInflater inflater = LayoutInflater.from(context); }
row = inflater.inflate(layoutResourceId, parent, false);
holder = new LightningViewHolder();
holder.txtTitle = (TextView) row.findViewById(R.id.textTab);
holder.favicon = (ImageView) row.findViewById(R.id.faviconTab);
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.exit.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
row.setTag(holder);
} else {
holder = (LightningViewHolder) row.getTag();
}
@Override
public void onBindViewHolder(LightningViewHolder holder, int position) {
holder.exitButton.setTag(position); holder.exitButton.setTag(position);
holder.exitButton.setOnClickListener(mExitListener); holder.exitButton.setOnClickListener(mExitListener);
holder.layout.setOnClickListener(mClickListener);
holder.layout.setOnLongClickListener(mLongClickListener);
ViewCompat.jumpDrawablesToCurrentState(holder.exitButton); ViewCompat.jumpDrawablesToCurrentState(holder.exitButton);
@ -1573,47 +1581,70 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
Bitmap favicon = web.getFavicon(); Bitmap favicon = web.getFavicon();
if (web.isForegroundTab()) { if (web.isForegroundTab()) {
holder.txtTitle.setTextAppearance(context, R.style.boldText); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
holder.favicon.setImageBitmap(favicon); holder.txtTitle.setTextAppearance(R.style.boldText);
if (!mShowTabsInDrawer) { } else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { holder.txtTitle.setTextAppearance(context, R.style.boldText);
holder.layout.setBackground(mForegroundTabDrawable); }
} else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
holder.layout.setBackgroundDrawable(mForegroundTabDrawable); holder.layout.setBackground(mForegroundTabDrawable);
} } else {
holder.layout.setBackgroundDrawable(mForegroundTabDrawable);
} }
if (!isIncognito() && mColorMode) { if (!isIncognito() && mColorMode) {
// TODO fix toolbar coloring // TODO fix toolbar coloring
// changeToolbarBackground(favicon, mForegroundTabDrawable); // changeToolbarBackground(favicon, mForegroundTabDrawable);
} }
holder.favicon.setImageBitmap(favicon);
} else { } else {
holder.txtTitle.setTextAppearance(context, R.style.normalText); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!mShowTabsInDrawer) { holder.txtTitle.setTextAppearance(R.style.normalText);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { } else {
holder.layout.setBackground(mBackgroundTabDrawable); holder.txtTitle.setTextAppearance(context, R.style.normalText);
} else {
holder.layout.setBackgroundDrawable(mBackgroundTabDrawable);
}
} }
Bitmap grayscaleBitmap = Bitmap.createBitmap(favicon.getWidth(), if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
favicon.getHeight(), Bitmap.Config.ARGB_8888); holder.layout.setBackground(mBackgroundTabDrawable);
} else {
Canvas c = new Canvas(grayscaleBitmap); holder.layout.setBackgroundDrawable(mBackgroundTabDrawable);
if (colorMatrix == null || filter == null || paint == null) {
paint = new Paint();
colorMatrix = new ColorMatrix();
colorMatrix.setSaturation(0.5f);
filter = new ColorMatrixColorFilter(colorMatrix);
paint.setColorFilter(filter);
} }
holder.favicon.setImageBitmap(getDesaturatedBitmap(favicon));
}
}
@Override
public int getItemCount() {
return (data != null) ? data.size() : 0;
}
c.drawBitmap(favicon, 0, 0, paint); public Bitmap getDesaturatedBitmap(Bitmap favicon) {
holder.favicon.setImageBitmap(grayscaleBitmap); Bitmap grayscaleBitmap = Bitmap.createBitmap(favicon.getWidth(),
favicon.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(grayscaleBitmap);
if (mColorMatrix == null || mFilter == null || mPaint == null) {
mPaint = new Paint();
mColorMatrix = new ColorMatrix();
mColorMatrix.setSaturation(DESATURATED);
mFilter = new ColorMatrixColorFilter(mColorMatrix);
mPaint.setColorFilter(mFilter);
} }
return row;
c.drawBitmap(favicon, 0, 0, mPaint);
return grayscaleBitmap;
} }
class LightningViewHolder { public class LightningViewHolder extends RecyclerView.ViewHolder {
public LightningViewHolder(View view) {
super(view);
txtTitle = (TextView) view.findViewById(R.id.textTab);
favicon = (ImageView) view.findViewById(R.id.faviconTab);
exit = (ImageView) view.findViewById(R.id.deleteButton);
layout = (LinearLayout) view.findViewById(R.id.tab_item_background);
exitButton = (FrameLayout) view.findViewById(R.id.deleteAction);
exit.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
}
TextView txtTitle; TextView txtTitle;
ImageView favicon; ImageView favicon;
ImageView exit; ImageView exit;
@ -2024,58 +2055,13 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} }
File bookmarkWebPage = new File(mActivity.getFilesDir(), BookmarkPage.FILENAME); File bookmarkWebPage = new File(mActivity.getFilesDir(), BookmarkPage.FILENAME);
buildBookmarkPage(null, mBookmarkManager.getBookmarksFromFolder(null, true)); BookmarkPage.buildBookmarkPage(this, null, mBookmarkManager.getBookmarksFromFolder(null, true));
view.loadUrl(Constants.FILE + bookmarkWebPage); view.loadUrl(Constants.FILE + bookmarkWebPage);
} }
private void buildBookmarkPage(final String folder, final List<HistoryItem> list) {
File bookmarkWebPage;
if (folder == null || folder.isEmpty()) {
bookmarkWebPage = new File(mActivity.getFilesDir(), BookmarkPage.FILENAME);
} else {
bookmarkWebPage = new File(mActivity.getFilesDir(), folder + '-' + BookmarkPage.FILENAME);
}
final StringBuilder bookmarkBuilder = new StringBuilder(BookmarkPage.HEADING);
String folderIconPath = Constants.FILE + mActivity.getCacheDir() + "/folder.png";
for (int n = 0; n < list.size(); n++) {
final HistoryItem item = list.get(n);
bookmarkBuilder.append(BookmarkPage.PART1);
if (item.isFolder()) {
File folderPage = new File(mActivity.getFilesDir(), item.getTitle() + '-' + BookmarkPage.FILENAME);
bookmarkBuilder.append(Constants.FILE).append(folderPage);
bookmarkBuilder.append(BookmarkPage.PART2);
bookmarkBuilder.append(folderIconPath);
new Thread(new Runnable() {
@Override
public void run() {
buildBookmarkPage(item.getTitle(), mBookmarkManager.getBookmarksFromFolder(item.getTitle(), true));
}
}).run();
} else {
bookmarkBuilder.append(item.getUrl());
bookmarkBuilder.append(BookmarkPage.PART2).append(BookmarkPage.PART3);
bookmarkBuilder.append(item.getUrl());
}
bookmarkBuilder.append(BookmarkPage.PART4);
bookmarkBuilder.append(item.getTitle());
bookmarkBuilder.append(BookmarkPage.PART5);
}
bookmarkBuilder.append(BookmarkPage.END);
FileWriter bookWriter = null;
try {
bookWriter = new FileWriter(bookmarkWebPage, false);
bookWriter.write(bookmarkBuilder.toString());
} catch (IOException e) {
e.printStackTrace();
} finally {
Utils.close(bookWriter);
}
}
@Override @Override
public void update() { public void updateTabs() {
mTitleAdapter.notifyDataSetChanged(); mTabAdapter.notifyDataSetChanged();
} }
/** /**

56
app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java

@ -3,8 +3,18 @@
*/ */
package acr.browser.lightning.constant; package acr.browser.lightning.constant;
import android.app.Activity;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import acr.browser.lightning.R; import acr.browser.lightning.R;
import acr.browser.lightning.activity.BrowserApp; import acr.browser.lightning.activity.BrowserApp;
import acr.browser.lightning.database.BookmarkManager;
import acr.browser.lightning.database.HistoryItem;
import acr.browser.lightning.utils.Utils;
public class BookmarkPage { public class BookmarkPage {
@ -39,4 +49,50 @@ public class BookmarkPage {
public static final String END = "</div></body></html>"; public static final String END = "</div></body></html>";
public static void buildBookmarkPage(final Activity activity, final String folder, final List<HistoryItem> list) {
final BookmarkManager manager = BookmarkManager.getInstance(activity);
File bookmarkWebPage;
if (folder == null || folder.isEmpty()) {
bookmarkWebPage = new File(activity.getFilesDir(), BookmarkPage.FILENAME);
} else {
bookmarkWebPage = new File(activity.getFilesDir(), folder + '-' + BookmarkPage.FILENAME);
}
final StringBuilder bookmarkBuilder = new StringBuilder(BookmarkPage.HEADING);
String folderIconPath = Constants.FILE + activity.getCacheDir() + "/folder.png";
for (int n = 0; n < list.size(); n++) {
final HistoryItem item = list.get(n);
bookmarkBuilder.append(BookmarkPage.PART1);
if (item.isFolder()) {
File folderPage = new File(activity.getFilesDir(), item.getTitle() + '-' + BookmarkPage.FILENAME);
bookmarkBuilder.append(Constants.FILE).append(folderPage);
bookmarkBuilder.append(BookmarkPage.PART2);
bookmarkBuilder.append(folderIconPath);
new Thread(new Runnable() {
@Override
public void run() {
buildBookmarkPage(activity, item.getTitle(), manager.getBookmarksFromFolder(item.getTitle(), true));
}
}).run();
} else {
bookmarkBuilder.append(item.getUrl());
bookmarkBuilder.append(BookmarkPage.PART2).append(BookmarkPage.PART3);
bookmarkBuilder.append(item.getUrl());
}
bookmarkBuilder.append(BookmarkPage.PART4);
bookmarkBuilder.append(item.getTitle());
bookmarkBuilder.append(BookmarkPage.PART5);
}
bookmarkBuilder.append(BookmarkPage.END);
FileWriter bookWriter = null;
try {
bookWriter = new FileWriter(bookmarkWebPage, false);
bookWriter.write(bookmarkBuilder.toString());
} catch (IOException e) {
e.printStackTrace();
} finally {
Utils.close(bookWriter);
}
}
} }

110
app/src/main/java/acr/browser/lightning/constant/StartPage.java

@ -3,8 +3,16 @@
*/ */
package acr.browser.lightning.constant; package acr.browser.lightning.constant;
import android.app.Activity;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import acr.browser.lightning.activity.BrowserApp; import acr.browser.lightning.activity.BrowserApp;
import acr.browser.lightning.R; import acr.browser.lightning.R;
import acr.browser.lightning.preference.PreferenceManager;
import acr.browser.lightning.utils.Utils;
public class StartPage { public class StartPage {
@ -38,4 +46,106 @@ public class StartPage {
+ "</span></form></br></br></div></div></div><script type=\"text/javascript\">function search(){if(document.getElementById(\"search_input\").value != \"\"){window.location.href = \""; + "</span></form></br></br></div></div></div><script type=\"text/javascript\">function search(){if(document.getElementById(\"search_input\").value != \"\"){window.location.href = \"";
public static final String END = "\" + document.getElementById(\"search_input\").value;document.getElementById(\"search_input\").value = \"\";}return false;}</script></body></html>"; public static final String END = "\" + document.getElementById(\"search_input\").value;document.getElementById(\"search_input\").value = \"\";}return false;}</script></body></html>";
/**
* This method builds the homepage and returns the local URL to be loaded
* when it finishes building.
*
* @return the URL to load
*/
public static String getHomepage(Activity activity) {
StringBuilder homepageBuilder = new StringBuilder(StartPage.HEAD);
String icon;
String searchUrl;
switch (PreferenceManager.getInstance().getSearchChoice()) {
case 0:
// CUSTOM SEARCH
icon = "file:///android_asset/lightning.png";
searchUrl = PreferenceManager.getInstance().getSearchUrl();
break;
case 1:
// GOOGLE_SEARCH;
icon = "file:///android_asset/google.png";
// "https://www.google.com/images/srpr/logo11w.png";
searchUrl = Constants.GOOGLE_SEARCH;
break;
case 2:
// ANDROID SEARCH;
icon = "file:///android_asset/ask.png";
searchUrl = Constants.ASK_SEARCH;
break;
case 3:
// BING_SEARCH;
icon = "file:///android_asset/bing.png";
// "http://upload.wikimedia.org/wikipedia/commons/thumb/b/b1/Bing_logo_%282013%29.svg/500px-Bing_logo_%282013%29.svg.png";
searchUrl = Constants.BING_SEARCH;
break;
case 4:
// YAHOO_SEARCH;
icon = "file:///android_asset/yahoo.png";
// "http://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Yahoo%21_logo.svg/799px-Yahoo%21_logo.svg.png";
searchUrl = Constants.YAHOO_SEARCH;
break;
case 5:
// STARTPAGE_SEARCH;
icon = "file:///android_asset/startpage.png";
// "https://startpage.com/graphics/startp_logo.gif";
searchUrl = Constants.STARTPAGE_SEARCH;
break;
case 6:
// STARTPAGE_MOBILE
icon = "file:///android_asset/startpage.png";
// "https://startpage.com/graphics/startp_logo.gif";
searchUrl = Constants.STARTPAGE_MOBILE_SEARCH;
break;
case 7:
// DUCK_SEARCH;
icon = "file:///android_asset/duckduckgo.png";
// "https://duckduckgo.com/assets/logo_homepage.normal.v101.png";
searchUrl = Constants.DUCK_SEARCH;
break;
case 8:
// DUCK_LITE_SEARCH;
icon = "file:///android_asset/duckduckgo.png";
// "https://duckduckgo.com/assets/logo_homepage.normal.v101.png";
searchUrl = Constants.DUCK_LITE_SEARCH;
break;
case 9:
// BAIDU_SEARCH;
icon = "file:///android_asset/baidu.png";
// "http://www.baidu.com/img/bdlogo.gif";
searchUrl = Constants.BAIDU_SEARCH;
break;
case 10:
// YANDEX_SEARCH;
icon = "file:///android_asset/yandex.png";
// "http://upload.wikimedia.org/wikipedia/commons/thumb/9/91/Yandex.svg/600px-Yandex.svg.png";
searchUrl = Constants.YANDEX_SEARCH;
break;
default:
// DEFAULT GOOGLE_SEARCH;
icon = "file:///android_asset/google.png";
searchUrl = Constants.GOOGLE_SEARCH;
break;
}
homepageBuilder.append(icon);
homepageBuilder.append(StartPage.MIDDLE);
homepageBuilder.append(searchUrl);
homepageBuilder.append(StartPage.END);
File homepage = new File(activity.getFilesDir(), StartPage.FILENAME);
FileWriter hWriter = null;
try {
hWriter = new FileWriter(homepage, false);
hWriter.write(homepageBuilder.toString());
} catch (IOException e) {
e.printStackTrace();
} finally {
Utils.close(hWriter);
}
return Constants.FILE + homepage;
}
} }

2
app/src/main/java/acr/browser/lightning/controller/BrowserController.java

@ -24,7 +24,7 @@ public interface BrowserController {
void openFileChooser(ValueCallback<Uri> uploadMsg); void openFileChooser(ValueCallback<Uri> uploadMsg);
void update(); void updateTabs();
void onLongPress(); void onLongPress();

25
app/src/main/java/acr/browser/lightning/utils/ThemeUtils.java

@ -1,6 +1,7 @@
package acr.browser.lightning.utils; package acr.browser.lightning.utils;
import android.content.Context; import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
@ -9,6 +10,7 @@ import android.graphics.ColorFilter;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.support.annotation.AttrRes; import android.support.annotation.AttrRes;
@ -44,10 +46,16 @@ public class ThemeUtils {
} }
public static int getIconLightThemeColor(@NonNull Context context) { public static int getIconLightThemeColor(@NonNull Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return context.getResources().getColor(R.color.icon_light_theme, context.getTheme());
}
return context.getResources().getColor(R.color.icon_light_theme); return context.getResources().getColor(R.color.icon_light_theme);
} }
public static int getIconDarkThemeColor(@NonNull Context context) { public static int getIconDarkThemeColor(@NonNull Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return context.getResources().getColor(R.color.icon_dark_theme, context.getTheme());
}
return context.getResources().getColor(R.color.icon_dark_theme); return context.getResources().getColor(R.color.icon_dark_theme);
} }
@ -70,7 +78,7 @@ public class ThemeUtils {
} }
@Nullable @Nullable
public static Drawable getThemedDrawable(@NonNull Context context, @DrawableRes int res, boolean dark){ public static Drawable getThemedDrawable(@NonNull Context context, @DrawableRes int res, boolean dark) {
int color = dark ? getIconDarkThemeColor(context) : getIconLightThemeColor(context); int color = dark ? getIconDarkThemeColor(context) : getIconLightThemeColor(context);
final Drawable drawable; final Drawable drawable;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
@ -86,7 +94,7 @@ public class ThemeUtils {
} }
@Nullable @Nullable
public static Drawable getLightThemedDrawable(@NonNull Context context, @DrawableRes int res){ public static Drawable getLightThemedDrawable(@NonNull Context context, @DrawableRes int res) {
final Drawable drawable; final Drawable drawable;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
drawable = context.getResources().getDrawable(res); drawable = context.getResources().getDrawable(res);
@ -99,4 +107,17 @@ public class ThemeUtils {
drawable.setColorFilter(getIconLightThemeColor(context), PorterDuff.Mode.SRC_IN); drawable.setColorFilter(getIconLightThemeColor(context), PorterDuff.Mode.SRC_IN);
return drawable; return drawable;
} }
public static ColorDrawable getSelectedBackground(@NonNull Context context, boolean dark) {
Resources res = context.getResources();
int color;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
color = (dark) ? res.getColor(R.color.divider_dark, context.getTheme()) :
res.getColor(R.color.divider_light, context.getTheme());
} else {
color = (dark) ? res.getColor(R.color.divider_dark) :
res.getColor(R.color.divider_light);
}
return new ColorDrawable(color);
}
} }

114
app/src/main/java/acr/browser/lightning/view/LightningView.java

@ -160,7 +160,7 @@ public class LightningView {
return; return;
} }
if (mHomepage.startsWith("about:home")) { if (mHomepage.startsWith("about:home")) {
mWebView.loadUrl(getHomepage()); mWebView.loadUrl(StartPage.getHomepage(mActivity));
} else if (mHomepage.startsWith("about:bookmarks")) { } else if (mHomepage.startsWith("about:bookmarks")) {
mBrowserController.openBookmarkPage(mWebView); mBrowserController.openBookmarkPage(mWebView);
} else { } else {
@ -168,108 +168,6 @@ public class LightningView {
} }
} }
/**
* This method builds the homepage and returns the local URL to be loaded
* when it finishes building.
*
* @return the URL to load
*/
private String getHomepage() {
StringBuilder homepageBuilder = new StringBuilder(StartPage.HEAD);
String icon;
String searchUrl;
switch (mPreferences.getSearchChoice()) {
case 0:
// CUSTOM SEARCH
icon = "file:///android_asset/lightning.png";
searchUrl = mPreferences.getSearchUrl();
break;
case 1:
// GOOGLE_SEARCH;
icon = "file:///android_asset/google.png";
// "https://www.google.com/images/srpr/logo11w.png";
searchUrl = Constants.GOOGLE_SEARCH;
break;
case 2:
// ANDROID SEARCH;
icon = "file:///android_asset/ask.png";
searchUrl = Constants.ASK_SEARCH;
break;
case 3:
// BING_SEARCH;
icon = "file:///android_asset/bing.png";
// "http://upload.wikimedia.org/wikipedia/commons/thumb/b/b1/Bing_logo_%282013%29.svg/500px-Bing_logo_%282013%29.svg.png";
searchUrl = Constants.BING_SEARCH;
break;
case 4:
// YAHOO_SEARCH;
icon = "file:///android_asset/yahoo.png";
// "http://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Yahoo%21_logo.svg/799px-Yahoo%21_logo.svg.png";
searchUrl = Constants.YAHOO_SEARCH;
break;
case 5:
// STARTPAGE_SEARCH;
icon = "file:///android_asset/startpage.png";
// "https://startpage.com/graphics/startp_logo.gif";
searchUrl = Constants.STARTPAGE_SEARCH;
break;
case 6:
// STARTPAGE_MOBILE
icon = "file:///android_asset/startpage.png";
// "https://startpage.com/graphics/startp_logo.gif";
searchUrl = Constants.STARTPAGE_MOBILE_SEARCH;
break;
case 7:
// DUCK_SEARCH;
icon = "file:///android_asset/duckduckgo.png";
// "https://duckduckgo.com/assets/logo_homepage.normal.v101.png";
searchUrl = Constants.DUCK_SEARCH;
break;
case 8:
// DUCK_LITE_SEARCH;
icon = "file:///android_asset/duckduckgo.png";
// "https://duckduckgo.com/assets/logo_homepage.normal.v101.png";
searchUrl = Constants.DUCK_LITE_SEARCH;
break;
case 9:
// BAIDU_SEARCH;
icon = "file:///android_asset/baidu.png";
// "http://www.baidu.com/img/bdlogo.gif";
searchUrl = Constants.BAIDU_SEARCH;
break;
case 10:
// YANDEX_SEARCH;
icon = "file:///android_asset/yandex.png";
// "http://upload.wikimedia.org/wikipedia/commons/thumb/9/91/Yandex.svg/600px-Yandex.svg.png";
searchUrl = Constants.YANDEX_SEARCH;
break;
default:
// DEFAULT GOOGLE_SEARCH;
icon = "file:///android_asset/google.png";
searchUrl = Constants.GOOGLE_SEARCH;
break;
}
homepageBuilder.append(icon);
homepageBuilder.append(StartPage.MIDDLE);
homepageBuilder.append(searchUrl);
homepageBuilder.append(StartPage.END);
File homepage = new File(mActivity.getFilesDir(), StartPage.FILENAME);
FileWriter hWriter = null;
try {
hWriter = new FileWriter(homepage, false);
hWriter.write(homepageBuilder.toString());
} catch (IOException e) {
e.printStackTrace();
} finally {
Utils.close(hWriter);
}
return Constants.FILE + homepage;
}
/** /**
* Initialize the preference driven settings of the WebView * Initialize the preference driven settings of the WebView
* *
@ -493,7 +391,7 @@ public class LightningView {
public void setForegroundTab(boolean isForeground) { public void setForegroundTab(boolean isForeground) {
isForegroundTab = isForeground; isForegroundTab = isForeground;
mBrowserController.update(); mBrowserController.updateTabs();
} }
public boolean isForegroundTab() { public boolean isForegroundTab() {
@ -758,7 +656,7 @@ public class LightningView {
if (API >= android.os.Build.VERSION_CODES.KITKAT && mInvertPage) { if (API >= android.os.Build.VERSION_CODES.KITKAT && mInvertPage) {
view.evaluateJavascript(Constants.JAVASCRIPT_INVERT_PAGE, null); view.evaluateJavascript(Constants.JAVASCRIPT_INVERT_PAGE, null);
} }
mBrowserController.update(); mBrowserController.updateTabs();
} }
@Override @Override
@ -769,7 +667,7 @@ public class LightningView {
mBrowserController.showActionBar(); mBrowserController.showActionBar();
} }
mTitle.setFavicon(mWebpageBitmap); mTitle.setFavicon(mWebpageBitmap);
mBrowserController.update(); mBrowserController.updateTabs();
} }
@Override @Override
@ -958,7 +856,7 @@ public class LightningView {
if (icon == null) if (icon == null)
return; return;
mTitle.setFavicon(icon); mTitle.setFavicon(icon);
mBrowserController.update(); mBrowserController.updateTabs();
cacheFavicon(icon); cacheFavicon(icon);
} }
@ -969,7 +867,7 @@ public class LightningView {
} else { } else {
mTitle.setTitle(mActivity.getString(R.string.untitled)); mTitle.setTitle(mActivity.getString(R.string.untitled));
} }
mBrowserController.update(); mBrowserController.updateTabs();
if (view != null) if (view != null)
mBrowserController.updateHistory(title, view.getUrl()); mBrowserController.updateHistory(title, view.getUrl());
} }

6
app/src/main/res/layout/tab_drawer.xml

@ -44,15 +44,13 @@
android:textAppearance="?android:attr/textAppearanceLarge" /> android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout> </LinearLayout>
<org.lucasr.twowayview.TwoWayView <android.support.v7.widget.RecyclerView
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"
android:layout_weight="1" android:layout_weight="1"
android:choiceMode="singleChoice"
android:divider="@null" android:divider="@null"
android:dividerHeight="0dp" android:dividerHeight="0dp" />
android:listSelector="?attr/listBackground" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

88
app/src/main/res/layout/tab_list_item.xml

@ -3,51 +3,59 @@
android:id="@+id/tab_item_background" 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:clickable="true"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal">
android:weightSum="1">
<ImageView <LinearLayout
android:id="@+id/faviconTab" android:layout_width="match_parent"
android:layout_width="24dp" android:layout_height="match_parent"
android:layout_height="24dp" android:background="?attr/listBackground"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:contentDescription="Favicon"
android:gravity="center_vertical" />
<TextView
android:id="@+id/textTab"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_weight="1"
android:ellipsize="end"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical" android:gravity="center_vertical"
android:maxLines="1" android:orientation="horizontal"
android:minHeight="?android:attr/listPreferredItemHeightSmall" android:weightSum="1">
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceListItemSmall" />
<FrameLayout
android:id="@+id/deleteAction"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="4dp"
android:background="?attr/actionBarItemBackground"
android:gravity="center">
<ImageView <ImageView
android:id="@+id/deleteButton" android:id="@+id/faviconTab"
android:layout_width="wrap_content" android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:contentDescription="Favicon"
android:gravity="center_vertical" />
<TextView
android:id="@+id/textTab"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_marginLeft="16dp"
android:contentDescription="Delete Tab" android:layout_marginRight="16dp"
android:src="@drawable/ic_action_delete" /> android:layout_weight="1"
</FrameLayout> 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/textAppearanceListItemSmall" />
<FrameLayout
android:id="@+id/deleteAction"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="4dp"
android:background="?attr/actionBarItemBackground"
android:gravity="center">
<ImageView
android:id="@+id/deleteButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="Delete Tab"
android:src="@drawable/ic_action_delete" />
</FrameLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>

1
app/src/main/res/layout/tab_list_item_horizontal.xml

@ -5,6 +5,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical" android:gravity="center_vertical"
android:orientation="horizontal" android:orientation="horizontal"
android:clickable="false"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:paddingRight="10dp" android:paddingRight="10dp"
android:weightSum="1"> android:weightSum="1">

7
app/src/main/res/layout/toolbar.xml

@ -8,18 +8,13 @@
android:elevation="2dp" android:elevation="2dp"
android:orientation="vertical"> android:orientation="vertical">
<org.lucasr.twowayview.TwoWayView <android.support.v7.widget.RecyclerView
android:id="@+id/twv_list" android:id="@+id/twv_list"
style="@style/TwoWayView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="30dp" android:layout_height="30dp"
android:background="@color/black" android:background="@color/black"
android:listSelector="?attr/listBackground"
android:overScrollMode="never" android:overScrollMode="never"
android:scrollbars="none" /> 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"

Loading…
Cancel
Save