add experimental hiding actionbar on scroll
This commit is contained in:
parent
026dc85826
commit
42a4fd5d39
@ -15,6 +15,7 @@ import android.util.TypedValue;
|
|||||||
import android.view.ContextMenu;
|
import android.view.ContextMenu;
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -24,12 +25,14 @@ import android.webkit.WebSettings;
|
|||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebView.HitTestResult;
|
import android.webkit.WebView.HitTestResult;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.shamanland.fab.ShowHideOnScroll;
|
import com.shamanland.fab.ShowHideOnScroll;
|
||||||
|
|
||||||
import org.fox.ttrss.types.Article;
|
import org.fox.ttrss.types.Article;
|
||||||
import org.fox.ttrss.types.Attachment;
|
import org.fox.ttrss.types.Attachment;
|
||||||
|
import org.fox.ttrss.util.NotifyingScrollView;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@ -165,9 +168,24 @@ public class ArticleFragment extends Fragment {
|
|||||||
m_contentView = view.findViewById(R.id.article_scrollview);
|
m_contentView = view.findViewById(R.id.article_scrollview);
|
||||||
m_customViewContainer = (FrameLayout) view.findViewById(R.id.article_fullscreen_video);
|
m_customViewContainer = (FrameLayout) view.findViewById(R.id.article_fullscreen_video);
|
||||||
|
|
||||||
View scrollView = view.findViewById(R.id.article_scrollview);
|
NotifyingScrollView scrollView = (NotifyingScrollView) view.findViewById(R.id.article_scrollview);
|
||||||
m_fab = view.findViewById(R.id.article_fab);
|
m_fab = view.findViewById(R.id.article_fab);
|
||||||
|
|
||||||
|
if (scrollView != null && m_activity.isSmallScreen()) {
|
||||||
|
view.findViewById(R.id.article_heading_spacer).setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
scrollView.setOnScrollChangedListener(new NotifyingScrollView.OnScrollChangedListener() {
|
||||||
|
@Override
|
||||||
|
public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) {
|
||||||
|
if (t > 0 && t > oldt) {
|
||||||
|
m_activity.getSupportActionBar().hide();
|
||||||
|
} else {
|
||||||
|
m_activity.getSupportActionBar().show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (scrollView != null && m_fab != null) {
|
if (scrollView != null && m_fab != null) {
|
||||||
if (m_prefs.getBoolean("enable_article_fab", true)) {
|
if (m_prefs.getBoolean("enable_article_fab", true)) {
|
||||||
scrollView.setOnTouchListener(new ShowHideOnScroll(m_fab));
|
scrollView.setOnTouchListener(new ShowHideOnScroll(m_fab));
|
||||||
|
@ -9,9 +9,11 @@ import android.os.Bundle;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.support.v4.view.WindowCompat;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
|
|
||||||
import org.fox.ttrss.types.Article;
|
import org.fox.ttrss.types.Article;
|
||||||
import org.fox.ttrss.types.ArticleList;
|
import org.fox.ttrss.types.ArticleList;
|
||||||
@ -223,6 +225,8 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
|
|||||||
saveArticleUnread(article);
|
saveArticleUnread(article);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!getSupportActionBar().isShowing()) getSupportActionBar().show();
|
||||||
|
|
||||||
if (open) {
|
if (open) {
|
||||||
|
|
||||||
final Article fArticle = article;
|
final Article fArticle = article;
|
||||||
|
@ -6,7 +6,7 @@ import android.view.View;
|
|||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
|
|
||||||
public class NoChildFocusScrollView extends ScrollView {
|
public class NoChildFocusScrollView extends NotifyingScrollView {
|
||||||
|
|
||||||
public NoChildFocusScrollView(Context context) {
|
public NoChildFocusScrollView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
package org.fox.ttrss.util;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.ScrollView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Cyril Mottier
|
||||||
|
*/
|
||||||
|
public class NotifyingScrollView extends ScrollView {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Cyril Mottier
|
||||||
|
*/
|
||||||
|
public interface OnScrollChangedListener {
|
||||||
|
void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt);
|
||||||
|
}
|
||||||
|
|
||||||
|
private OnScrollChangedListener mOnScrollChangedListener;
|
||||||
|
|
||||||
|
public NotifyingScrollView(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotifyingScrollView(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotifyingScrollView(Context context, AttributeSet attrs, int defStyle) {
|
||||||
|
super(context, attrs, defStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
|
||||||
|
super.onScrollChanged(l, t, oldl, oldt);
|
||||||
|
if (mOnScrollChangedListener != null) {
|
||||||
|
mOnScrollChangedListener.onScrollChanged(this, l, t, oldl, oldt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnScrollChangedListener(OnScrollChangedListener listener) {
|
||||||
|
mOnScrollChangedListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -22,6 +22,14 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical" >
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<!-- hack for hiding actionbar on small devices -->
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/article_heading_spacer"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_marginTop="?android:attr/actionBarSize"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:id="@+id/article_header"
|
android:id="@+id/article_header"
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/headlines"
|
android:id="@+id/headlines"
|
||||||
android:fitsSystemWindows="true"
|
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent">
|
android:layout_height="fill_parent">
|
||||||
|
|
||||||
|
@ -81,6 +81,8 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="DarkTheme" parent="Theme.AppCompat">
|
<style name="DarkTheme" parent="Theme.AppCompat">
|
||||||
|
<item name="windowActionBarOverlay">true</item>
|
||||||
|
|
||||||
<item name="statusBarHintColor">?colorPrimary</item>
|
<item name="statusBarHintColor">?colorPrimary</item>
|
||||||
<item name="unreadCounterColor">#909090</item>
|
<item name="unreadCounterColor">#909090</item>
|
||||||
<item name="feedlistTextColor">@android:color/primary_text_dark</item>
|
<item name="feedlistTextColor">@android:color/primary_text_dark</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user