Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fullscreen issue #870

Merged
merged 2 commits into from
Jan 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,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 @@ -151,17 +152,12 @@ public class ReadArticleActivity extends BaseActionBarActivity {
private boolean loadingFinished;

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 @@ -171,6 +167,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 @@ -537,9 +538,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 @@ -549,13 +548,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