Browse Source

Animate toolbar hide/show

master
Anthony Restaino 10 years ago
parent
commit
376ac564b8
  1. 11
      res/anim/slide_down.xml
  2. 11
      res/anim/slide_up.xml
  3. 188
      res/layout/activity_main.xml
  4. 61
      res/layout/bookmark_drawer.xml
  5. 122
      res/layout/tab_drawer.xml
  6. 1
      res/layout/tab_list_item.xml
  7. 4
      res/layout/two_line_autocomplete.xml
  8. 2
      res/values/strings.xml
  9. 3
      src/acr/browser/lightning/AboutSettingsActivity.java
  10. 88
      src/acr/browser/lightning/BrowserActivity.java
  11. 2
      src/acr/browser/lightning/BrowserController.java
  12. 59
      src/acr/browser/lightning/LightningView.java

11
res/anim/slide_down.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate android:fromYDelta="-50%" android:toYDelta="0"
android:interpolator="@android:anim/decelerate_interpolator"
android:duration="@android:integer/config_shortAnimTime"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:interpolator="@android:anim/decelerate_interpolator"
android:duration="@android:integer/config_shortAnimTime" />
</set>

11
res/anim/slide_up.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate android:fromYDelta="0" android:toYDelta="-50%"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="@android:integer/config_shortAnimTime"/>
<alpha android:fromAlpha="1.0" android:toAlpha="0.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="@android:integer/config_shortAnimTime" />
</set>

188
res/layout/activity_main.xml

@ -14,6 +14,7 @@
android:fitsSystemWindows="true" > android:fitsSystemWindows="true" >
<LinearLayout <LinearLayout
android:id="@+id/ui_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" > android:orientation="vertical" >
@ -23,193 +24,16 @@
<FrameLayout <FrameLayout
android:id="@+id/content_frame" android:id="@+id/content_frame"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:background="@color/primary_color" android:layout_weight="1"
android:layout_weight="1"/> android:background="@color/primary_color" />
<include layout="@layout/search_interface" /> <include layout="@layout/search_interface" />
</LinearLayout> </LinearLayout>
<RelativeLayout <include layout="@layout/tab_drawer" />
android:id="@+id/left_drawer"
android:layout_width="@dimen/navigation_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/drawer_background"
android:clickable="true"
android:fitsSystemWindows="true"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/new_tab_button"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentTop="true"
android:background="?attr/listBackground"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:id="@+id/plusIcon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:contentDescription="Favicon"
android:gravity="center_vertical"
android:src="@drawable/ic_action_plus" >
</ImageView>
<TextView
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/plusIcon"
android:gravity="center_vertical"
android:maxLines="1"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:text="@string/action_new_tab"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="@color/black" />
</RelativeLayout>
<View
android:id="@+id/view"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="@+id/new_tab_button"
android:background="@color/gray_list_bg" />
<ListView
android:id="@+id/left_drawer_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/lineView"
android:layout_below="@+id/view"
android:choiceMode="singleChoice"
android:dividerHeight="1dp"
android:listSelector="?attr/listBackground" />
<View
android:id="@+id/lineView"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_above="@+id/linearLayout1"
android:background="@color/gray_list_bg" />
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:baselineAligned="false"
android:orientation="horizontal"
android:weightSum="2" >
<RelativeLayout
android:id="@+id/action_back"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/listBackground"
android:clickable="true" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:contentDescription="@string/action_back"
android:paddingBottom="4dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingTop="4dp"
android:src="@drawable/ic_action_back" />
</RelativeLayout>
<RelativeLayout <include layout="@layout/bookmark_drawer" />
android:id="@+id/action_forward"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/listBackground"
android:clickable="true" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:contentDescription="@string/action_forward"
android:paddingBottom="4dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingTop="4dp"
android:src="@drawable/ic_action_forward" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/right_drawer"
android:layout_width="@dimen/navigation_width"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="@color/drawer_background"
android:clickable="true"
android:fitsSystemWindows="true"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/bookmark_title"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/listBackground"
android:clickable="true"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:id="@+id/starIcon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:contentDescription="Favicon"
android:gravity="center_vertical"
android:src="@drawable/ic_action_star" >
</ImageView>
<TextView
android:id="@+id/text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/starIcon"
android:gravity="center_vertical"
android:maxLines="1"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:text="@string/action_bookmarks"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="@color/black" />
</RelativeLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="@color/gray_list_bg" />
<ListView
android:id="@+id/right_drawer_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#bababa"
android:dividerHeight="1dp"
android:listSelector="?attr/listBackground" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout> </android.support.v4.widget.DrawerLayout>
</LinearLayout> </LinearLayout>

61
res/layout/bookmark_drawer.xml

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/right_drawer"
android:layout_width="@dimen/navigation_width"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="@color/drawer_background"
android:clickable="true"
android:fitsSystemWindows="true"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/bookmark_title"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/listBackground"
android:clickable="true"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:id="@+id/starIcon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:contentDescription="Favicon"
android:gravity="center_vertical"
android:src="@drawable/ic_action_star" >
</ImageView>
<TextView
android:id="@+id/text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/starIcon"
android:gravity="center_vertical"
android:maxLines="1"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:text="@string/action_bookmarks"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="@color/black" />
</RelativeLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="@color/gray_list_bg" />
<ListView
android:id="@+id/right_drawer_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#bababa"
android:dividerHeight="1dp"
android:listSelector="?attr/listBackground" />
</LinearLayout>

122
res/layout/tab_drawer.xml

@ -0,0 +1,122 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/left_drawer"
android:layout_width="@dimen/navigation_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/drawer_background"
android:clickable="true"
android:fitsSystemWindows="true"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/new_tab_button"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentTop="true"
android:background="?attr/listBackground"
android:gravity="center_vertical"
android:orientation="horizontal" >
<ImageView
android:id="@+id/plusIcon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:contentDescription="Favicon"
android:gravity="center_vertical"
android:src="@drawable/ic_action_plus" >
</ImageView>
<TextView
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/plusIcon"
android:gravity="center_vertical"
android:maxLines="1"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:text="@string/action_new_tab"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:textColor="@color/black" />
</RelativeLayout>
<View
android:id="@+id/view"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_below="@+id/new_tab_button"
android:background="@color/gray_list_bg" />
<ListView
android:id="@+id/left_drawer_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/lineView"
android:layout_below="@+id/view"
android:choiceMode="singleChoice"
android:dividerHeight="1dp"
android:listSelector="?attr/listBackground" />
<View
android:id="@+id/lineView"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_above="@+id/linearLayout1"
android:background="@color/gray_list_bg" />
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentBottom="true"
android:baselineAligned="false"
android:orientation="horizontal"
android:weightSum="2" >
<RelativeLayout
android:id="@+id/action_back"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/listBackground"
android:clickable="true" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:contentDescription="@string/action_back"
android:paddingBottom="4dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingTop="4dp"
android:src="@drawable/ic_action_back" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/action_forward"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/listBackground"
android:clickable="true" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:contentDescription="@string/action_forward"
android:paddingBottom="4dp"
android:paddingLeft="4dp"
android:paddingRight="4dp"
android:paddingTop="4dp"
android:src="@drawable/ic_action_forward" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>

1
res/layout/tab_list_item.xml

@ -41,7 +41,6 @@
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginRight="13dp" android:layout_marginRight="13dp"
android:background="?attr/actionBarItemBackground"
android:alpha="0.5" android:alpha="0.5"
android:contentDescription="Delete Tab" android:contentDescription="Delete Tab"
android:gravity="center_vertical" android:gravity="center_vertical"

4
res/layout/two_line_autocomplete.xml

@ -18,8 +18,6 @@
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?android:attr/listChoiceBackgroundIndicator"
android:clickable="false"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="5dp" > android:paddingLeft="5dp" >
@ -28,7 +26,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:clickable="false"
android:maxLines="1" android:maxLines="1"
android:textColor="#000000" android:textColor="#000000"
android:textSize="18sp" /> android:textSize="18sp" />
@ -38,7 +35,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:clickable="false"
android:maxLines="1" android:maxLines="1"
android:textColor="#6a6a6a" /> android:textColor="#6a6a6a" />
</LinearLayout> </LinearLayout>

2
res/values/strings.xml

@ -131,7 +131,7 @@
<string name="action_manual">Manual</string> <string name="action_manual">Manual</string>
<string name="action_auto">Auto</string> <string name="action_auto">Auto</string>
<string name="action_follow_me">Contact Me</string> <string name="action_follow_me">Contact Me</string>
<string name="url_twitter">twitter.com/ACRDevelopment</string> <string name="url_twitter">twitter.com/RestainoAnthony</string>
<string name="clear_cache">Clear cache</string> <string name="clear_cache">Clear cache</string>
<string name="message_cache_cleared">Cache Cleared</string> <string name="message_cache_cleared">Cache Cleared</string>
<string name="message_import">Bookmarks Were Imported</string> <string name="message_import">Bookmarks Were Imported</string>

3
src/acr/browser/lightning/AboutSettingsActivity.java

@ -22,7 +22,6 @@ import android.widget.TextView;
public class AboutSettingsActivity extends Activity { public class AboutSettingsActivity extends Activity {
// mPreferences variables // mPreferences variables
private static final int API = android.os.Build.VERSION.SDK_INT;
private SharedPreferences mPreferences; private SharedPreferences mPreferences;
private int mEasterEggCounter; private int mEasterEggCounter;
private Context mContext; private Context mContext;
@ -116,7 +115,7 @@ public class AboutSettingsActivity extends Activity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri startActivity(new Intent(Intent.ACTION_VIEW, Uri
.parse("http://twitter.com/ACRDevelopment"), mContext, MainActivity.class)); .parse("http://twitter.com/RestainoAnthony"), mContext, MainActivity.class));
finish(); finish();
} }

88
src/acr/browser/lightning/BrowserActivity.java

@ -48,6 +48,8 @@ import android.view.View.OnLongClickListener;
import android.view.View.OnTouchListener; import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup.LayoutParams;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator; import android.view.animation.DecelerateInterpolator;
import android.view.animation.Transformation; import android.view.animation.Transformation;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
@ -101,6 +103,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
private boolean mFullScreen; private boolean mFullScreen;
private FrameLayout mBrowserFrame; private FrameLayout mBrowserFrame;
private LinearLayout mPageLayout; private LinearLayout mPageLayout;
private LinearLayout mUiLayout;
private FullscreenHolder mFullscreenContainer; private FullscreenHolder mFullscreenContainer;
private CustomViewCallback mCustomViewCallback; private CustomViewCallback mCustomViewCallback;
private final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams( private final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams(
@ -166,6 +169,7 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
mBrowserFrame = (FrameLayout) findViewById(R.id.content_frame); mBrowserFrame = (FrameLayout) findViewById(R.id.content_frame);
mToolbarLayout = (LinearLayout) findViewById(R.id.toolbar_layout); mToolbarLayout = (LinearLayout) findViewById(R.id.toolbar_layout);
mPageLayout = (LinearLayout) findViewById(R.id.main_layout); mPageLayout = (LinearLayout) findViewById(R.id.main_layout);
mUiLayout = (LinearLayout) findViewById(R.id.ui_layout);
mProgressBar = (AnimatedProgressBar) findViewById(R.id.progress_view); mProgressBar = (AnimatedProgressBar) findViewById(R.id.progress_view);
// mProgressBar.setVisibility(View.GONE); // mProgressBar.setVisibility(View.GONE);
// TODO // TODO
@ -715,6 +719,18 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0); mPreferences = getSharedPreferences(PreferenceConstants.PREFERENCES, 0);
} }
mFullScreen = mPreferences.getBoolean(PreferenceConstants.FULL_SCREEN, false); mFullScreen = mPreferences.getBoolean(PreferenceConstants.FULL_SCREEN, false);
if(mFullScreen){
if (mBrowserFrame.findViewById(R.id.toolbar_layout) == null) {
mUiLayout.removeView(mToolbarLayout);
mBrowserFrame.addView(mToolbarLayout);
mToolbarLayout.bringToFront();
}
} else {
if (mBrowserFrame.findViewById(R.id.toolbar_layout) != null) {
mBrowserFrame.removeView(mToolbarLayout);
mUiLayout.addView(mToolbarLayout, 0);
}
}
if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) { if (mPreferences.getBoolean(PreferenceConstants.HIDE_STATUS_BAR, false)) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN); WindowManager.LayoutParams.FLAG_FULLSCREEN);
@ -2335,6 +2351,47 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
* if (mActionBar.isShowing() && mFullScreen) { mActionBar.hide(); } * if (mActionBar.isShowing() && mFullScreen) { mActionBar.hide(); }
*/ */
// TODO // TODO
if (mFullScreen) {
if (mBrowserFrame.findViewById(R.id.toolbar_layout) == null) {
mUiLayout.removeView(mToolbarLayout);
mBrowserFrame.addView(mToolbarLayout);
mToolbarLayout.bringToFront();
Log.i(Constants.TAG, "Move view to browser frame");
}
if (mToolbarLayout.getVisibility() != View.GONE) {
Animation hide = AnimationUtils.loadAnimation(mContext, R.anim.slide_up);
hide.setAnimationListener(new AnimationListener(){
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mToolbarLayout.setVisibility(View.GONE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
mToolbarLayout.startAnimation(hide);
Log.i(Constants.TAG, "Hide");
}
}
}
@Override
public void toggleActionBar(){
if (mFullScreen) {
if (mToolbarLayout.getVisibility() != View.VISIBLE) {
showActionBar();
} else {
hideActionBar();
}
}
} }
@Override @Override
@ -2346,6 +2403,37 @@ public class BrowserActivity extends ActionBarActivity implements BrowserControl
* if (!mActionBar.isShowing() && mFullScreen) { mActionBar.show(); } * if (!mActionBar.isShowing() && mFullScreen) { mActionBar.show(); }
*/ */
// TODO // TODO
if (mFullScreen) {
if (mBrowserFrame.findViewById(R.id.toolbar_layout) == null) {
mUiLayout.removeView(mToolbarLayout);
mBrowserFrame.addView(mToolbarLayout);
mToolbarLayout.bringToFront();
Log.i(Constants.TAG, "Move view to browser frame");
}
if (mToolbarLayout.getVisibility() != View.VISIBLE) {
Animation show = AnimationUtils.loadAnimation(mContext, R.anim.slide_down);
show.setAnimationListener(new AnimationListener(){
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mToolbarLayout.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
mToolbarLayout.startAnimation(show);
Log.i(Constants.TAG, "Show");
}
}
} }
@Override @Override

2
src/acr/browser/lightning/BrowserController.java

@ -41,6 +41,8 @@ public interface BrowserController {
public void hideActionBar(); public void hideActionBar();
public void showActionBar(); public void showActionBar();
public void toggleActionBar();
public void longClickPage(String url); public void longClickPage(String url);

59
src/acr/browser/lightning/LightningView.java

@ -17,6 +17,7 @@ import android.graphics.Paint;
import android.net.MailTo; import android.net.MailTo;
import android.net.Uri; import android.net.Uri;
import android.net.http.SslError; import android.net.http.SslError;
import android.os.Build;
import android.os.Message; import android.os.Message;
import android.text.InputType; import android.text.InputType;
import android.text.method.PasswordTransformationMethod; import android.text.method.PasswordTransformationMethod;
@ -121,7 +122,11 @@ public class LightningView {
mLocation = mY; mLocation = mY;
} else if (mAction == MotionEvent.ACTION_UP) { } else if (mAction == MotionEvent.ACTION_UP) {
if ((mY - mLocation) > 10) { if ((mY - mLocation) > 10) {
mBrowserController.showActionBar(); if (mWebView.getScrollY() != 0) {
mBrowserController.showActionBar();
} else {
mBrowserController.toggleActionBar();
}
} else if ((mY - mLocation) < -10) { } else if ((mY - mLocation) < -10) {
mBrowserController.hideActionBar(); mBrowserController.hideActionBar();
} }
@ -373,8 +378,11 @@ public class LightningView {
if (API < 19) { if (API < 19) {
settings.setDatabasePath(context.getCacheDir() + "/databases"); settings.setDatabasePath(context.getCacheDir() + "/databases");
} }
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE); if (API >= Build.VERSION_CODES.LOLLIPOP) {
//TODO mWebView.getSettings()
.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
}
// TODO
settings.setDomStorageEnabled(true); settings.setDomStorageEnabled(true);
settings.setAppCacheEnabled(true); settings.setAppCacheEnabled(true);
settings.setAppCachePath(context.getCacheDir().toString()); settings.setAppCachePath(context.getCacheDir().toString());
@ -477,12 +485,12 @@ public class LightningView {
ColorMatrixColorFilter filterInvertGray = new ColorMatrixColorFilter(concat); ColorMatrixColorFilter filterInvertGray = new ColorMatrixColorFilter(concat);
mPaint.setColorFilter(filterInvertGray); mPaint.setColorFilter(filterInvertGray);
setHardwareRendering(); setHardwareRendering();
mInvertPage = true; mInvertPage = true;
break; break;
} }
} }
public synchronized void pauseTimers() { public synchronized void pauseTimers() {
@ -739,7 +747,7 @@ public class LightningView {
} else { } else {
mTitle.setTitle(view.getTitle()); mTitle.setTitle(view.getTitle());
} }
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.update();
@ -751,7 +759,7 @@ public class LightningView {
mBrowserController.updateUrl(url, false); mBrowserController.updateUrl(url, false);
mBrowserController.showActionBar(); mBrowserController.showActionBar();
} }
mTitle.setFavicon(mWebpageBitmap); mTitle.setFavicon(mWebpageBitmap);
mBrowserController.update(); mBrowserController.update();
} }
@ -799,24 +807,26 @@ public class LightningView {
alert.show(); alert.show();
} }
boolean isRunning = false; boolean isRunning = false;
@Override @Override
public void onScaleChanged(final WebView view, final float oldScale, final float newScale) { public void onScaleChanged(final WebView view, final float oldScale, final float newScale) {
if (view.isShown() && mTextReflow && API >= android.os.Build.VERSION_CODES.KITKAT) { if (view.isShown() && mTextReflow && API >= android.os.Build.VERSION_CODES.KITKAT) {
view.invalidate(); view.invalidate();
if(isRunning) if (isRunning)
return; return;
isRunning = view.postDelayed(new Runnable(){ isRunning = view.postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
//TODO // TODO
view.evaluateJavascript(Constants.JAVASCRIPT_TEXT_REFLOW, null); view.evaluateJavascript(Constants.JAVASCRIPT_TEXT_REFLOW, null);
isRunning = false; isRunning = false;
} }
}, 100); }, 100);
} }
} }
@ -1095,7 +1105,7 @@ public class LightningView {
public void setTitleAndFavicon(String title, Bitmap favicon) { public void setTitleAndFavicon(String title, Bitmap favicon) {
mTitle = title; mTitle = title;
if (favicon == null) { if (favicon == null) {
mFavicon = mDefaultIcon; mFavicon = mDefaultIcon;
} else { } else {
@ -1110,30 +1120,29 @@ public class LightningView {
public Bitmap getFavicon() { public Bitmap getFavicon() {
return mFavicon; return mFavicon;
} }
} }
private class CustomGestureListener extends SimpleOnGestureListener { private class CustomGestureListener extends SimpleOnGestureListener {
/** /**
* Without this, onLongPress is not called when user is zooming * Without this, onLongPress is not called when user is zooming using
* using two fingers, but is when using only one. * two fingers, but is when using only one.
* *
* The required behaviour is to not trigger this when the * The required behaviour is to not trigger this when the user is
* user is zooming, it shouldn't matter how much fingers * zooming, it shouldn't matter how much fingers the user's using.
* the user's using.
*/ */
private boolean mCanTriggerLongPress = true; private boolean mCanTriggerLongPress = true;
@Override @Override
public void onLongPress(MotionEvent e) { public void onLongPress(MotionEvent e) {
if(mCanTriggerLongPress) if (mCanTriggerLongPress)
mBrowserController.onLongPress(); mBrowserController.onLongPress();
} }
/** /**
* Is called when the user is swiping after the doubletap, * Is called when the user is swiping after the doubletap, which in our
* which in our case means that he is zooming. * case means that he is zooming.
*/ */
@Override @Override
public boolean onDoubleTapEvent(MotionEvent e) { public boolean onDoubleTapEvent(MotionEvent e) {
@ -1142,8 +1151,8 @@ public class LightningView {
} }
/** /**
* Is called when something is starting being pressed, * Is called when something is starting being pressed, always before
* always before onLongPress. * onLongPress.
*/ */
@Override @Override
public void onShowPress(MotionEvent e) { public void onShowPress(MotionEvent e) {

Loading…
Cancel
Save