diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index c3d47ec..9b9b0a9 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -88,7 +88,6 @@
-
diff --git a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java b/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
index 684ee5e..9557061 100644
--- a/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
+++ b/app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
@@ -28,6 +28,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore;
+import android.support.annotation.ColorInt;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@@ -240,16 +241,12 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
mIconColor = mDarkTheme ? ThemeUtils.getIconDarkThemeColor(this) : ThemeUtils.getIconLightThemeColor(this);
mShowTabsInDrawer = mPreferences.getShowTabsInDrawer(!isTablet());
-
// initialize background ColorDrawable
mBackground.setColor(((ColorDrawable) mToolbarLayout.getBackground()).getColor());
// Drawer stutters otherwise
mDrawerLeft.setLayerType(View.LAYER_TYPE_HARDWARE, null);
mDrawerRight.setLayerType(View.LAYER_TYPE_HARDWARE, null);
-// TODO Please review this
-// ImageView tabTitleImage = (ImageView) findViewById(R.id.plusIcon);
-// tabTitleImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !mShowTabsInDrawer) {
getWindow().setStatusBarColor(Color.BLACK);
@@ -413,9 +410,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} else {
mSearch.setText(url);
}
- ((AutoCompleteTextView) v).selectAll(); // Hack to make sure
- // the text gets
- // selected
+ // Hack to make sure the text gets selected
+ ((AutoCompleteTextView) v).selectAll();
mIcon = mClearIcon;
mSearch.setCompoundDrawables(null, null, mClearIcon, null);
}
@@ -1211,7 +1207,8 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
* @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) {
+ @Override
+ public void changeToolbarBackground(@NonNull Bitmap favicon, @Nullable final Drawable tabBackground) {
final int defaultColor = ContextCompat.getColor(this, R.color.primary_color);
if (mCurrentUiColor == Color.BLACK) {
mCurrentUiColor = defaultColor;
@@ -1259,6 +1256,12 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
});
}
+ @ColorInt
+ @Override
+ public int getUiColor() {
+ return mCurrentUiColor;
+ }
+
@Override
public void updateUrl(String url, boolean shortUrl) {
final LightningView currentTab = tabsManager.getCurrentTab();
diff --git a/app/src/main/java/acr/browser/lightning/controller/BrowserController.java b/app/src/main/java/acr/browser/lightning/controller/BrowserController.java
index 2fc296f..e5f860a 100644
--- a/app/src/main/java/acr/browser/lightning/controller/BrowserController.java
+++ b/app/src/main/java/acr/browser/lightning/controller/BrowserController.java
@@ -3,8 +3,13 @@
*/
package acr.browser.lightning.controller;
+import android.graphics.Bitmap;
+import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Message;
+import android.support.annotation.ColorInt;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import android.view.View;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient.CustomViewCallback;
@@ -13,6 +18,11 @@ import acr.browser.lightning.view.LightningView;
public interface BrowserController {
+ void changeToolbarBackground(@NonNull Bitmap favicon, @Nullable Drawable drawable);
+
+ @ColorInt
+ int getUiColor();
+
void updateUrl(String title, boolean shortUrl);
void updateProgress(int n);
@@ -21,8 +31,6 @@ public interface BrowserController {
void openFileChooser(ValueCallback uploadMsg);
-// void onLongPress();
-
void onShowCustomView(View view, CustomViewCallback callback);
void onHideCustomView();
@@ -35,12 +43,8 @@ public interface BrowserController {
void showActionBar();
- // void longClickPage(String url);
-
void showFileChooser(ValueCallback filePathCallback);
void closeEmptyTab();
- // void updateBookmarkIndicator(String url);
-
}
diff --git a/app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java b/app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java
index acab87c..cfa310a 100644
--- a/app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java
+++ b/app/src/main/java/acr/browser/lightning/fragment/TabsFragment.java
@@ -1,9 +1,6 @@
package acr.browser.lightning.fragment;
-import android.animation.ArgbEvaluator;
-import android.animation.ValueAnimator;
import android.content.Context;
-import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
@@ -13,7 +10,6 @@ import android.graphics.ColorMatrixColorFilter;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
@@ -21,9 +17,7 @@ import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
-import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewCompat;
-import android.support.v7.graphics.Palette;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.LayoutManager;
@@ -46,14 +40,18 @@ import acr.browser.lightning.app.BrowserApp;
import acr.browser.lightning.bus.BrowserEvents;
import acr.browser.lightning.bus.NavigationEvents;
import acr.browser.lightning.bus.TabEvents;
+import acr.browser.lightning.controller.BrowserController;
import acr.browser.lightning.preference.PreferenceManager;
import acr.browser.lightning.utils.ThemeUtils;
import acr.browser.lightning.utils.Utils;
import acr.browser.lightning.view.LightningView;
/**
- * @author Stefano Pacifici based on Anthony C. Restaino's code
- * @date 2015/09/14
+ * A fragment that holds and manages the tabs and interaction with the tabs.
+ * It is reliant on the BrowserController in order to get the current UI state
+ * of the browser. It also uses the BrowserController to signal that the UI needs
+ * to change. This class contains the adapter used by both the drawer tabs and
+ * the desktop tabs. It delegates touch events for the tab UI appropriately.
*/
public class TabsFragment extends Fragment implements View.OnClickListener, View.OnLongClickListener {
@@ -70,16 +68,16 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
private int mIconColor;
private boolean mColorMode = true;
private boolean mShowInNavigationDrawer;
- private int mCurrentUiColor = Color.BLACK; // TODO Only temporary
private RecyclerView mRecyclerView;
private LightningViewAdapter mTabsAdapter;
+ private BrowserController mUiController;
@Inject
TabsManager tabsManager;
@Inject
- Bus bus;
+ Bus mBus;
@Inject
PreferenceManager mPreferences;
@@ -93,6 +91,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
super.onCreate(savedInstanceState);
final Bundle arguments = getArguments();
final Context context = getContext();
+ mUiController = (BrowserController) getActivity();
mIsIncognito = arguments.getBoolean(IS_INCOGNITO, false);
mShowInNavigationDrawer = arguments.getBoolean(VERTICAL_MODE, true);
mDarkTheme = mPreferences.getUseTheme() != 0 || mIsIncognito;
@@ -106,7 +105,6 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final Bundle arguments = getArguments();
final View view;
final LayoutManager layoutManager;
if (mShowInNavigationDrawer) {
@@ -148,7 +146,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
@Override
public void onStart() {
super.onStart();
- bus.register(this);
+ mBus.register(this);
}
@Override
@@ -161,7 +159,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
@Override
public void onStop() {
super.onStop();
- bus.unregister(this);
+ mBus.unregister(this);
}
@Subscribe
@@ -175,16 +173,16 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
public void onClick(View v) {
switch (v.getId()) {
case R.id.new_tab_button:
- bus.post(new TabEvents.NewTab());
+ mBus.post(new TabEvents.NewTab());
break;
case R.id.action_back:
- bus.post(new NavigationEvents.GoBack());
+ mBus.post(new NavigationEvents.GoBack());
break;
case R.id.action_forward:
- bus.post(new NavigationEvents.GoForward());
+ mBus.post(new NavigationEvents.GoForward());
break;
case R.id.action_home:
- bus.post(new NavigationEvents.GoHome());
+ mBus.post(new NavigationEvents.GoHome());
default:
break;
}
@@ -194,7 +192,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
public boolean onLongClick(View v) {
switch (v.getId()) {
case R.id.action_new_tab:
- bus.post(new TabEvents.NewTabLongPress());
+ mBus.post(new TabEvents.NewTabLongPress());
break;
default:
break;
@@ -204,7 +202,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
public class LightningViewAdapter extends RecyclerView.Adapter {
- private final int layoutResourceId;
+ private final int mLayoutResourceId;
private final Drawable mBackgroundTabDrawable;
private final Drawable mForegroundTabDrawable;
private final Bitmap mForegroundTabBitmap;
@@ -213,11 +211,11 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
private ColorFilter mFilter;
private static final float DESATURATED = 0.5f;
- private final boolean vertical;
+ private final boolean mDrawerTabs;
public LightningViewAdapter(final boolean vertical) {
- this.layoutResourceId = vertical ? R.layout.tab_list_item : R.layout.tab_list_item_horizontal;
- this.vertical = vertical;
+ this.mLayoutResourceId = vertical ? R.layout.tab_list_item : R.layout.tab_list_item_horizontal;
+ this.mDrawerTabs = vertical;
if (vertical) {
mBackgroundTabDrawable = null;
@@ -239,7 +237,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
@Override
public LightningViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
- View view = inflater.inflate(layoutResourceId, viewGroup, false);
+ View view = inflater.inflate(mLayoutResourceId, viewGroup, false);
return new LightningViewHolder(view);
}
@@ -263,10 +261,10 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
holder.txtTitle.setTextAppearance(getContext(), R.style.boldText);
}
Drawable foregroundDrawable;
- if (!vertical) {
+ if (!mDrawerTabs) {
foregroundDrawable = new BitmapDrawable(getResources(), mForegroundTabBitmap);
if (!mIsIncognito && mColorMode) {
- foregroundDrawable.setColorFilter(mCurrentUiColor, PorterDuff.Mode.SRC_IN);
+ foregroundDrawable.setColorFilter(mUiController.getUiColor(), PorterDuff.Mode.SRC_IN);
}
} else {
foregroundDrawable = mForegroundTabDrawable;
@@ -277,7 +275,7 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
holder.layout.setBackgroundDrawable(foregroundDrawable);
}
if (!mIsIncognito && mColorMode) {
- changeToolbarBackground(favicon, foregroundDrawable);
+ mUiController.changeToolbarBackground(favicon, foregroundDrawable);
}
holder.favicon.setImageBitmap(favicon);
} else {
@@ -317,57 +315,6 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
return grayscaleBitmap;
}
- /**
- * 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) {
- if (mShowInNavigationDrawer) {
- return;
- }
-
- final int defaultColor = ContextCompat.getColor(getContext(), R.color.primary_color);
- if (mCurrentUiColor == Color.BLACK) {
- mCurrentUiColor = defaultColor;
- }
- Palette.from(favicon).generate(new Palette.PaletteAsyncListener() {
- @Override
- public void onGenerated(Palette palette) {
-
- // OR with opaque black to remove transparency glitches
- int color = 0xff000000 | palette.getVibrantColor(defaultColor);
-
- int finalColor = Utils.mixTwoColors(defaultColor, color, 0.25f);
-
- ValueAnimator anim = ValueAnimator.ofInt(mCurrentUiColor, finalColor);
- anim.setEvaluator(new ArgbEvaluator());
- // final Window window = getWindow();
- // TODO Check this
- // if (!mShowInNavigationDrawer) {
- // window.setBackgroundDrawable(new ColorDrawable(Color.BLACK));
- // }
- anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
-
- @Override
- public void onAnimationUpdate(ValueAnimator animation) {
- final int color = (Integer) animation.getAnimatedValue();
- if (tabBackground != null) {
- tabBackground.setColorFilter(color, PorterDuff.Mode.SRC_IN);
- }
- mCurrentUiColor = color;
- }
-
- });
- anim.setDuration(300);
- anim.start();
- }
- });
- }
-
public class LightningViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
public LightningViewHolder(View view) {
@@ -394,17 +341,17 @@ public class TabsFragment extends Fragment implements View.OnClickListener, View
public void onClick(View v) {
if (v == exitButton) {
// Close tab
- bus.post(new TabEvents.CloseTab(getAdapterPosition()));
+ mBus.post(new TabEvents.CloseTab(getAdapterPosition()));
}
if (v == layout) {
- bus.post(new TabEvents.ShowTab(getAdapterPosition()));
+ mBus.post(new TabEvents.ShowTab(getAdapterPosition()));
}
}
@Override
public boolean onLongClick(View v) {
// Show close dialog
- bus.post(new TabEvents.ShowCloseDialog(getAdapterPosition()));
+ mBus.post(new TabEvents.ShowCloseDialog(getAdapterPosition()));
return true;
}
}
diff --git a/app/src/main/java/acr/browser/lightning/view/LightningView.java b/app/src/main/java/acr/browser/lightning/view/LightningView.java
index 715d295..fa487fd 100644
--- a/app/src/main/java/acr/browser/lightning/view/LightningView.java
+++ b/app/src/main/java/acr/browser/lightning/view/LightningView.java
@@ -35,6 +35,7 @@ import com.squareup.otto.Bus;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.lang.ref.WeakReference;
import javax.inject.Inject;
@@ -74,7 +75,7 @@ public class LightningView {
0, 0, -1.0f, 0, 255, // blue
0, 0, 0, 1.0f, 0 // alpha
};
- private final WebViewHandler mWebViewHandler = new WebViewHandler();
+ private final WebViewHandler mWebViewHandler = new WebViewHandler(this);
@Inject
Bus mEventBus;
@@ -773,12 +774,22 @@ public class LightningView {
}
}
- private class WebViewHandler extends Handler {
+ private static class WebViewHandler extends Handler {
+
+ private WeakReference mReference;
+
+ public WebViewHandler(LightningView view) {
+ mReference = new WeakReference<>(view);
+ }
+
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
final String url = msg.getData().getString("url");
- longClickPage(url);
+ LightningView view = mReference.get();
+ if (view != null) {
+ view.longClickPage(url);
+ }
}
}
}
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index 5c4c744..545b736 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -123,7 +123,6 @@
Licenze Open Source
Cerca
Blocca Annunci
- Il certificato di questo sito non รจ sicuro. Vuoi procedere lo stesso?
Reinvio Modulo
Vuoi inviare nuovamente i dati?
\nVorrebbe usare la tua posizione
diff --git a/app/src/main/res/values-v16/styles.xml b/app/src/main/res/values-v16/styles.xml
new file mode 100644
index 0000000..e5a495e
--- /dev/null
+++ b/app/src/main/res/values-v16/styles.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 53bd99c..a4f614a 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -123,7 +123,6 @@