Skip to content

Commit

Permalink
Merge pull request #870 from wallabag/fix_fullscreen_issue
Browse files Browse the repository at this point in the history
Fix fullscreen issue
  • Loading branch information
Strubbl authored Jan 2, 2020
2 parents 08bc0a1 + ff419ba commit 4afcfbe
Showing 1 changed file with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public class ReadArticleActivity extends BaseActionBarActivity {

private ArticleDao articleDao;

private boolean fullscreenArticleView;
private int fontSize;
private boolean volumeButtonsScrolling;
private boolean tapToScroll;
Expand Down Expand Up @@ -164,17 +165,12 @@ public void applyOverrideConfiguration(Configuration overrideConfiguration) {
}

public void onCreate(Bundle savedInstanceState) {

settings = App.getInstance().getSettings();

if(settings.isFullscreenArticleView()) {
fullscreenArticleView = settings.isFullscreenArticleView();
if(fullscreenArticleView) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
);
ActionBar actionBar = super.getSupportActionBar();
if(actionBar != null) actionBar.hide();
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}

if(settings.isKeepScreenOn()) {
Expand All @@ -184,6 +180,11 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.article);

if(fullscreenArticleView) {
ActionBar actionBar = getSupportActionBar();
if(actionBar != null) actionBar.hide();
}

Intent intent = getIntent();
long articleID = intent.getLongExtra(EXTRA_ID, -1);
Log.d(TAG, "onCreate() articleId: " + articleID);
Expand Down Expand Up @@ -550,9 +551,7 @@ public void onShowCustomView(View paramView, WebChromeClient.CustomViewCallback
customView = paramView;

//Hide action bar and bottom buttons while in fullscreen
ReadArticleActivity.this.getSupportActionBar().hide();
LinearLayout bottom = findViewById(R.id.bottomTools);
bottom.setVisibility(View.GONE);
hideUi(true);

FrameLayout.LayoutParams fullscreen = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
((FrameLayout) ReadArticleActivity.this.getWindow().getDecorView())
Expand All @@ -562,13 +561,23 @@ public void onShowCustomView(View paramView, WebChromeClient.CustomViewCallback
//Necessary for enabling watching youtube videos in fullscreen
public void onHideCustomView() {
//Show action bar and bottom buttons when leaving fullscreen
ReadArticleActivity.this.getSupportActionBar().show();
LinearLayout bottom = findViewById(R.id.bottomTools);
bottom.setVisibility(View.VISIBLE);
hideUi(false);

((FrameLayout) ReadArticleActivity.this.getWindow().getDecorView())
.removeView(customView);
}

private void hideUi(boolean hide) {
if(!fullscreenArticleView) {
ActionBar actionBar = getSupportActionBar();
if(actionBar != null) {
if(hide) actionBar.hide();
else actionBar.show();
}
}
LinearLayout bottom = findViewById(R.id.bottomTools);
if(bottom != null) bottom.setVisibility(hide ? View.GONE : View.VISIBLE);
}
});

webViewContent.setWebViewClient(new WebViewClient() {
Expand Down

0 comments on commit 4afcfbe

Please sign in to comment.