Skip to content

Commit

Permalink
reorganise loadDocument() to original location
Browse files Browse the repository at this point in the history
  • Loading branch information
guanglinn committed Sep 5, 2024
1 parent e0253ff commit 9653fc0
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
return;
}

if (_appSettings.getSetWebViewFulldrawing()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && _appSettings.getSetWebViewFulldrawing()) {
WebView.enableSlowWholeDocumentDraw();
}

Expand All @@ -170,7 +170,7 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
webSettings.setAllowUniversalAccessFromFileURLs(false);
webSettings.setMediaPlaybackRequiresUserGesture(false);

if (BuildConfig.IS_TEST_BUILD && BuildConfig.DEBUG) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && BuildConfig.IS_TEST_BUILD && BuildConfig.DEBUG) {
WebView.setWebContentsDebuggingEnabled(true); // Inspect on computer chromium browser: chrome://inspect/#devices
}

Expand All @@ -194,9 +194,9 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
}

_hlEditor.setSaveInstanceState(false); // We will reload from disk
_document.resetChangeTracking(); // force next reload

// If not set by loadDocument, se the undo-redo helper here
_document.resetChangeTracking(); // Force next reload
loadDocument();
// If not set the undo-redo helper by loadDocument, set it here
if (_editTextUndoRedoHelper == null) {
_editTextUndoRedoHelper = new TextViewUndoRedo(_hlEditor);
}
Expand All @@ -218,8 +218,6 @@ public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
}
_webView.setBackgroundColor(Color.TRANSPARENT);

loadDocument();

// Various settings
setHorizontalScrollMode(isDisplayedAtMainActivity() || _appSettings.getDocumentWrapState(_document.getPath()));
updateMenuToggleStates(0);
Expand Down Expand Up @@ -547,8 +545,10 @@ public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
Toast.makeText(activity, R.string.please_wait, Toast.LENGTH_LONG).show();
_webView.postDelayed(() -> {
if (item.getItemId() == R.id.action_share_pdf) {
_cu.printOrCreatePdfFromWebview(_webView, _document, getTextString().contains("beamer\n"));
} else if (item.getItemId() != R.id.action_share_pdf) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
_cu.printOrCreatePdfFromWebview(_webView, _document, getTextString().contains("beamer\n"));
}
} else {
Bitmap bmp = _cu.getBitmapFromWebView(_webView, item.getItemId() == R.id.action_share_image);
_cu.shareImage(getContext(), bmp, null);
}
Expand Down

0 comments on commit 9653fc0

Please sign in to comment.