diff --git a/app/src/main/assets/dark.css b/app/src/main/assets/dark.css
index d5bb51ed0..71dfd29a8 100755
--- a/app/src/main/assets/dark.css
+++ b/app/src/main/assets/dark.css
@@ -178,7 +178,7 @@ h2:after {
========================================================================== */
#content {
- margin-top: 1em;
+ margin-top: 100px;
min-height: 30em;
}
diff --git a/app/src/main/assets/main.css b/app/src/main/assets/main.css
index 81c0eaff0..86ed934c4 100755
--- a/app/src/main/assets/main.css
+++ b/app/src/main/assets/main.css
@@ -168,7 +168,7 @@ h2:after {
========================================================================== */
#content {
- margin-top: 1em;
+ margin-top: 100px;
min-height: 30em;
}
diff --git a/app/src/main/assets/solarized.css b/app/src/main/assets/solarized.css
index 45422b31d..cf0a533a3 100755
--- a/app/src/main/assets/solarized.css
+++ b/app/src/main/assets/solarized.css
@@ -185,7 +185,7 @@ h2:after {
========================================================================== */
#content {
- margin-top: 1em;
+ margin-top: 100px;
min-height: 30em;
}
diff --git a/app/src/main/java/fr/gaulupeau/apps/Poche/data/Settings.java b/app/src/main/java/fr/gaulupeau/apps/Poche/data/Settings.java
index db6d414f6..28c88ee7a 100644
--- a/app/src/main/java/fr/gaulupeau/apps/Poche/data/Settings.java
+++ b/app/src/main/java/fr/gaulupeau/apps/Poche/data/Settings.java
@@ -368,6 +368,10 @@ public boolean isFullscreenArticleView() {
return getBoolean(R.string.pref_key_ui_article_fullscreen, false);
}
+ public boolean isAutoFullscreenArticleView() {
+ return getBoolean(R.string.pref_key_ui_article_fullscreen_auto, true);
+ }
+
public void setFullScreenArticleView(boolean value) {
setBoolean(R.string.pref_key_ui_article_fullscreen, value);
}
diff --git a/app/src/main/java/fr/gaulupeau/apps/Poche/ui/ReadArticleActivity.java b/app/src/main/java/fr/gaulupeau/apps/Poche/ui/ReadArticleActivity.java
index 4a6bc3f51..3cabcd362 100644
--- a/app/src/main/java/fr/gaulupeau/apps/Poche/ui/ReadArticleActivity.java
+++ b/app/src/main/java/fr/gaulupeau/apps/Poche/ui/ReadArticleActivity.java
@@ -35,6 +35,7 @@
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
+import android.support.v7.widget.Toolbar;
import com.di72nn.stuff.wallabag.apiwrapper.WallabagService;
@@ -144,6 +145,9 @@ public class ReadArticleActivity extends BaseActionBarActivity {
private boolean onPageFinishedCallPostponedUntilResume;
private boolean loadingFinished;
+ private boolean isFullscreen;
+ private View decorView;
+
public void onCreate(Bundle savedInstanceState) {
settings = App.getInstance().getSettings();
@@ -153,7 +157,7 @@ public void onCreate(Bundle savedInstanceState) {
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
- );
+ );
ActionBar actionBar = super.getSupportActionBar();
if(actionBar != null) actionBar.hide();
}
@@ -199,7 +203,35 @@ public void onCreate(Bundle savedInstanceState) {
// article is loaded - update menu
invalidateOptionsMenu();
+ // Grab the action bar and decorView for making reading view fullscreen
+ decorView = getWindow().getDecorView();
+ isFullscreen = false;
+
+ // Toggle stable and fullscreen layout flags so everything is overlaid by the
+ // actionbar AND the status bar when article is opened
+ decorView.setSystemUiVisibility(
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ );
+
+
scrollView = (ScrollView)findViewById(R.id.scroll);
+
+// // Hide status and action bar when scrolling down, show when scrolling up
+// // TODO: change to a method compatible with API 14.
+ if (Build.VERSION.SDK_INT >= 23 && settings.isAutoFullscreenArticleView()) {
+ scrollView.setOnScrollChangeListener(new View.OnScrollChangeListener(){
+ @Override
+ public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
+ if (oldScrollY - scrollY > 5 && isFullscreen){
+ isFullscreen = goFullscreen(false);
+ } else if (oldScrollY - scrollY < -5 && !isFullscreen) {
+ isFullscreen = goFullscreen(true);
+ }
+ }
+ });
+ }
+
scrollViewLastChild = scrollView.getChildAt(scrollView.getChildCount() - 1);
webViewContent = (WebView)findViewById(R.id.webViewContent);
loadingPlaceholder = (TextView)findViewById(R.id.tv_loading_article);
@@ -481,6 +513,24 @@ public void onArticlesChangedEvent(ArticlesChangedEvent event) {
}
}
+ private boolean goFullscreen(boolean gofs) {
+ // Hide both status bar and action bar if true else, show them
+ if(gofs){
+ decorView.setSystemUiVisibility(
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_FULLSCREEN
+ );
+ return true;
+ } else {
+ decorView.setSystemUiVisibility(
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ );
+ return false;
+ }
+ }
+
private void showDisableTouchToast() {
Toast.makeText(this, disableTouch
? R.string.message_disableTouch_inputDisabled
@@ -598,22 +648,28 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
- if(!tapToScroll) return false;
-
if(e.getPointerCount() > 1) return false;
- int viewHeight = scrollView.getHeight();
- float y = e.getY() - scrollView.getScrollY();
+ float x = e.getX();
+ int viewWidth = scrollView.getWidth();
- if(y > viewHeight * 0.25 && y < viewHeight * 0.75) {
- int viewWidth = scrollView.getWidth();
- float x = e.getX();
+ if(tapToScroll) {
+ int viewHeight = scrollView.getHeight();
+ float y = e.getY() - scrollView.getScrollY();
+ if (y > viewHeight * 0.25 && y < viewHeight * 0.75) {
- if(x < viewWidth * 0.3) { // left part
- scroll(true, screenScrollingPercent, smoothScrolling, false);
- } else if(x > viewWidth * 0.7) { // right part
- scroll(false, screenScrollingPercent, smoothScrolling, false);
+ if (x < viewWidth * 0.3) { // left part
+ scroll(true, screenScrollingPercent, smoothScrolling, false);
+ } else if (x > viewWidth * 0.7) { // right part
+ scroll(false, screenScrollingPercent, smoothScrolling, false);
+ }
}
+ // TODO: Maybe enable this with option in settings menu?
+ // Toggle fullscreen if touching center of screen
+ }
+
+ if(x > viewWidth * 0.3 && x < viewWidth * 0.7){
+ isFullscreen = goFullscreen(!isFullscreen);
}
return false;
diff --git a/app/src/main/res/values/strings-preference-keys.xml b/app/src/main/res/values/strings-preference-keys.xml
index 8d844c298..127edaa3c 100644
--- a/app/src/main/res/values/strings-preference-keys.xml
+++ b/app/src/main/res/values/strings-preference-keys.xml
@@ -35,6 +35,7 @@
ui.screenScrolling.smooth
ui.misc.category
ui.article.fullscreen
+ ui.article.fullscreen_auto
ui.disableTouch.enabled
ui.disableTouch.lastState
ui.disableTouch.keyCode
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 026771d3b..7015625c6 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -198,6 +198,8 @@
Stretches lines to equal width (like in newspapers)
Fullscreen Article View
Hides system and app bars when reading articles
+ Fullscreen Article View on Scroll
+ Hides/Shows system and app bars automatically scroll. Only works on Android 6.0 and above.
Reading speed
Your reading speed (measured in words per minute). Used to calculate estimated reading time.
Keep screen on while reading
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index a0b976541..baac728b3 100644
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -150,6 +150,11 @@
android:title="@string/pref_name_ui_article_fullscreen"
android:summary="@string/pref_desc_ui_article_fullscreen"
android:defaultValue="false"/>
+